diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime')
6 files changed, 85 insertions, 56 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DeployerTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DeployerTestCase.java index 12204883f8..8713d0b478 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DeployerTestCase.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DeployerTestCase.java @@ -19,10 +19,14 @@ package org.apache.tuscany.sca.runtime; import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; import java.net.MalformedURLException; import java.net.URI; import java.util.List; +import java.util.Map; +import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; import junit.framework.Assert; @@ -51,7 +55,7 @@ public class DeployerTestCase { Contribution contribution = deployer.loadContribution(URI.create("foo"), new File("src/test/resources/sample-helloworld-nodeployable.jar").toURI().toURL(), monitor); monitor.analyzeProblems(); - node.installContribution(contribution, null, true); + node.installContribution(contribution, null); List<String> ics = node.getInstalledContributionURIs(); Assert.assertEquals(1, ics.size()); Assert.assertEquals("foo", ics.get(0)); @@ -62,17 +66,31 @@ public class DeployerTestCase { TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance(); Node node = tuscanyRuntime.createNode("myDomain"); - node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true); + node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null); Deployer deployer = tuscanyRuntime.getDeployer(); Monitor monitor = deployer.createMonitor(); Composite composite = deployer.loadXMLDocument(new File("src/test/resources/helloworld2.composite").toURI().toURL(), monitor); monitor.analyzeProblems(); - composite.setURI("helloworld2.composite"); - node.start("foo", composite); - List<String> dcs = node.getStartedCompositeURIs("foo"); + String cmpuri = node.addDeploymentComposite("foo", composite); + node.startComposite("foo", cmpuri); + Map<String, List<QName>> dcs = node.getStartedComposites(); Assert.assertEquals(1, dcs.size()); - Assert.assertEquals("helloworld2.composite", dcs.get(0)); + Assert.assertEquals("helloworld2", dcs.get("foo").get(0).getLocalPart()); + } + + @Test + public void testAddDeploymentCompositeXML() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException, XMLStreamException, FileNotFoundException { + TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance(); + Node node = tuscanyRuntime.createNode("myDomain"); + + node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null); + + String cmpuri = node.addDeploymentComposite("foo", new FileReader(new File("src/test/resources/helloworld2.composite"))); + node.startComposite("foo", cmpuri); + Map<String, List<QName>> dcs = node.getStartedComposites(); + Assert.assertEquals(1, dcs.size()); + Assert.assertEquals("helloworld2", dcs.get("foo").get(0).getLocalPart()); } } diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DomainCompositeTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DomainCompositeTestCase.java index ce5ba2432c..e4f93ca85d 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DomainCompositeTestCase.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DomainCompositeTestCase.java @@ -33,31 +33,32 @@ public class DomainCompositeTestCase { @Test
public void localOnlyDomain() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
- Node node = TuscanyRuntime.newInstance().createNode("DomainCompositeTestCase.localOnlyDomain");
+ Node node = TuscanyRuntime.newInstance().createNode("DomainCompositeTestCase");
testIt(node);
}
@Test
public void distributedDomain() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
- Node node = TuscanyRuntime.newInstance().createNode("uri:DomainCompositeTestCase.distributedDomain");
+ Node node = TuscanyRuntime.newInstance().createNode("uri:DomainCompositeTestCase");
testIt(node);
}
private void testIt(Node node) throws ContributionReadException, ActivationException, ValidationException {
- node.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null, true);
+ node.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null);
+ node.startComposite("helloworld", "helloworld.composite");
- Composite dc = node.getDomainLevelComposite();
- Assert.assertEquals("domainComposite", dc.getName().getLocalPart());
+ Composite dc = node.getDomainComposite();
+ Assert.assertEquals("DomainCompositeTestCase", dc.getName().getLocalPart());
Assert.assertEquals(1, dc.getIncludes().size());
Composite c = dc.getIncludes().get(0);
Assert.assertEquals("helloworld", c.getName().getLocalPart());
- String s = node.getDomainLevelCompositeAsString();
- System.out.println(s);
- Assert.assertTrue(s.contains(":helloworld\""));
+// String s = node.getDomainLevelCompositeAsString();
+// System.out.println(s);
+// Assert.assertTrue(s.contains(":helloworld\""));
- node.stop("helloworld", "helloworld.composite");
- Assert.assertEquals(0, node.getDomainLevelComposite().getIncludes().size());
+ node.stopComposite("helloworld", "helloworld.composite");
+ Assert.assertEquals(0, node.getDomainComposite().getIncludes().size());
}
}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeXMLTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeXMLTestCase.java index d245ea2ec6..ca4ea32c4d 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeXMLTestCase.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeXMLTestCase.java @@ -19,6 +19,9 @@ package org.apache.tuscany.sca.runtime; import java.util.List; +import java.util.Map; + +import javax.xml.namespace.QName; import junit.framework.Assert; @@ -37,9 +40,9 @@ public class NodeXMLTestCase { List<String> cs = node.getInstalledContributionURIs(); Assert.assertEquals(1, cs.size()); Assert.assertEquals("sample-helloworld", cs.get(0)); - List<String> compsoites = node.getStartedCompositeURIs("sample-helloworld"); - Assert.assertEquals(1, compsoites.size()); - Assert.assertEquals("helloworld.composite", compsoites.get(0)); + Map<String, List<QName>> startedComposites = node.getStartedComposites(); + Assert.assertEquals(1, startedComposites.size()); + Assert.assertEquals("helloworld", startedComposites.get("sample-helloworld").get(0).getLocalPart()); } } diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.java index 4b889f56bc..97b3755f2e 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.java @@ -39,15 +39,15 @@ public class PerfTest { Properties config = new Properties(); config.setProperty(RuntimeProperties.QUIET_LOGGING, "true"); Node node = TuscanyRuntime.newInstance(config).createNode(); - node.installContribution(null, "src/test/resources/sample-helloworld.jar", null, null, false); + node.installContribution(null, "src/test/resources/sample-helloworld.jar", null, null); validate(node); int count = 3000; long start = System.currentTimeMillis(); for (int i=0; i<count; i++) { - node.start("sample-helloworld", "helloworld.composite"); - node.stop("sample-helloworld", "helloworld.composite"); + node.startComposite("sample-helloworld", "helloworld.composite"); + node.stopComposite("sample-helloworld", "helloworld.composite"); } long total = System.currentTimeMillis() - start; System.out.println(count + " = " + total + " = " + total / (double)count); @@ -57,12 +57,12 @@ public class PerfTest { } private void validate(Node node) throws ActivationException, ValidationException, NoSuchServiceException, ContributionReadException { - node.start("sample-helloworld", "helloworld.composite"); + node.startComposite("sample-helloworld", "helloworld.composite"); Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); - node.stop("sample-helloworld", "helloworld.composite"); + node.stopComposite("sample-helloworld", "helloworld.composite"); try { node.getService(Helloworld.class, "HelloworldComponent"); Assert.fail(); diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java index 99f51a2604..55d164c56e 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java @@ -21,6 +21,9 @@ package org.apache.tuscany.sca.runtime; import java.net.MalformedURLException; import java.net.URI; import java.util.List; +import java.util.Map; + +import javax.xml.namespace.QName; import junit.framework.Assert; @@ -41,7 +44,8 @@ public class TuscanyRuntimeTestCase { @Test public void testInstallDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException { Node node = TuscanyRuntime.newInstance().createNode("default"); - node.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null, true); + node.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null); + node.startComposite("helloworld", "helloworld.composite"); Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); @@ -50,13 +54,16 @@ public class TuscanyRuntimeTestCase { @Test public void testStopStart() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException { Node node = TuscanyRuntime.newInstance().createNode("default"); - node.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null, true); - String ci = node.getStartedCompositeURIs("helloworld").get(0); + node.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null); + node.startComposite("helloworld", "helloworld.composite"); + + Map<String, List<QName>> ci = node.getStartedComposites(); + Assert.assertEquals(1, ci.size()); Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); - node.stop("helloworld", ci); + node.stopComposite("helloworld", "helloworld.composite"); try { node.getService(Helloworld.class, "HelloworldComponent"); Assert.fail(); @@ -64,7 +71,7 @@ public class TuscanyRuntimeTestCase { // expected as there is no deployables } - node.start("helloworld", ci); + node.startComposite("helloworld", "helloworld.composite"); helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); } @@ -73,8 +80,10 @@ public class TuscanyRuntimeTestCase { @Ignore("Depdends on itest/T3558 which isn't in the build?") public void testInstallWithDependent() throws NoSuchServiceException, ContributionReadException, ActivationException, ValidationException { Node node = TuscanyRuntime.newInstance().createNode("default"); - node.installContribution("store", "../../itest/T3558/src/test/resources/sample-store.jar", null, null, true); - node.installContribution("store-client", "../../itest/T3558/src/test/resources/sample-store-client.jar", null, null, true); + node.installContribution("store", "../../testing/itest/T3558/src/test/resources/sample-store.jar", null, null); + node.installContribution("store-client", "../../testing/itest/T3558/src/test/resources/sample-store-client.jar", null, null); + node.startComposite("store", "store.composite"); + node.startComposite("store-client", "store-client.composite"); Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); @@ -83,7 +92,7 @@ public class TuscanyRuntimeTestCase { @Test public void testInstallNoDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException { Node node = TuscanyRuntime.newInstance().createNode("default"); - node.installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true); + node.installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", null, null); try { node.getService(Helloworld.class, "HelloworldComponent"); @@ -92,7 +101,7 @@ public class TuscanyRuntimeTestCase { // expected as there is no deployables } - node.start("helloworld", "helloworld.composite"); + node.startComposite("helloworld", "helloworld.composite"); Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); } @@ -100,7 +109,7 @@ public class TuscanyRuntimeTestCase { @Test public void testGetInstalledContributions() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException { Node node = TuscanyRuntime.newInstance().createNode("default"); - node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true); + node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null); List<String> ics = node.getInstalledContributionURIs(); Assert.assertEquals(1, ics.size()); Assert.assertEquals("foo", ics.get(0)); @@ -109,8 +118,8 @@ public class TuscanyRuntimeTestCase { @Test public void testGetDeployedCompostes() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, MalformedURLException, ActivationException, ValidationException { Node node = TuscanyRuntime.newInstance().createNode("default"); - node.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null, true); - List<String> dcs = node.getStartedCompositeURIs("foo"); + node.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null); + List<String> dcs = node.startDeployables("foo"); Assert.assertEquals(1, dcs.size()); Assert.assertEquals("helloworld.composite", dcs.get(0)); } @@ -118,20 +127,25 @@ public class TuscanyRuntimeTestCase { @Test public void testRemoveComposte() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, MalformedURLException, ActivationException, ValidationException { Node node = TuscanyRuntime.newInstance().createNode("default"); - node.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null, true); - node.stop("foo", "helloworld.composite"); - List<String> dcs = node.getStartedCompositeURIs("foo"); - Assert.assertEquals(0, dcs.size()); + node.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null); + List<String> dcs = node.startDeployables("foo"); + Assert.assertEquals(1, dcs.size()); + Map<String, List<QName>> dcsx = node.getStartedComposites(); + Assert.assertEquals(1, dcsx.size()); + node.stopComposite("foo", "helloworld.composite"); + dcsx = node.getStartedComposites(); + Assert.assertEquals(0, dcsx.size()); } @Test public void testInstallWithMetaData() throws ContributionReadException, ActivationException, ValidationException, NoSuchServiceException { Node node = TuscanyRuntime.newInstance().createNode("default"); - ((NodeImpl)node).installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", "src/test/resources/sca-contribution-generated.xml", null, true); + node.installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", "src/test/resources/sca-contribution-generated.xml", null); + node.startComposite("helloworld", "helloworld.composite"); - List<String> dcs = node.getStartedCompositeURIs("helloworld"); + Map<String, List<QName>> dcs = node.getStartedComposites(); Assert.assertEquals(1, dcs.size()); - Assert.assertEquals("helloworld.composite", dcs.get(0)); + Assert.assertEquals("helloworld", dcs.get("helloworld").get(0).getLocalPart()); Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); @@ -149,9 +163,9 @@ public class TuscanyRuntimeTestCase { Node node = TuscanyRuntime.runComposite("helloworld.composite", "src/test/resources/sample-helloworld.jar"); List<String> cs = node.getInstalledContributionURIs(); Assert.assertEquals(1, cs.size()); - List<String> dcs = node.getStartedCompositeURIs(cs.get(0)); + Map<String, List<QName>> dcs = node.getStartedComposites(); Assert.assertEquals(1, dcs.size()); - Assert.assertEquals("helloworld.composite", dcs.get(0)); + Assert.assertEquals("helloworld", dcs.get("sample-helloworld").get(0).getLocalPart()); } @Test @@ -159,29 +173,21 @@ public class TuscanyRuntimeTestCase { Node node = TuscanyRuntime.runComposite(null, "src/test/resources/sample-helloworld.jar"); List<String> cs = node.getInstalledContributionURIs(); Assert.assertEquals(1, cs.size()); - List<String> dcs = node.getStartedCompositeURIs(cs.get(0)); + Map<String, List<QName>> dcs = node.getStartedComposites(); Assert.assertEquals(1, dcs.size()); - Assert.assertEquals("helloworld.composite", dcs.get(0)); + Assert.assertEquals("helloworld", dcs.get("sample-helloworld").get(0).getLocalPart()); } @Test public void testRunComposite() throws NoSuchServiceException { Node node = TuscanyRuntime.runComposite("helloworld.composite", "src/test/resources/sample-helloworld.jar"); - try { Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); - } finally { - node.stop(); - } } @Test public void testRunCompositeSharedRuntime() throws NoSuchServiceException { Node node = TuscanyRuntime.runComposite(URI.create("default"), "helloworld.composite", "src/test/resources/sample-helloworld.jar"); - try { Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); - } finally { - node.stop(); - } } } diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java index 6205b26a8a..4de9215838 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java @@ -35,7 +35,8 @@ public class TwoNodesTestCase { @Test public void testInstallDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException { Node node1 = TuscanyRuntime.newInstance().createNode("uri:TwoNodesTestCase?multicast=off&bind=127.0.0.1:44331"); - node1.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null, true); + node1.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null); + node1.startComposite("helloworld", "helloworld.composite"); Node node2 = TuscanyRuntime.newInstance().createNode("uri:TwoNodesTestCase?multicast=off&bind=127.0.0.1:44332&wka=127.0.0.1:44331"); |