diff options
4 files changed, 113 insertions, 9 deletions
diff --git a/sca-java-2.x/trunk/testing/itest/scaclient-api/pom.xml b/sca-java-2.x/trunk/testing/itest/scaclient-api/pom.xml index f872d3721b..1b7ef1257c 100644 --- a/sca-java-2.x/trunk/testing/itest/scaclient-api/pom.xml +++ b/sca-java-2.x/trunk/testing/itest/scaclient-api/pom.xml @@ -35,5 +35,20 @@ <type>pom</type> <version>2.0-SNAPSHOT</version> </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-rmi-runtime</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-ws-runtime-axis2</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-jetty</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> </dependencies> </project> diff --git a/sca-java-2.x/trunk/testing/itest/scaclient-api/src/main/java/itest/SingleServiceImpl.java b/sca-java-2.x/trunk/testing/itest/scaclient-api/src/main/java/itest/SingleServiceImpl.java new file mode 100644 index 0000000000..93ce660c6a --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/scaclient-api/src/main/java/itest/SingleServiceImpl.java @@ -0,0 +1,34 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package itest;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+@EagerInit
+@Scope("COMPOSITE")
+@Service(HelloworldService.class)
+public class SingleServiceImpl implements HelloworldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/scaclient-api/src/main/resources/Helloworld.composite b/sca-java-2.x/trunk/testing/itest/scaclient-api/src/main/resources/Helloworld.composite index 2d5ae6a57c..0be26056cc 100644 --- a/sca-java-2.x/trunk/testing/itest/scaclient-api/src/main/resources/Helloworld.composite +++ b/sca-java-2.x/trunk/testing/itest/scaclient-api/src/main/resources/Helloworld.composite @@ -26,4 +26,24 @@ <implementation.java class="itest.HelloworldServiceImpl"/> </component> + <component name="SingleServiceComponent"> + <implementation.java class="itest.SingleServiceImpl"/> + </component> + + <component name="OnlyWSBindingComponent"> + <implementation.java class="itest.HelloworldServiceImpl"/> + <service name="RemoteHelloworldService"> + <binding.ws /> + </service> + </component> + + <component name="MultipleBindingsComponent"> + <implementation.java class="itest.HelloworldServiceImpl"/> + <service name="RemoteHelloworldService"> + <binding.ws name="ws" /> + <binding.sca /> + <tuscany:binding.rmi name="rmi" /> + </service> + </component> + </composite> diff --git a/sca-java-2.x/trunk/testing/itest/scaclient-api/src/test/java/test/scaclient/SCAClientTestCase.java b/sca-java-2.x/trunk/testing/itest/scaclient-api/src/test/java/test/scaclient/SCAClientTestCase.java index c64350eb2a..ac3f3fd5a5 100644 --- a/sca-java-2.x/trunk/testing/itest/scaclient-api/src/test/java/test/scaclient/SCAClientTestCase.java +++ b/sca-java-2.x/trunk/testing/itest/scaclient-api/src/test/java/test/scaclient/SCAClientTestCase.java @@ -31,6 +31,7 @@ import org.apache.tuscany.sca.node.NodeFactory; import org.junit.Test; import org.oasisopen.sca.NoSuchDomainException; import org.oasisopen.sca.NoSuchServiceException; +import org.oasisopen.sca.ServiceRuntimeException; import org.oasisopen.sca.client.SCAClientFactory; /** @@ -71,15 +72,29 @@ public class SCAClientTestCase extends TestCase { assertEquals("Hello petra", service.sayHello("petra")); } -// @Test -// public void testWithoutServiceName() throws Exception { -// node = NodeFactory.getInstance().createNode(URI.create("myFooDomain"), new String[] {"target/classes"}); -// node.start(); -// -// SCAClientFactory clientFactory = SCAClientFactory.newInstance(URI.create("myFooDomain")); -// HelloworldService service = clientFactory.getService(HelloworldService.class, "HelloworldComponent"); -// assertEquals("Hello petra", service.sayHello("petra")); -// } + @Test + public void testWithoutServiceName() throws Exception { + node = NodeFactory.getInstance().createNode(URI.create("myFooDomain"), new String[] {"target/classes"}); + node.start(); + + SCAClientFactory clientFactory = SCAClientFactory.newInstance(URI.create("myFooDomain")); + try { + clientFactory.getService(HelloworldService.class, "HelloworldComponent"); + fail("expecting ServiceRuntimeException"); + } catch (ServiceRuntimeException e) { + assertTrue(e.getMessage().contains("More than one service is declared on component")); + } + } + + @Test + public void testWithoutServiceNameSingleService() throws Exception { + node = NodeFactory.getInstance().createNode(URI.create("myFooDomain"), new String[] {"target/classes"}); + node.start(); + + SCAClientFactory clientFactory = SCAClientFactory.newInstance(URI.create("myFooDomain")); + HelloworldService service = clientFactory.getService(HelloworldService.class, "SingleServiceComponent"); + assertEquals("Hello petra", service.sayHello("petra")); + } @Test public void testWithBadServiceName() throws Exception { @@ -108,6 +123,26 @@ public class SCAClientTestCase extends TestCase { } } + @Test + public void testOnlyWSBinding() throws Exception { + node = NodeFactory.getInstance().createNode(URI.create("myFooDomain"), new String[] {"target/classes"}); + node.start(); + + SCAClientFactory clientFactory = SCAClientFactory.newInstance(URI.create("myFooDomain")); + RemoteHelloworldService service = clientFactory.getService(RemoteHelloworldService.class, "OnlyWSBindingComponent/RemoteHelloworldService"); + assertEquals("Hello petra", service.sayHelloRemote("petra")); + } + + @Test + public void testMultipleBindings() throws Exception { + node = NodeFactory.getInstance().createNode(URI.create("myFooDomain"), new String[] {"target/classes"}); + node.start(); + + SCAClientFactory clientFactory = SCAClientFactory.newInstance(URI.create("myFooDomain")); + RemoteHelloworldService service = clientFactory.getService(RemoteHelloworldService.class, "MultipleBindingsComponent/RemoteHelloworldService"); + assertEquals("Hello petra", service.sayHelloRemote("petra")); + } + // @Test @Ignore // public void testHTTPURI() throws Exception { // node = NodeFactory.getInstance().createNode(URI.create("http://defaultDomain"), new String[] {"target/classes"}); |