summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-10-17 12:55:31 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-10-17 12:55:31 +0000
commit7d550f3ba9d89ba24b44fa4f2ee7eff519bdaaa2 (patch)
tree87243994de2f86ca08fd95a8fcd4226a102e3bdf /sca-java-2.x
parenta206102be754cca89c3aa8b386f635521aa56bde (diff)
TUSCANY-3959 - Correct interface matching so that it takes account of mayProvides intents.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1185139 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java39
-rw-r--r--sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedClient.composite30
-rw-r--r--sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedService.composite31
-rw-r--r--sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMissmatchTestCase.java41
-rw-r--r--sca-java-2.x/trunk/testing/itest/policies/src/main/resources/Payment.composite3
5 files changed, 132 insertions, 12 deletions
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
index 179c60a829..d5695f1cc4 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
@@ -444,11 +444,11 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
// 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 implements EndpointReferenceBinder {
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 implements EndpointReferenceBinder {
} 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 implements EndpointReferenceBinder {
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 implements EndpointReferenceBinder {
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;
diff --git a/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedClient.composite b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedClient.composite
new file mode 100644
index 0000000000..b8f51c9afc
--- /dev/null
+++ b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedClient.composite
@@ -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
diff --git a/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedService.composite b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedService.composite
new file mode 100644
index 0000000000..a90d9e0a3f
--- /dev/null
+++ b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/resources/org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchPolicyDistributedService.composite
@@ -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
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 0c54e5f8e7..f12be0247f 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
@@ -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 []"));
+ }
+
+ }
}
diff --git a/sca-java-2.x/trunk/testing/itest/policies/src/main/resources/Payment.composite b/sca-java-2.x/trunk/testing/itest/policies/src/main/resources/Payment.composite
index 96f4f45cc7..87e8fe2bc9 100644
--- a/sca-java-2.x/trunk/testing/itest/policies/src/main/resources/Payment.composite
+++ b/sca-java-2.x/trunk/testing/itest/policies/src/main/resources/Payment.composite
@@ -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>