db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r630077 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
Date Fri, 22 Feb 2008 03:10:30 GMT
Author: myrnavl
Date: Thu Feb 21 19:10:28 2008
New Revision: 630077

URL: http://svn.apache.org/viewvc?rev=630077&view=rev
Log:
DERBY-2667 - improve junit test runs - save off derby.log for failing fixtures.
  patch (DERBY-2667_diff_02_21.txt) contributed by Manjula Kutty.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java?rev=630077&r1=630076&r2=630077&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java Thu Feb
21 19:10:28 2008
@@ -26,9 +26,11 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.OutputStream;
 import java.io.Reader;
 import java.io.PrintStream;
 import java.net.URL;
@@ -97,6 +99,39 @@
     	 
         try {
             super.runBare();   
+        }
+        //To save the derby.log of failed tests. 
+        catch (Throwable running) {
+        	try{
+        		AccessController.doPrivileged(new PrivilegedExceptionAction() {
+        			public Object run() throws SQLException, FileNotFoundException,
+        			IOException {
+
+        				File origLogDir = new File("system", "derby.log");
+        				if (origLogDir.exists()) {
+        					File failDir = getFailureFolder();
+        					InputStream in = new FileInputStream(origLogDir);
+        					OutputStream out = new FileOutputStream(new File(failDir,
+        					"derby.log"));
+        					byte[] buf = new byte[32 * 1024];
+
+        					for (;;) {
+        						int read = in.read(buf);
+        						if (read == -1)
+        							break;
+        						out.write(buf, 0, read);
+        					}
+        					in.close();
+        					out.close();
+        				}
+
+        				return null;
+        			}
+        		});
+        	}
+        	finally{        		
+        			throw running;
+        	}
         }
         finally{
             if ( trace )



Mime
View raw message