diff options
Diffstat (limited to '')
-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(); + } } |