Hi Michelle,

Is it possible to get the run time output to the log also?
Sure! Just let me know what exactly you have in mind.

It's good to
know what impact our fixes have on test run performance.
There is a performance output in the log printed by junit. The output is printed for a complete TCK run. You can find it after the result of the last test execution and before the stacktraces:

    ...
    [java] RUN SetSynchronizationToNull.test
    [java] Time: 858,891
    [java] There were 81 errors:
    ...

Regards,
Michael


-- Michelle

Michael Watzek wrote:

Hi,

JIRA JDO-33 suggests to print the TCK output to a log file in addition to standard out. The attached patch solves this issue.

The log file is created in directory "target/logs". If this directory does not exist at the time the TCK is started, then it is created. The file name pattern for the log file is "TCKLog-<currentDate>.txt". The format of <currentDate> is "yyyyMMdd-HHmmss".

You can switch off printing to a log file if you set the system property "noLogFile" to "true". In this case you'll only have console output. Otherwise, System.out and System.err are redirected to a log file and to the console.

Because the patch redirects the console output, you'll see also logging output in the log file. For this reason, we decided not to log exceptions in case of failures and/or errors using fatal/error log level. Instead, those exceptions are logged using level info. Thus, if you want to see exceptions at once with the test result, then please set the log level of the TCK to info. By default, it is set to error and you see exceptions only at the end of the TCK output after the output of all tests.

Regards,
Michael

------------------------------------------------------------------------

Index: test/java/org/apache/jdo/tck/JDO_Test.java
===================================================================
--- test/java/org/apache/jdo/tck/JDO_Test.java    (revision 189748)
+++ test/java/org/apache/jdo/tck/JDO_Test.java    (working copy)
@@ -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;
        }
Index: test/java/org/apache/jdo/tck/util/BatchTestRunner.java
===================================================================
--- test/java/org/apache/jdo/tck/util/BatchTestRunner.java (revision 189748) +++ test/java/org/apache/jdo/tck/util/BatchTestRunner.java (working copy)
@@ -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
@@ -172,4 +188,53 @@
    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();
+        }        +    }
}




--
-------------------------------------------------------------------
Michael Watzek                  [EMAIL PROTECTED] Engineering GmbH
mailto:[EMAIL PROTECTED]        Buelowstr. 66
Tel.:  ++49/30/235 520 36       10783 Berlin - Germany
Fax.:  ++49/30/217 520 12       http://www.spree.de/
-------------------------------------------------------------------

Reply via email to