You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2011/08/19 14:38:11 UTC

svn commit: r1159615 - in /tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src: main/java/org/apache/tuscany/sca/itest/interfaces/ main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/local/ test/java/org/apache/tuscany/sca/ites...

Author: slaws
Date: Fri Aug 19 12:38:10 2011
New Revision: 1159615

URL: http://svn.apache.org/viewvc?rev=1159615&view=rev
Log:
Add miss-matched local interface. Accept for the time being that interface matching for remote java interfaces is rather lenient when Java beans are involved.

Added:
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceMissmatchComponent.java
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceMissmatchComponentImpl.java
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchRemoteable.composite
Modified:
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchLocal.composite
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMissmatchTestCase.java

Added: tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java?rev=1159615&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java Fri Aug 19 12:38:10 2011
@@ -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 LocalCallbackInterface {
+
+    void callbackMethod(String str);
+
+    void modifyParameter(ParameterObject po);
+
+}

Added: tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java?rev=1159615&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java Fri Aug 19 12:38:10 2011
@@ -0,0 +1,83 @@
+/*
+ * 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.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(ClientComponent.class)
+public class LocalClientComponentImpl implements ClientComponent, LocalCallbackInterface {
+
+    @Reference
+    protected LocalServiceComponent aCallBackService;
+    private static String callbackValue;
+    private static String onewayValue;
+
+    public String foo1(ParameterObject po) {
+        po.field1 = "AComponent";
+        return aCallBackService.foo("AComponent");
+    }
+
+    public String foo2(String str) throws Exception {
+        return str + "AComponent";
+    }
+
+    public String foo3(String str, int i) {
+        return str + "AComponent" + i;
+    }
+
+    public String foo4(int i, String str) throws Exception {
+        return str + "AComponent" + i;
+    }
+
+    public void callback(String str) {
+        aCallBackService.callback(str);
+    }
+
+    public void callbackMethod(String str) {
+        callbackValue = str;
+    }
+
+    public void callModifyParameter() {
+        this.aCallBackService.modifyParameter();
+    }
+
+    public String getCallbackValue() {
+        return callbackValue;
+    }
+
+    public void onewayMethod(String str) {
+        onewayValue = str;
+        try {
+            Thread.sleep(200);
+        } catch (Exception e) {
+            //do nothing
+        }
+    }
+
+    public String getOnewayValue() {
+        return onewayValue;
+    }
+
+    public void modifyParameter(ParameterObject po) {
+        po.field1 = "AComponent";
+    }
+
+}

Added: tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java?rev=1159615&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java Fri Aug 19 12:38:10 2011
@@ -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(LocalCallbackInterface.class)
+public interface LocalServiceComponent {
+
+    String foo(String str);
+
+    void callback(String str);
+
+    void modifyParameter();
+
+    ParameterObject getPO();
+
+}

Added: tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceMissmatchComponent.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceMissmatchComponent.java?rev=1159615&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceMissmatchComponent.java (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceMissmatchComponent.java Fri Aug 19 12:38:10 2011
@@ -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(LocalCallbackInterface.class)
+public interface LocalServiceMissmatchComponent {
+
+    String foo(ParameterObject po);
+
+    void callback(String str);
+
+    void modifyParameter();
+
+    ParameterObject getPO();
+
+}

Added: tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceMissmatchComponentImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceMissmatchComponentImpl.java?rev=1159615&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceMissmatchComponentImpl.java (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceMissmatchComponentImpl.java Fri Aug 19 12:38:10 2011
@@ -0,0 +1,49 @@
+/*
+ * 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(LocalServiceMissmatchComponent.class)
+public class LocalServiceMissmatchComponentImpl implements LocalServiceMissmatchComponent {
+
+    @Callback
+    protected LocalCallbackInterface callback;
+
+    private static ParameterObject po;
+
+    public void callback(String str) {
+        callback.callbackMethod(str);
+    }
+
+    public void modifyParameter() {
+        po = new ParameterObject("CallBack");
+        callback.modifyParameter(po);
+    }
+
+    public String foo(ParameterObject po) {
+        return po.field1;
+    }
+
+    public ParameterObject getPO() {
+        return po;
+    }
+
+}

Modified: tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchLocal.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchLocal.composite?rev=1159615&r1=1159614&r2=1159615&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchLocal.composite (original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchLocal.composite Fri Aug 19 12:38:10 2011
@@ -19,14 +19,14 @@
 <composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" 
            xmlns:foo="http://foo" targetNamespace="http://foo"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-           name="LocalMissmatch" >
+           name="MissmatchLocal" >
 
     <component name="LocalClientComponent">
-        <implementation.java class="org.apache.tuscany.sca.itest.interfaces.ClientComponentImpl" />
+        <implementation.java class="org.apache.tuscany.sca.itest.interfaces.LocalClientComponentImpl" />
         <reference name="aCallBackService" target="LocalServiceComponent" />
     </component> 
     
     <component name="LocalServiceComponent">
-        <implementation.java class="org.apache.tuscany.sca.itest.interfaces.ServiceMissmatchComponentImpl" />
+        <implementation.java class="org.apache.tuscany.sca.itest.interfaces.LocalServiceMissmatchComponentImpl" />
     </component>  
 </composite>
\ No newline at end of file

Added: tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchRemoteable.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchRemoteable.composite?rev=1159615&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchRemoteable.composite (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchRemoteable.composite Fri Aug 19 12:38:10 2011
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    * 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
+    * 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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" 
+           xmlns:foo="http://foo" targetNamespace="http://foo"
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           name="MissmatchRemoteable" >
+
+    <component name="LocalClientComponent">
+        <implementation.java class="org.apache.tuscany.sca.itest.interfaces.ClientComponentImpl" />
+        <reference name="aCallBackService" target="LocalServiceComponent" />
+    </component> 
+    
+    <component name="LocalServiceComponent">
+        <implementation.java class="org.apache.tuscany.sca.itest.interfaces.ServiceMissmatchComponentImpl" />
+    </component>  
+</composite>
\ No newline at end of file

Modified: tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMissmatchTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMissmatchTestCase.java?rev=1159615&r1=1159614&r2=1159615&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMissmatchTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMissmatchTestCase.java Fri Aug 19 12:38:10 2011
@@ -30,11 +30,10 @@ import org.junit.Test;
 import org.oasisopen.sca.ServiceRuntimeException;
 
 public class InerfaceMissmatchTestCase {
-   
+    
+    
     @Test
-    @Ignore("Interfaces are not detected as being incompatible")
     public void testLocal() throws Exception {
-     
         String [] contributions = {"./target/classes"};
         Node node1 = NodeFactory.newInstance().createNode(URI.create("tuscany:InerfaceMissmatchTestCase"), 
                                                                      "org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchLocal.composite", 
@@ -50,11 +49,37 @@ public class InerfaceMissmatchTestCase {
         } catch (ServiceRuntimeException ex){
             Assert.assertTrue(ex.getMessage().startsWith("Unable to bind []"));
         }
+        
+        node1.stop();
+        
+    }
+   
+    @Test
+    public void testNonDistributedRemotable() throws Exception {
+     
+        String [] contributions = {"./target/classes"};
+        Node node1 = NodeFactory.newInstance().createNode(URI.create("tuscany:InerfaceMissmatchTestCase"), 
+                                                                     "org/apache/tuscany/sca/itest/interfaces/missmatch/local/MissmatchRemoteable.composite", 
+                                                                     contributions);
+        node1.start();
+        
+        ClientComponent local = node1.getService(ClientComponent.class, "LocalClientComponent");
+        ParameterObject po = new ParameterObject();
+        
+        try {
+            local.foo1(po);
+        } catch (ServiceRuntimeException ex){
+            //Assert.assertTrue(ex.getMessage().startsWith("Unable to bind []"));
+            Assert.fail("It seems that the matching process can't tell that these don't match as it has a " +
+                        "String on one side and a complex type (Java Object) on the other");
+        }
+        
+        node1.stop();
     }
   
     
     @Test
-    public void testDistributed() throws Exception {
+    public void testDistributedRemotable() throws Exception {
         
         String [] contributions = {"./target/classes"};
         Node node1 = NodeFactory.newInstance().createNode(URI.create("tuscany:InerfaceMissmatchTestCase"), 
@@ -76,6 +101,9 @@ public class InerfaceMissmatchTestCase {
         } catch (ServiceRuntimeException ex){
             Assert.assertTrue(ex.getMessage().startsWith("Unable to bind []"));
         }
+        
+        node1.stop();
+        node2.stop();
 
     }
 }