db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcai...@apache.org
Subject svn commit: r1151713 - in /db/jdo/trunk: exectck/src/main/java/org/apache/jdo/exectck/ lib/iut/ tck/iut_jars/ tck/src/conf/
Date Thu, 28 Jul 2011 03:30:57 GMT
Author: mcaisse
Date: Thu Jul 28 03:30:56 2011
New Revision: 1151713

URL: http://svn.apache.org/viewvc?rev=1151713&view=rev
Log:
JDO-647 - Errors when running IUT.

Added:
    db/jdo/trunk/lib/iut/iut-jdoconfig.xml
      - copied unchanged from r1151301, db/jdo/trunk/tck/src/conf/iut-jdoconfig.xml
    db/jdo/trunk/lib/iut/iut-log4j.properties
    db/jdo/trunk/lib/iut/iut-persistence.xml
      - copied unchanged from r1151301, db/jdo/trunk/tck/src/conf/iut-persistence.xml
    db/jdo/trunk/lib/iut/iut-pmf.properties
      - copied unchanged from r1151301, db/jdo/trunk/tck/src/conf/iut-pmf.properties
Removed:
    db/jdo/trunk/tck/iut_jars/
    db/jdo/trunk/tck/src/conf/iut-jdoconfig.xml
    db/jdo/trunk/tck/src/conf/iut-persistence.xml
    db/jdo/trunk/tck/src/conf/iut-pmf.properties
Modified:
    db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/   (props changed)
    db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/Enhance.java
    db/jdo/trunk/tck/src/conf/   (props changed)
    db/jdo/trunk/tck/src/conf/log4j.properties

Propchange: db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Jul 28 03:30:56 2011
@@ -0,0 +1 @@
+.Enhance.java.save2.swp

Modified: db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/Enhance.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/Enhance.java?rev=1151713&r1=1151712&r2=1151713&view=diff
==============================================================================
--- db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/Enhance.java (original)
+++ db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/Enhance.java Thu Jul 28 03:30:56
2011
@@ -1,4 +1,3 @@
-
 package org.apache.jdo.exectck;
 
 import java.net.MalformedURLException;
@@ -14,6 +13,7 @@ import java.io.IOException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Iterator;
 import javax.jdo.JDOEnhancer;
@@ -66,6 +66,13 @@ public class Enhance extends AbstractMoj
      */
     private String impl;
     /**
+     * Name of the log4j properties file to be used by the iut.
+     * @parameter expression="${jdo.tck.iutLog4jProperties}"
+     *      default-value="iut-log4j.properties"
+     * @optional
+     */
+    private String iutLog4jProperties;
+    /**
      * Location of jar files for implementation under test.
      * @parameter expression="${project.lib.iut.directory}"
      *      default-value="${basedir}/../lib/iut"
@@ -91,6 +98,9 @@ public class Enhance extends AbstractMoj
 
         idtypes = new HashSet();
         PropertyUtils.string2Set(identitytypes, idtypes);
+        if (impl.equals("iut")) {
+            System.setProperty("log4j.configuration", iutLog4jProperties);
+        }
 
         // Create directory for enhancer logs
         String enhanceLogsDirName = logsDirectory + File.separator + "enhancer";
@@ -113,7 +123,7 @@ public class Enhance extends AbstractMoj
             "org/apache/jdo/tck/pc/",
             "org/apache/jdo/tck/models/inheritance/"};
         String[] metadataExtensions = {"jdo", "jdoquery", "orm", "xml", "properties"};  //
we really want "jdo.properties", but this is easier
-        String[] srcDirs = {"jdo", "orm", "testdata"};
+        String[] srcDirs = {"jdo", "orm", "testdata", "conf"};
         String genericPkgName = "org";
         File toFile = null;
         File fromFile = null;
@@ -144,12 +154,19 @@ public class Enhance extends AbstractMoj
                             toFile = new File(enhancedDirName + File.separator
                                     + pkgName);
                             FileUtils.copyFile(fromFile, toFile);
+//                            System.out.println("Copying from " + fromFile.toString()
+//                                    + " to " + toFile.toString());
                         } else if (srcDir.equals("testdata")) {
                             startIdx = fromFileName.indexOf("org" + File.separator);
                             pkgName = fromFileName.substring(startIdx);
                             toFile = new File(enhancedDirName + File.separator
                                     + idtype + File.separator + pkgName);
                             FileUtils.copyFile(fromFile, toFile);
+                        } else if (srcDir.equals("conf")) {
+                            startIdx = fromFileName.lastIndexOf(File.separator) + 1;
+                            pkgName = fromFileName.substring(startIdx);
+                            toFile = new File(enhancedDirName + File.separator + pkgName);
+                            FileUtils.copyFile(fromFile, toFile);
                         } else {
                             continue;  // idtype not in pathname, do not copy
                         }
@@ -178,6 +195,9 @@ public class Enhance extends AbstractMoj
                             toFile = new File(enhancedIdDirName + fromFileName.substring(
                                     fromFileName.indexOf(pcPkgName)));
                             FileUtils.copyFile(fromFile, toFile);
+//                            System.out.println("Copying from " + fromFile.toString()
+//                                    + " to " + toFile.toString());
+                            // to be provided to enhancer
                             classes.add(toFile.toString());
                         } catch (IOException ex) {
                             throw new MojoExecutionException("Failed to copy files from "
@@ -187,36 +207,62 @@ public class Enhance extends AbstractMoj
                     }
                 }
             }
-                // Enhance classes
 
-                URL[] classPathURLs = new URL[2];
-                ArrayList<URL> cpList = new ArrayList<URL>();
-                ClassLoader loader = null;
-                try {
-                    cpList.add((new File(enhancedIdDirName)).toURI().toURL());
-                    cpList.add((new File(fromDirName)).toURI().toURL());
+            // Get the enhancer
+            ArrayList<URL> cpList = new ArrayList<URL>();
+            ClassLoader getEnhancerLoader = null;
+            try {
+                if (impl.equals("iut")) {
+                    cpList.add((new File(iutLibsDirectory)).toURI().toURL());
                     String[] jars = {"jar"};
-                    if (impl.equals("iut")) {
-                        fi = FileUtils.iterateFiles(
+                    fi = FileUtils.iterateFiles(
                             new File(iutLibsDirectory), jars, true);
-                        while (fi.hasNext()) {
-                            cpList.add(fi.next().toURI().toURL());
-                        }
+                    while (fi.hasNext()) {
+                        cpList.add(fi.next().toURI().toURL());
                     }
-                    loader = new URLClassLoader(cpList.toArray(classPathURLs),
-                             getClass().getClassLoader());
-//                    Utilities.printClasspath(loader);
-                } catch (MalformedURLException ex) {
-                    Logger.getLogger(Enhance.class.getName()).log(Level.SEVERE, null, ex);
                 }
-                JDOEnhancer enhancer = JDOHelper.getEnhancer(loader);
-                enhancer.setVerbose(true);
-                enhancer.setClassLoader(loader);
-                String[] classArr = classes.toArray(classArray);
-                enhancer.addClasses(classArr);
-                System.out.println("Enhancing classes for identity type " +
-                        idtype);
-                enhancer.enhance();
+                cpList.trimToSize();
+                URL[] classPathURLs = new URL[cpList.size()];
+                getEnhancerLoader = new URLClassLoader(cpList.toArray(classPathURLs),
+                        Thread.currentThread().getContextClassLoader());//
+                Utilities.printClasspath(getEnhancerLoader);
+            } catch (MalformedURLException ex) {
+                Logger.getLogger(Enhance.class.getName()).log(Level.SEVERE, null, ex);
+            }
+            ClassLoader startingContextClassLoader =
+                    Thread.currentThread().getContextClassLoader();
+            Thread.currentThread().setContextClassLoader(getEnhancerLoader);
+            JDOEnhancer enhancer = JDOHelper.getEnhancer();
+            Thread.currentThread().setContextClassLoader(startingContextClassLoader);
+            
+            // Enhance
+            try {
+                cpList = new ArrayList<URL>();  // start fresh for new classloader
+                if (impl.equals("iut")) {
+                    cpList.add((new File(iutLibsDirectory)).toURI().toURL());
+                    String[] jars = {"jar"};
+                    fi = FileUtils.iterateFiles(
+                            new File(iutLibsDirectory), jars, true);
+                    while (fi.hasNext()) {
+                        cpList.add(fi.next().toURI().toURL());
+                    }
+                }
+                cpList.add((new File(enhancedIdDirName)).toURI().toURL());
+                cpList.add((new File(enhancedDirName)).toURI().toURL());
+            } catch (MalformedURLException ex) {
+                Logger.getLogger(Enhance.class.getName()).log(Level.SEVERE, null, ex);
+            }
+            enhancer.setVerbose(true);
+            URL[] classPathURLs = new URL[cpList.size()];
+            URLClassLoader enhancementClassLoader =
+                    new URLClassLoader(cpList.toArray(classPathURLs));
+            Utilities.printClasspath(enhancementClassLoader);
+            enhancer.setClassLoader(enhancementClassLoader);
+            String[] classArr = classes.toArray(classArray);
+            enhancer.addClasses(classArr);
+            System.out.println("Enhancing classes for identity type "
+                    + idtype);
+            enhancer.enhance();
         }
     }
 }

Added: db/jdo/trunk/lib/iut/iut-log4j.properties
URL: http://svn.apache.org/viewvc/db/jdo/trunk/lib/iut/iut-log4j.properties?rev=1151713&view=auto
==============================================================================
--- db/jdo/trunk/lib/iut/iut-log4j.properties (added)
+++ db/jdo/trunk/lib/iut/iut-log4j.properties Thu Jul 28 03:30:56 2011
@@ -0,0 +1,93 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+#############################
+# TCK loggers and appenders 
+#############################
+
+# 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
+log4j.logger.org.apache.jdo.tck.pc.mylib.MylibReader = 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
+
+###################################
+# DataNucleus loggers and appenders 
+###################################
+
+# DataNucleus loggers
+# For more details on DataNucleus logging see 
+# http://www.datanucleus.org/products/accessplatform/logging.html
+log4j.logger.DataNucleus = INFO, DataNucleus
+log4j.logger.DataNucleus.Enhancer = INFO, DataNucleus
+log4j.additivity.DataNucleus = false
+#log4j.logger.DataNucleus.JDO = INFO, DataNucleus
+#log4j.logger.DataNucleus.Persistence = INFO, DataNucleus
+#log4j.logger.DataNucleus.Query = INFO, DataNucleus
+#log4j.logger.DataNucleus.Lifecycle = INFO, DataNucleus
+#log4j.logger.DataNucleus.Reachability = INFO, DataNucleus
+#log4j.logger.DataNucleus.Cache = INFO, DataNucleus
+#log4j.logger.DataNucleus.ClassLoading = INFO, DataNucleus
+#log4j.logger.DataNucleus.MetaData = DEBUG, DataNucleus
+#log4j.logger.DataNucleus.Management = DEBUG, DataNucleus
+#log4j.logger.DataNucleus.General = DEBUG, DataNucleus
+#log4j.logger.DataNucleus.Connection = DEBUG, DataNucleus
+#log4j.logger.DataNucleus.JCA = DEBUG, DataNucleus
+#log4j.logger.DataNucleus.Transaction = INFO, DataNucleus
+#log4j.logger.DataNucleus.Plugin = INFO, DataNucleus
+#log4j.logger.DataNucleus.Store.Poid = INFO, DataNucleus
+#log4j.logger.DataNucleus.Datastore = DEBUG, DataNucleus
+#log4j.logger.DataNucleus.Datastore.Schema = INFO, DataNucleus
+#log4j.logger.DataNucleus.Datastore.Persist = INFO, DataNucleus
+#log4j.logger.DataNucleus.Datastore.Retrieve = DEBUG, DataNucleus
+#log4j.logger.DataNucleus.SchemaTool = INFO, DataNucleus
+
+# C3P0 loggers
+log4j.logger.com.mchange.v2 = INFO, DataNucleus
+log4j.additivity.com.mchange.v2 = false 
+
+# DataNucleus appenders
+#log4j.appender.DataNucleus = org.apache.jdo.tck.util.TCKFileAppender
+log4j.appender.DataNucleus = org.apache.log4j.FileAppender
+log4j.appender.DataNucleus.Enhancer.File = datanucleus.txt
+log4j.appender.DataNucleus.File = datanucleus.txt
+log4j.appender.DataNucleus.layout = org.apache.log4j.PatternLayout
+log4j.appender.DataNucleus.layout.ConversionPattern = %d{HH:mm:ss,SSS} (%t) %-5p [%c] - %m%n

Propchange: db/jdo/trunk/tck/src/conf/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Jul 28 03:30:56 2011
@@ -1 +1,2 @@
 .exclude.list.swp
+.log4j.properties.swp

Modified: db/jdo/trunk/tck/src/conf/log4j.properties
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/conf/log4j.properties?rev=1151713&r1=1151712&r2=1151713&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/conf/log4j.properties (original)
+++ db/jdo/trunk/tck/src/conf/log4j.properties Thu Jul 28 03:30:56 2011
@@ -57,6 +57,7 @@ log4j.appender.TCK.layout.ConversionPatt
 # For more details on DataNucleus logging see 
 # http://www.datanucleus.org/products/accessplatform/logging.html
 log4j.logger.DataNucleus = INFO, DataNucleus
+log4j.logger.DataNucleus.Enhancer = INFO, DataNucleus
 log4j.additivity.DataNucleus = false
 #log4j.logger.DataNucleus.JDO = INFO, DataNucleus
 #log4j.logger.DataNucleus.Persistence = INFO, DataNucleus
@@ -84,7 +85,9 @@ log4j.logger.com.mchange.v2 = INFO, Data
 log4j.additivity.com.mchange.v2 = false 
 
 # DataNucleus appenders
-log4j.appender.DataNucleus = org.apache.jdo.tck.util.TCKFileAppender
+#log4j.appender.DataNucleus = org.apache.jdo.tck.util.TCKFileAppender
+log4j.appender.DataNucleus = org.apache.log4j.FileAppender
+log4j.appender.DataNucleus.Enhancer.File = datanucleus.txt
 log4j.appender.DataNucleus.File = datanucleus.txt
 log4j.appender.DataNucleus.layout = org.apache.log4j.PatternLayout
 log4j.appender.DataNucleus.layout.ConversionPattern = %d{HH:mm:ss,SSS} (%t) %-5p [%c] - %m%n



Mime
View raw message