db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r239279 - in /incubator/jdo/trunk/tck20: ./ test/conf/ test/java/org/apache/jdo/tck/util/
Date Tue, 23 Aug 2005 00:43:48 GMT
Author: mbo
Date: Mon Aug 22 17:43:43 2005
New Revision: 239279

URL: http://svn.apache.org/viewcvs?rev=239279&view=rev
Log:
Changed logging: all log files for a tck run go into a separate directory.
Added a new properties file log4j.properties to configure log4j logging.
Changes provided by Michael Watzek.

Added:
    incubator/jdo/trunk/tck20/test/conf/log4j.properties
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/TCKFileAppender.java
Modified:
    incubator/jdo/trunk/tck20/maven.xml
    incubator/jdo/trunk/tck20/project.properties
    incubator/jdo/trunk/tck20/test/conf/derby.properties
    incubator/jdo/trunk/tck20/test/conf/logging.properties
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/BatchTestRunner.java

Modified: incubator/jdo/trunk/tck20/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/maven.xml?rev=239279&r1=239278&r2=239279&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/maven.xml (original)
+++ incubator/jdo/trunk/tck20/maven.xml Mon Aug 22 17:43:43 2005
@@ -142,6 +142,7 @@
     </goal>
 
     <goal name="privateInstallSchema">
+        <mkdir dir="${jdo.tck.log.directory.database}"/>
         <!-- load mappings into a HashSet to unique them -->
         <j:new var="uniqueMappings" className="java.util.HashSet"/>
         <j:forEach var="cfg" items="${jdo.tck.cfglist}">
@@ -197,12 +198,17 @@
     <!-- ================== -->
 
     <goal name="runtck.iut" prereqs="setProps">
+        <mkdir dir="${jdo.tck.log.directory.database}"/>
         <attainGoal name="privateRuntck.iut"/>
     </goal>
 
     <goal name="privateRuntck.iut"
           prereqs="java:compile, testrunner.set, copyprops, doEnhance.iut, package.iut">
         <!-- Run tests for all databases, identity types, and configurations -->
+        <tstamp>
+            <format property="timestamp" pattern="yyyyMMdd-HHmmss"/>
+        </tstamp>
+        <mkdir dir="${jdo.tck.log.directory}/${timestamp}"/>
         <echo>Run all configurations on iut</echo>
         <j:forEach var="jdo.tck.database" items="${jdo.tck.dblist}">
             <j:forEach var="jdo.tck.identitytype" items="${jdo.tck.identitytypes}">
@@ -228,12 +234,17 @@
     </goal>
 
     <goal name="runtck.jdori" prereqs="setProps">
+        <mkdir dir="${jdo.tck.log.directory.database}"/>
         <attainGoal name="privateRuntck.jdori"/>
     </goal>
 
     <goal name="privateRuntck.jdori"
           prereqs="java:compile, testrunner.set, copyprops, doEnhance.jdori, package.jdori">
         <!-- Run tests for all databases, identity types, and configurations -->
+        <tstamp>
+            <format property="timestamp" pattern="yyyyMMdd-HHmmss"/>
+        </tstamp>
+        <mkdir dir="${jdo.tck.log.directory}/${timestamp}"/>
         <echo>Run all configurations on jdori</echo>
         <j:forEach var="jdo.tck.database" items="${jdo.tck.dblist}">
             <j:forEach var="jdo.tck.identitytype" items="${jdo.tck.identitytypes}">
@@ -296,6 +307,8 @@
                          value="${jdo.tck.cfg}"/>
             <sysproperty key="jdo.tck.exclude"
                          value="${jdo.tck.exclude}"/>
+            <sysproperty key="jdo.tck.log.directory"
+                         value="${jdo.tck.log.directory}/${timestamp}"/>
             <jvmarg line="${database.runtck.sysproperties}"/>
             <jvmarg line="${iut.runtck.sysproperties}"/>
             <arg line="${jdo.tck.classes}"/>
@@ -341,6 +354,8 @@
                          value="${jdo.tck.cfg}"/>
             <sysproperty key="jdo.tck.exclude"
                          value="${jdo.tck.exclude}"/>
+            <sysproperty key="jdo.tck.log.directory"
+                         value="${jdo.tck.log.directory}/${timestamp}"/>
             <jvmarg line="${database.runtck.sysproperties}"/>
             <jvmarg line="${jdo.runtck.sysproperties}"/>
             <arg line="${jdo.tck.classes}"/>
@@ -375,7 +390,7 @@
         </condition>
     </goal>
 
-    <goal name="enhance.prepare">
+    <goal name="enhance.prepare" prereqs="java:compile, copyprops">
         <!-- copy metadata -->
         <mkdir dir="${jdo.tck.enhanced.dir}/${jdo.tck.identitytype}" />
         <copy todir="${jdo.tck.enhanced.dir}/${jdo.tck.identitytype}">
@@ -398,6 +413,7 @@
     </goal>
 
     <goal name="doEnhance.iut">
+        <mkdir dir="${jdo.tck.log.directory.enhancer}"/>
         <j:set var="jdo.tck.enhanced.dir" value="${iut.enhanced.dir}"/>
         <j:forEach var="jdo.tck.identitytype" items="${jdo.tck.identitytypes}">
             <attainGoal name="enhance.check"/>
@@ -410,6 +426,10 @@
                       dir="${jdo.tck.enhanced.dir}/${jdo.tck.identitytype}"
                       classname="${iut.enhancer.main}"
                       classpathref="this.enhance.class.path">
+                     <sysproperty key="jdo.tck.identitytype"
+                                  value="${jdo.tck.identitytype}"/>
+                     <sysproperty key="jdo.tck.log.directory"
+                                  value="${jdo.tck.log.directory.enhancer}"/>
                      <jvmarg line="${iut.enhancer.sysproperties}"/>
                      <arg line="${iut.enhancer.options}"/>
                      <arg line="${iut.enhancer.args}"/>
@@ -420,6 +440,7 @@
     </goal>
 
     <goal name="doEnhance.jdori">
+        <mkdir dir="${jdo.tck.log.directory.enhancer}"/>
         <j:set var="jdo.tck.enhanced.dir" value="${jdo.enhanced.dir}"/>
         <j:forEach var="jdo.tck.identitytype" items="${jdo.tck.identitytypes}">
             <attainGoal name="enhance.check"/>
@@ -432,6 +453,10 @@
                       dir="${jdo.tck.enhanced.dir}/${jdo.tck.identitytype}"
                       classname="${jdo.enhancer.main}"
                       classpathref="this.enhance.class.path">
+                     <sysproperty key="jdo.tck.identitytype"
+                                  value="${jdo.tck.identitytype}"/>
+                     <sysproperty key="jdo.tck.log.directory"
+                                  value="${jdo.tck.log.directory.enhancer}"/>
                      <jvmarg line="${jdo.enhancer.sysproperties}"/>
                      <arg line="${jdo.enhancer.options}"/>
                      <arg line="${jdo.enhancer.args}"/>
@@ -577,6 +602,7 @@
                <include name="commons-logging.properties"/>
                <include name="simplelog.properties"/>
                <include name="logging.properties"/>
+               <include name="log4j.properties"/>
                <include name="jndi.properties"/>
             </fileset>
             <fileset dir="${basedir}/test/java">

Modified: incubator/jdo/trunk/tck20/project.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/project.properties?rev=239279&r1=239278&r2=239279&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/project.properties (original)
+++ incubator/jdo/trunk/tck20/project.properties Mon Aug 22 17:43:43 2005
@@ -21,7 +21,7 @@
 
 # iut properties file
 iut.runtck.properties = iut.properties
-iut.runtck.sysproperties = -Dderby.system.home=${jdo.tck.testdir}/database/${jdo.tck.database}
-Dlog4j.configuration=file:${basedir}/test/conf/logging.properties
+iut.runtck.sysproperties = -Dderby.system.home=${jdo.tck.testdir}/database/${jdo.tck.database}
 
 # Flags indicating whether IUT supports application/datastore identity 
 iut.applicationidentity.supported = yes
@@ -32,7 +32,7 @@
 iut.enhancer.main = ${jdo.enhancer.main}
 iut.enhancer.options = -v -d "${iut.enhanced.dir}"
 iut.enhancer.args = ${jdo.tck.jdometadata.files}
-iut.enhancer.sysproperties = -Dlog4j.configuration=file:${basedir}/test/conf/logging.properties
+iut.enhancer.sysproperties =
 iut.enhancer.sourcepath = ${jdo.tck.testclasses.dir}${path.separator}${jdo.jdoapi.jarfile}${path.separator}${junit.jarfile}${path.separator}${log4j.jarfile}
 iut.enhancer.classpath = ${jpox.enhancer.jarfile}${path.separator}${jpox.jdori.jarfile}${path.separator}${jdo.jdoapi.jarfile}${path.separator}${log4j.jarfile}${path.separator}${bcel.jarfile}${path.separator}${jdo.tck.testclasses.dir}
 
@@ -49,7 +49,10 @@
 jdo.tck.testclasses.dir = ${maven.build.dir}/classes
 jdo.tck.testdir = ${maven.build.dir}
 jdo.tck.resultprinterclass = org.apache.jdo.tck.util.BatchResultPrinter
-database.runtck.sysproperties = -Dderby.system.home=${jdo.tck.testdir}/database/${jdo.tck.database}
-Dlog4j.configuration=file:${basedir}/test/conf/logging.properties
+jdo.tck.log.directory = ${maven.build.dir}/logs
+jdo.tck.log.directory.database = ${jdo.tck.log.directory}/database
+jdo.tck.log.directory.enhancer = ${jdo.tck.log.directory}/enhancer
+database.runtck.sysproperties = -Dderby.system.home=${jdo.tck.testdir}/database/${jdo.tck.database}
 jdo.runtck.sysproperties = -Xmx512m
 
 # dependencies

Modified: incubator/jdo/trunk/tck20/test/conf/derby.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/conf/derby.properties?rev=239279&r1=239278&r2=239279&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/conf/derby.properties (original)
+++ incubator/jdo/trunk/tck20/test/conf/derby.properties Mon Aug 22 17:43:43 2005
@@ -1,2 +1,46 @@
-# This flag must be set on Mac OSX
-#derby.storage.fileSyncTransactionLog=true
+# This flag must be set on Mac OSX
+#derby.storage.fileSyncTransactionLog=true
+
+#When this property is set to true, Derby writes the query plan information 
+#into the derby.log file for all executed queries.
+#Default: false
+#derby.language.logQueryPlan=true
+
+#When this property is set to true, Derby writes the text and parameter values 
+#of all executed statements to the information log at the beginning of 
+#execution. It also writes information about commits and rollbacks. 
+#Information includes the time and thread number.
+#Default: false
+derby.language.logStatementText=true
+
+#Specifies name of the file to which the error log is written. 
+#If the file name is relative, it is taken as relative to the system directory.
+#If this property is set, the derby.stream.error.method and 
+#derby.stream.error.field properties are ignored.
+#Default: derby.log
+derby.stream.error.file=../../logs/database/derby.log
+
+#Specifies which errors are logged to the Derby error log 
+#(typically the derby.log file). In test environments, use the setting 
+#derby.stream.error.logSeverityLevel=0 so that all problems are reported.
+#Any error raised in a Derby system is given a level of severity. 
+#This property indicates the minimum severity necessary for an error to appear 
+#in the error log. The severities are defined in the class 
+#org.apache.derby.types.ExceptionSeverity. 
+#The higher the number, the more severe the error.
+#20000: Errors that cause the statement to be rolled back, 
+#for example syntax errors and constraint violations.
+#30000: Errors that cause the transaction to be rolled back, 
+#for example deadlocks.
+#40000: Errors that cause the connection to be closed.
+#50000: Errors that shut down the Derby system.
+#Default: 40000
+#derby.stream.error.logSeverityLevel=0
+
+#Specifies whether to append to or destroy and re-create the derby.log file, 
+#which is used to record error and other information 
+#when Derby starts up in a JVM.
+#You can set this property even if the file does not yet exist; 
+#Derby creates the file.
+#Default: false
+derby.infolog.append=true

Added: incubator/jdo/trunk/tck20/test/conf/log4j.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/conf/log4j.properties?rev=239279&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/conf/log4j.properties (added)
+++ incubator/jdo/trunk/tck20/test/conf/log4j.properties Mon Aug 22 17:43:43 2005
@@ -0,0 +1,40 @@
+#
+# Copyright 2005 The Apache Software Foundation.
+# 
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at 
+# 
+#     http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software 
+# distributed under the License is distributed on an "AS IS" BASIS, 
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+# See the License for the specific language governing permissions and 
+# limitations under the License.
+
+###########################
+# JPOX logging properties #
+###########################
+
+# JPOX appenders
+log4j.appender.JPOX=org.apache.jdo.tck.util.TCKFileAppender
+log4j.appender.JPOX.File=jpox.txt
+log4j.appender.JPOX.layout=org.apache.log4j.PatternLayout
+log4j.appender.JPOX.layout.ConversionPattern=%d{HH:mm:ss,SSS} (%t) %-5p [%c] - %m%n
+
+# JPOX loggers
+log4j.logger.JPOX=INFO, JPOX
+#log4j.logger.JPOX.JDO=INFO, JPOX
+#log4j.logger.JPOX.Cache=INFO, JPOX
+#log4j.logger.JPOX.MetaData=INFO, JPOX
+#log4j.logger.JPOX.General=DEBUG, JPOX
+#log4j.logger.JPOX.Utility=INFO, JPOX
+#log4j.logger.JPOX.Transaction=INFO, JPOX
+#log4j.logger.JPOX.RDBMS=INFO, JPOX
+
+log4j.logger.JPOX.Enhancer=INFO, JPOX
+log4j.logger.JPOX.SchemaTool=INFO, JPOX
+
+# C3P0 loggers
+log4j.logger.com.mchange.v2=INFO, JPOX

Modified: incubator/jdo/trunk/tck20/test/conf/logging.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/conf/logging.properties?rev=239279&r1=239278&r2=239279&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/conf/logging.properties (original)
+++ incubator/jdo/trunk/tck20/test/conf/logging.properties Mon Aug 22 17:43:43 2005
@@ -41,26 +41,3 @@
 
 handlers = java.util.logging.ConsoleHandler
 java.util.logging.ConsoleHandler.level = FINEST
-
-
-######################
-# JPOX logging properties
-######################
-
-# Define the destination and format of our logging
-log4j.appender.A1=org.apache.log4j.FileAppender
-log4j.appender.A1.File=jpox.log
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} (%t) %-5p [%c] - %m%n
-
-# JPOX Categories
-log4j.category.JPOX.JDO=INFO, A1
-log4j.category.JPOX.Cache=INFO, A1
-log4j.category.JPOX.MetaData=INFO, A1
-log4j.category.JPOX.General=DEBUG, A1
-log4j.category.JPOX.Utility=INFO, A1
-log4j.category.JPOX.Transaction=INFO, A1
-log4j.category.JPOX.RDBMS=DEBUG, A1
-
-log4j.category.JPOX.Enhancer=INFO, A1
-log4j.category.JPOX.SchemaTool=INFO, A1

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=239279&r1=239278&r2=239279&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 Mon Aug
22 17:43:43 2005
@@ -17,16 +17,13 @@
 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.text.SimpleDateFormat;
 import java.util.Arrays;
-import java.util.Date;
 
 import junit.framework.Test;
 import junit.framework.TestResult;
@@ -55,15 +52,6 @@
     /** 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
@@ -146,8 +134,11 @@
                     Constructor ctor = clazz.getConstructor(
                         new Class[] { PrintStream.class } );
                     // create instance
+                    PrintStream stream = !Boolean.getBoolean("no.log.file") ?
+                        new PrintStream(new ConsoleFileOutput()) :
+                        System.out;
                     return (ResultPrinter)ctor.newInstance(
-                        new Object[] { System.out });
+                        new Object[] { stream });
                 }
                 catch (ClassNotFoundException ex) {
                     // specified ResultPrinter class not 
@@ -189,36 +180,25 @@
         return new BatchResultPrinter(System.out);
     }
     
+    /**
+     * Creates an output stream that delegates to
+     * {@link System#out} and to a file output stream.
+     * The file name of the file output stream is determined
+     * by method {@link BatchTestRunner#getFileName()}.
+     */
     private static class ConsoleFileOutput extends OutputStream {
 
-        private static String outDir = "logs";
-        private static String fileNameSuffix = ".txt";
-        private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss");
+        private String fileName;
         private PrintStream systemOut = System.out;
         private FileOutputStream fileOut;
         
         private ConsoleFileOutput() {
-            String identityType =  System.getProperty("jdo.tck.identitytype");
-            String db =  System.getProperty("jdo.tck.database");
-            String testConfig =  System.getProperty("jdo.tck.cfg");
-            if (identityType.equals("applicationidentity"))
-                identityType = "app";
-            else identityType = "dsid";
-            testConfig = testConfig.substring(0, testConfig.indexOf('.'));
-            String fileName = simpleDateFormat.format(new Date()) + "-"
-                              + db + "-"
-                              + identityType + "-"
-                              + testConfig
-                              + 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);
+                this.fileName = getFileName();
+                this.fileOut = new FileOutputStream(this.fileName);
+            } catch (IOException e) {
+                if (this.fileName!=null)
+                    System.err.println("Cannot create log file "+this.fileName+". "+e);
             }
         }
         
@@ -245,5 +225,95 @@
             this.systemOut.flush();
             this.fileOut.flush();
         }        
+    }
+    
+    /**
+     * Returns a file name which is determined by method
+     * {@link BatchTestRunner#changeFileName(String)}.
+     * The file name has suffix <code>.txt</code>.
+     * @return the file name
+     * @throws IOException
+     */
+    public static String getFileName() {
+        return changeFileName(".txt");
+    }
+    
+    /**
+     * Returns a file name which is constructed by values
+     * of some system properties and by the given file name.
+     * The system properties evaluated are:
+     * <ul>
+     * <li>jdo.tck.log.directory: Specifies the directory for the file.</li>
+     * <li>jdo.tck.database, jdo.tck.cfg: 
+     * The values of these properties prepend the given file name.</li>
+     * <li>jdo.tck.identitytype: The value of this property is replaced by
+     * <code>"app"</code> if it equals <code>"applicationidentity"</code>,

+     * else it is replaced by <code>"dsid"</code>.</li>
+     * </ul>
+     * The returned file name is constructed as follows:<br>
+     * <jdo.tck.log.directory>/<jdo.tck.database>-<jdo.tck.identitytype>-<jdo.tck.cfg><given
file name>
+     * Values of properties which do not exist are given by <code>""</code>.

+     * @param fileName the file name
+     * @return the changed file name
+     */
+    public static String changeFileName(String fileName) {
+        String directory = System.getProperty("jdo.tck.log.directory");
+        if (directory!=null &&
+            !directory.endsWith(File.separator)) {
+            directory += File.separator;
+        }
+
+        String db = System.getProperty("jdo.tck.database");
+        
+        String identityType = System.getProperty("jdo.tck.identitytype");
+        if (identityType!=null) {
+            if (identityType.equals("applicationidentity")) {
+                identityType = "app";
+            } else { 
+                identityType = "dsid";
+            }
+        }
+        
+        String configuration = System.getProperty("jdo.tck.cfg");
+        if (configuration!=null) {
+            int index = configuration.indexOf('.');
+            if (index!=-1) {
+                configuration = configuration.substring(0, index);
+            }
+        }
+        
+        directory = fixPartialFileName(directory);
+        db = fixPartialFileName(db, '-',
+                new String[]{identityType, configuration, fileName});
+        identityType = fixPartialFileName(identityType, '-',
+                new String[]{configuration, fileName});
+        configuration = fixPartialFileName(configuration, '-',
+                new String[]{fileName});
+
+        return directory + db + identityType + configuration + fileName;
+    }
+    
+    private static String fixPartialFileName(String str) {
+        if (str==null) {
+            str = "";
+        }
+        return str;
+    }
+    
+    private static String fixPartialFileName(String str, char c, 
+            String[] values) {
+        str = fixPartialFileName(str);
+        if (!str.equals("")) {
+            for (int i = 0; i < values.length; i++) {
+                String value = values[i];
+                if (value!=null &&
+                    !value.equals("") &&
+                    !value.startsWith(".")) {
+                    str += c;
+                    break;
+                }
+            }
+        }
+        return str;
     }
 }

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/TCKFileAppender.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/TCKFileAppender.java?rev=239279&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/TCKFileAppender.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/TCKFileAppender.java Mon Aug
22 17:43:43 2005
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.util;
+
+import java.io.IOException;
+
+import org.apache.log4j.FileAppender;
+import org.apache.log4j.Layout;
+
+/**
+ *  TCKFileAppender appends log events to a file.
+ *  Overrides {@link FileAppender#setFile(java.lang.String, boolean, boolean, int)}
+ *  changing the given file name.
+ */
+public class TCKFileAppender extends FileAppender {
+
+    /**
+     * @see FileAppender#FileAppender()
+     */
+    public TCKFileAppender() {}
+    
+    public TCKFileAppender(Layout layout, String filename, boolean append, 
+            boolean bufferedIO, int bufferSize) throws IOException {
+        super(layout, filename, append, bufferedIO, bufferSize);
+    }
+    
+    /**
+     * @see FileAppender#FileAppender(org.apache.log4j.Layout, java.lang.String, boolean,
boolean, int)
+     */
+    public TCKFileAppender(Layout layout, String filename, boolean append) 
+        throws IOException {
+        super(layout, filename, append);
+    }
+    
+    /**
+     * @see FileAppender#FileAppender(org.apache.log4j.Layout, java.lang.String)
+     */
+    public TCKFileAppender(Layout layout, String filename) throws IOException {
+        this(layout, filename, true);
+    }
+
+    /**
+     * The given file name is changed calling method
+     * {@link BatchTestRunner#changeFileName(String)}.
+     * @see FileAppender#setFile(java.lang.String, boolean, boolean, int)
+     */
+    public synchronized void setFile(String fileName, boolean append, boolean bufferedIO,
int bufferSize) 
+        throws IOException {
+        String changedFileName = BatchTestRunner.changeFileName(fileName);
+        super.setFile(changedFileName, append, bufferedIO, bufferSize);
+    }
+}
+



Mime
View raw message