[jboss-cvs] JBossAS SVN: r94202 - in projects/jboss-osgi/projects/aQute/trunk/aQute.runtime: src/main/java/aQute/junit/runtime and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 1 03:19:47 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-10-01 03:19:47 -0400 (Thu, 01 Oct 2009)
New Revision: 94202

Added:
   projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/src/main/java/aQute/junit/runtime/PlainResultFormatter.java
   projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/src/main/java/aQute/junit/runtime/XMLResultFormatter.java
Modified:
   projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/scripts/assembly-ant-junit.xml
   projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/src/main/java/aQute/junit/runtime/GenericFramework.java
   projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/src/main/java/aQute/junit/runtime/Target.java
Log:
Ant test reports - ok

Modified: projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/scripts/assembly-ant-junit.xml
===================================================================
--- projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/scripts/assembly-ant-junit.xml	2009-10-01 06:35:20 UTC (rev 94201)
+++ projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/scripts/assembly-ant-junit.xml	2009-10-01 07:19:47 UTC (rev 94202)
@@ -23,6 +23,9 @@
       <unpackOptions>
         <includes>
           <include>org/apache/tools/ant/BuildException.class</include>
+          <include>org/apache/tools/ant/ProjectComponent.class</include>
+          <include>org/apache/tools/ant/taskdefs/condition/Condition.class</include>
+          <include>org/apache/tools/ant/taskdefs/condition/Os.class</include>
           <include>org/apache/tools/ant/taskdefs/optional/junit/BaseTest.class</include>
           <include>org/apache/tools/ant/taskdefs/optional/junit/JUnitResultFormatter.class</include>
           <include>org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirror.class</include>
@@ -34,9 +37,16 @@
           <include>org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.class</include>
           <include>org/apache/tools/ant/taskdefs/optional/junit/XMLConstants.class</include>
           <include>org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.class</include>
+          <include>org/apache/tools/ant/types/DataType.class</include>
+          <include>org/apache/tools/ant/types/ResourceCollection.class</include>
+          <include>org/apache/tools/ant/types/Resource.class</include>
+          <include>org/apache/tools/ant/types/resources/FileResource.class</include>
+          <include>org/apache/tools/ant/types/resources/Touchable.class</include>
           <include>org/apache/tools/ant/util/DOMElementWriter.class</include>
+          <include>org/apache/tools/ant/util/DOMElementWriter$*.class</include>
           <include>org/apache/tools/ant/util/DateUtils.class</include>
           <include>org/apache/tools/ant/util/FileUtils.class</include>
+          <include>org/apache/tools/ant/util/FileUtils$*.class</include>
           <include>org/apache/tools/ant/util/StringUtils.class</include>
           <include>org/apache/tools/ant/util/TeeOutputStream.class</include>
         </includes>

Modified: projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/src/main/java/aQute/junit/runtime/GenericFramework.java
===================================================================
--- projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/src/main/java/aQute/junit/runtime/GenericFramework.java	2009-10-01 06:35:20 UTC (rev 94201)
+++ projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/src/main/java/aQute/junit/runtime/GenericFramework.java	2009-10-01 07:19:47 UTC (rev 94202)
@@ -1,16 +1,40 @@
 package aQute.junit.runtime;
 
-import java.io.*;
-import java.lang.reflect.*;
-import java.net.*;
-import java.security.*;
-import java.util.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.AllPermission;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Policy;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Vector;
 
-import org.osgi.framework.*;
-import org.osgi.framework.launch.*;
-import org.osgi.service.permissionadmin.*;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+import org.osgi.service.permissionadmin.PermissionInfo;
 
-import aQute.junit.runtime.minifw.*;
+import aQute.junit.runtime.minifw.MiniFramework;
 
 public class GenericFramework {
     private String                 framework;
@@ -319,8 +343,7 @@
             out.println();
             out.println("Framework             " + framework);
             out.println("SystemBundle          "
-                    + (systemBundle == null ? "<>" : systemBundle.getClass()
-                            .toString()));
+                    + (systemBundle == null ? "<>" : systemBundle.getClass().getName()));
             out.println("Storage               " + storage);
             out.println("Keep                  " + keep);
             out.println("Security              " + security);

Added: projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/src/main/java/aQute/junit/runtime/PlainResultFormatter.java
===================================================================
--- projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/src/main/java/aQute/junit/runtime/PlainResultFormatter.java	                        (rev 0)
+++ projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/src/main/java/aQute/junit/runtime/PlainResultFormatter.java	2009-10-01 07:19:47 UTC (rev 94202)
@@ -0,0 +1,46 @@
+/*
+ *  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.
+ *
+ */
+package aQute.junit.runtime;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter;
+
+/**
+ * An extension of the standard Ant PlainJUnitResultFormatter.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 01-Oct-2009
+ */
+public class PlainResultFormatter extends PlainJUnitResultFormatter {
+
+	/**
+	 * Creates an XMLResultFormatter with the given report specs. 
+	 * 
+	 * @param reportDir The directory to generate the test reports in
+	 * @param testSuiteName The test suite name.
+	 * @throws IOException if the test report file cannot be created
+	 */
+	public PlainResultFormatter(String reportDir, String testSuiteName) throws IOException {
+		new File(reportDir).mkdirs();
+		File outFile = new File(reportDir + "/" + testSuiteName + ".xml");
+		setOutput(new FileOutputStream(outFile));
+	}
+}

Modified: projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/src/main/java/aQute/junit/runtime/Target.java
===================================================================
--- projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/src/main/java/aQute/junit/runtime/Target.java	2009-10-01 06:35:20 UTC (rev 94201)
+++ projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/src/main/java/aQute/junit/runtime/Target.java	2009-10-01 07:19:47 UTC (rev 94202)
@@ -11,14 +11,12 @@
 import java.util.Properties;
 
 import junit.framework.Test;
-import junit.framework.TestListener;
 import junit.framework.TestResult;
 import junit.framework.TestSuite;
 
 import org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter;
 import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
 import org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter;
-import org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 
@@ -172,17 +170,24 @@
                 result.addListener(otl);
                 
                 // Add the standard plain and xml formatters 
+                String testSuiteName = getTestSuiteName();
+                String reportDir = new File(reportName).getParentFile() + "/test-reports";
                 List<JUnitResultFormatter> formatters = new ArrayList<JUnitResultFormatter>();
-                formatters.add(new XMLJUnitResultFormatter());
-                formatters.add(new PlainJUnitResultFormatter());
+                formatters.add(new XMLResultFormatter(reportDir, testSuiteName));
+                formatters.add(new PlainResultFormatter(reportDir, testSuiteName));
                 for (JUnitResultFormatter formatter : formatters) 
                     result.addListener(formatter);
                 
-                JUnitTest junitTest = new JUnitTest(target);
+				JUnitTest junitTest = new JUnitTest(testSuiteName);
+                junitTest.setProperties(System.getProperties());
+                
+                long startTime = System.currentTimeMillis();
                 fireStartTestSuite(formatters, junitTest);
                 try {
 					suite.run(result);
 				} finally {
+	                junitTest.setCounts(realcount, result.failureCount(), result.errorCount());
+	                junitTest.setRunTime(System.currentTimeMillis() - startTime);
 	                fireEndTestSuite(formatters, junitTest);
 				}
 				
@@ -205,7 +210,15 @@
             throw new IllegalStateException("Framework does not activate");
     }
 
-    private int flatten(List list, TestSuite suite) {
+    private String getTestSuiteName() {
+		String name = new File(target).getName();
+		int dashIndex = name.indexOf("-");
+		if (dashIndex > 0)
+			name = name.substring(0, dashIndex);
+		return name;
+	}
+
+	private int flatten(List list, TestSuite suite) {
         int realCount = 0;
         for (Enumeration e = suite.tests(); e.hasMoreElements();) {
             Test test = (Test) e.nextElement();

Added: projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/src/main/java/aQute/junit/runtime/XMLResultFormatter.java
===================================================================
--- projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/src/main/java/aQute/junit/runtime/XMLResultFormatter.java	                        (rev 0)
+++ projects/jboss-osgi/projects/aQute/trunk/aQute.runtime/src/main/java/aQute/junit/runtime/XMLResultFormatter.java	2009-10-01 07:19:47 UTC (rev 94202)
@@ -0,0 +1,46 @@
+/*
+ *  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.
+ *
+ */
+package aQute.junit.runtime;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter;
+
+/**
+ * An extension of the standard Ant XMLJUnitResultFormatter.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 01-Oct-2009
+ */
+public class XMLResultFormatter extends XMLJUnitResultFormatter {
+
+	/**
+	 * Creates an XMLResultFormatter with the given report specs. 
+	 * 
+	 * @param reportDir The directory to generate the test reports in
+	 * @param testSuiteName The test suite name.
+	 * @throws IOException if the test report file cannot be created
+	 */
+	public XMLResultFormatter(String reportDir, String testSuiteName) throws IOException {
+		new File(reportDir).mkdirs();
+		File outFile = new File(reportDir + "/TEST-" + testSuiteName + ".xml");
+		setOutput(new FileOutputStream(outFile));
+	}
+}




More information about the jboss-cvs-commits mailing list