diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2011-12-05 14:18:01 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2011-12-05 14:18:01 +0000 |
commit | 53009c23578ca33e2e6d4e8ac73f4da2e27d9b8e (patch) | |
tree | f8141e72b2c47eba7808dfa0cff315f0fc11fd14 /sca-java-2.x/trunk/testing/itest/implementation-composite | |
parent | 49ebcc7d0da9250df065f0c3e8b9a8abe706b74d (diff) |
TUSCANY-3988 - Apply Greg's suggested fix to ensure that policy provider lists are maintained independently for cloned composites. Add a tests case for it as well.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1210470 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/testing/itest/implementation-composite')
9 files changed, 74 insertions, 28 deletions
diff --git a/sca-java-2.x/trunk/testing/itest/implementation-composite/pom.xml b/sca-java-2.x/trunk/testing/itest/implementation-composite/pom.xml index 89bb6969b6..2a09922406 100644 --- a/sca-java-2.x/trunk/testing/itest/implementation-composite/pom.xml +++ b/sca-java-2.x/trunk/testing/itest/implementation-composite/pom.xml @@ -42,6 +42,12 @@ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-logging</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
diff --git a/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/java/policy/TargetClientImpl.java b/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/java/policy/TargetClientImpl.java index ca45ab7905..7a88fe526f 100644 --- a/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/java/policy/TargetClientImpl.java +++ b/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/java/policy/TargetClientImpl.java @@ -25,9 +25,20 @@ import org.oasisopen.sca.annotation.Service; public class TargetClientImpl implements Target {
@Reference
- protected Target targetService;
+ protected Target targetService1;
+
+ @Reference(required=false)
+ protected Target targetService2;
public String hello(String arg) {
- return "Target: Hello " + targetService.hello(arg) + "!";
+ String returnString = "Target: Hello " + targetService1.hello(arg + "1");
+
+ if(targetService2 != null){
+ returnString += " " + targetService2.hello(arg + "2");
+ }
+
+ returnString += "!";
+
+ return returnString;
}
}
diff --git a/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions new file mode 100644 index 0000000000..8ca579a99f --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions @@ -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.
+policy/definitions.xml
\ No newline at end of file diff --git a/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/bindingoverride/OuterComposite.composite b/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/bindingoverride/OuterComposite.composite index 3f76efb11b..8c13415639 100644 --- a/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/bindingoverride/OuterComposite.composite +++ b/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/bindingoverride/OuterComposite.composite @@ -24,7 +24,7 @@ <component name="OuterClientComponent">
<implementation.java class="policy.TargetClientImpl"/>
- <reference name="targetService" target="OuterServiceComponent"/>
+ <reference name="targetService1" target="OuterServiceComponent"/>
</component>
<component name="OuterServiceComponent">
diff --git a/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyInnerComposite.composite b/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyInnerComposite.composite index 3e78eb4533..585ee7f801 100644 --- a/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyInnerComposite.composite +++ b/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyInnerComposite.composite @@ -30,7 +30,6 @@ <implementation.java class="policy.TargetServiceImpl"/>
<service name="Target">
<interface.java interface="policy.Target"/>
- <binding.ws uri="http://localhost:8085/TargetServiceComponent"/>
</service>
</component>
diff --git a/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyOuterComposite.composite b/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyOuterComposite.composite index 6e686a579f..23c39fce82 100644 --- a/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyOuterComposite.composite +++ b/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyOuterComposite.composite @@ -20,20 +20,29 @@ <composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
targetNamespace="http://policy"
xmlns:policy="http://policy"
- name="PolicyOuterComposite"
- requires="policy:TestIntent_1">
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ name="PolicyOuterComposite">
<component name="TargetClientComponent">
<implementation.java class="policy.TargetClientImpl"/>
- <reference name="targetService" target="OuterTargetServiceComponent"/>
+ <reference name="targetService1" target="OuterTargetService1Component"/>
+ <reference name="targetService2" target="OuterTargetService2Component"/>
</component>
- <component name="OuterTargetServiceComponent">
+ <component name="OuterTargetService1Component">
<implementation.composite name="policy:PolicyInnerComposite"/>
- <service name="TargetService">
+ <service name="TargetService" requires="tuscany:logging">
<interface.java interface="policy.Target"/>
- <binding.ws uri="http://localhost:8085/OuterTargetServiceComponent"/>
+ <binding.ws uri="http://localhost:8085/OuterTargetService1Component"/>
</service>
</component>
+
+ <component name="OuterTargetService2Component">
+ <implementation.composite name="policy:PolicyInnerComposite"/>
+ <service name="TargetService" requires="tuscany:logging">
+ <interface.java interface="policy.Target"/>
+ <binding.ws uri="http://localhost:8085/OuterTargetService2Component"/>
+ </service>
+ </component>
</composite>
diff --git a/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/definitions.xml b/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/definitions.xml index 6e4e4f1380..d67603c8ce 100644 --- a/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/definitions.xml +++ b/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/definitions.xml @@ -21,19 +21,18 @@ targetNamespace="http://policy"
xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
- xmlns:ip="http://policy" >
+ xmlns:policy="http://policy"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" >
+
+ <policySet name="JDKLoggingPolicy"
+ provides="tuscany:logging"
+ appliesTo="//sca:binding.ws"
+ attachTo="//sca:reference | //sca:service">
+ <tuscany:jdkLogger name="test.logger">
+ <tuscany:logLevel>FINE</tuscany:logLevel>
+ <tuscany:resourceBundle>LoggingMessages.properties</tuscany:resourceBundle>
+ </tuscany:jdkLogger>
- <!-- Policy Intents -->
- <sca:intent name="TestIntent_1" constrains="sca:binding.ws">
- <description>Test Intent One</description>
- </sca:intent>
-
- <!-- Policy Sets -->
- <sca:policySet name="TestPolicySet_1_binding"
- provides="ip:TestIntent_1"
- appliesTo="sca:binding.ws"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <wsp:Policy />
- </sca:policySet>
+ </policySet>
</definitions>
\ No newline at end of file diff --git a/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/bindingoverride/BindingOverrideTestCase.java b/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/bindingoverride/BindingOverrideTestCase.java index 1012233984..e25517b110 100644 --- a/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/bindingoverride/BindingOverrideTestCase.java +++ b/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/bindingoverride/BindingOverrideTestCase.java @@ -57,6 +57,6 @@ public class BindingOverrideTestCase{ @Test
public void test() throws Exception {
- Assert.assertEquals("Target: Hello Target: Hello Fred!!", targetClient.hello("Fred"));
+ Assert.assertEquals("Target: Hello Target: Hello Fred1!!", targetClient.hello("Fred"));
}
}
diff --git a/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/policy/PolicyTestCase.java b/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/policy/PolicyTestCase.java index 0cf1496489..9580b3a2a2 100644 --- a/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/policy/PolicyTestCase.java +++ b/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/policy/PolicyTestCase.java @@ -29,12 +29,13 @@ import org.apache.tuscany.sca.node.impl.NodeImpl; import org.apache.tuscany.sca.node.NodeFactory;
import org.apache.tuscany.sca.node.Contribution;
import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
-@Ignore("Doesn't work after porting")
public class PolicyTestCase{
private Node node;
@@ -62,7 +63,7 @@ public class PolicyTestCase{ public void test() throws Exception {
//Check that the binding policy sets do flow down to the component but not down to the
//component inside implementation.composite
- Component outerComponent = ((NodeImpl)node).getDomainComposite().getComponent("OuterTargetServiceComponent");
+ Component outerComponent = ((NodeImpl)node).getDomainComposite().getComponent("OuterTargetService1Component");
// The outer component service bindings should have policy sets attached
Assert.assertEquals(1, outerComponent.getServices().get(0).getPolicySets().size());
@@ -70,10 +71,14 @@ public class PolicyTestCase{ Component component = ((CompositeImpl)outerComponent.getImplementation()).getComponents().get(0);
// The original inner component service binding should not have policy sets attached
- Assert.assertEquals(0, ((PolicySet)component.getServices().get(0).getBindings().get(0)).getReferencedPolicySets().size());
+ Assert.assertEquals(0, ((PolicySubject)component.getServices().get(0).getBindings().get(0)).getPolicySets().size());
// The promoted inner component service binding should have policy sets attached
- Assert.assertEquals(1, ((PolicySet)component.getServices().get(1).getBindings().get(0)).getReferencedPolicySets().size());
+ Assert.assertEquals(1, outerComponent.getServices().get(0).getEndpoints().get(0).getPolicySets().size());
+
+ // TUSCANY-3988
+ // The inner component should have a single set of policy providers
+ Assert.assertEquals(3, ((RuntimeComponent)component).getPolicyProviders().size());
String result = targetClient.hello("Fred");
|