avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject svn commit: rev 37394 - in avalon/trunk/tools: . magic/src/main/org/apache/avalon/tools/model magic/src/main/org/apache/avalon/tools/tasks
Date Thu, 02 Sep 2004 16:13:58 GMT
Author: niclas
Date: Thu Sep  2 09:13:58 2004
New Revision: 37394

Modified:
   avalon/trunk/tools/index.xml
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Context.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Magic.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BlockTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java
Log:
Fixed a x:configuration problem. Implemented includes/excludes for JUnitTask.

Modified: avalon/trunk/tools/index.xml
==============================================================================
--- avalon/trunk/tools/index.xml	(original)
+++ avalon/trunk/tools/index.xml	Thu Sep  2 09:13:58 2004
@@ -6,7 +6,7 @@
     <info>
       <group>ant</group>
       <name>ant</name>
-      <version>1.6.1</version>
+      <version>1.6.2</version>
       <type>jar</type>
     </info>
     <gump>
@@ -20,7 +20,7 @@
     <info>
       <group>ant</group>
       <name>ant-nodeps</name>
-      <version>1.6.1</version>
+      <version>1.6.2</version>
       <type>jar</type>
     </info>
     <gump>
@@ -35,7 +35,7 @@
     <info>
       <group>ant</group>
       <name>ant-junit</name>
-      <version>1.6.1</version>
+      <version>1.6.2</version>
       <type>jar</type>
     </info>
     <gump>

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Context.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Context.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Context.java	Thu Sep 
2 09:13:58 2004
@@ -138,7 +138,27 @@
 
     public static final String SRC_TEST_KEY = "project.src.test";
 
+    /**
+    * the key for the include pattern for test cases
+    */
+    public static final String TEST_INCLUDES_KEY = "project.test.includes";
+    
+    /**
+    * default value
+    */
+    public static final String TEST_INCLUDES_VALUE = "**/*TestCase.java, **/*Test.java";
+    
+    /**
+    * the key for the exclude pattern for test cases
+    */
+    public static final String TEST_EXCLUDES_KEY = "project.test.excludes";
+
    /**
+    * default value
+    */
+    public static final String TEST_EXCLUDES_VALUE = "**/Abstract*.java, **/AllTest*.java";
+    
+    /**
     * The value of the default project.src.test property value.
     */
     public static final String SRC_TEST = "test";
@@ -316,6 +336,8 @@
     private File m_temp;
     private File m_docs;
     private File m_test;
+    private String m_testIncludes;
+    private String m_testExcludes;
 
    /**
     * Creation of the context and association ofnthe context under the KEY key.
@@ -333,6 +355,8 @@
         project.setNewProperty( SRC_MAIN_KEY, SRC_MAIN );
         project.setNewProperty( SRC_CONFIG_KEY, SRC_CONFIG );
         project.setNewProperty( SRC_TEST_KEY, SRC_TEST );
+        project.setNewProperty( TEST_INCLUDES_KEY, TEST_INCLUDES_VALUE );
+        project.setNewProperty( TEST_EXCLUDES_KEY, TEST_EXCLUDES_VALUE );
 
         project.setNewProperty( ETC_KEY, ETC_VALUE );
 
@@ -352,7 +376,8 @@
         m_testClasses = setBuildPath( TEST_CLASSES );
         m_testReports = setBuildPath( TEST_REPORTS );
         m_docs = setBuildPath( DOCS );
-
+        m_testIncludes = setupTestIncludes(project.getProperty(TEST_INCLUDES_KEY));
+        m_testExcludes = setupTestExcludes(project.getProperty(TEST_EXCLUDES_KEY));
         project.addReference( KEY, this );
 
     }
@@ -455,6 +480,24 @@
     {
         return m_test;
     }
+    
+    /**
+    * Return the project test includes.
+    * @return the includes pattern
+    */
+    public String getTestIncludes()
+    {
+        return m_testIncludes;
+    }
+    
+    /**
+    * Return the project test excludes.
+    * @return the excludes pattern
+    */
+    public String getTestExcludes()
+    {
+        return m_testExcludes;
+    }
 
    /**
     * Reuturn the project docs directory.
@@ -558,6 +601,21 @@
         if( null == path ) return new File( basedir, SRC_VALUE );
         return new File( basedir, path );
     }
+    
+    private static String setupTestIncludes( final String includes )
+    {
+        if( null == includes ) 
+            return TEST_INCLUDES_VALUE;
+        return includes;
+    }
+    
+    private static String setupTestExcludes( final String excludes )
+    {
+        if( null == excludes ) 
+            return TEST_EXCLUDES_VALUE;
+        return excludes;
+    }
+
 
     private static File setupEtc( final File basedir, final String path )
     {

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Magic.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Magic.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Magic.java	Thu Sep  2
09:13:58 2004
@@ -146,7 +146,8 @@
         m_signature = project.getProperty( GUMP_SIGNATURE_KEY );
         m_system = getSystemDirectory( project );
         project.setProperty( KEY, Context.getCanonicalPath( m_system ) );
-        File user = new File( m_system, "user.properties" );
+        File home = new File( System.getProperty( "user.home" ) );
+        File user = new File( home, "magic.properties" );
         loadProperties( project, user );
         File properties = new File( m_system, "magic.properties" );
         loadProperties( project, properties );

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BlockTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BlockTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BlockTask.java	Thu Sep
 2 09:13:58 2004
@@ -653,6 +653,7 @@
             String uri, String localName, String qName, String value)
             throws BuildException
         {
+       	     System.out.println("setting DynamicAttribute with: " + localName + ", " + qName
+ ", " + value );
              m_attributes.put( qName, value );
         }
 
@@ -705,7 +706,7 @@
         */
         public Configuration[] getChildren()
         {
-            return (Configuration[]) m_children.toArray( new Configuration[0] );
+            return (Configuration[]) m_children.toArray( new Configuration[m_children.size()]
);
         }
     }
 
@@ -1053,7 +1054,7 @@
         if( attributes.size() > 0 )
         {
             Map.Entry[] values = (Map.Entry[]) attributes.entrySet().toArray( new Map.Entry[0]
);
-            for( int i=0; i<values.length; i++ )
+            for( int i=0; i < values.length; i++ )
             {
                  Map.Entry entry = values[i];
                  writer.write( " " + entry.getKey() + "=\"" + entry.getValue() + "\"" );
@@ -1064,7 +1065,7 @@
         if( children.length > 0 )
         {
             writer.write( ">" );
-            for( int i=0; i<children.length; i++ )
+            for( int i=0; i < children.length; i++ )
             {
                  writeConfiguration( pad + "  ", writer, children[i] );
             }
@@ -1072,7 +1073,16 @@
         }
         else
         {
-            writer.write( "/>" );
+            if( null == config.getValue() )
+            {
+                writer.write( "/>" );
+            }
+            else
+            {
+            	writer.write( ">" );
+                writer.write( config.getValue() );
+                writer.write( "</" + name + ">" );
+            }
         }
     }
 

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java	Thu
Sep  2 09:13:58 2004
@@ -35,6 +35,8 @@
 
 import java.io.File;
 
+import java.util.StringTokenizer;
+
 /**
  * Load a goal. 
  *
@@ -214,8 +216,11 @@
 
         final FileSet fileset = new FileSet();
         fileset.setDir( src );
-        fileset.createInclude().setName( "**/*TestCase.java" );
-        fileset.createExclude().setName( "**/Abstract*.java" );
+        final String includes = getContext().getTestIncludes();
+        final String excludes = getContext().getTestExcludes();
+        createIncludes(fileset, includes);
+        createExcludes(fileset, excludes);
+        project.log( "MAGIC TEST FILTERS: includes=" + includes + ", excludes=" + excludes,
Project.MSG_VERBOSE );
 
         final JUnitTask junit = (JUnitTask) getProject().createTask( "junit" );
         junit.init();
@@ -288,6 +293,28 @@
         junit.setTaskName( getTaskName() );
 
         junit.execute();
+    }
+    
+    private void createIncludes(FileSet set, String pattern)
+    {
+    	StringTokenizer tokenizer = new StringTokenizer(pattern, ", ", false);
+    	while( tokenizer.hasMoreTokens())
+    	{
+    	    String item = tokenizer.nextToken();
+    	    set.createInclude().setName( item );
+        }
+	
+    }
+    
+    private void createExcludes(FileSet set, String pattern)
+    {
+    	StringTokenizer tokenizer = new StringTokenizer(pattern, ", ", false);
+    	while( tokenizer.hasMoreTokens())
+    	{
+            String item = tokenizer.nextToken();
+    	    set.createExclude().setName( item );
+        }
+	
     }
 
     private String getCachePath()

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message