You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2009/10/15 11:09:25 UTC

svn commit: r825442 - /tuscany/java/sca/otest/newlayout/tuscany-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java

Author: antelder
Date: Thu Oct 15 09:09:24 2009
New Revision: 825442

URL: http://svn.apache.org/viewvc?rev=825442&view=rev
Log:
Update the Tuscany assmebly tests runner to log missing and incorrect test messages to files in the target directory, enable starting expected messages with an '*' to bypass failing a test due to the message

Modified:
    tuscany/java/sca/otest/newlayout/tuscany-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java

Modified: tuscany/java/sca/otest/newlayout/tuscany-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/otest/newlayout/tuscany-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java?rev=825442&r1=825441&r2=825442&view=diff
==============================================================================
--- tuscany/java/sca/otest/newlayout/tuscany-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java (original)
+++ tuscany/java/sca/otest/newlayout/tuscany-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java Thu Oct 15 09:09:24 2009
@@ -21,6 +21,8 @@
 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.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 @@
         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 @@
             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 @@
             // 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 @@
        
     }
 
+    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