summaryrefslogtreecommitdiffstats
path: root/java/sca/otest
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-08-11 12:49:50 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-08-11 12:49:50 +0000
commit16a65da7bf3f40e6ce5c26456ef1cc7bba624d04 (patch)
tree1500b4bb63870cbd094d23cb240eaafb5445682a /java/sca/otest
parent9d5277114787650d7117bdd2689182cdcbb2489c (diff)
Code to start discussion about testing Tuscany specific errors in otests.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@803094 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/otest')
-rw-r--r--java/sca/otest/current/tests/src/main/resources/oasis-sca-tests-errors.properties19
-rw-r--r--java/sca/otest/current/tests/src/main/ttest/org/apache/tuscany/sca/otest/TuscanyOSGiRuntimeBridge.java5
-rw-r--r--java/sca/otest/current/tests/src/main/ttest/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java45
3 files changed, 68 insertions, 1 deletions
diff --git a/java/sca/otest/current/tests/src/main/resources/oasis-sca-tests-errors.properties b/java/sca/otest/current/tests/src/main/resources/oasis-sca-tests-errors.properties
new file mode 100644
index 0000000000..ddc07053da
--- /dev/null
+++ b/java/sca/otest/current/tests/src/main/resources/oasis-sca-tests-errors.properties
@@ -0,0 +1,19 @@
+# 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_10001=Duplicate intent {http://docs.oasis-open.org/ns/opencsa/scatests/200903}Fred found in domain
+
diff --git a/java/sca/otest/current/tests/src/main/ttest/org/apache/tuscany/sca/otest/TuscanyOSGiRuntimeBridge.java b/java/sca/otest/current/tests/src/main/ttest/org/apache/tuscany/sca/otest/TuscanyOSGiRuntimeBridge.java
index f399fd6786..d0290ffdb7 100644
--- a/java/sca/otest/current/tests/src/main/ttest/org/apache/tuscany/sca/otest/TuscanyOSGiRuntimeBridge.java
+++ b/java/sca/otest/current/tests/src/main/ttest/org/apache/tuscany/sca/otest/TuscanyOSGiRuntimeBridge.java
@@ -119,5 +119,10 @@ public class TuscanyOSGiRuntimeBridge implements RuntimeBridge {
public String getContributionLocation(Class<?> testClass) {
return ContributionLocationHelper.getContributionLocation(testConfiguration.getTestClass());
} // end method getContributionLocation
+
+ public boolean checkError(String testName, Throwable exception) {
+ // TODO Auto-generated method stub
+ return true;
+ }
} // end class TuscanyRuntimeBridge
diff --git a/java/sca/otest/current/tests/src/main/ttest/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java b/java/sca/otest/current/tests/src/main/ttest/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
index c938088e99..e780fc4ae8 100644
--- a/java/sca/otest/current/tests/src/main/ttest/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
+++ b/java/sca/otest/current/tests/src/main/ttest/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
@@ -18,6 +18,10 @@
*/
package org.apache.tuscany.sca.otest;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
import org.apache.tuscany.sca.node.Contribution;
import org.apache.tuscany.sca.node.ContributionLocationHelper;
import org.apache.tuscany.sca.node.Node;
@@ -36,10 +40,19 @@ public class TuscanyRuntimeBridge implements RuntimeBridge {
protected NodeFactory launcher;
protected Node node;
+ protected Properties expectedErrorMessages;
+
TestConfiguration testConfiguration = null;
public TuscanyRuntimeBridge() {
-
+ // read test error mapping
+ expectedErrorMessages = new Properties();
+ try {
+ InputStream propertiesStream = this.getClass().getResourceAsStream("/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() {
@@ -118,5 +131,35 @@ public class TuscanyRuntimeBridge implements RuntimeBridge {
public String getContributionLocation(Class<?> testClass) {
return ContributionLocationHelper.getContributionLocation(testConfiguration.getTestClass());
} // end method getContributionLocation
+
+ public boolean checkError(String testName, Throwable ex){
+ 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;
+ }
+
+ if (receivedMessage == null){
+ System.out.println("Null received error message for test " + testName);
+ return false;
+ }
+
+ int messageStart = receivedMessage.indexOf("] - ");
+
+ if (messageStart < 0){
+ System.out.println("Message separator not found for test " + testName);
+ }
+
+ receivedMessage = receivedMessage.substring(messageStart + 4);
+
+ if (receivedMessage.startsWith(expectedMessage)){
+ return true;
+ } else {
+ return false;
+ }
+ }
} // end class TuscanyRuntimeBridge