You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by fu...@apache.org on 2006/11/03 00:50:59 UTC

svn commit: r470604 - in /db/derby/code/trunk: build.xml java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java

Author: fuzzylogic
Date: Thu Nov  2 15:50:58 2006
New Revision: 470604

URL: http://svn.apache.org/viewvc?view=rev&rev=470604
Log:
DERBY-2006: Add a top-level Ant target that runs the junit tests and generates
a report.

Modified:
    db/derby/code/trunk/build.xml
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java

Modified: db/derby/code/trunk/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/build.xml?view=diff&rev=470604&r1=470603&r2=470604
==============================================================================
--- db/derby/code/trunk/build.xml (original)
+++ db/derby/code/trunk/build.xml Thu Nov  2 15:50:58 2006
@@ -1595,4 +1595,69 @@
     <echo message=""/>
     <fail message="Exiting snapshot build..."/>
   </target>
+
+<!-- =================================================================== -->
+<!--                         Junit utility targets                       -->
+<!-- =================================================================== -->
+
+  <target name="junit-init">
+    <tstamp prefix="derby.junit"/>
+    <mkdir dir="junit_${derby.junit.DSTAMP}_${derby.junit.TSTAMP}/testout"/>
+  </target>
+
+  <target name="junit-clean">
+    <delete includeEmptyDirs="true">
+      <fileset dir="${basedir}" includes="junit*/**"/>
+    </delete>
+  </target>
+
+  <target name="junit-oneclass" depends="junit-init">
+    <junit printsummary="on"
+           fork="yes" forkmode="once"
+           showoutput="yes"
+           dir="junit_${derby.junit.DSTAMP}_${derby.junit.TSTAMP}/testout">
+      <formatter type="xml"/>
+      <test name="${derby.junit.testname}" todir="junit_${derby.junit.DSTAMP}_${derby.junit.TSTAMP}"/>
+      <classpath path="${out.dir};${junit}"/>
+    </junit>
+  </target>
+ 
+  <!-- only execute jdbc4 suite if we have a pointer to a 1.6 VM -->
+  <target name="junit-jdbc4" if="jdk16">
+    <junit printsummary="on"
+           fork="yes" forkmode="once"
+           jvm="${jdk16}/bin/java"
+           showoutput="yes"
+           dir="junit_${derby.junit.DSTAMP}_${derby.junit.TSTAMP}/testout">
+      <formatter type="xml"/>
+      <test name="org.apache.derbyTesting.functionTests.tests.jdbc4._Suite"
+            todir="junit_${derby.junit.DSTAMP}_${derby.junit.TSTAMP}"/>
+      <classpath path="${out.dir};${junit}"/>
+    </junit> 
+  </target>
+
+  <target name="junit-all" depends="junit-init,junit-jdbc4">
+    <antcall target="junit-oneclass">
+      <param name="derby.junit.testname"
+             value="org.apache.derbyTesting.functionTests.tests.tools._Suite"/>
+    </antcall>
+    <antcall target="junit-oneclass">
+      <param name="derby.junit.testname"
+             value="org.apache.derbyTesting.functionTests.tests.lang._Suite"/>
+    </antcall>
+    <antcall target="junit-oneclass">
+      <param name="derby.junit.testname"
+             value="org.apache.derbyTesting.functionTests.tests.jdbcapi._Suite"/>
+    </antcall>
+  </target>
+
+  <target name="junitreport" depends="junit-all"> 
+    <junitreport todir="junit_${derby.junit.DSTAMP}_${derby.junit.TSTAMP}">
+      <fileset dir="junit_${derby.junit.DSTAMP}_${derby.junit.TSTAMP}">
+        <include name="TEST-*.xml"/>
+      </fileset>
+      <report format="frames" todir="junit_${derby.junit.DSTAMP}_${derby.junit.TSTAMP}"/>
+    </junitreport>
+  </target>   
+
 </project>

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy?view=diff&rev=470604&r1=470603&r2=470604
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy Thu Nov  2 15:50:58 2006
@@ -159,14 +159,17 @@
 // JUnit jar file tries to read junit.properties in the user's
 // home directory and seems to require permission to read the
 // property user.home as well.
-// Ideally these would be granted to junit.jar only but currently
-// the jar may be anyway on a file system. Could expand the test harness
-// to look for junit.jar on the classpath as it done for the Derby jars.
-// The exposure in making these properties grantable to all is somewhat low,
-// though reading the property user.home is a little troubling.
-grant {
+grant codeBase "${derbyTesting.junit}" {
     permission java.util.PropertyPermission "user.home", "read";
     permission java.io.FilePermission "${user.home}${/}junit.properties", "read";
+};
+
+// Ant's junit runner requires setOut to redirect the System output streams
+// to the forked JVM used when running junit tests inside Ant. Ant requires
+// forking the JVM if you want to run tests in a different directory than the
+// current one.
+grant codeBase "${derbyTesting.antjunit}" {
+    permission java.lang.RuntimePermission "setIO";
 };
 
 // functionTests.tests.lang.RoutineSecurityTest requires this grant

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java?view=diff&rev=470604&r1=470603&r2=470604
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java Thu Nov  2 15:50:58 2006
@@ -216,6 +216,24 @@
 		if (System.getSecurityManager() != null) {		
 			return true;
 		}
+
+		//We need the junit classes to instantiate this class, so the
+		//following should not cause runtime errors.
+        URL junit = null;
+        junit = getURL(junit.framework.Test.class);
+        classPathSet.setProperty("derbyTesting.junit", junit == null ? "" : junit.toString());
+	
+        URL antjunit = null;
+        Class antjunitclass = null;
+        try {
+        	// Load indirectly so we don't need ant-junit.jar at compile time.
+            antjunitclass = Class.forName("org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner");
+            antjunit = getURL(antjunitclass);
+            classPathSet.setProperty("derbyTesting.antjunit", antjunit == null ? "" : antjunit.toString());
+        } catch (java.lang.ClassNotFoundException e) {
+        	// Not running in Ant, do nothing.
+            antjunit = null;
+        }
 		
 		URL testing = getURL(SecurityManagerSetup.class);
 		
@@ -250,7 +268,7 @@
 		}
 		
 		classPathSet.setProperty("derbyTesting.clientjar", stripJar(client));
-		
+	
 		return false;
 	}