summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-03-05 10:30:22 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-03-05 10:30:22 +0000
commitcc1316754fddeeaa691825a79b9db3c5f227cdcc (patch)
treeb7b698274764fd0ff44c2d1609c1c08cf41fe62d /sca-java-2.x
parentd97753e4e92b873251bac044357ebc13f3e29a3d (diff)
Additions/adjustments to the policy matching test case
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@919361 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x')
-rw-r--r--sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/definitions.xml28
-rw-r--r--sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.composite29
-rw-r--r--sca-java-2.x/trunk/itest/policy/matching/src/test/java/org/apache/tuscany/sca/policy/matching/MatchingTestCase.java56
3 files changed, 93 insertions, 20 deletions
diff --git a/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/definitions.xml b/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/definitions.xml
index e166011951..e56ebc859a 100644
--- a/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/definitions.xml
+++ b/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/definitions.xml
@@ -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
diff --git a/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.composite b/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.composite
index dc860320fa..0dacc5b9bc 100644
--- a/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.composite
+++ b/sca-java-2.x/trunk/itest/policy/matching/src/main/resources/org/apache/tuscany/sca/policy/matching/helloworld/helloworld.composite
@@ -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>
diff --git a/sca-java-2.x/trunk/itest/policy/matching/src/test/java/org/apache/tuscany/sca/policy/matching/MatchingTestCase.java b/sca-java-2.x/trunk/itest/policy/matching/src/test/java/org/apache/tuscany/sca/policy/matching/MatchingTestCase.java
index fb27e9fd37..d4ae722318 100644
--- a/sca-java-2.x/trunk/itest/policy/matching/src/test/java/org/apache/tuscany/sca/policy/matching/MatchingTestCase.java
+++ b/sca-java-2.x/trunk/itest/policy/matching/src/test/java/org/apache/tuscany/sca/policy/matching/MatchingTestCase.java
@@ -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 @@ import org.apache.tuscany.sca.policy.matching.helloworld.HelloWorld;
* 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 @@ public class MatchingTestCase extends TestCase {
}
}
+ @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 @@ public class MatchingTestCase extends TestCase {
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();
}