You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2011/05/18 14:00:55 UTC
svn commit: r1124209 - in /tuscany/sca-java-2.x/trunk/modules:
domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/
domain-node/src/test/java/org/apache/tuscany/sca/impl/
domain-node/src/test/java/org/apache/tuscany/sca/runtime/
Author: antelder
Date: Wed May 18 12:00:54 2011
New Revision: 1124209
URL: http://svn.apache.org/viewvc?rev=1124209&view=rev
Log:
Fix Hazelcast reg to properly remove entries when things are removed and update tests so properly shutdown the runtime after each test
Modified:
tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/Node2TestCase.java
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DomainCompositeTestCase.java
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java
Modified: tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java?rev=1124209&r1=1124208&r2=1124209&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java Wed May 18 12:00:54 2011
@@ -278,7 +278,7 @@ public class HazelcastDomainRegistry ext
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 ext
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();
Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/Node2TestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/Node2TestCase.java?rev=1124209&r1=1124208&r2=1124209&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/Node2TestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/Node2TestCase.java Wed May 18 12:00:54 2011
@@ -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.contributi
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");
Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DomainCompositeTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DomainCompositeTestCase.java?rev=1124209&r1=1124208&r2=1124209&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DomainCompositeTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DomainCompositeTestCase.java Wed May 18 12:00:54 2011
@@ -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 {
Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java?rev=1124209&r1=1124208&r2=1124209&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java Wed May 18 12:00:54 2011
@@ -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(); }
}
}