diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-01-19 10:19:55 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-01-19 10:19:55 +0000 |
commit | 15515ccfca972c119501c2d269ed83e586c515d6 (patch) | |
tree | 38f0f77e1f801c0c226b63c0330e0d652f8a03e7 /sca-java-2.x/trunk/modules/domain-node | |
parent | 58b2e5ffa7d3a0cd7c16e2cca9b305487bc03071 (diff) |
Fix runComposite with shared runtime instance and update testcase
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1060741 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/domain-node')
-rw-r--r-- | sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/TuscanyRuntime.java | 10 | ||||
-rw-r--r-- | sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java (renamed from sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeTestCase.java) | 25 |
2 files changed, 32 insertions, 3 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/TuscanyRuntime.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/TuscanyRuntime.java index b2181ef1f4..fa062b1933 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/TuscanyRuntime.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/TuscanyRuntime.java @@ -49,6 +49,8 @@ import org.apache.tuscany.sca.runtime.impl.NodeImpl; import org.apache.tuscany.sca.work.WorkScheduler; import org.oasisopen.sca.ServiceRuntimeException; +import sun.security.jca.GetInstance; + public class TuscanyRuntime { private Deployer deployer; @@ -73,7 +75,7 @@ public class TuscanyRuntime { * @return a Node with installed contributions */ public static Node runComposite(String compositeURI, String contributionURL, String... dependentContributionURLs) { - return runComposite(newInstance(), compositeURI, contributionURL, dependentContributionURLs); + return runComposite(null, compositeURI, contributionURL, dependentContributionURLs); } /** @@ -88,8 +90,12 @@ public class TuscanyRuntime { */ public static Node runComposite(TuscanyRuntime runtime, String compositeURI, String contributionURL, String... dependentContributionURLs) { try { + boolean sharedRuntime = runtime != null; + if (runtime == null) { + runtime = newInstance(); + } EndpointRegistry endpointRegistry = new EndpointRegistryImpl(runtime.extensionPointRegistry, null, null); - NodeImpl node = new NodeImpl("default", runtime.deployer, runtime.compositeActivator, endpointRegistry, runtime.extensionPointRegistry, runtime); + NodeImpl node = new NodeImpl("default", runtime.deployer, runtime.compositeActivator, endpointRegistry, runtime.extensionPointRegistry, sharedRuntime? null : runtime); if (dependentContributionURLs != null) { for (int i=dependentContributionURLs.length-1; i>-1; i--) { diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java index 6787804f06..f194751e6f 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeTestCase.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java @@ -36,7 +36,7 @@ import org.oasisopen.sca.NoSuchServiceException; import sample.Helloworld; -public class NodeTestCase { +public class TuscanyRuntimeTestCase { @Test public void testInstallDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException { @@ -163,4 +163,27 @@ public class NodeTestCase { Assert.assertEquals(1, dcs.size()); Assert.assertEquals("helloworld.composite", dcs.get(0)); } + @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 { + TuscanyRuntime runtime = TuscanyRuntime.newInstance(); + Node node = TuscanyRuntime.runComposite(runtime, "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(); + } + runtime.stop(); + } } |