summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-09-23 17:37:40 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-09-23 17:37:40 +0000
commit6000b221ac2f097498c4915279351d53108277f3 (patch)
treee6d0d7cadb2491ee5a4f82d3d2f96cdecba0e4b0 /java
parent4c31e02ecc8216a242419b451dfec4a48fe8645d (diff)
Updates to make the runtime bridge implementations match the new interface in OASIS that allows individual errors to be checked for
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@818171 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rw-r--r--java/sca/otest/newlayout/tuscany-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties21
-rw-r--r--java/sca/otest/newlayout/tuscany-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyOSGiRuntimeBridge.java46
-rw-r--r--java/sca/otest/newlayout/tuscany-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java25
3 files changed, 74 insertions, 18 deletions
diff --git a/java/sca/otest/newlayout/tuscany-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties b/java/sca/otest/newlayout/tuscany-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties
new file mode 100644
index 0000000000..184d8a415e
--- /dev/null
+++ b/java/sca/otest/newlayout/tuscany-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties
@@ -0,0 +1,21 @@
+# 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.
+
+ASM_4002=Duplicate service name: Component = TestComponent1 Service = Service1
+ASM_4003=Duplicate reference name: Component = TestComponent1 Reference = Reference1
+ASM_10001=Duplicate intent {http://docs.oasis-open.org/ns/opencsa/scatests/200903}Fred found in domain
+
diff --git a/java/sca/otest/newlayout/tuscany-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyOSGiRuntimeBridge.java b/java/sca/otest/newlayout/tuscany-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyOSGiRuntimeBridge.java
index d0290ffdb7..afea19fe0b 100644
--- a/java/sca/otest/newlayout/tuscany-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyOSGiRuntimeBridge.java
+++ b/java/sca/otest/newlayout/tuscany-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyOSGiRuntimeBridge.java
@@ -18,6 +18,13 @@
*/
package org.apache.tuscany.sca.otest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.equinox.launcher.Contribution;
import org.apache.tuscany.sca.node.equinox.launcher.ContributionLocationHelper;
@@ -38,9 +45,17 @@ public class TuscanyOSGiRuntimeBridge implements RuntimeBridge {
protected NodeLauncher launcher;
protected Node node;
TestConfiguration testConfiguration = null;
+ protected Properties expectedErrorMessages;
public TuscanyOSGiRuntimeBridge() {
-
+ // read test error mapping
+ expectedErrorMessages = new Properties();
+ try {
+ InputStream propertiesStream = this.getClass().getResourceAsStream("/tuscany-oasis-sca-tests-errors.properties");
+ expectedErrorMessages.load(propertiesStream);
+ } catch (IOException e) {
+ System.out.println("Unable to read oasis-sca-tests-errors.properties file");
+ }
}
public TestConfiguration getTestConfiguration() {
@@ -120,9 +135,30 @@ public class TuscanyOSGiRuntimeBridge implements RuntimeBridge {
return ContributionLocationHelper.getContributionLocation(testConfiguration.getTestClass());
} // end method getContributionLocation
- public boolean checkError(String testName, Throwable exception) {
- // TODO Auto-generated method stub
- return true;
- }
+ public void checkError(String testName, Throwable ex) throws Throwable {
+ String expectedMessage = expectedErrorMessages.getProperty(testName);
+ String receivedMessage = ex.getMessage();
+
+ if (expectedMessage == null){
+ fail("Null expected error message for test " + testName +
+ "Please add message to oasis-sca-tests-errors.properties");
+ }
+
+ if (receivedMessage == null){
+ fail("Null received error message for test " + testName);
+ }
+
+ int messageStart = receivedMessage.indexOf("] - ");
+
+ if (messageStart < 0){
+ fail("Message separator not found for test " + testName);
+ }
+
+ receivedMessage = receivedMessage.substring(messageStart + 4);
+
+ assertEquals( expectedMessage, receivedMessage );
+
+ return;
+ }
} // end class TuscanyRuntimeBridge
diff --git a/java/sca/otest/newlayout/tuscany-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java b/java/sca/otest/newlayout/tuscany-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
index 98aaa2ef7b..9658dfd0ad 100644
--- a/java/sca/otest/newlayout/tuscany-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
+++ b/java/sca/otest/newlayout/tuscany-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
@@ -18,6 +18,9 @@
*/
package org.apache.tuscany.sca.otest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
@@ -48,7 +51,7 @@ public class TuscanyRuntimeBridge implements RuntimeBridge {
// read test error mapping
expectedErrorMessages = new Properties();
try {
- InputStream propertiesStream = this.getClass().getResourceAsStream("/oasis-sca-tests-errors.properties");
+ InputStream propertiesStream = this.getClass().getResourceAsStream("/tuscany-oasis-sca-tests-errors.properties");
expectedErrorMessages.load(propertiesStream);
} catch (IOException e) {
System.out.println("Unable to read oasis-sca-tests-errors.properties file");
@@ -131,34 +134,30 @@ public class TuscanyRuntimeBridge implements RuntimeBridge {
return ContributionLocationHelper.getContributionLocation(testConfiguration.getTestClass());
} // end method getContributionLocation
- public boolean checkError(String testName, Throwable ex){
+ public void checkError(String testName, Throwable ex) throws Throwable {
String expectedMessage = expectedErrorMessages.getProperty(testName);
String receivedMessage = ex.getMessage();
if (expectedMessage == null){
- System.out.println("Null expected error message for test " + testName);
- System.out.println("Please add message to oasis-sca-tests-errors.properties");
- return false;
+ fail("Null expected error message for test " + testName +
+ "Please add message to oasis-sca-tests-errors.properties");
}
if (receivedMessage == null){
- System.out.println("Null received error message for test " + testName);
- return false;
+ fail("Null received error message for test " + testName);
}
int messageStart = receivedMessage.indexOf("] - ");
if (messageStart < 0){
- System.out.println("Message separator not found for test " + testName);
+ fail("Message separator not found for test " + testName);
}
receivedMessage = receivedMessage.substring(messageStart + 4);
- if (receivedMessage.startsWith(expectedMessage)){
- return true;
- } else {
- return false;
- }
+ assertEquals( expectedMessage, receivedMessage );
+
+ return;
}
} // end class TuscanyRuntimeBridge