diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-06-08 13:04:07 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-06-08 13:04:07 +0000 |
commit | e3ecaeadeba1df24575ec739f747166463285652 (patch) | |
tree | 3593d8b28e98f153df8eee4194f207df03f6d23a /sca-java-2.x/trunk | |
parent | d77d75c6fc53d7a52dec23ec52aed57a26e9c8be (diff) |
Add a test with a contribution containing an invalid composite and update the code to not fail with that
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1133382 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk')
3 files changed, 38 insertions, 1 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java index f611a8bdd3..b5814550ab 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java @@ -302,7 +302,9 @@ public class NodeImpl implements Node { if (contribution == null) { Monitor monitor = deployer.createMonitor(); contribution = deployer.loadContribution(IOHelper.createURI(cd.getURI()), IOHelper.getLocationAsURL(cd.getURL()), monitor); - monitor.analyzeProblems(); + + // TODO: should the monitor be checked? If it is then the peek in to get the metadata doesn't work if there's a problem + // monitor.analyzeProblems(); if (cd.getAdditionalDeployables().size() > 0) { for (String uri : cd.getAdditionalDeployables().keySet()) { String compositeXML = cd.getAdditionalDeployables().get(uri); diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/Node2TestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/Node2TestCase.java index 0bffc9fb9e..1d1e70b11e 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/Node2TestCase.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/Node2TestCase.java @@ -18,6 +18,7 @@ */
package org.apache.tuscany.sca.impl;
+import java.io.Reader;
import java.io.StringReader;
import java.util.List;
import java.util.Map;
@@ -251,4 +252,38 @@ public class Node2TestCase { Composite runningComposite = dc.getIncludes().get(0);
Assert.assertEquals("TestComposite", runningComposite.getName().getLocalPart());
}
+
+ @Test
+ public void invalidCompositeStartTest() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException {
+ Node node = TuscanyRuntime.newInstance().createNode("invalidCompositeStartTest");
+ String curi = node.installContribution("src/test/resources/helloworld-invalidComposite.jar");
+ Assert.assertEquals(1, node.getInstalledContributionURIs().size());
+ Assert.assertEquals(0, node.getStartedCompositeURIs().size());
+ ContributionDescription cd = node.getInstalledContribution(curi);
+ Assert.assertEquals(1, cd.getDeployables().size());
+
+ String compositeXML =
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\""
+ + " xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\""
+ + " targetNamespace=\"http://test/composite\""
+ + " name=\"TestComposite\">"
+ + " <component name=\"TestComponent\">"
+ + " <implementation.java class=\"sample.HelloworldImpl\"/>"
+ + " </component>"
+ + "</composite>";
+ String compositeURI = node.addDeploymentComposite(curi, new StringReader(compositeXML));
+ node.startComposite(curi, compositeURI);
+
+// node.startComposite("sample-helloworld", "helloworld.composite");
+// Assert.assertEquals(1, node.getStartedCompositeURIs().size());
+// Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
+//
+// node.stopComposite("sample-helloworld", "helloworld.composite");
+//// Assert.assertEquals(0, node.getStartedComposites().size());
+// node.startComposite("sample-helloworld", "helloworld.composite");
+// Assert.assertEquals(1, node.getStartedCompositeURIs().size());
+// Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
+// node.stopComposite("sample-helloworld", "helloworld.composite");
+ }
+
}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/resources/helloworld-invalidComposite.jar b/sca-java-2.x/trunk/modules/domain-node/src/test/resources/helloworld-invalidComposite.jar Binary files differnew file mode 100644 index 0000000000..fa35a21696 --- /dev/null +++ b/sca-java-2.x/trunk/modules/domain-node/src/test/resources/helloworld-invalidComposite.jar |