tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sl...@apache.org
Subject svn commit: r1210470 - in /tuscany/sca-java-2.x/trunk: modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ testing/itest/implementation-composite/ testing/itest/implementation-composite/src/main/java/policy/ testing/itest/implementati...
Date Mon, 05 Dec 2011 14:18:02 GMT
Author: slaws
Date: Mon Dec  5 14:18:01 2011
New Revision: 1210470

URL: http://svn.apache.org/viewvc?rev=1210470&view=rev
Log:
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.

Added:
    tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/META-INF/
    tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/META-INF/services/
    tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
Modified:
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java
    tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/pom.xml
    tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/java/policy/TargetClientImpl.java
    tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/bindingoverride/OuterComposite.composite
    tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyInnerComposite.composite
    tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyOuterComposite.composite
    tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/definitions.xml
    tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/bindingoverride/BindingOverrideTestCase.java
    tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/policy/PolicyTestCase.java

Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.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/RuntimeComponentImpl.java?rev=1210470&r1=1210469&r2=1210470&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java
Mon Dec  5 14:18:01 2011
@@ -128,4 +128,12 @@ public class RuntimeComponentImpl extend
         }
 
     }
+    
+    // TUSCANY-3988
+    @Override
+    public Object clone() throws CloneNotSupportedException {
+        RuntimeComponentImpl clone = (RuntimeComponentImpl)super.clone();
+        clone.policyProviders = new ArrayList<PolicyProvider>();
+        return clone;
+    } 
 }

Modified: tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/pom.xml?rev=1210470&r1=1210469&r2=1210470&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/pom.xml (original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/pom.xml Mon Dec  5 14:18:01
2011
@@ -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>

Modified: tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/java/policy/TargetClientImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/java/policy/TargetClientImpl.java?rev=1210470&r1=1210469&r2=1210470&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/java/policy/TargetClientImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/java/policy/TargetClientImpl.java
Mon Dec  5 14:18:01 2011
@@ -25,9 +25,20 @@ import org.oasisopen.sca.annotation.Serv
 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;
     }
 }

Added: tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/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/implementation-composite/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions?rev=1210470&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
(added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
Mon Dec  5 14:18:01 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.
+policy/definitions.xml
\ No newline at end of file

Modified: tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/bindingoverride/OuterComposite.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/bindingoverride/OuterComposite.composite?rev=1210470&r1=1210469&r2=1210470&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/bindingoverride/OuterComposite.composite
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/bindingoverride/OuterComposite.composite
Mon Dec  5 14:18:01 2011
@@ -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">

Modified: tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyInnerComposite.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyInnerComposite.composite?rev=1210470&r1=1210469&r2=1210470&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyInnerComposite.composite
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyInnerComposite.composite
Mon Dec  5 14:18:01 2011
@@ -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>
 

Modified: tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyOuterComposite.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyOuterComposite.composite?rev=1210470&r1=1210469&r2=1210470&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyOuterComposite.composite
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/PolicyOuterComposite.composite
Mon Dec  5 14:18:01 2011
@@ -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>

Modified: tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/definitions.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/definitions.xml?rev=1210470&r1=1210469&r2=1210470&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/definitions.xml
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/main/resources/policy/definitions.xml
Mon Dec  5 14:18:01 2011
@@ -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

Modified: tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/bindingoverride/BindingOverrideTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/bindingoverride/BindingOverrideTestCase.java?rev=1210470&r1=1210469&r2=1210470&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/bindingoverride/BindingOverrideTestCase.java
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/bindingoverride/BindingOverrideTestCase.java
Mon Dec  5 14:18:01 2011
@@ -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"));
     }
 }

Modified: tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/policy/PolicyTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/policy/PolicyTestCase.java?rev=1210470&r1=1210469&r2=1210470&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/policy/PolicyTestCase.java
(original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/implementation-composite/src/test/java/policy/PolicyTestCase.java
Mon Dec  5 14:18:01 2011
@@ -29,12 +29,13 @@ import org.apache.tuscany.sca.node.impl.
 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");
 



Mime
View raw message