db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r279042 - in /incubator/jdo/trunk/tck20/test: conf/ java/org/apache/jdo/tck/util/
Date Tue, 06 Sep 2005 17:12:14 GMT
Author: mbo
Date: Tue Sep  6 10:11:59 2005
New Revision: 279042

URL: http://svn.apache.org/viewcvs?rev=279042&view=rev
Log:
Update logging properties files to support vendors' IUT using JDK 1.4 
logging. Synchronize logging implementation with logging description 
on the JDO wiki. Changes provided by Michael Watzek.

Added:
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/TCKFileHandler.java
Modified:
    incubator/jdo/trunk/tck20/test/conf/commons-logging.properties
    incubator/jdo/trunk/tck20/test/conf/log4j.properties
    incubator/jdo/trunk/tck20/test/conf/logging.properties
    incubator/jdo/trunk/tck20/test/conf/simplelog.properties
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/BatchTestRunner.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/TCKFileAppender.java

Modified: incubator/jdo/trunk/tck20/test/conf/commons-logging.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/conf/commons-logging.properties?rev=279042&r1=279041&r2=279042&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/conf/commons-logging.properties (original)
+++ incubator/jdo/trunk/tck20/test/conf/commons-logging.properties Tue Sep  6 10:11:59 2005
@@ -28,7 +28,10 @@
 #
 
 # Uncomment the next line if you want to use the apache simple logger
-org.apache.commons.logging.Log = org.apache.commons.logging.impl.SimpleLog
+#org.apache.commons.logging.Log = org.apache.commons.logging.impl.SimpleLog
 
-# Uncomment the next two lines if you want to use JDK 1.4 logging
+# Uncomment the next line if you want to use JDK 1.4 logging
 #org.apache.commons.logging.Log = org.apache.jdo.tck.util.JDOJdk14Logger
+
+# Uncomment the next line if you want to use Log4j logging
+org.apache.commons.logging.Log = org.apache.commons.logging.impl.Log4JLogger

Modified: incubator/jdo/trunk/tck20/test/conf/log4j.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/conf/log4j.properties?rev=279042&r1=279041&r2=279042&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/conf/log4j.properties (original)
+++ incubator/jdo/trunk/tck20/test/conf/log4j.properties Tue Sep  6 10:11:59 2005
@@ -13,28 +13,64 @@
 # See the License for the specific language governing permissions and 
 # limitations under the License.
 
-###########################
-# JPOX logging properties #
-###########################
+#############################
+# TCK loggers and appenders 
+#############################
 
-# 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
+# Root logger
+log4j.rootLogger = ERROR, TCK
+
+# TCK logger
+log4j.logger.org.apache.jdo.tck = INFO, TCK
+log4j.additivity.org.apache.jdo.tck = false 
+
+# SpringFramework loggers 
+log4j.logger.org.springframework = ERROR, TCK
+log4j.additivity.org.springframework = false 
+log4j.logger.org.apache.jdo.tck.pc.company.CompanyModelReader = ERROR, TCK
+
+# TCK appenders
+log4j.appender.TCK = org.apache.jdo.tck.util.TCKFileAppender
+log4j.appender.TCK.File = tck.txt
+log4j.appender.TCK.layout = org.apache.log4j.PatternLayout
+log4j.appender.TCK.layout.ConversionPattern = %d{HH:mm:ss,SSS} (%t) %-5p [%c] - %m%n
+
+############################################
+# JDO vendor specific loggers and appenders 
+############################################
+
+#log4j.logger.<vendor> = INFO
+#log4j.additivity.<vendor> = false 
+
+#log4j.appender.<VENDOR> = org.apache.jdo.tck.util.TCKFileAppender
+#log4j.appender.<VENDOR>.File = <vendor>.txt
+#log4j.appender.<VENDOR>.layout = org.apache.log4j.PatternLayout
+#log4j.appender.<VENDOR>.layout.ConversionPattern = %d{HH:mm:ss,SSS} (%t) %-5p [%c]
- %m%n
+
+#############################
+# JPOX loggers and appenders 
+#############################
 
 # 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 = INFO, JPOX
+log4j.additivity.JPOX = false 
+#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 = DEBUG, JPOX
 
-log4j.logger.JPOX.Enhancer=INFO, JPOX
-log4j.logger.JPOX.SchemaTool=INFO, JPOX
+log4j.logger.JPOX.Enhancer = INFO, JPOX
+log4j.logger.JPOX.SchemaTool = INFO, JPOX
 
 # C3P0 loggers
-log4j.logger.com.mchange.v2=INFO, JPOX
+log4j.logger.com.mchange.v2 = INFO, JPOX
+log4j.additivity.com.mchange.v2 = false 
+
+# 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

Modified: incubator/jdo/trunk/tck20/test/conf/logging.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/conf/logging.properties?rev=279042&r1=279041&r2=279042&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/conf/logging.properties (original)
+++ incubator/jdo/trunk/tck20/test/conf/logging.properties Tue Sep  6 10:11:59 2005
@@ -29,15 +29,31 @@
 #   SEVERE         error, fatal
 #
 
-######################
-# JDO TCK test cases
-######################
+#############################
+# TCK loggers and appenders 
+#############################
+
+# Root logger
+.level = SEVERE
+
+# TCK logger
+org.apache.jdo.tck.level = INFO
+
+# SpringFramework loggers 
+org.springframework.level = SEVERE
+org.apache.jdo.tck.pc.company.CompanyModelReader.level = SEVERE
+
+org.apache.jdo.tck.util.TCKFileHandler.fileName = tck.txt
+org.apache.jdo.tck.util.TCKFileHandler.level = FINEST
+
+##############################
+# JDO vendor specific loggers 
+##############################
 
-#org.apache.jdo.tck.level = FINE
+#<vendor> = INFO
 
 ######################
-# JDK 1.4 logging properties
+# Default handlers
 ######################
 
-handlers = java.util.logging.ConsoleHandler
-java.util.logging.ConsoleHandler.level = FINEST
+handlers = org.apache.jdo.tck.util.TCKFileHandler

Modified: incubator/jdo/trunk/tck20/test/conf/simplelog.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/conf/simplelog.properties?rev=279042&r1=279041&r2=279042&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/conf/simplelog.properties (original)
+++ incubator/jdo/trunk/tck20/test/conf/simplelog.properties Tue Sep  6 10:11:59 2005
@@ -21,15 +21,18 @@
 #
 
 ######################
-# JDO TCK test cases
-######################
-
-#org.apache.commons.logging.simplelog.log.org.apache.jdo.tck = debug
-
-######################
-# default logging level
+# Loggers
 ######################
 
+# Root logger
 org.apache.commons.logging.simplelog.defaultlog = error
 
+# TCK logger
+org.apache.commons.logging.simplelog.log.org.apache.jdo.tck = info
+
+# SpringFramework loggers 
+org.apache.commons.logging.simplelog.log.org.springframework = error
+org.apache.commons.logging.simplelog.log.org.apache.jdo.tck.pc.company.CompanyModelReader
= error
 
+# JDO vendor specific loggers 
+#org.apache.commons.logging.simplelog.log.<vendor> = info

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=279042&r1=279041&r2=279042&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 Tue Sep
 6 10:11:59 2005
@@ -203,12 +203,12 @@
      * @throws IOException
      */
     public static String getFileName() {
-        return changeFileName(".txt");
+        return changeFileName("junit.txt");
     }
     
     /**
      * Returns a file name which is constructed by values
-     * of some system properties and by the given file name.
+     * of some system properties appended by the given file name.
      * The system properties evaluated are:
      * <ul>
      * <li>jdo.tck.log.directory: Specifies the directory for the file.</li>
@@ -220,7 +220,7 @@
      * </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>.

+     * Values of properties which do not exist default to <code>""</code>. 
      * @param fileName the file name
      * @return the changed file name
      */

Modified: 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=279042&r1=279041&r2=279042&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/TCKFileAppender.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/TCKFileAppender.java Tue Sep
 6 10:11:59 2005
@@ -25,6 +25,8 @@
  *  TCKFileAppender appends log events to a file.
  *  Overrides {@link FileAppender#setFile(java.lang.String, boolean, boolean, int)}
  *  changing the given file name.
+ *  For details on the construction of the changed file name see method
+ *  {@link BatchTestRunner#changeFileName(String)}.
  */
 public class TCKFileAppender extends FileAppender {
 

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/TCKFileHandler.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/TCKFileHandler.java?rev=279042&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/TCKFileHandler.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/TCKFileHandler.java Tue Sep
 6 10:11:59 2005
@@ -0,0 +1,343 @@
+/*
+ * 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.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.logging.ErrorManager;
+import java.util.logging.Filter;
+import java.util.logging.Formatter;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.LogRecord;
+import java.util.logging.SimpleFormatter;
+import java.util.logging.StreamHandler;
+
+/**
+ * A JDK1.4 logging Handler class which delegates to a file handler.
+ * Configuration: By default each TCKFileHandler is initialized using 
+ * the following LogManager configuration properties:
+ * <ul>
+ * <li>java.util.logging.TCKFileHandler.level 
+ * specifies the default level for the Handler (defaults to Level.ALL).</li>
+ * <li>java.util.logging.FileHandler.filter 
+ * specifies the name of a Filter class to use (defaults to no Filter).</li>
+ * <li>java.util.logging.FileHandler.formatter 
+ * specifies the name of a Formatter class to use 
+ * (defaults to java.util.logging.SimpleFormatter).</li>
+ * <li>java.util.logging.FileHandler.encoding 
+ * the name of the character set encoding to use 
+ * (defaults to the default platform encoding).</li>
+ * <li>java.util.logging.FileHandler.fileName 
+ * specifies a the output file name. See below for details.</li>
+ * <li>java.util.logging.FileHandler.append 
+ * specifies whether the FileHandler should append onto any existing files 
+ * (defaults to false).</li>
+ * </ul> 
+ *  For details on the construction of the file name see method
+ *  {@link BatchTestRunner#changeFileName(String)}.
+ */
+public class TCKFileHandler extends Handler {
+
+    private static final String defaultName = "";
+    private static final boolean defaultAppend = false;
+    private static final Level defaultLevel = Level.ALL;
+    private static final Filter defaultFilter = null;
+    private static final Formatter defaultFormatter = new SimpleFormatter();
+    private static final String defaultEncoding = null;
+    
+    private String fileName;
+    private boolean append;
+    
+    private Level level;
+    private Filter filter;
+    private Formatter formatter;
+    private String encoding;
+    
+    private FileHandlerDelegate delegate;
+    
+    /**
+     * @see Handler#Handler()
+     * @throws IOException
+     * @throws SecurityException
+     */
+    public TCKFileHandler() throws IOException, SecurityException {
+        configure();
+        
+        this.delegate = new FileHandlerDelegate();
+        
+        OutputStream stream = new FileOutputStream(this.fileName, this.append);
+        this.delegate.setOutputStream(stream);
+        
+        this.delegate.setLevel(this.level);
+        this.delegate.setFilter(this.filter);
+        this.delegate.setFormatter(this.formatter);
+        this.delegate.setEncoding(this.encoding);
+    }
+
+    /**
+     * @see Handler#publish(java.util.logging.LogRecord)
+     */
+    public synchronized void publish(LogRecord record) {
+        this.delegate.publish(record);
+    }
+
+    /**
+     * @see Handler#close()
+     */
+    public synchronized void close() throws SecurityException {
+        this.delegate.close();
+    }
+
+    
+    /**
+     * @see Handler#flush()
+     */
+    public void flush() {
+        this.delegate.flush();
+    }
+    
+    /**
+     * @see Handler#getEncoding()
+     */
+    public String getEncoding() {
+        return this.encoding;
+    }
+
+    /**
+     * @see Handler#getErrorManager()
+     */
+    public ErrorManager getErrorManager() {
+        return this.delegate.getErrorManager();
+    }
+    
+    /**
+     * @see Handler#getFilter()
+     */
+    public Filter getFilter() {
+        return this.filter;
+    }
+    
+    /**
+     * @see Handler#getFormatter()
+     */
+    public Formatter getFormatter() {
+        return this.formatter;
+    }
+    
+    /**
+     * @see Handler#getLevel()
+     */
+    public Level getLevel() {
+        return this.level;
+    }
+    
+    /**
+     * @see Handler#reportError(java.lang.String, java.lang.Exception, int)
+     */
+    protected void reportError(String msg, Exception ex, int code) {
+        this.delegate.reportError(msg, ex, code);
+    }
+    
+    /**
+     * @see Handler#setErrorManager(java.util.logging.ErrorManager)
+     */
+    public void setErrorManager(ErrorManager em) {
+        this.delegate.setErrorManager(em);
+    }
+
+    /**
+     * @see StreamHandler#isLoggable(java.util.logging.LogRecord)
+     */
+    public boolean isLoggable(LogRecord record) {
+        return this.delegate.isLoggable(record);
+    }
+
+    /**
+     * Sets the file name fileName property.
+     * @param fileName The fileName to set
+     */
+    protected void setPattern(String fileName) {
+        this.fileName = BatchTestRunner.changeFileName(fileName);
+    }
+
+    /**
+     * Sets the append property.
+     * @param append The append to set.
+     */
+    protected void setAppend(boolean append) {
+        this.append = append;
+    }
+
+    /**
+     * Sets the level property.
+     * @param level The level to set.
+     */
+    public void setLevel(Level level) {
+        this.level = level;
+        if (this.delegate != null) {
+            this.delegate.setLevel(level);
+        }
+    }
+
+    /**
+     * Sets the filter property.
+     * @param filter The filter to set.
+     */
+    public void setFilter(Filter filter) {
+        this.filter = filter;
+        if (this.delegate != null) {
+            this.delegate.setFilter(filter);
+        }
+    }
+
+    /**
+     * Sets the formatter property.
+     * @param formatter The formatter to set.
+     */
+    public void setFormatter(Formatter formatter) {
+        this.formatter = formatter;
+        if (this.delegate != null) {
+            this.delegate.setFormatter(formatter);
+        }
+    }
+
+    /**
+     * Sets the encoding property.
+     * @param encoding The encoding to set.
+     * @throws UnsupportedEncodingException 
+     * @throws SecurityException 
+     */
+    public void setEncoding(String encoding) 
+        throws SecurityException, UnsupportedEncodingException {
+        this.encoding = encoding;
+        if (this.delegate != null) {
+            this.delegate.setEncoding(encoding);
+        }
+    }
+
+    /**
+     * Sets the delegate.
+     * @param delegate The delegate to set.
+     */
+    protected void setDelegate(FileHandlerDelegate delegate) {
+        this.delegate = delegate;
+    }
+    
+    private void configure() {
+        LogManager manager = LogManager.getLogManager();
+        String className = this.getClass().getName();
+        
+        setPattern(getStringProperty(manager, className + ".fileName", defaultName));
+        setAppend(getBooleanProperty(manager, className + ".append", defaultAppend));
+
+        setLevel(getLevelProperty(manager, className + ".level", defaultLevel));
+        setFilter(getFilterProperty(manager, className + ".filter", defaultFilter));
+        setFormatter(getFormatterProperty(manager, className + ".formatter", defaultFormatter));
+        try {
+            setEncoding(getStringProperty(manager, className + ".encoding", defaultEncoding));
+        } catch (Exception e) {
+            try {
+                setEncoding(defaultEncoding);
+            } catch (Exception ex) {
+            }
+        }
+    }
+    
+    private boolean getBooleanProperty(LogManager manager, String property, 
+            boolean defaultValue) {
+        boolean result = defaultValue;
+        String value = manager.getProperty(property);
+        if ( value != null) {
+            try {
+                result = Boolean.valueOf(value.trim()).booleanValue();
+            } catch (Exception ex) {
+            }    
+        }
+        return result;
+    }
+
+    private String getStringProperty(LogManager manager, String property, 
+            String defaultValue) {
+        String result = defaultValue;
+        String value = manager.getProperty(property);
+        if ( value != null) {
+            result = value.trim();
+        }
+        return result;
+    }
+
+    private Level getLevelProperty(LogManager manager, String property, 
+            Level defaultValue) {
+        Level result = defaultValue;
+        String value = manager.getProperty(property);
+        if (value != null) {
+            try {
+                result = Level.parse(value.trim());
+            } catch (Exception ex) {
+            }
+        }
+        return result;
+    }
+
+    private Filter getFilterProperty(LogManager manager, String property, 
+            Filter defaultValue) {
+        return (Filter) newInstanceForProperty(manager, property, defaultValue);
+    }
+
+    private Formatter getFormatterProperty(LogManager manager, String property, 
+            Formatter defaultValue) {
+        return (Formatter) newInstanceForProperty(manager, property, defaultValue);
+    }
+
+    private Object newInstanceForProperty(LogManager manager, String property, 
+            Object defaultValue) {
+        Object result = defaultValue;
+        String value = manager.getProperty(property);
+        if (value != null) {
+            try {
+                Class clazz = 
+                    ClassLoader.getSystemClassLoader().loadClass(value);
+                result = clazz.newInstance();
+            } catch (Exception ex) {
+            }
+        }
+        return result;
+    }
+    
+    /**
+     * This class has been defined to make method 
+     * {@link Handler#reportError(java.lang.String, java.lang.Exception, int)}
+     * accessible in the outer class. 
+     */
+    private static class FileHandlerDelegate extends StreamHandler {
+
+        protected void setOutputStream(OutputStream out) {
+            super.setOutputStream(out);
+        }
+
+        /**
+         * @see Handler#reportError(java.lang.String, java.lang.Exception, int)
+         */
+        protected void reportError(String msg, Exception ex, int code) {
+            super.reportError(msg, ex, code);
+        }
+    }
+}



Mime
View raw message