Author: vgritsenko
Date: Thu Oct 28 07:34:55 2004
New Revision: 55858

Modified:
   
cocoon/trunk/src/test/org/apache/cocoon/environment/commandline/test/CommandLineContextTestCase.java
   cocoon/trunk/tools/src/blocks-build.xsl
   cocoon/trunk/tools/targets/test-build.xml
Log:
Fix junit-tests-report target.
Output junit test report into separate directory.
Add junit.test.loglevel property to specify log level for junit tests logger.
Sync blocks junit target with core junit target (record results, do not halt on 
failure).


Modified: 
cocoon/trunk/src/test/org/apache/cocoon/environment/commandline/test/CommandLineContextTestCase.java
==============================================================================
--- 
cocoon/trunk/src/test/org/apache/cocoon/environment/commandline/test/CommandLineContextTestCase.java
        (original)
+++ 
cocoon/trunk/src/test/org/apache/cocoon/environment/commandline/test/CommandLineContextTestCase.java
        Thu Oct 28 07:34:55 2004
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2004 The Apache Software Foundation.
- * 
+ *
  * Licensed 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.
@@ -14,72 +14,48 @@
  * limitations under the License.
  */
 package org.apache.cocoon.environment.commandline.test;
-import java.io.File;
-import java.net.URL;
+
+import org.apache.avalon.framework.logger.ConsoleLogger;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.cocoon.environment.commandline.CommandLineContext;
 
 import junit.framework.TestCase;
 import junit.swingui.TestRunner;
 
-import org.apache.avalon.framework.logger.ConsoleLogger;
-import org.apache.cocoon.environment.commandline.CommandLineContext;
-import org.apache.log.Priority;
+import java.io.File;
+import java.net.URL;
 
 /**
  * A simple test case for CommandLineContext.
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Bernhard Huber</a>
- * @version CVS $Id: CommandLineContextTestCase.java,v 1.6 2004/03/05 13:03:03 
bdelacretaz Exp $
+ * @version CVS $Id$
  */
-public final class CommandLineContextTestCase
-         extends TestCase
-{
-    ///Format of default formatter
-    /**
-     *Description of the Field
-     *
-     * @since
-     */
-    protected final static String FORMAT =
-            "%7.7{priority} %{time}   [%8.8{category}] (%{context}): 
%{message}\\n%{throwable}";
-    /**
-     *Description of the Field
-     *
-     * @since
-     */
-    protected Priority m_logPriority = Priority.INFO;
+public final class CommandLineContextTestCase extends TestCase {
 
     private String commandLineContextDir;
     private CommandLineContext commandLineContext;
 
 
     /**
-     *Constructor for the CommandLineContextTestCase object
-     *
-     * @since
+     * Constructor for the CommandLineContextTestCase object
      */
     public CommandLineContextTestCase() {
         this("CommandLineContextTestCase");
     }
 
-
     /**
-     *Constructor for the CommandLineContextTestCase object
-     *
-     * @param  name  Description of Parameter
-     * @since
+     * Constructor for the CommandLineContextTestCase object
      */
     public CommandLineContextTestCase(String name) {
         super(name);
-
     }
 
-
     /**
-     *The main program for the CommandLineContextTestCase class
+     * The main program for the CommandLineContextTestCase class
      *
      * @param  args           The command line arguments
-     * @exception  Exception  Description of Exception
-     * @since
      */
     public static void main(final String[] args) throws Exception {
         final String[] testCaseName = 
{CommandLineContextTestCase.class.getName()};
@@ -88,39 +64,31 @@
 
 
     /**
-     *The JUnit setup method
-     *
-     * @exception  Exception  Description of Exception
-     * @since
+     * The JUnit setup method
      */
     public void setUp() throws Exception {
         commandLineContextDir = System.getProperty("java.io.tmpdir", "/tmp");
-        new File(commandLineContextDir, "foo"+File.separator+"bar").mkdirs();
+        new File(commandLineContextDir, "foo" + File.separator + 
"bar").mkdirs();
+
+        String level = System.getProperty("junit.test.loglevel", "" + 
ConsoleLogger.LEVEL_DEBUG);
+        Logger logger = new ConsoleLogger(Integer.parseInt(level));
+
         commandLineContext = new CommandLineContext(commandLineContextDir);
-        commandLineContext.enableLogging( new ConsoleLogger() );
+        commandLineContext.enableLogging(logger);
     }
 
-
     /**
-     *The teardown method for JUnit
-     *
-     * @exception  Exception  Description of Exception
-     * @since
+     * The teardown method for JUnit
      */
     public void tearDown() throws Exception {
-        new File(commandLineContextDir, "foo"+File.separator+"bar").delete();
+        new File(commandLineContextDir, "foo" + File.separator + 
"bar").delete();
         new File(commandLineContextDir, "foo").delete();
     }
 
-
     /**
      * A unit test for <code>getResource()</code>
-     *
-     * @exception  Exception  Description of Exception
-     * @since
      */
     public void testGetResource() throws Exception {
-
         Object[] test_values = {
                 new String[]{"", commandLineContextDir},
                 new String[]{"/", commandLineContextDir},
@@ -136,21 +104,15 @@
             if (result != null) {
                 expected = new File(tests[1]).toURL();
             }
-            String message = "Test " +
-                    "'" + test + "'";
+            String message = "Test " + "'" + test + "'";
             assertEquals(message, expected, result);
         }
     }
 
-
     /**
      * A unit test for <code>getRealPath()</code>
-     *
-     * @exception  Exception  Description of Exception
-     * @since
      */
     public void testGetRealPath() throws Exception {
-
         Object[] test_values = {
                 new String[]{"", ""},
                 new String[]{"/", "/"},
@@ -170,13 +132,9 @@
         }
     }
 
-
     /**
      * A unit test for <code>getAttribute</code>,
      * <code>setAttribute</code>, and <code>removeAttribute()</code>
-     *
-     * @exception  Exception  Description of Exception
-     * @since
      */
     public void testAttributes() throws Exception {
         Object[] test_values = {
@@ -189,11 +147,6 @@
             String name = tests[0];
             String expected = tests[1];
 
-            /* NEVER USED!
-            String message = "Test " +
-                    "'" + name + "'" + ", " + "'" + expected + "'";
-            */
-
             commandLineContext.setAttribute(name, expected);
 
             String result = (String) commandLineContext.getAttribute(name);
@@ -204,29 +157,4 @@
             assertEquals("Test " + "'" + "<null>" + "'", null, result);
         }
     }
-
-
-    /**
-     * Setup a <code>Logger</code>.
-     * <p>
-     *   Setup a logger needed by AbstractLogEnabled objects.
-     * </p>
-     *
-     * @return    Logger for logging
-     * @since
-    private final Logger setupLogger() {
-        //FIXME(GP): This method should setup a LogConfigurator and LogManager
-        //           according to the configuration spec. not yet 
completed/implemented
-        //           It will return a default logger for now.
-        final org.apache.log.Logger logger = 
Hierarchy.getDefaultHierarchy().getLoggerFor("Test");
-        logger.setPriority(m_logPriority);
-
-        final PatternFormatter formatter = new PatternFormatter(FORMAT);
-        final StreamTarget target = new StreamTarget(System.out, formatter);
-        logger.setLogTargets(new LogTarget[]{target});
-
-        return logger;
-    }
-     */
 }
-

Modified: cocoon/trunk/tools/src/blocks-build.xsl
==============================================================================
--- cocoon/trunk/tools/src/blocks-build.xsl     (original)
+++ cocoon/trunk/tools/src/blocks-build.xsl     Thu Oct 28 07:34:55 2004
@@ -667,8 +667,9 @@
             </classpath>
           </javac>
 
-          <junit printsummary="yes" haltonfailure="yes" fork="yes">
+          <junit printsummary="yes" fork="yes" 
failureproperty="junit.test.failed">
             <jvmarg value="-Djava.endorsed.dirs=lib/endorsed"/>
+            <jvmarg value="-Djunit.test.loglevel=${{junit.test.loglevel}}"/>
             <classpath>
               <path refid="{$block-name}.classpath"/>
               <path refid="test.classpath"/>
@@ -676,7 +677,8 @@
               <pathelement location="${{build.blocks}}/{$block-name}/test"/>
             </classpath>
             <formatter type="plain" usefile="no"/>
-            <batchtest>
+            <formatter type="xml"/>
+            <batchtest todir="${{build.test.output}}">
               <fileset dir="${{build.blocks}}/{$block-name}/test">
                 <include name="**/*TestCase.class"/>
                 <include name="**/*Test.class"/>

Modified: cocoon/trunk/tools/targets/test-build.xml
==============================================================================
--- cocoon/trunk/tools/targets/test-build.xml   (original)
+++ cocoon/trunk/tools/targets/test-build.xml   Thu Oct 28 07:34:55 2004
@@ -32,16 +32,19 @@
 
   <target name="junit-tests-prepare">
     <delete dir="${build.test.output}"/>
+    <delete dir="${build.test.report}"/>
     <mkdir dir="${build.test.output}"/>
   </target>
 
   <!-- Runs JUnit tests -->
   <target name="core-junit-tests" depends="compile-tests, junit-tests-prepare">
     <junit printsummary="yes" fork="yes" failureproperty="junit.test.failed">
+      <jvmarg value="-Djava.endorsed.dirs=lib/endorsed"/>
+      <jvmarg value="-Djunit.test.loglevel=${junit.test.loglevel}"/>
       <classpath>
         <path refid="test.classpath"/>
       </classpath>
-      <formatter type="plain"/>
+      <formatter type="plain" usefile="no"/>
       <formatter type="xml"/>
       <batchtest todir="${build.test.output}">
         <fileset dir="${build.test}">
@@ -68,6 +71,7 @@
     <junit printsummary="yes" fork="yes" failureproperty="junit.test.failed">
       <jvmarg value="-Xdebug"/>
       <jvmarg 
value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${junit.test.debugport}"/>
+      <jvmarg value="-Djunit.test.loglevel=${junit.test.loglevel}"/>
       <classpath refid="test.classpath"/>
       <formatter type="plain"/>
       <formatter type="xml"/>
@@ -83,14 +87,15 @@
          target="tests"/>
   </target>      
   
-  <target name="junit-tests-report">
+  <target name="junit-tests-report" depends="init">
+    <mkdir dir="${build.test.report}"/>
     <junitreport todir="${build.test.output}">
       <fileset dir="${build.test.output}">
        <include name="TEST-*.xml"/>
       </fileset>
-      <report format="frames" todir="${build.test.output}"/>
+      <report format="frames" todir="${build.test.report}"/>
     </junitreport>
-    <echo message="Unit report is at ${build.test.output}/index.html"/>
+    <echo message="Unit report is at ${build.test.report}/index.html"/>
     <fail if="junit.test.failed"
           message="One or more JUnit tests failed or caused errors. Please 
have a look into the report for details."/>
   </target>

Reply via email to