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/10/17 14:51:23 UTC

svn commit: r1185135 - in /tuscany/sca-java-2.x/trunk: modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ modules/core/META-INF/ modules/core/src/main/java/org/apache/t...

Author: slaws
Date: Mon Oct 17 12:51:22 2011
New Revision: 1185135

URL: http://svn.apache.org/viewvc?rev=1185135&view=rev
Log:
TUSCANY-3958 - serialize endpoint intents/policy sets across the registry for matching purposes. In this change they are stashed in the component element on write and then retrieved back into the endpoint model on read.

Added:
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/META-INF/   (with props)
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/META-INF/services/   (with props)
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/definitions.xml
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchPolicyDistributedClient.composite
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchPolicyDistributedService.composite
Modified:
    tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java
    tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java
    tuscany/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/pom.xml
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/ServiceComponentImpl.java
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchDistributedService.composite
    tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMatchTestCase.java

Modified: tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java?rev=1185135&r1=1185134&r2=1185135&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java Mon Oct 17 12:51:22 2011
@@ -19,6 +19,9 @@
 
 package org.apache.tuscany.sca.assembly.xml;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
@@ -41,6 +44,7 @@ import org.apache.tuscany.sca.contributi
 import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.policy.PolicySet;
 
 /**
  *
@@ -87,6 +91,10 @@ public class EndpointProcessor extends B
             endpoint.setComponent(component);
             endpoint.setService(service);
             endpoint.setBinding(binding);
+            
+            // retrieve the stash of intents and policy sets from the component
+            endpoint.getRequiredIntents().addAll(component.getRequiredIntents());
+            endpoint.getPolicySets().addAll(component.getPolicySets());
         }
         return endpoint;
     }
@@ -108,6 +116,14 @@ public class EndpointProcessor extends B
                 composite.getComponents().add(component);
                 component.getReferences().clear();
                 component.getServices().clear();
+                
+                // stash endpoint intents and policy sets on the component so that they are all
+                // in one place
+                component.getRequiredIntents().clear();
+                component.getRequiredIntents().addAll(endpoint.getRequiredIntents());
+                component.getPolicySets().clear();
+                component.getPolicySets().addAll(endpoint.getPolicySets());
+                
                 if (endpoint.getService() != null) {
                     ComponentService service = (ComponentService)endpoint.getService().clone();
                     component.getServices().add(service);
@@ -143,5 +159,11 @@ public class EndpointProcessor extends B
     }
 
     public void resolve(Endpoint model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+        // the only thing we'll resolve here is the policy model as the endpoint 
+        // matching algorithm needs to look inside the policy model
+        
+        for (PolicySet policySet : model.getPolicySets()){
+            extensionProcessor.resolve(policySet, resolver, context);
+        }
     }
 }

Modified: tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java?rev=1185135&r1=1185134&r2=1185135&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java Mon Oct 17 12:51:22 2011
@@ -33,4 +33,6 @@ public interface EndpointSerializer {
     Endpoint readEndpoint(String xml);
 
     String write(Endpoint endpoint);
+    
+    void resolveEndpoint(Endpoint endpoint);
 }

Modified: tuscany/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF?rev=1185135&r1=1185134&r2=1185135&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF (original)
+++ tuscany/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF Mon Oct 17 12:51:22 2011
@@ -68,6 +68,7 @@ Import-Package: javax.security.auth,
  org.apache.tuscany.sca.monitor;version="2.0.0",
  org.apache.tuscany.sca.node;version="2.0.0",
  org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.policy.util;version="2.0.0",
  org.apache.tuscany.sca.provider;version="2.0.0",
  org.apache.tuscany.sca.runtime;version="2.0.0",
  org.apache.tuscany.sca.work;version="2.0.0",

Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java?rev=1185135&r1=1185134&r2=1185135&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java Mon Oct 17 12:51:22 2011
@@ -21,6 +21,8 @@ package org.apache.tuscany.sca.core.asse
 
 import java.io.StringReader;
 import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLOutputFactory;
@@ -29,12 +31,21 @@ import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.tuscany.sca.assembly.Endpoint;
 import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.contribution.Contribution;
 import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.util.PolicyHelper;
 import org.apache.tuscany.sca.runtime.EndpointSerializer;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
 import org.oasisopen.sca.ServiceRuntimeException;
 
 public class EndpointSerializerImpl implements EndpointSerializer {
@@ -57,6 +68,7 @@ public class EndpointSerializerImpl impl
 
     public Endpoint readEndpoint(String xml) {
         try {
+            //System.out.println("Read Endpoint string >> " + xml);
             XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml));
             Endpoint result = processor.read(reader, new ProcessorContext(registry));
             result.setRemote(true);
@@ -66,6 +78,84 @@ public class EndpointSerializerImpl impl
             throw new ServiceRuntimeException(e);
         }
     }
+    
+    public void resolveEndpoint(Endpoint endpoint) {
+        CompositeContext compositeContext = ((RuntimeEndpoint)endpoint).getCompositeContext();
+        
+        if (compositeContext == null){
+            // will be null if this is the SCAClient
+            return;
+        }
+        
+        Definitions systemDefinitions = compositeContext.getSystemDefinitions();
+        if (systemDefinitions != null){
+            // Find pre-resolved intents from the system definition
+            List<Intent> intents = new ArrayList<Intent>();
+            
+            for (Intent intent : endpoint.getRequiredIntents()){
+                Intent resolvedIntent = PolicyHelper.getIntent(systemDefinitions, intent.getName());
+              
+                if (resolvedIntent != null){
+                    intents.add(resolvedIntent);
+                } else {
+                    // look to see if this intent is provided by the binding
+                    BindingType bindingType = systemDefinitions.getBindingType(endpoint.getBinding().getType());
+
+                    if (bindingType != null){
+                        for (Intent apIntent : bindingType.getAlwaysProvidedIntents()){
+                            if (apIntent.getName().equals(intent.getName())){
+                                resolvedIntent = apIntent;
+                                break;
+                            }
+                        }
+                        
+                        if (resolvedIntent == null){
+                            for (Intent mpIntent : bindingType.getMayProvidedIntents()){
+                                if (mpIntent.getName().equals(intent.getName())){
+                                    resolvedIntent = mpIntent;
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                    
+                    if (resolvedIntent != null){
+                        intents.add(resolvedIntent);
+                    } else {
+                        throw new ServiceRuntimeException("Remote endpoint " +
+                                                          endpoint +
+                                                          " has intent " +
+                                                          intent +
+                                                          " that can't be found in the local system definitions in node " +
+                                                          compositeContext.getNodeURI());
+                    }
+                }
+            }
+            
+            endpoint.getRequiredIntents().clear();
+            endpoint.getRequiredIntents().addAll(intents);
+            
+            // Find pre-resolved policy sets from the system definition
+            List<PolicySet> policySets = new ArrayList<PolicySet>();
+            
+            for (PolicySet policySet : endpoint.getPolicySets()){
+                PolicySet resolvedPolicySet = PolicyHelper.getPolicySet(systemDefinitions, policySet.getName());
+                if (resolvedPolicySet != null){
+                    policySets.add(resolvedPolicySet);
+                } else {
+                    throw new ServiceRuntimeException("Remote endpoint " +
+                                                      endpoint +
+                                                      " has policy set " +
+                                                      policySet +
+                                                      " that can't be found in the local system definitions in node " +
+                                                      compositeContext.getNodeURI());
+                }
+            }
+            
+            endpoint.getPolicySets().clear();
+            endpoint.getPolicySets().addAll(policySets);
+        }
+    }
 
     public String write(Endpoint endpoint) {
         StringWriter sw = new StringWriter();
@@ -74,7 +164,9 @@ public class EndpointSerializerImpl impl
             processor.write(endpoint, writer, new ProcessorContext(registry));
             writer.flush();
             writer.close();
-            return sw.toString();
+            String endpointString = sw.toString();
+            //System.out.println("Write Endpoint string >> " + endpointString);
+            return endpointString;
         } catch (Exception e) {
             throw new ServiceRuntimeException(e);
         }

Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java?rev=1185135&r1=1185134&r2=1185135&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java Mon Oct 17 12:51:22 2011
@@ -925,7 +925,12 @@ public class RuntimeEndpointImpl extends
     @Override
     protected synchronized void resolve() {
         if (xml != null && component == null) {
-            if (compositeContext == null) {
+            // TUSCANY-3958 - when an endpoint arrives at the remote side of the 
+            //                domain registry it's composite context is set, but to 
+            //                a default that's not that useful. We can tell because it
+            //                doesn't set the system definitions
+            if (compositeContext == null || 
+                compositeContext.getSystemDefinitions() == null) {
                 compositeContext = CompositeContext.getCurrentCompositeContext();
                 if (compositeContext != null) {
                     bind(compositeContext);
@@ -934,6 +939,7 @@ public class RuntimeEndpointImpl extends
             if (serializer != null) {
                 RuntimeEndpointImpl ep = (RuntimeEndpointImpl)serializer.readEndpoint(xml);
                 copyFrom(ep);
+                serializer.resolveEndpoint(this);
             } else {
             	// In this case, we assume that we're running on a detached (non Tuscany) thread and
             	// as a result we need to connect back to the Tuscany environment...

Modified: tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/pom.xml?rev=1185135&r1=1185134&r2=1185135&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/pom.xml (original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/pom.xml Mon Oct 17 12:51:22 2011
@@ -67,7 +67,20 @@
             <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-host-rmi</artifactId>
             <version>2.0-SNAPSHOT</version>
-        </dependency>         
+        </dependency> 
+        
+        <dependency>
+            <groupId>org.codehaus.woodstox</groupId>
+            <artifactId>wstx-asl</artifactId>
+            <version>3.2.9</version>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                   <groupId>stax</groupId>
+                   <artifactId>stax-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>                
         
     </dependencies>
 </project>

Modified: tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/ServiceComponentImpl.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/ServiceComponentImpl.java?rev=1185135&r1=1185134&r2=1185135&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/ServiceComponentImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/ServiceComponentImpl.java Mon Oct 17 12:51:22 2011
@@ -28,10 +28,6 @@ public class ServiceComponentImpl implem
     @Callback
     protected CallbackInterface callback;
  
-/*    
-    @Reference
-    protected ServiceComponent chainedCallbackReference;
-*/
     private static ParameterObject po;
 
     public String foo(String str) {

Propchange: tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/META-INF/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/META-INF/services/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions?rev=1185135&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions Mon Oct 17 12:51:22 2011
@@ -0,0 +1,17 @@
+# 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.
+org/apache/tuscany/sca/itest/interfaces/definitions.xml
\ 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/definitions.xml
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/definitions.xml?rev=1185135&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/definitions.xml (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/definitions.xml Mon Oct 17 12:51:22 2011
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+    * 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.    
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" 
+             targetNamespace="http://www.tuscany.apache.org/itests/interface/match"
+    		 xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" 
+    		 xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" >
+
+
+    <sca:policySet name="BasicAuthenticationPolicySet"
+                   attachTo="//sca:binding.ws"
+                   provides="clientAuthentication.transport"
+                   appliesTo="//sca:binding.ws">
+        <tuscany:basicAuthentication>
+          <tuscany:userName>myname</tuscany:userName>
+          <tuscany:password>mypassword</tuscany:password>
+        </tuscany:basicAuthentication>
+    </sca:policySet>   
+      
+</definitions>
\ No newline at end of file

Modified: tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchDistributedService.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/match/distributed/MatchDistributedService.composite?rev=1185135&r1=1185134&r2=1185135&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchDistributedService.composite (original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchDistributedService.composite Mon Oct 17 12:51:22 2011
@@ -22,10 +22,6 @@
            name="MatchDistributedService" >
     
     <component name="DistributedServiceComponent">
-        <implementation.java class="org.apache.tuscany.sca.itest.interfaces.ServiceComponentImpl" />
-<!--        
-        <reference name="chainedCallbackReference" target="DistributedServiceComponent">
-        </reference>
--->        
+        <implementation.java class="org.apache.tuscany.sca.itest.interfaces.ServiceComponentImpl" />        
     </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/match/distributed/MatchPolicyDistributedClient.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/match/distributed/MatchPolicyDistributedClient.composite?rev=1185135&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchPolicyDistributedClient.composite (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchPolicyDistributedClient.composite Mon Oct 17 12:51:22 2011
@@ -0,0 +1,29 @@
+<?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="MatchPolicyDistributedClient" >
+
+    <component name="DistributedClientComponent">
+        <implementation.java class="org.apache.tuscany.sca.itest.interfaces.ClientComponentImpl" />
+        <reference name="aCallBackService" target="DistributedServiceComponent"/>
+    </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/match/distributed/MatchPolicyDistributedService.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/match/distributed/MatchPolicyDistributedService.composite?rev=1185135&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchPolicyDistributedService.composite (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchPolicyDistributedService.composite Mon Oct 17 12:51:22 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="MatchPolicyDistributedService" >
+    
+    <component name="DistributedServiceComponent">
+        <implementation.java class="org.apache.tuscany.sca.itest.interfaces.ServiceComponentImpl" />       
+        <service name="ServiceComponent" requires="authentication">
+            <binding.ws requires="sca:SOAP.v1_2"/>
+        </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/InerfaceMatchTestCase.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/InerfaceMatchTestCase.java?rev=1185135&r1=1185134&r2=1185135&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMatchTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMatchTestCase.java Mon Oct 17 12:51:22 2011
@@ -35,7 +35,7 @@ import org.oasisopen.sca.ServiceRuntimeE
 public class InerfaceMatchTestCase {
     
     /**
-     * Non-remoteable client and service interfaces where the interfaces match.
+     * Non-remotable client and service interfaces where the interfaces match.
      * Components running in the same composite/JVM, i.e. no remote registry
      * 
      * @throws Exception
@@ -62,8 +62,8 @@ public class InerfaceMatchTestCase {
     }
   
     /**
-     * Remoteable client and service interfaces where the interfaces match.
-     * Components running in the seaprate composite/JVM, i.e. there is a remote registry
+     * Remotable client and service interfaces where the interfaces match.
+     * Components running in the separate composite/JVM, i.e. there is a remote registry
      * 
      * @throws Exception
      */
@@ -84,7 +84,7 @@ public class InerfaceMatchTestCase {
                                                                      "org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchDistributedService.composite", 
                                                                      contributions);
         
-        // for default binding on node2 to use a different port from node 1(which will default to 8080
+        // force default binding on node2 to use a different port from node 1(which will default to 8080
         ((NodeImpl)node2).getConfiguration().addBinding(WebServiceBinding.TYPE, "http://localhost:8081/");
         ((NodeImpl)node2).getConfiguration().addBinding(SCABinding.TYPE, "http://localhost:8081/");
         node2.start();
@@ -112,7 +112,7 @@ public class InerfaceMatchTestCase {
     }
     
     /**
-     * Remoteable client and service interfaces where the interfaces match but
+     * Remotable client and service interfaces where the interfaces match but
      * where there is a parameter that can't be converted to/from XML using JAXB
      * Components running in the separate composite/JVM, i.e. there is a remote registry
      * 
@@ -137,7 +137,7 @@ public class InerfaceMatchTestCase {
                                                                      "org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchNonJAXBDistributedService.composite", 
                                                                      contributions);
         
-        // for default binding on node2 to use a different port from node 1(which will default to 8080
+        // force default binding on node2 to use a different port from node 1(which will default to 8080
         // Don't need to do this as not testing callbacks here
         //((NodeImpl)node2).getConfiguration().addBinding(WebServiceBinding.TYPE, "http://localhost:8081/");
         //((NodeImpl)node2).getConfiguration().addBinding(SCABinding.TYPE, "http://localhost:8081/");
@@ -164,4 +164,49 @@ public class InerfaceMatchTestCase {
         node1.stop();
         node2.stop();
     }    
+    
+    /**
+     * Remotable client and service interfaces where the interfaces match and the service has 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/match/distributed/MatchPolicyDistributedClient.composite", 
+                                                                     contributions);
+        node1.start();
+
+        Node node2 = NodeFactory.newInstance().createNode(URI.create("uri:default"), 
+                                                                     "org/apache/tuscany/sca/itest/interfaces/match/distributed/MatchPolicyDistributedService.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);
+            Assert.assertEquals("AComponent", response);
+        } catch (ServiceRuntimeException ex){
+            Assert.fail("Unexpected exception with foo " + ex.toString());
+        }
+        
+        try {
+            local.callback("Callback");
+            String response = local.getCallbackValue();
+            Assert.assertEquals("Callback", response);
+        } catch (ServiceRuntimeException ex){
+            Assert.fail("Unexpected exception with callback" + ex.toString());
+        }        
+        
+        node1.stop();
+        node2.stop();
+    }    
 }