db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcai...@apache.org
Subject svn commit: r1043028 - in /db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck: Enhance.java RunTCK.java Utilities.java
Date Tue, 07 Dec 2010 13:14:27 GMT
Author: mcaisse
Date: Tue Dec  7 13:14:27 2010
New Revision: 1043028

URL: http://svn.apache.org/viewvc?rev=1043028&view=rev
Log:
JDO-647 - Limited testing on a single configuration (instancecallbacks) works, with tests
passing.

Modified:
    db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/Enhance.java
    db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java
    db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/Utilities.java

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=1043028&r1=1043027&r2=1043028&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 Tue Dec  7 13:14:27
2010
@@ -39,7 +39,6 @@ public class Enhance extends AbstractMoj
      * @required
      */
     private boolean doEnhance;
-
     /**
      * Root of the TCK source installation.
      * @parameter expression="${project.src.directory}"
@@ -112,6 +111,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 genericPkgName = "org";
         File toFile = null;
         File fromFile = null;
@@ -124,86 +124,88 @@ public class Enhance extends AbstractMoj
 
         // Copy metadata from src to enhanced
         for (String idtype : idtypes) {
-            fromDirName = srcDirectory + File.separator + "jdo";
-            // iterator over list of abs name of metadata files in src
-            fi = FileUtils.iterateFiles(
-                    new File(fromDirName), metadataExtensions, true);
-
-            while (fi.hasNext()) {
-                try {
-                    fromFile = fi.next();
-                    fromFileName = fromFile.toString();
-//                    System.out.println("Copying " + fromFileName);
-                    if ((startIdx = fromFileName.indexOf(idtype + File.separator /*+ genericPkgName*/))
> -1) {
-                        // fully specified name of file (idtype + package + filename)
-                        pkgName = fromFileName.substring(startIdx);
-                        toFile = new File(enhancedDirName + File.separator
-                                + pkgName);
-//                        System.out.println("Copy from source dir to " + toFile.toString());
-                        FileUtils.copyFile(fromFile, toFile);
-                    } else {
-                        continue;  // idtype not in pathname, do not copy
-                    }
-                } catch (IOException ex) {
-                    throw new MojoExecutionException("Failed to copy files from "
-                            + fromFileName + " to " + toFile.toString()
-                            + ": " + ex.getLocalizedMessage());
-                }
-            }
-
-            // Copy pc and pa classes from target/classes to enhanced
-            String[] extensions = {"class"};
-            fromDirName = buildDirectory + File.separator
-                    + "classes" + File.separator;
-            String enhancedIdDirName = enhancedDirName + idtype + File.separator;
-            ArrayList<String> classes = new ArrayList<String>();
-            for (String pcPkgName : pcPkgNames) {
-                // iterator over list of abs name of class files in target/classes
+            for (String srcDir : srcDirs) {
+                fromDirName = srcDirectory + File.separator + srcDir;
+                // iterator over list of abs name of metadata files in src
                 fi = FileUtils.iterateFiles(
-                        new File(fromDirName + pcPkgName), extensions, true);
+                        new File(fromDirName), metadataExtensions, true);
+
                 while (fi.hasNext()) {
                     try {
                         fromFile = fi.next();
                         fromFileName = fromFile.toString();
-                        // fully specified name of file (package + filename)
-                        toFile = new File(enhancedIdDirName + fromFileName.substring(
-                                fromFileName.indexOf(pcPkgName)));
-                        FileUtils.copyFile(fromFile, toFile);
-                        classes.add(toFile.toString());
+//                    System.out.println("Copying " + fromFileName);
+                        if ((startIdx = fromFileName.indexOf(idtype + File.separator)) >
-1) {
+                            // fully specified name of file (idtype + package + filename)
+                            pkgName = fromFileName.substring(startIdx);
+                            toFile = new File(enhancedDirName + File.separator
+                                    + pkgName);
+//                        System.out.println("Copy from source dir to " + toFile.toString());
+                            FileUtils.copyFile(fromFile, toFile);
+                        } else {
+                            continue;  // idtype not in pathname, do not copy
+                        }
                     } catch (IOException ex) {
                         throw new MojoExecutionException("Failed to copy files from "
                                 + fromFileName + " to " + toFile.toString()
                                 + ": " + ex.getLocalizedMessage());
                     }
                 }
-            }
 
-            // Enhance classes
+                // Copy pc and pa classes from target/classes to enhanced
+                String[] extensions = {"class"};
+                fromDirName = buildDirectory + File.separator
+                        + "classes" + File.separator;
+                String enhancedIdDirName = enhancedDirName + idtype + File.separator;
+                ArrayList<String> classes = new ArrayList<String>();
+                for (String pcPkgName : pcPkgNames) {
+                    // iterator over list of abs name of class files in target/classes
+                    fi = FileUtils.iterateFiles(
+                            new File(fromDirName + pcPkgName), extensions, true);
+                    while (fi.hasNext()) {
+                        try {
+                            fromFile = fi.next();
+                            fromFileName = fromFile.toString();
+                            // fully specified name of file (package + filename)
+                            toFile = new File(enhancedIdDirName + fromFileName.substring(
+                                    fromFileName.indexOf(pcPkgName)));
+                            FileUtils.copyFile(fromFile, toFile);
+                            classes.add(toFile.toString());
+                        } catch (IOException ex) {
+                            throw new MojoExecutionException("Failed to copy files from "
+                                    + fromFileName + " to " + toFile.toString()
+                                    + ": " + ex.getLocalizedMessage());
+                        }
+                    }
+                }
+
+                // Enhance classes
 
-            URL[] classPathURLs = new URL[2];
-            ClassLoader loader = null;
-            try {
-                classPathURLs[0] = (new File(enhancedIdDirName)).toURI().toURL();
-                classPathURLs[1] = (new File(fromDirName)).toURI().toURL();
-                loader = new URLClassLoader(classPathURLs, getClass().getClassLoader());
-                Utilities.printClasspath(loader);
-                // debugging
+                URL[] classPathURLs = new URL[2];
+                ClassLoader loader = null;
+                try {
+                    classPathURLs[0] = (new File(enhancedIdDirName)).toURI().toURL();
+                    classPathURLs[1] = (new File(fromDirName)).toURI().toURL();
+                    loader = new URLClassLoader(classPathURLs, getClass().getClassLoader());
+                    Utilities.printClasspath(loader);
+                    // debugging
 //                Class cls = null;
 //                try {
 //                    cls = loader.loadClass("org.apache.jdo.tck.pc.companyListWithoutJoin.CompanyModelReader");
 //                } catch (ClassNotFoundException ex) {
 //                    Logger.getLogger(Enhance.class.getName()).log(Level.SEVERE, null, ex);
 //                }
-            } catch (MalformedURLException ex) {
-                Logger.getLogger(Enhance.class.getName()).log(Level.SEVERE, null, ex);
+                } catch (MalformedURLException ex) {
+                    Logger.getLogger(Enhance.class.getName()).log(Level.SEVERE, null, ex);
+                }
+                JDOEnhancer enhancer = JDOHelper.getEnhancer();
+                enhancer.setVerbose(true);
+                String[] classArr = classes.toArray(classArray);
+                enhancer.addClasses(classArr);
+                enhancer.setClassLoader(loader);
+                System.out.println("Enhancing classes");
+                enhancer.enhance();
             }
-            JDOEnhancer enhancer = JDOHelper.getEnhancer();
-            enhancer.setVerbose(true);
-            String[] classArr = classes.toArray(classArray);
-            enhancer.addClasses(classArr);
-            enhancer.setClassLoader(loader);
-            System.out.println("Enhancing classes");
-            enhancer.enhance();
         }
     }
 }

Modified: db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java?rev=1043028&r1=1043027&r2=1043028&view=diff
==============================================================================
--- db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java (original)
+++ db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java Tue Dec  7 13:14:27
2010
@@ -420,6 +420,15 @@ public class RunTCK extends AbstractMojo
         URL[] cpURLs = ((URLClassLoader) Thread.currentThread().getContextClassLoader()).getURLs();
         ArrayList<URL> urlList = new ArrayList<URL>(Arrays.asList(cpURLs));
 
+        // Get contents of pmf properties file to build new file below
+        String pmfPropsReadFileName = confDirectory + File.separator + pmfProperties;
+        String defaultPropsContents = "";
+        try {
+            defaultPropsContents = Utilities.readFile(pmfPropsReadFileName);
+        } catch (IOException ex) {
+            Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex);
+        }
+
         for (String db : dbs) {
             System.setProperty("jdo.tck.database", db);
             alreadyran = false;
@@ -435,7 +444,8 @@ public class RunTCK extends AbstractMojo
                 }
 
                 // Set classpath string: add new entries to URLS from loader
-                ArrayList<URL> cpList = urlList;
+                ArrayList<URL> cpList = new ArrayList<URL>();
+                cpList.addAll(urlList);
                 try {
                     URL url1 = enhancedDir.toURI().toURL();
                     URL url2 = new File(buildDirectory + File.separator
@@ -448,7 +458,7 @@ public class RunTCK extends AbstractMojo
                 }
                 String cpString = Utilities.urls2ClasspathString(cpList);
                 if (runtckVerbose) {
-                    System.out.println("Classpath is " + cpString);
+                    System.out.println("\nClasspath is " + cpString);
                 }
 
                 for (String cfg : cfgs) {
@@ -487,16 +497,16 @@ public class RunTCK extends AbstractMojo
 
                     // Add Mapping and schemaname to properties file
                     StringBuffer propsFileData = new StringBuffer();
-                    propsFileData.append("\n### Properties below added by maven goal doRuntck.jdori");
+                    propsFileData.append("\n### Properties below added by maven 2 goal RunTCK.jdori");
                     propsFileData.append("\njavax.jdo.mapping.Schema=" + idtype + mapping);
                     mapping = (mapping.equals("0")) ? "" : mapping;
                     propsFileData.append("\njavax.jdo.option.Mapping=standard" + mapping);
                     propsFileData.append("\n");
-                    String pmfPropsFileName = buildDirectory + File.separator
+                    String pmfPropsWriteFileName = buildDirectory + File.separator
                             + "classes" + File.separator + pmfProperties;
                     try {
-                        BufferedWriter out = new BufferedWriter(new FileWriter(pmfPropsFileName,
true));
-                        out.write(propsFileData.toString());
+                        BufferedWriter out = new BufferedWriter(new FileWriter(pmfPropsWriteFileName,
false));
+                        out.write(defaultPropsContents + propsFileData.toString());
                         out.close();
                     } catch (IOException ex) {
                         Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null,
ex);
@@ -518,17 +528,6 @@ public class RunTCK extends AbstractMojo
                     command.add(testRunnerClass);
                     command.addAll(classesList);
 
-//                    cmdBuf.append("java ");
-//                    cmdBuf.append("-cp " + cpString + " ");
-//                    cmdBuf.append(propsString + " ");
-//                    cmdBuf.append(dbproperties + " ");
-//                    cmdBuf.append(jvmproperties + " ");
-//                    if (debugTCK) {
-//                        cmdBuf.append(debugDirectives + " ");
-//                    }
-//                    cmdBuf.append(testRunnerClass + " ");
-//                    cmdBuf.append(classes);
-
                     // invoke class runner
                     System.out.println("Starting configuration=" + cfg +
                             " with database=" + db + " identitytype=" + idtype
@@ -540,7 +539,7 @@ public class RunTCK extends AbstractMojo
                     if (runonce.equals("true") && alreadyran) {
                         continue;
                     }
-                    System.out.println("Command line is: \n" + command.toString());
+                    System.out.println("\nCommand line is: \n" + command.toString());
                     InvocationResult result = (new Utilities()).invokeTest(command);
 
                     if (runtckVerbose) {

Modified: db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/Utilities.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/Utilities.java?rev=1043028&r1=1043027&r2=1043028&view=diff
==============================================================================
--- db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/Utilities.java (original)
+++ db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/Utilities.java Tue Dec  7 13:14:27
2010
@@ -2,6 +2,7 @@ package org.apache.jdo.exectck;
 
 import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -96,33 +97,18 @@ public class Utilities {
 
     }
 
-//    public static String convertStreamToString(InputStream is)
-//            throws IOException {
-//        /*
-//         * To convert the InputStream to String we use the
-//         * Reader.read(char[] buffer) method. We iterate until the
-//         * Reader return -1 which means there's no more data to
-//         * read. We use the StringWriter class to produce the string.
-//         */
-//        if (is != null) {
-//            Writer writer = new StringWriter();
-//
-//            char[] buffer = new char[1024];
-//            try {
-//                Reader reader = new BufferedReader(
-//                        new InputStreamReader(is, "UTF-8"));
-//                int n;
-//                while ((n = reader.read(buffer)) != -1) {
-//                    writer.write(buffer, 0, n);
-//                }
-//            } finally {
-//                is.close();
-//            }
-//            return writer.toString();
-//        } else {
-//            return "";
-//        }
-//    }
+ static String readFile( String fileName ) throws IOException {
+    BufferedReader reader = new BufferedReader( new FileReader (fileName));
+    String line  = null;
+    StringBuffer stringBuf = new StringBuffer();
+    String ls = System.getProperty("line.separator");
+    while( ( line = reader.readLine() ) != null ) {
+        stringBuf.append( line );
+        stringBuf.append( ls );
+    }
+    return stringBuf.toString();
+ }
+
     InvocationResult invokeTest(List command) {
         InvocationResult result = new InvocationResult();
         try {



Mime
View raw message