The attached diff includes interrogation of a new property under the
magic JUnitTest task:

  project.test.fork.mode

This property can contain one of the JUnitTask.ForkMode enumerated
values 'once', 'perBatch' or 'perTest'. If forking of a test is enabled,
the diff adds supporting for the setting of the fork mode based on the
above property value.  The changes have been tested and have resolved
the OutOfMemory issue raised by David on the users list earlier today.

Stephen.

Index: src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java
===================================================================
--- src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java   (revision 51899)
+++ src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java   (working copy)
@@ -62,6 +62,8 @@
     public static final String HALT_ON_ERROR_KEY = "project.test.halt-on-error";
     public static final boolean HALT_ON_ERROR_VALUE = false;
 
+    public static final String TEST_FORK_MODE_KEY = "project.test.fork.mode";
+
     public static final String HALT_ON_FAILURE_KEY = "project.test.halt-on-failure";
     public static final boolean HALT_ON_FAILURE_VALUE = true;
 
@@ -214,7 +216,7 @@
     private void test( final File src, final Path classpath, File working )
     {
         final Project project = getProject();
-        project.log( "MAGIC TEST CLASSPATH: " + classpath, Project.MSG_VERBOSE );
+        log( "Test classpath: " + classpath, Project.MSG_VERBOSE );
 
         final FileSet fileset = new FileSet();
         fileset.setDir( src );
@@ -222,7 +224,7 @@
         final String excludes = getContext().getTestExcludes();
         createIncludes(fileset, includes);
         createExcludes(fileset, excludes);
-        project.log( "MAGIC TEST FILTERS: includes=" + includes + ", excludes=" + 
excludes, Project.MSG_VERBOSE );
+        log( "Test filters: includes=" + includes + ", excludes=" + excludes, 
Project.MSG_VERBOSE );
 
         final JUnitTask junit = (JUnitTask) getProject().createTask( "junit" );
         junit.init();
@@ -288,12 +290,18 @@
         junit.setErrorProperty( ERROR_KEY );
         junit.setFailureProperty( FAILURE_KEY );
         junit.setTaskName( getTaskName() );
-       if( getForkProperty() )
+         if( getForkProperty() )
         {
+            JUnitTask.ForkMode mode = getForkMode();
+            log( "Executing forked test with mode: '" + mode + "'." );
             junit.setFork( true );
             junit.setDir( project.getBaseDir() );
+            junit.setForkMode( mode );
         }
-        
+        else
+        {
+            log( "executing in local jvm" );
+        }
         junit.execute();
     }
     
@@ -352,6 +360,19 @@
         return getBooleanProperty( FORK_KEY, FORK_VALUE );
     }
 
+    private JUnitTask.ForkMode getForkMode()
+    {
+        final String value = getProject().getProperty( TEST_FORK_MODE_KEY );
+        if( null == value )
+        {
+            return new JUnitTask.ForkMode( JUnitTask.ForkMode.ONCE );
+        }
+        else 
+        {
+            return new JUnitTask.ForkMode( value );
+        }
+    }
+
     private boolean getBooleanProperty( final String key, final boolean fallback )
     {
         final String value = getProject().getProperty( key );
Index: build.xml
===================================================================
--- build.xml   (revision 51899)
+++ build.xml   (working copy)
@@ -21,6 +21,12 @@
   </target>
   -->
 
+  <!--
+  <target name="build" depends="standard.build">
+    <x:artifact factory="xyz"/>
+  </target>
+  -->
+
   <target name="package" depends="standard.package">
     <x:bar/>
   </target>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to