tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sl...@apache.org
Subject svn commit: r1185139 - in /tuscany/sca-java-2.x/trunk: modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/ testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/ testing/itest...
Date Mon, 17 Oct 2011 12:55:32 GMT
Author: slaws
Date: Mon Oct 17 12:55:31 2011
New Revision: 1185139

URL: http://svn.apache.org/viewvc?rev=1185139&view=rev
Log:
TUSCANY-3959 - Correct interface matching so that it takes account of mayProvides intents.


Added:
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedClient.composite
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedService.composite
Modified:
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMissmatchTestCase.java
    tuscany/sca-java-2.x/trunk/testing/itest/policies/src/main/resources/Payment.composite

Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java?rev=1185139&r1=1185138&r2=1185139&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
Mon Oct 17 12:55:31 2011
@@ -444,11 +444,11 @@ public class EndpointReferenceBinderImpl
             // TUSCANY-3873 - add policy from the service
             //                we don't care about intents at this stage
             endpointReference.getPolicySets().addAll(matchedEndpoint.getPolicySets());
+            
             // TODO - we need to re-run the appliesTo processing here but there is some question
about what 
             //        appliesTo means. It's also difficult to get to the PolicyAppliesToBuilder
from here and
             //        need a new EntensionInterface to support access. So for now I'm just
cheating and looking to 
             //        see if the XPath expression contains the binding type as a string while
we discuss appliesTo
-            
             List<PolicySet> psToRemove = new ArrayList<PolicySet>();
             
             for (PolicySet ps : endpointReference.getPolicySets() ) {
@@ -765,18 +765,14 @@ public class EndpointReferenceBinderImpl
             systemDefinitions = ((RuntimeEndpoint)endpoint).getCompositeContext().getSystemDefinitions();
         }
         
-        for (BindingType loopBindingType : systemDefinitions.getBindingTypes()){
-            if (loopBindingType.getType().equals(binding.getType())){
-                bindingType = loopBindingType;
-                break;
-            }
-        }
+        bindingType = systemDefinitions.getBindingType(binding.getType());
         
         // Before we start examining intents, remove any whose constrained
         // types don't include the binding type
         removeConstrainedIntents(endpointReference, bindingType);
         
         List<Intent> eprIntents = new ArrayList<Intent>();
+        List<Intent> eprMayProvideInterationIntents = new ArrayList<Intent>();
         eprIntents.addAll(endpointReference.getRequiredIntents());
         
         // first check the binding type
@@ -787,6 +783,9 @@ public class EndpointReferenceBinderImpl
             } else if (bindingType != null &&
                        bindingType.getMayProvidedIntents().contains(intent)){
                 eprIntents.remove(intent);
+                if (intent.getType().equals(Intent.Type.interaction)){
+                    eprMayProvideInterationIntents.add(intent);
+                }
             } else {
                // TODO - this code also appears in the ComponentPolicyBuilder
                //        so should rationalize
@@ -820,7 +819,29 @@ public class EndpointReferenceBinderImpl
             matchAudit.append("No match because there are unresolved intents " + eprIntents.toString()
+ " ");
             matchAudit.appendSeperator();
             return false;
-        }   
+        }  
+        
+        // TUSCANY-3959 - something that's not explicitly stated in the spec. mayProvides
intents don't
+        //                don't lead to policy sets as the binding natively implements the
intent. So 
+        //                we need to check that these intents match explicitly between reference
and service
+        //                sides
+        if (eprMayProvideInterationIntents.size() > 0){
+            for (Intent eprIntent : eprMayProvideInterationIntents){
+                boolean match = false;
+                for (Intent epIntent : endpoint.getRequiredIntents()){
+                    if (epIntent.equals(eprIntent)){
+                        match = true;
+                        break;
+                    }
+                }
+                
+                if (!match){
+                    matchAudit.append("No match because the reference has a mayProvide intent
that the service doesn't have " + eprIntent.getName());
+                    matchAudit.appendSeperator();
+                    return false;
+                }
+            }
+        }
         
         // if there are no policies on epr or ep side then 
         // they match
@@ -932,7 +953,7 @@ public class EndpointReferenceBinderImpl
             	
                 if (constrainedTypes.size() > 0){               
                     boolean constraintFound = false;
-                    for (ExtensionType constrainedType : i.getConstrainedTypes()){
+                    for (ExtensionType constrainedType : constrainedTypes){
                         if (constrainedType.getType().equals(bindingType.getType()) ||
                             constrainedType.getType().equals(bindingType.getBaseType())){
                             constraintFound = true;

Added: tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedClient.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/distributed/MissmatchPolicyDistributedClient.composite?rev=1185139&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedClient.composite
(added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedClient.composite
Mon Oct 17 12:55:31 2011
@@ -0,0 +1,30 @@
+<?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:sca="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="MissmatchPolicyDistributedClient" >
+
+    <component name="DistributedClientComponent">
+        <implementation.java class="org.apache.tuscany.sca.itest.interfaces.ClientComponentImpl"
/>
+        <reference name="aCallBackService" target="DistributedServiceComponent" requires="sca:SOAP.v1_2"/>
+    </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/distributed/MissmatchPolicyDistributedService.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/distributed/MissmatchPolicyDistributedService.composite?rev=1185139&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedService.composite
(added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedService.composite
Mon Oct 17 12:55:31 2011
@@ -0,0 +1,31 @@
+<?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:sca="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="MissmatchPolicyDistributedService" >
+    
+    <component name="DistributedServiceComponent">
+        <implementation.java class="org.apache.tuscany.sca.itest.interfaces.ServiceComponentImpl"
/>       
+        <service name="ServiceComponent" requires="authentication">
+            <binding.ws/>
+        </service>
+    </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=1185139&r1=1185138&r2=1185139&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
Mon Oct 17 12:55:31 2011
@@ -201,6 +201,45 @@ public class InerfaceMissmatchTestCase {
             node2.stop();
             Assert.assertTrue(ex.getMessage().startsWith("Unable to bind []"));
         }
-
     }
+    
+    /**
+     * Remotable client and service interfaces where the interfaces match and the service
and reference
+     * have missmatching policy.
+     * Components running in the separate composite/JVM, i.e. there is a remote registry
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testPolicyDistributedRemotable() throws Exception {
+        
+        
+        String [] contributions = {"./target/classes"};
+        Node node1 = NodeFactory.newInstance().createNode(URI.create("uri:default"), 
+                                                                     "org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedClient.composite",

+                                                                     contributions);
+        node1.start();
+
+        Node node2 = NodeFactory.newInstance().createNode(URI.create("uri:default"), 
+                                                                     "org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedService.composite",

+                                                                     contributions);
+        // force binding.ws on node2 to use a different port from node 1(which will default
to 8080
+        ((NodeImpl)node2).getConfiguration().addBinding(WebServiceBinding.TYPE, "http://localhost:8081/");
+        node2.start();
+        
+        ClientComponent local = node1.getService(ClientComponent.class, "DistributedClientComponent");
+        ParameterObject po = new ParameterObject();
+        
+        try {
+            String response = local.foo1(po);
+            node1.stop();
+            node2.stop();            
+            Assert.fail("Expected exception indicating that interfaces don't match");
+        } catch (ServiceRuntimeException ex){
+            node1.stop();
+            node2.stop();
+            Assert.assertTrue(ex.getMessage().startsWith("Unable to bind []"));
+        }
+        
+    }     
 }

Modified: tuscany/sca-java-2.x/trunk/testing/itest/policies/src/main/resources/Payment.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/policies/src/main/resources/Payment.composite?rev=1185139&r1=1185138&r2=1185139&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/policies/src/main/resources/Payment.composite
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/policies/src/main/resources/Payment.composite
Mon Oct 17 12:55:31 2011
@@ -36,8 +36,7 @@
     <component name="Payment">
         <implementation.java class="org.apache.tuscany.sca.itest.policies.impl.PaymentImpl"
/>
         <reference name="creditCardPayment">
-            <binding.sca requires="sca:integrity tuscany:logging" uri="CreditCardPayment">
-            </binding.sca>
+            <binding.sca requires="sca:integrity.transport tuscany:logging" uri="CreditCardPayment"/>
         </reference>
         <reference name="customerRegistry" target="Customer/Registry" requires="sca:suspendsTransaction
tuscany:logging"/>
     </component>



Mime
View raw message