diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl')
-rw-r--r-- | sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/Node2TestCase.java | 71 |
1 files changed, 58 insertions, 13 deletions
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 dcb35995a8..dccdb051ed 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 @@ -22,7 +22,6 @@ import java.io.StringReader; import java.util.List;
import java.util.Map;
-import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import junit.framework.Assert;
@@ -35,6 +34,7 @@ import org.apache.tuscany.sca.contribution.processor.ContributionReadException; import org.apache.tuscany.sca.monitor.ValidationException;
import org.apache.tuscany.sca.runtime.ActivationException;
import org.apache.tuscany.sca.runtime.InstalledContribution;
+import org.junit.Ignore;
import org.junit.Test;
import org.oasisopen.sca.NoSuchDomainException;
import org.oasisopen.sca.NoSuchServiceException;
@@ -65,7 +65,9 @@ public class Node2TestCase { @Test
public void DistributedInstall() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
- Node nodeA = TuscanyRuntime.newInstance().createNode("uri:DistributedInstall");
+ TuscanyRuntime runtime = TuscanyRuntime.newInstance();
+ try {
+ Node nodeA = runtime.createNode("uri:DistributedInstall");
nodeA.installContribution("https://repository.apache.org/content/groups/snapshots/org/apache/tuscany/sca/samples/helloworld/2.0-SNAPSHOT/helloworld-2.0-SNAPSHOT.jar");
nodeA.installContribution("src/test/resources/export.jar");
@@ -75,7 +77,7 @@ public class Node2TestCase { Contribution cA = nodeA.getContribution("helloworld");
Assert.assertNotNull(cA);
- Node nodeB = TuscanyRuntime.newInstance().createNode("uri:DistributedInstall");
+ Node nodeB = runtime.createNode("uri:DistributedInstall");
Assert.assertEquals(2, nodeB.getInstalledContributionURIs().size());
Assert.assertTrue(nodeB.getInstalledContributionURIs().contains("export"));
Assert.assertTrue(nodeB.getInstalledContributionURIs().contains("helloworld"));
@@ -85,6 +87,9 @@ public class Node2TestCase { InstalledContribution ic = ((NodeImpl)nodeB).getInstalledContribution("export");
Assert.assertEquals(1, ic.getJavaExports().size());
Assert.assertEquals("sample", ic.getJavaExports().get(0));
+ } finally {
+ runtime.stop();
+ }
}
@Test
@@ -149,19 +154,25 @@ public class Node2TestCase { @Test
public void importExportDistributedValidate() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
- Node nodeA = TuscanyRuntime.newInstance().createNode("uri:ImportTestCase");
- nodeA.installContribution("src/test/resources/import.jar");
+ TuscanyRuntime runtime = TuscanyRuntime.newInstance();
try {
+ Node nodeA = runtime.createNode("uri:ImportTestCase");
+ nodeA.installContribution("src/test/resources/import.jar");
+ try {
+ nodeA.validateContribution("import");
+ } catch (ValidationException e) {
+ // expected
+ }
+ Node nodeB =runtime.createNode("uri:ImportTestCase");
+ nodeB.installContribution("src/test/resources/export.jar");
nodeA.validateContribution("import");
- } catch (ValidationException e) {
- // expected
+ nodeA.startComposite("import", "helloworld.composite");
+ Map<String, List<String>> scs = nodeB.getStartedCompositeURIs();
+ Assert.assertEquals(1, scs.size());
+ }finally {
+ runtime.stop();
}
- Node nodeB = TuscanyRuntime.newInstance().createNode("uri:ImportTestCase");
- nodeB.installContribution("src/test/resources/export.jar");
- nodeA.validateContribution("import");
- nodeA.startComposite("import", "helloworld.composite");
- Map<String, List<String>> scs = nodeB.getStartedCompositeURIs();
- Assert.assertEquals(1, scs.size());
+
}
@Test
@@ -183,6 +194,40 @@ public class Node2TestCase { }
@Test
+ public void startDistributedTest() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, InterruptedException {
+ TuscanyRuntime runtime = TuscanyRuntime.newInstance();
+ try {
+ Node node = runtime.createNode("uri:ImportTestCase");
+ Node node2 = runtime.createNode("uri:ImportTestCase");
+
+ node.installContribution("src/test/resources/sample-helloworld.jar");
+ Assert.assertEquals(1, node.getInstalledContributionURIs().size());
+ Assert.assertEquals(1, node2.getInstalledContributionURIs().size());
+
+ node.startComposite("sample-helloworld", "helloworld.composite");
+ Assert.assertEquals(1, node.getStartedCompositeURIs().size());
+ Assert.assertEquals(1, node2.getStartedCompositeURIs().size());
+
+ Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
+ Assert.assertEquals("helloworld.composite", node2.getStartedCompositeURIs().get("sample-helloworld").get(0));
+
+ node.stopComposite("sample-helloworld", "helloworld.composite");
+ Assert.assertEquals(0, node.getStartedCompositeURIs().size());
+ Assert.assertEquals(0, node2.getStartedCompositeURIs().size());
+
+ node2.startComposite("sample-helloworld", "helloworld.composite");
+ Assert.assertEquals(1, node.getStartedCompositeURIs().size());
+ Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
+
+ Assert.assertEquals(1, node2.getStartedCompositeURIs().size());
+ Assert.assertEquals("helloworld.composite", node2.getStartedCompositeURIs().get("sample-helloworld").get(0));
+
+ } finally {
+ runtime.stop();
+ }
+ }
+
+ @Test
public void addDeploymentCompositeTest() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException {
Node node = TuscanyRuntime.newInstance().createNode("addDeploymentCompositeTest");
String curi = node.installContribution("src/test/resources/sample-helloworld.jar");
|