From 4ca42d5aeabc4e7309cbd3773db4f183f12af1e2 Mon Sep 17 00:00:00 2001 From: slaws Date: Fri, 19 Aug 2011 13:15:52 +0000 Subject: TUSCANY-3916 - Add local callback miss-match case. Remote callback case to follow. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1159623 13f79535-47bb-0310-9956-ffa450edef68 --- .../LocalCallbackMissmatchInterface.java | 32 +++++++++++++ .../LocalServiceCallbackMissmatchComponent.java | 38 ++++++++++++++++ ...LocalServiceCallbackMissmatchComponentImpl.java | 50 +++++++++++++++++++++ .../local/MissmatchCallbackLocal.composite | 32 +++++++++++++ .../interfaces/InerfaceMissmatchTestCase.java | 52 ++++++++++++++++++++-- 5 files changed, 200 insertions(+), 4 deletions(-) create mode 100644 sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackMissmatchInterface.java create mode 100644 sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceCallbackMissmatchComponent.java create mode 100644 sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceCallbackMissmatchComponentImpl.java create mode 100644 sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchCallbackLocal.composite (limited to 'sca-java-2.x') diff --git a/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackMissmatchInterface.java b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackMissmatchInterface.java new file mode 100644 index 0000000000..fbb81ae5c1 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackMissmatchInterface.java @@ -0,0 +1,32 @@ +/* + * 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 org.apache.tuscany.sca.itest.interfaces; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * only for callBack + */ +public interface LocalCallbackMissmatchInterface { + + void callbackMethod(ParameterObject po); + + void modifyParameter(ParameterObject po); + +} diff --git a/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceCallbackMissmatchComponent.java b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceCallbackMissmatchComponent.java new file mode 100644 index 0000000000..7a66b2d900 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceCallbackMissmatchComponent.java @@ -0,0 +1,38 @@ +/* + * 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 org.apache.tuscany.sca.itest.interfaces; + +import org.oasisopen.sca.annotation.Callback; +import org.oasisopen.sca.annotation.Remotable; + +/** + * Local be-directional callBackService + */ +@Callback(LocalCallbackMissmatchInterface.class) +public interface LocalServiceCallbackMissmatchComponent { + + String foo(String str); + + void callback(String str); + + void modifyParameter(); + + ParameterObject getPO(); + +} diff --git a/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceCallbackMissmatchComponentImpl.java b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceCallbackMissmatchComponentImpl.java new file mode 100644 index 0000000000..7ef6c04a9c --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceCallbackMissmatchComponentImpl.java @@ -0,0 +1,50 @@ +/* + * 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 org.apache.tuscany.sca.itest.interfaces; + +import org.oasisopen.sca.annotation.Callback; +import org.oasisopen.sca.annotation.Service; + +@Service(LocalServiceCallbackMissmatchComponent.class) +public class LocalServiceCallbackMissmatchComponentImpl implements LocalServiceCallbackMissmatchComponent { + + @Callback + protected LocalCallbackMissmatchInterface callback; + + private static ParameterObject po; + + public void callback(String str) { + po = new ParameterObject("CallBack"); + callback.callbackMethod(po); + } + + public void modifyParameter() { + po = new ParameterObject("CallBack"); + callback.modifyParameter(po); + } + + public String foo(String str) { + return po.field1; + } + + public ParameterObject getPO() { + return po; + } + +} diff --git a/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchCallbackLocal.composite b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchCallbackLocal.composite new file mode 100644 index 0000000000..2c673054a6 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchCallbackLocal.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMissmatchTestCase.java b/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMissmatchTestCase.java index a15ba144b4..203b1a4ce0 100644 --- a/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMissmatchTestCase.java +++ b/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMissmatchTestCase.java @@ -31,7 +31,12 @@ import org.oasisopen.sca.ServiceRuntimeException; public class InerfaceMissmatchTestCase { - + /** + * Non-remoteable client and service interfaces where the parameter types of one of the operations don't match. + * Components running in the same composite/JVM, i.e. no remote registry + * + * @throws Exception + */ @Test public void testLocal() throws Exception { String [] contributions = {"./target/classes"}; @@ -50,10 +55,43 @@ public class InerfaceMissmatchTestCase { Assert.assertTrue(ex.getMessage().startsWith("Unable to bind []")); } - node1.stop(); - + node1.stop(); } + + /** + * Non-remoteable client and service interfaces where the parameter types of one of the callback operations don't match. + * Components running in the same composite/JVM, i.e. no remote registry + * + * @throws Exception + */ + @Test + public void testCallbackLocal() throws Exception { + String [] contributions = {"./target/classes"}; + Node node1 = NodeFactory.newInstance().createNode(URI.create("tuscany:InerfaceMissmatchTestCase"), + "org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchCallbackLocal.composite", + contributions); + node1.start(); + + ClientComponent local = node1.getService(ClientComponent.class, "LocalClientComponent"); + ParameterObject po = new ParameterObject(); + + try { + local.foo1(po); + Assert.fail("Expection exteption indicating that interfaces don't match"); + } catch (ServiceRuntimeException ex){ + Assert.assertTrue(ex.getMessage().startsWith("Unable to bind []")); + } + + node1.stop(); + } + /** + * Remoteable client and service interfaces where the parameter types of one of the operations don't match. + * Components running in the same composite/JVM, i.e. no remote registry + * Tuscany is not able to detect miss-match here? + * + * @throws Exception + */ @Test public void testNonDistributedRemotable() throws Exception { @@ -77,7 +115,13 @@ public class InerfaceMissmatchTestCase { node1.stop(); } - + /** + * Remoteable client and service interfaces where the parameter types of one of the operations don't match. + * Components running in the seaprate composite/JVM, i.e. there is a remote registry + * Both of the interfaces are converted to WSDL and Tuscany is able to detect miss-match. + * + * @throws Exception + */ @Test public void testDistributedRemotable() throws Exception { -- cgit v1.2.3