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
This commit is contained in:
parent
4c31e02ecc
commit
6000b221ac
3 changed files with 74 additions and 18 deletions
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue