diff options
Diffstat (limited to 'java/sca/otest/newlayout/tuscany-test-runner/src')
-rw-r--r-- | java/sca/otest/newlayout/tuscany-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java | 34 |
1 files changed, 33 insertions, 1 deletions
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 8ceb44e976..e2a38ae6f3 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 @@ -21,6 +21,8 @@ package org.apache.tuscany.sca.otest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; +import java.io.BufferedWriter; +import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.util.Properties; @@ -29,7 +31,6 @@ import org.apache.tuscany.sca.node.Contribution; import org.apache.tuscany.sca.node.ContributionLocationHelper; import org.apache.tuscany.sca.node.Node; import org.apache.tuscany.sca.node.NodeFactory; -import org.apache.tuscany.sca.node.impl.NodeImpl; import client.RuntimeBridge; import client.TestConfiguration; @@ -145,6 +146,7 @@ public class TuscanyRuntimeBridge implements RuntimeBridge { String receivedMessage = ex.getMessage(); if (expectedMessage == null){ + writeMissingMessage(testName, ex); fail("Null expected error message for test " + testName + "Please add message to oasis-sca-tests-errors.properties"); } // end if @@ -153,6 +155,11 @@ public class TuscanyRuntimeBridge implements RuntimeBridge { ex.printStackTrace(); fail("Null received error message for test " + testName); } // end if + + if (expectedMessage.startsWith("*")) { + // allow using * to ignore a message comparison + return; + } // 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 @@ -161,6 +168,10 @@ public class TuscanyRuntimeBridge implements RuntimeBridge { // Truncate the received message to the length of the expected message receivedMessage = receivedMessage.substring(0, expectedMessage.length() ); } // end if + + if (!expectedMessage.equals(receivedMessage)) { + writeIncorrectMessage(testName, expectedMessage, receivedMessage); + } assertEquals( expectedMessage, receivedMessage ); @@ -168,4 +179,25 @@ public class TuscanyRuntimeBridge implements RuntimeBridge { } + protected void writeMissingMessage(String testName, Throwable ex) { + try { + BufferedWriter out = new BufferedWriter(new FileWriter("target/OTestMissingMsgs.txt", true)); + out.write(testName + "=*"); + out.newLine(); + out.close(); + } catch (IOException e) { + } + } + + protected void writeIncorrectMessage(String testName, String expected, String received) { + try { + BufferedWriter out = new BufferedWriter(new FileWriter("target/OTestIncorrectMsgs.txt", true)); + out.write(testName); out.newLine(); + out.write(" " + expected); out.newLine(); + out.write(" " + received); out.newLine(); + out.close(); + } catch (IOException e) { + } + } + } // end class TuscanyRuntimeBridge |