Author: mcaisse
Date: Thu Jun 9 20:42:16 2005
New Revision: 189888
URL: http://svn.apache.org/viewcvs?rev=189888&view=rev
Log:
JDO-33 submitted by Michael Watzek
Modified:
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/JDO_Test.java
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/BatchTestRunner.java
Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/JDO_Test.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/JDO_Test.java?rev=189888&r1=189887&r2=189888&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/JDO_Test.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/JDO_Test.java Thu Jun 9 20:42:16
2005
@@ -182,11 +182,13 @@
testSucceeded = true;
}
catch (AssertionFailedError e) {
- logger.error("Exception during setUp or runtest: ", e);
+ if (logger.isInfoEnabled())
+ logger.info("Exception during setUp or runtest: ", e);
throw e;
}
catch (Throwable t) {
- logger.fatal("Exception during setUp or runtest: ", t);
+ if (logger.isInfoEnabled())
+ logger.info("Exception during setUp or runtest: ", t);
throw t;
}
finally {
@@ -204,7 +206,8 @@
*/
private void setTearDownThrowable(String context, Throwable throwable)
{
- logger.fatal("Exception during "+context+": ", throwable);
+ if (logger.isInfoEnabled())
+ logger.info("Exception during "+context+": ", throwable);
if (this.tearDownThrowable == null) {
this.tearDownThrowable = throwable;
}
Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/BatchTestRunner.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/BatchTestRunner.java?rev=189888&r1=189887&r2=189888&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/BatchTestRunner.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/BatchTestRunner.java Thu Jun
9 20:42:16 2005
@@ -16,10 +16,17 @@
package org.apache.jdo.tck.util;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
-import java.io.PrintStream;
+import java.text.SimpleDateFormat;
import java.util.Arrays;
+import java.util.Date;
import junit.framework.Test;
import junit.framework.TestResult;
@@ -47,7 +54,16 @@
/** Default of the system property ResultPrinterClass. */
public static final String RESULTPRINTER_DEFAULT = BatchResultPrinter.class.getName();
-
+
+ /** Redirect System.out and System.err to an ConsoleFileOutput instance. */
+ static {
+ if (!Boolean.getBoolean("noLogFile")) {
+ PrintStream printStream = new PrintStream(new ConsoleFileOutput());
+ System.setErr(printStream);
+ System.setOut(printStream);
+ }
+ }
+
/**
* Constructor.
* It creates a result printer instance based on the system property
@@ -171,5 +187,54 @@
*/
protected ResultPrinter getDefaultResultPrinter() {
return new BatchResultPrinter(System.out);
+ }
+
+ private static class ConsoleFileOutput extends OutputStream {
+
+ private static String outDir = "logs";
+ private static String fileNamePrefix = "TCKLog-";
+ private static String fileNameSuffix = ".txt";
+ private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss");
+
+ private PrintStream systemOut = System.out;
+ private FileOutputStream fileOut;
+
+ private ConsoleFileOutput() {
+ String fileName = fileNamePrefix+simpleDateFormat.format(new Date())+fileNameSuffix;
+ File dir = new File(outDir);
+ if (!dir.exists()) {
+ dir.mkdir();
+ }
+
+ try {
+ fileOut = new FileOutputStream(new File(dir, fileName));
+ } catch (FileNotFoundException e) {
+ System.err.println("Cannot create log file "+fileName+". "+e);
+ }
+ }
+
+ /*
+ * @see java.io.OutputStream#write(int)
+ */
+ public void write(int b) throws IOException {
+ this.systemOut.write(b);
+ this.fileOut.write(b);
+ }
+
+ /**
+ * @see java.io.OutputStream#close()
+ */
+ public void close() throws IOException {
+ this.fileOut.close();
+ this.systemOut.close();
+ }
+
+ /**
+ * @see java.io.OutputStream#flush()
+ */
+ public void flush() throws IOException {
+ this.systemOut.flush();
+ this.fileOut.flush();
+ }
}
}
|