From a6d1b69e97bdd7d018b7d7d5bfa3aca4124d56b8 Mon Sep 17 00:00:00 2001 From: slaws Date: Mon, 5 Oct 2009 13:11:22 +0000 Subject: Update error checking code to match the full error from the start and truncate to the right length git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@821785 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/otest/TuscanyRuntimeBridge.java | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'java/sca/otest/newlayout/tuscany-test-runner/src') 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 9658dfd0ad..d9a0dc0ac7 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 @@ -134,30 +134,33 @@ public class TuscanyRuntimeBridge implements RuntimeBridge { return ContributionLocationHelper.getContributionLocation(testConfiguration.getTestClass()); } // end method getContributionLocation - public void checkError(String testName, Throwable ex) throws Throwable { + 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"); - } + } // end if if (receivedMessage == null){ + ex.printStackTrace(); fail("Null received error message for test " + testName); - } - - int messageStart = receivedMessage.indexOf("] - "); - - if (messageStart < 0){ - fail("Message separator not found for test " + testName); - } + } // end if - receivedMessage = receivedMessage.substring(messageStart + 4); + // Deal with the case where the end of the message is variable (eg contains absolute filenames) + // and where the only relevant part is the start of the message - in this case the expected + // message only contains the stem section which is unchanging... + if( receivedMessage.length() > expectedMessage.length() ) { + // Truncate the received message to the length of the expected message + receivedMessage = receivedMessage.substring(0, expectedMessage.length() ); + } // end if assertEquals( expectedMessage, receivedMessage ); return; + } } // end class TuscanyRuntimeBridge -- cgit v1.2.3