diff options
4 files changed, 77 insertions, 16 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java index 91bf6dbef3..11bc791fe1 100644 --- a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java +++ b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java @@ -278,7 +278,7 @@ public class HazelcastDomainRegistry extends BaseDomainRegistry implements Domai public void addEndpoint(Endpoint endpoint) { if (findEndpoint(endpoint.getURI()).size() > 0) { Member m = getOwningMember(endpoint.getURI()); - throw new IllegalStateException("Endpoint " + endpoint.getURI() + " already exists in domain " + domainURI + " at " + m.getInetSocketAddress()); + throw new IllegalStateException("Endpoint " + endpoint.getURI() + " already exists in domain " + domainURI + " at " + (m == null? "null" : m.getInetSocketAddress())); } String localMemberAddr = hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString(); @@ -549,12 +549,22 @@ public class HazelcastDomainRegistry extends BaseDomainRegistry implements Domai Map<String, String> cs = runningComposites.get(curi); if (cs != null) { cs.remove(compositeURI); + if (cs.size() > 0) { + runningComposites.put(curi, cs); + } else { + runningComposites.remove(curi); + } } Map<String, List<String>> ocs = runningCompositeOwners.get(localMemberAddr); if (ocs != null) { List<String> xya = ocs.get(curi); if (xya != null) { xya.remove(compositeURI); + if (xya.size() > 0) { + runningCompositeOwners.put(localMemberAddr, ocs); + } else { + runningCompositeOwners.remove(localMemberAddr); + } } } txn.commit(); 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");
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 e4f93ca85d..6edd6d454a 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 @@ -39,8 +39,11 @@ public class DomainCompositeTestCase { @Test
public void distributedDomain() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
- Node node = TuscanyRuntime.newInstance().createNode("uri:DomainCompositeTestCase");
+ TuscanyRuntime runtime = TuscanyRuntime.newInstance();
+ try {
+ Node node = runtime.createNode("uri:DomainCompositeTestCase");
testIt(node);
+ } finally { runtime.stop(); }
}
private void testIt(Node node) throws ContributionReadException, ActivationException, ValidationException {
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 4de9215838..0b71b68d70 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 @@ -34,7 +34,9 @@ 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"); + TuscanyRuntime runtime = TuscanyRuntime.newInstance(); + try { + Node node1 = runtime.createNode("uri:TwoNodesTestCase?multicast=off&bind=127.0.0.1:44331"); node1.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null); node1.startComposite("helloworld", "helloworld.composite"); @@ -42,6 +44,7 @@ public class TwoNodesTestCase { Helloworld helloworldService = node2.getService(Helloworld.class, "HelloworldComponent"); Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); + } finally { runtime.stop(); } } } |