Author: antelder
Date: Wed Jan 19 10:19:55 2011
New Revision: 1060741
URL: http://svn.apache.org/viewvc?rev=1060741&view=rev
Log:
Fix runComposite with shared runtime instance and update testcase
Added:
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java
- copied, changed from r1060728,
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeTestCase.java
Removed:
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeTestCase.java
Modified:
tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/TuscanyRuntime.java
Modified:
tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/TuscanyRuntime.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/TuscanyRuntime.java?rev=1060741&r1=1060740&r2=1060741&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/TuscanyRuntime.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/runtime/TuscanyRuntime.java
Wed Jan 19 10:19:55 2011
@@ -49,6 +49,8 @@ import org.apache.tuscany.sca.runtime.im
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--) {
Copied:
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java
(from r1060728,
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeTestCase.java)
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java?p2=tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java&p1=tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeTestCase.java&r1=1060728&r2=1060741&rev=1060741&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeTestCase.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java
Wed Jan 19 10:19:55 2011
@@ -36,7 +36,7 @@ import org.oasisopen.sca.NoSuchServiceEx
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();
+ }
}