From 9a4d83faf250efb00160c20c05fb727ad92c555c Mon Sep 17 00:00:00 2001 From: antelder Date: Wed, 12 Jan 2011 08:56:52 +0000 Subject: Update to create a service proxy directly instead of using the sca client factory api and update testcases for that, and rename package git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1058025 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tuscany/sca/node2/NodeTestCase.java | 63 +++++++++++++++------- 1 file changed, 44 insertions(+), 19 deletions(-) (limited to 'sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java') diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java index 6637f05979..2fd1cb7a4e 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java @@ -25,13 +25,17 @@ import junit.framework.Assert; import org.apache.tuscany.sca.contribution.processor.ContributionReadException; import org.apache.tuscany.sca.monitor.ValidationException; -import org.apache.tuscany.sca.node2.impl.NodeImpl; import org.apache.tuscany.sca.runtime.ActivationException; +import org.apache.tuscany.sca.runtime.Node; +import org.apache.tuscany.sca.runtime.NodeFactory; +import org.apache.tuscany.sca.runtime.impl.NodeImpl; import org.junit.Ignore; import org.junit.Test; import org.oasisopen.sca.NoSuchDomainException; import org.oasisopen.sca.NoSuchServiceException; +import sample.Helloworld; + public class NodeTestCase { @Test @@ -39,8 +43,30 @@ public class NodeTestCase { Node node = NodeFactory.newInstance().createNode("default"); node.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null, true); -// Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); -// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); + Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); + Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); + } + + @Test + public void testStopStart() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException { + Node node = NodeFactory.newInstance().createNode("default"); + node.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null, true); + String ci = node.getStartedCompositeURIs("helloworld").get(0); + + Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); + Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); + + node.stop("helloworld", ci); + try { + node.getService(Helloworld.class, "HelloworldComponent"); + Assert.fail(); + } catch (NoSuchServiceException e) { + // expected as there is no deployables + } + + node.start("helloworld", ci); + helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); + Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); } @Test @@ -50,8 +76,8 @@ public class NodeTestCase { node.installContribution("store", "../../itest/T3558/src/test/resources/sample-store.jar", null, null, true); node.installContribution("store-client", "../../itest/T3558/src/test/resources/sample-store-client.jar", null, null, true); -// Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); -// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); + Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); + Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); } @Test @@ -59,17 +85,16 @@ public class NodeTestCase { Node node = NodeFactory.newInstance().createNode("default"); node.installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true); -// SCAClientFactory scaClientFactory = node.getSCAClientFactory(); -// try { -// scaClientFactory.getService(Helloworld.class, "HelloworldComponent"); -// Assert.fail(); -// } catch (NoSuchServiceException e) { -// // expected as there is no deployables -// } + try { + node.getService(Helloworld.class, "HelloworldComponent"); + Assert.fail(); + } catch (NoSuchServiceException e) { + // expected as there is no deployables + } node.start("helloworld", "helloworld.composite"); -// Helloworld helloworldService = scaClientFactory.getService(Helloworld.class, "HelloworldComponent"); -// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); + Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); + Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); } @Test @@ -100,7 +125,7 @@ public class NodeTestCase { } @Test - public void testInstallWithMetaData() throws ContributionReadException, ActivationException, ValidationException { + public void testInstallWithMetaData() throws ContributionReadException, ActivationException, ValidationException, NoSuchServiceException { Node node = NodeFactory.newInstance().createNode("default"); ((NodeImpl)node).installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", "src/test/resources/sca-contribution-generated.xml", null, true); @@ -108,8 +133,8 @@ public class NodeTestCase { Assert.assertEquals(1, dcs.size()); Assert.assertEquals("helloworld.composite", dcs.get(0)); -// Helloworld helloworldService = scaClientFactory.getService(Helloworld.class, "HelloworldComponent"); -// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); + Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); + Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); } @Test @@ -121,7 +146,7 @@ public class NodeTestCase { @Test public void testStaticCreate() { - Node node = NodeFactory.newStandaloneNode("helloworld.composite", "src/test/resources/sample-helloworld.jar"); + Node node = NodeFactory.createStandaloneNode("helloworld.composite", "src/test/resources/sample-helloworld.jar"); List cs = node.getInstalledContributionURIs(); Assert.assertEquals(1, cs.size()); List dcs = node.getStartedCompositeURIs(cs.get(0)); @@ -131,7 +156,7 @@ public class NodeTestCase { @Test public void testStaticCreateWithNullComposite() { - Node node = NodeFactory.newStandaloneNode(null, "src/test/resources/sample-helloworld.jar"); + Node node = NodeFactory.createStandaloneNode(null, "src/test/resources/sample-helloworld.jar"); List cs = node.getInstalledContributionURIs(); Assert.assertEquals(1, cs.size()); List dcs = node.getStartedCompositeURIs(cs.get(0)); -- cgit v1.2.3