From 16a65da7bf3f40e6ce5c26456ef1cc7bba624d04 Mon Sep 17 00:00:00 2001 From: slaws Date: Tue, 11 Aug 2009 12:49:50 +0000 Subject: 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 --- .../resources/oasis-sca-tests-errors.properties | 19 +++++++++ .../sca/otest/TuscanyOSGiRuntimeBridge.java | 5 +++ .../tuscany/sca/otest/TuscanyRuntimeBridge.java | 45 +++++++++++++++++++++- 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 java/sca/otest/current/tests/src/main/resources/oasis-sca-tests-errors.properties (limited to 'java') 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 -- cgit v1.2.3