Return-Path: Delivered-To: apmail-db-jdo-commits-archive@www.apache.org Received: (qmail 94493 invoked from network); 15 Dec 2010 03:26:05 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 15 Dec 2010 03:26:05 -0000 Received: (qmail 50657 invoked by uid 500); 15 Dec 2010 03:26:04 -0000 Mailing-List: contact jdo-commits-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-commits@db.apache.org Received: (qmail 50644 invoked by uid 99); 15 Dec 2010 03:26:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Dec 2010 03:26:03 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Dec 2010 03:26:02 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3CF2E23888D2; Wed, 15 Dec 2010 03:25:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1049404 - in /db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck: RunTCK.java Utilities.java Date: Wed, 15 Dec 2010 03:25:42 -0000 To: jdo-commits@db.apache.org From: mcaisse@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101215032542.3CF2E23888D2@eris.apache.org> Author: mcaisse Date: Wed Dec 15 03:25:41 2010 New Revision: 1049404 URL: http://svn.apache.org/viewvc?rev=1049404&view=rev Log: JDO-647 - Create result summary, copy config files to logs configuration directory. Modified: 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/RunTCK.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java?rev=1049404&r1=1049403&r2=1049404&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 Wed Dec 15 03:25:41 2010 @@ -1,4 +1,3 @@ - package org.apache.jdo.exectck; import java.io.BufferedWriter; @@ -11,10 +10,12 @@ import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; +import org.apache.commons.io.FileUtils; import org.apache.jdo.exectck.Utilities.InvocationResult; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -150,21 +151,18 @@ public class RunTCK extends AbstractMojo * @optional */ private String cleanupaftertest; - /** * Properties to use in accessing database. * @parameter expression="${database.runtck.sysproperties}" * @optional */ private String dbproperties; // NOTE: only allows for one db - /** * Properties to use in accessing database. * @parameter expression="${jdo.tck.signaturefile}" * @optional */ private String signaturefile; - /** * JVM properties. * @parameter expression="${jdo.tck.jvmproperties}" @@ -172,7 +170,6 @@ public class RunTCK extends AbstractMojo * @optional */ private String jvmproperties; - /** * The port number the JVM should listen for a debugger on. * @parameter expression="${jdo.tck.debug.port}" @@ -217,6 +214,9 @@ public class RunTCK extends AbstractMojo boolean alreadyran = false; String runonce = "false"; List propsString = new ArrayList(); + List command; + String cpString = null; + InvocationResult result; if (cfgs != null) { // System.out.println("Configurations specified in cfgs are " + cfgs.toString()); @@ -247,8 +247,8 @@ public class RunTCK extends AbstractMojo propsString.add("-DPMF2Properties=" + buildDirectory + File.separator + "classes" + File.separator + pmfProperties); String excludeFile = confDirectory + File.separator + exclude; - propsString.add("-Djdo.tck.exclude=" + - PropertyUtils.getProperties(excludeFile).getProperty("jdo.tck.exclude")); + propsString.add("-Djdo.tck.exclude=" + + PropertyUtils.getProperties(excludeFile).getProperty("jdo.tck.exclude")); // Create configuration log directory String timestamp = Utilities.now(); @@ -302,7 +302,7 @@ public class RunTCK extends AbstractMojo ex.printStackTrace(); Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex); } - String cpString = Utilities.urls2ClasspathString(cpList); + cpString = Utilities.urls2ClasspathString(cpList); if (runtckVerbose) { System.out.println("\nClasspath is " + cpString); } @@ -312,18 +312,18 @@ public class RunTCK extends AbstractMojo // Parse conf file and set properties String props = PropertyUtils.getProperties(confDirectory + File.separator + cfg); - propsString.add("-Djdo.tck.testdata=" + - props.getProperty("jdo.tck.testdata")); - propsString.add("-Djdo.tck.standarddata=" + - props.getProperty("jdo.tck.standarddata")); - propsString.add("-Djdo.tck.mapping.companyfactory=" + - props.getProperty("jdo.tck.mapping.companyfactory")); + propsString.add("-Djdo.tck.testdata=" + + props.getProperty("jdo.tck.testdata")); + propsString.add("-Djdo.tck.standarddata=" + + props.getProperty("jdo.tck.standarddata")); + propsString.add("-Djdo.tck.mapping.companyfactory=" + + props.getProperty("jdo.tck.mapping.companyfactory")); // propsString.append("-Djdo.tck.description=\"" + // props.getProperty("jdo.tck.description") + "\""); - propsString.add("-Djdo.tck.requiredOptions=" + - props.getProperty("jdo.tck.requiredOptions")); - propsString.add("-Djdo.tck.signaturefile=" + - signaturefile); + propsString.add("-Djdo.tck.requiredOptions=" + + props.getProperty("jdo.tck.requiredOptions")); + propsString.add("-Djdo.tck.signaturefile=" + + signaturefile); String mapping = props.getProperty("jdo.tck.mapping"); if (mapping == null) { throw new MojoExecutionException( @@ -361,8 +361,7 @@ public class RunTCK extends AbstractMojo } // build command line string -// StringBuffer cmdBuf = new StringBuffer(); - List command = new ArrayList(); + command = new ArrayList(); command.add("java"); command.add("-cp"); command.add(cpString); @@ -377,8 +376,8 @@ public class RunTCK extends AbstractMojo command.addAll(classesList); // invoke class runner - System.out.println("*> Starting configuration=" + cfg + - " with database=" + db + " identitytype=" + idtype + System.out.println("*> Starting configuration=" + cfg + + " with database=" + db + " identitytype=" + idtype + " mapping=" + mapping + " on the " + impl + "."); if (debugTCK) { System.out.println("Using debug arguments: \n" @@ -388,7 +387,7 @@ public class RunTCK extends AbstractMojo continue; } // System.out.println("\nCommand line is: \n" + command.toString()); - InvocationResult result = (new Utilities()).invokeTest(command); + result = (new Utilities()).invokeTest(command); if (runtckVerbose) { System.out.println("Test exit value is " + result.getExitValue()); @@ -400,33 +399,57 @@ public class RunTCK extends AbstractMojo alreadyran = true; } - - // Output results - /* - - - - - - - - - - */ - - // Copy files to configuration logs directory -// -// -// -// -// -// - } } } + // Output results + command = new ArrayList(); + command.add("java"); + command.add("-cp"); + command.add(cpString); + command.add("org.apache.jdo.tck.util.ResultSummary"); + command.add(thisLogDir); + result = (new Utilities()).invokeTest(command, new File(buildDirectory)); + + // Create system configuration description file + command.set(3, "org.apache.jdo.tck.util.SystemCfgSummary"); + command.set(4, cfgDirName); + command.add("system_config.txt"); + result = (new Utilities()).invokeTest(command, new File(buildDirectory)); + + // Copy metadata from enhanced to configuration logs directory + for (String idtype : idtypes) { + String fromDirName = buildDirectory + File.separator + "enhanced" + + File.separator + impl + File.separator + idtype + File.separator; + String[] metadataExtensions = {"jdo", "jdoquery", "orm", "xml", "properties"}; + File fromFile = null; + File toFile = null; + String fromFileName = null; + String pkgName = null; + int startIdx = -1; + // iterator over list of abs name of metadata files in src + Iterator 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)) > -1) { + // fully specified name of file (idtype + package + filename) + pkgName = fromFileName.substring(startIdx); + toFile = new File(cfgDirName + File.separator + + pkgName); +// System.out.println("Copy from source dir to " + toFile.toString()); + FileUtils.copyFile(fromFile, toFile); + } + } catch (IOException ex) { + throw new MojoExecutionException("Failed to copy files from " + + fromFileName + " to " + toFile.toString() + + ": " + ex.getLocalizedMessage()); + } + } + } } } 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=1049404&r1=1049403&r2=1049404&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 Wed Dec 15 03:25:41 2010 @@ -141,6 +141,41 @@ public class Utilities { return result; } + InvocationResult invokeTest(List command, File directory) { + InvocationResult result = new InvocationResult(); + try { + ProcessBuilder builder = new ProcessBuilder(command); + builder.directory(directory); + Map env = builder.environment(); + Process proc = builder.start(); + InputStream stdout = proc.getInputStream(); + InputStream stderr = proc.getErrorStream(); + CharBuffer outBuffer = CharBuffer.allocate(1000000); + CharBuffer errBuffer = CharBuffer.allocate(1000000); + Thread outputThread = createReaderThread(stdout, outBuffer); + Thread errorThread = createReaderThread(stderr, errBuffer); + int exitValue = proc.waitFor(); + result.setExitValue(exitValue); + errorThread.join(10000); // wait ten seconds to get stderr after process terminates + outputThread.join(10000); // wait ten seconds to get stdout after process terminates + result.setErrorString(errBuffer.toString()); + result.setOutputString(outBuffer.toString()); + // wait until the Enhancer command finishes + } catch (InterruptedException ex) { + throw new RuntimeException("InterruptedException", ex); + } catch (IOException ex) { + throw new RuntimeException("IOException", ex); + } catch (JDOException jdoex) { + jdoex.printStackTrace(); + Throwable[] throwables = jdoex.getNestedExceptions(); + System.out.println("Exception throwables of size: " + throwables.length); + for (Throwable throwable: throwables) { + throwable.printStackTrace(); + } + } + return result; + } + private Thread createReaderThread(final InputStream input, final CharBuffer output) { final Reader reader = new InputStreamReader(input); Thread thread = new Thread(