Author: slaws
Date: Fri Mar  5 10:30:22 2010
New Revision: 919361

URL: http://svn.apache.org/viewvc?rev=919361&view=rev
Log:
Additions/adjustments to the policy matching test case

Modified:
    
tuscany/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/definitions.xml
    
tuscany/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.composite
    
tuscany/sca-java-2.x/trunk/itest/policy/matching/src/test/java/org/apache/tuscany/sca/policy/matching/MatchingTestCase.java

Modified: 
tuscany/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/definitions.xml
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/definitions.xml?rev=919361&r1=919360&r2=919361&view=diff
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/definitions.xml
 (original)
+++ 
tuscany/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/definitions.xml
 Fri Mar  5 10:30:22 2010
@@ -28,10 +28,38 @@
     <intent name="testIntent2" constrains="sca:binding" 
intentType="interaction"/>
     
     <intent name="testIntent3" constrains="sca:binding" 
intentType="interaction" excludes="tuscany:testIntent1" />
+    
+    <intent name="testIntent4" constrains="sca:binding" 
intentType="interaction"/>
+    
+    <intent name="testIntent5" constrains="sca:binding" 
intentType="interaction"/>
+    
+    <intent name="testIntent6" constrains="sca:binding" 
intentType="interaction"/>
    
     <policySet name="testPolicy1" 
                provides="tuscany:testIntent1" 
                appliesTo="//binding | //implementation">
     </policySet>
     
+    <policySet name="testPolicy2" 
+               provides="tuscany:testIntent4 tuscany:testIntent5" 
+               appliesTo="//binding | //implementation">
+        <tuscany:jdkLogger name="test.logger">
+            <tuscany:logLevel>FINE</tuscany:logLevel>
+            
<tuscany:resourceBundle>LoggingMessages.properties</tuscany:resourceBundle>
+        </tuscany:jdkLogger>               
+    </policySet>  
+    
+    <policySet name="testPolicy3" 
+               provides="tuscany:testIntent6" 
+               appliesTo="//binding | //implementation">
+        <wsp:ExactlyOne>
+            <wsp:All>
+                <tuscany:jdkLogger name="test.logger">
+                    <tuscany:logLevel>FINE</tuscany:logLevel>
+                    
<tuscany:resourceBundle>LoggingMessages.properties</tuscany:resourceBundle>
+                </tuscany:jdkLogger>
+            </wsp:All>
+        </wsp:ExactlyOne>              
+    </policySet> 
+    
 </definitions>
\ No newline at end of file

Modified: 
tuscany/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.composite
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.composite?rev=919361&r1=919360&r2=919361&view=diff
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.composite
 (original)
+++ 
tuscany/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.composite
 Fri Mar  5 10:30:22 2010
@@ -38,12 +38,30 @@
         <reference name="helloWorld" target="HelloWorldService2" 
requires="tuscany:testIntent1 tuscany:testIntent2"/>
     </component>    
     
-    <component name="HelloWorldClientMatchingIntents">
+    <component name="HelloWorldClientIntentsButNoPolicies1">
         <implementation.java 
class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldClient"/>
-        <reference name="helloWorld" target="HelloWorldService1" />
-    </component>    
+        <reference name="helloWorld" target="HelloWorldService2" />
+    </component>   
     
+    <component name="HelloWorldClientIntentsButNoPolicies2">
+        <implementation.java 
class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldClient"/>
+        <reference name="helloWorld" target="HelloWorldService2" 
requires="tuscany:testIntent1"/>
+    </component>      
     
+    <component name="HelloWorldClientSomePoliciesOnOneSideButNoneOnTheOther">
+        <implementation.java 
class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldClient"/>
+        <reference name="helloWorld" target="HelloWorldService3" />
+    </component>      
+    
+    <component name="HelloWorldClientPolicySetQNameMatch">
+        <implementation.java 
class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldClient"/>
+        <reference name="helloWorld" target="HelloWorldService3" 
requires="tuscany:testIntent5"/>
+    </component> 
+    
+    <component name="HelloWorldClientDifferentPolicyLanguage">
+        <implementation.java 
class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldClient"/>
+        <reference name="helloWorld" target="HelloWorldService3" 
requires="tuscany:testIntent6"/>
+    </component>     
     
     <component name="HelloWorldService1">
                <implementation.java 
class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldService"/>
@@ -55,4 +73,9 @@
         <service name="HelloWorld" requires="tuscany:testIntent1"/>     
     </component>    
     
+    <component name="HelloWorldService3">
+        <implementation.java 
class="org.apache.tuscany.sca.policy.matching.helloworld.HelloWorldService"/>
+        <service name="HelloWorld" requires="tuscany:testIntent4"/>     
+    </component>      
+    
 </composite>

Modified: 
tuscany/sca-java-2.x/trunk/itest/policy/matching/src/test/java/org/apache/tuscany/sca/policy/matching/MatchingTestCase.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/itest/policy/matching/src/test/java/org/apache/tuscany/sca/policy/matching/MatchingTestCase.java?rev=919361&r1=919360&r2=919361&view=diff
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/itest/policy/matching/src/test/java/org/apache/tuscany/sca/policy/matching/MatchingTestCase.java
 (original)
+++ 
tuscany/sca-java-2.x/trunk/itest/policy/matching/src/test/java/org/apache/tuscany/sca/policy/matching/MatchingTestCase.java
 Fri Mar  5 10:30:22 2010
@@ -19,12 +19,15 @@
 
 package org.apache.tuscany.sca.policy.matching;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
 
 import org.apache.tuscany.sca.node.Contribution;
 import org.apache.tuscany.sca.node.Node;
 import org.apache.tuscany.sca.node.NodeFactory;
 import org.apache.tuscany.sca.policy.matching.helloworld.HelloWorld;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 /* 
  * Test the various conditions in the matching algorithm
@@ -37,16 +40,18 @@
  *  7 - FAIL if the policy languages on both sides are different
  *  8 - Perform policy specific match
  */
-public class MatchingTestCase extends TestCase {
+public class MatchingTestCase {
 
-    private Node node;
+    private static Node node;
 
-    @Override
-    protected void setUp() throws Exception {
+    
+    @BeforeClass
+    public static void setUp() throws Exception {
         node = NodeFactory.newInstance().createNode(new Contribution("test", 
"target/classes"));
         node.start();
     }
     
+    @Test
     public void testMutuallyExclusiveIntents() throws Exception {
         HelloWorld helloWorld = node.getService(HelloWorld.class, 
"HelloWorldClientMutuallyExclusiveIntents");
         try {
@@ -56,11 +61,13 @@
         }
     }
     
+    @Test
     public void testNoIntentsOrPolicies() throws Exception {
         HelloWorld helloWorld = node.getService(HelloWorld.class, 
"HelloWorldClientNoIntentsOrPolicies");
         assertEquals("Hello petra", helloWorld.getGreetings("petra"));
     }    
    
+    @Test
     public void testUnresolvedIntentsOnReference() throws Exception {
         HelloWorld helloWorld = node.getService(HelloWorld.class, 
"HelloUnresolvedIntentsOnReference");
         try {
@@ -69,34 +76,49 @@
             assertEquals("Unable to bind", ex.getMessage().substring(0, 14));
         }
     }   
-    
-    public void testMatchingIntents() throws Exception {
-        HelloWorld helloWorld = node.getService(HelloWorld.class, 
"HelloWorldClientMatchingIntents");
-        assertEquals("Hello petra", helloWorld.getGreetings("petra"));
-    }
-    
+       
+    @Test
     public void testIntentsButNoPolicies() throws Exception {
+        HelloWorld helloWorld = node.getService(HelloWorld.class, 
"HelloWorldClientIntentsButNoPolicies1");
+        assertEquals("Hello petra", helloWorld.getGreetings("petra"));
         
+        helloWorld = node.getService(HelloWorld.class, 
"HelloWorldClientIntentsButNoPolicies2");
+        assertEquals("Hello petra", helloWorld.getGreetings("petra"));        
     } 
     
+    @Test
     public void testSomePoliciesOnOneSideButNoneOnTheOther() throws Exception {
-        
+        try {
+            HelloWorld helloWorld = node.getService(HelloWorld.class, 
"HelloWorldClientSomePoliciesOnOneSideButNoneOnTheOther");
+            assertEquals("Hello petra", helloWorld.getGreetings("petra")); 
+        } catch (Exception ex) {
+            assertEquals("Unable to bind", ex.getMessage().substring(0, 14));
+        }
     } 
     
+    @Test
     public void testPolicySetQNameMatch() throws Exception {
-        
+        HelloWorld helloWorld = node.getService(HelloWorld.class, 
"HelloWorldClientPolicySetQNameMatch");
+        assertEquals("Hello petra", helloWorld.getGreetings("petra"));
     } 
     
+    @Test
     public void testDifferentPolicyLanguage() throws Exception {
-        
+        try {
+            HelloWorld helloWorld = node.getService(HelloWorld.class, 
"HelloWorldClientDifferentPolicyLanguage");
+            assertEquals("Hello petra", helloWorld.getGreetings("petra"));     
   
+        } catch (Exception ex) {
+            assertEquals("Unable to bind", ex.getMessage().substring(0, 14));
+        }    
     } 
     
+    @Test
     public void testPolicySpecificMatch() throws Exception {
-        
+        // TODO
     }    
     
-    @Override
-    protected void tearDown() throws Exception {
+    @AfterClass
+    public static void tearDown() throws Exception {
         node.stop();
     }
 


Reply via email to