avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject svn commit: rev 22676 - in avalon/trunk/tools/magic/src: main/org/apache/avalon/tools/model main/org/apache/avalon/tools/tasks test/org test/org/apache test/org/apache/avalon test/org/apache/avalon/tools test/org/apache/avalon/tools/model test/org/apache/avalon/tools/model/test
Date Wed, 07 Jul 2004 15:34:39 GMT
Author: mcconnell
Date: Wed Jul  7 08:34:38 2004
New Revision: 22676

Added:
   avalon/trunk/tools/magic/src/test/org/
   avalon/trunk/tools/magic/src/test/org/apache/
   avalon/trunk/tools/magic/src/test/org/apache/avalon/
   avalon/trunk/tools/magic/src/test/org/apache/avalon/tools/
   avalon/trunk/tools/magic/src/test/org/apache/avalon/tools/model/
   avalon/trunk/tools/magic/src/test/org/apache/avalon/tools/model/test/
   avalon/trunk/tools/magic/src/test/org/apache/avalon/tools/model/test/ContextTestCase.java
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/Definition.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Gump.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Home.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Magic.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/MagicPath.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Repository.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/XMLDefinitionBuilder.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/AbstractDeliverableTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BarTask.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/DeclareTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/FilterTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/GumpTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/HomeTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JarTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ReactorTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ReplicateTask.java
Log:
Cleanup in the code, test case addition, and some optimization in the gump task.

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	Wed Jul 
7 08:34:38 2004
@@ -232,7 +232,9 @@
     }
 
    /**
-    * Return the concatonal variant of a file and create it if it does not exist.
+    * Return the concatonal variant of a file and ensure that the parent directory
+    * path is created.
+    *
     * @param file the file argument
     * @return the concatonal variant
     */
@@ -301,7 +303,6 @@
     private final Map m_map = new Hashtable();
 
     private String m_key;
-    private File m_file;
 
     private File m_src;
     private File m_etc;
@@ -521,11 +522,6 @@
     // internal
     //--------------------------------------------------------------------
 
-    private File getTargetDirectory( final String path )
-    {
-        return new File( m_target, path );
-    }
-
     private String resolveKey()
     {
         if( null != m_key )
@@ -584,15 +580,8 @@
 
     private void setupBuildProperties( final Project project, final File basedir )
     {
-        if( null == m_file )
-        {  
-            final File build = Context.getFile( basedir, BUILD_PROPERTIES );
-            readProperties( project, build );
-        }
-        else
-        {
-            readProperties( project, m_file );
-        }
+        final File build = Context.getFile( basedir, BUILD_PROPERTIES );
+        readProperties( project, build );
     }
 
     private void readProperties( final Project project, final File file ) throws BuildException

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Definition.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Definition.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Definition.java	Wed Jul
 7 08:34:38 2004
@@ -17,8 +17,6 @@
 
 package org.apache.avalon.tools.model;
 
-import org.apache.tools.ant.Project;
-
 import java.io.File;
 
 /**

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Gump.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Gump.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Gump.java	Wed Jul  7 08:34:38
2004
@@ -17,8 +17,6 @@
 
 package org.apache.avalon.tools.model;
 
-import org.apache.tools.ant.BuildException;
-
 /**
  * An immutable data object holding supplimentary information required for
  * the creation fo gump project defintions.

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Home.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Home.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Home.java	Wed Jul  7 08:34:38
2004
@@ -18,12 +18,8 @@
 package org.apache.avalon.tools.model;
 
 import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.BuildListener;
-import org.apache.tools.ant.Task;
 import org.apache.tools.ant.Location;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Get;
-import org.apache.tools.ant.taskdefs.Property;
 import org.apache.tools.ant.types.DataType;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
@@ -33,11 +29,9 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.FileNotFoundException;
-import java.io.FileInputStream;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Hashtable;
-import java.util.Date;
 
 /**
  * A Home is an immutable data object that aggregates a suite of buildable 
@@ -339,14 +333,6 @@
                 final File anchor = source.getParentFile();
                 buildLocalList( anchor, elements );
             }
-            else if( "project".equals( rootElementName ) )
-            {
-                //
-                // its probably a maven project definition
-                //
-
-                buildFromMavenProject( source, root );
-            }
             else
             {
                 final String error = 
@@ -542,22 +528,6 @@
           "resource".equals( tag ) 
           || "project".equals( tag )
           || "plugin".equals( tag ) );
-    }
-
-   /**
-    * Create a magic index from a maven project file.
-    * @param root the root DOM element of the maven project file
-    */
-    private void buildFromMavenProject( File file, Element root )
-    {
-        //
-        // maven uses the notion of project inheritance which is 
-        // functionally equivalent to magic's index inclusion
-        // .. so the first step is to resolve the any project
-        // that the target project extends
-        //
-        
-        throw new UnsupportedOperationException();
     }
 
     /*

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	Wed Jul  7
08:34:38 2004
@@ -18,20 +18,14 @@
 package org.apache.avalon.tools.model;
 
 import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.BuildListener;
-import org.apache.tools.ant.Task;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Property;
 import org.apache.tools.ant.taskdefs.optional.net.SetProxy;
 import org.apache.tools.ant.types.DataType;
-import org.w3c.dom.Element;
 
 import java.io.File;
-import java.io.IOException;
 import java.io.FileNotFoundException;
 import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.Map;
 import java.util.StringTokenizer;
 
 /**
@@ -139,7 +133,7 @@
     private final File m_system;
     private final Repository m_main;
     private final Repository m_docs;
-    private final Map m_homes = new Hashtable();
+    //private final Map m_homes = new Hashtable();
 
     //-------------------------------------------------------------
     // constructor
@@ -167,12 +161,12 @@
         project.setNewProperty( CACHE_KEY, "main" );
         final String cachePath = project.getProperty( CACHE_KEY );
         final File main = Context.getFile( m_system, cachePath );
-        m_main = new Repository( project, main, hosts );
+        m_main = new Repository( main, hosts );
 
         project.setNewProperty( DOCS_KEY, "docs" );
         final String docsPath = project.getProperty( DOCS_KEY );
         final File docs = Context.getFile( m_system, docsPath );
-        m_docs = new Repository( project, docs, hosts );
+        m_docs = new Repository( docs, hosts );
 
         setupProxy( project );
 

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/MagicPath.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/MagicPath.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/MagicPath.java	Wed Jul
 7 08:34:38 2004
@@ -21,9 +21,6 @@
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.Path;
 
-import java.io.File;
-import java.io.IOException;
-
 /**
  * An ant datatype that represent a typical ant path created using 
  * transitive magic dependencies.

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Repository.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Repository.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Repository.java	Wed Jul
 7 08:34:38 2004
@@ -17,13 +17,7 @@
 
 package org.apache.avalon.tools.model;
 
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-
 import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.StringTokenizer;
 
 /**
  *
@@ -35,8 +29,7 @@
     private final File m_cache;
     private final String[] m_hosts;
 
-    public Repository( 
-      final Project project, final File cache, final String[] hosts )
+    public Repository( final File cache, final String[] hosts )
     {
         if( null == cache ) 
         {

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java	Wed Jul
 7 08:34:38 2004
@@ -36,6 +36,25 @@
  */
 public class Resource 
 {
+    /**
+     * Return the gump key for the resource taking into consideration any alias declared
under
+     * the resource definition.
+     * @param resource the resource from which to return the key
+     * @return the resource key
+     */
+    public static String getKeyForResource( Resource resource )
+    {
+        final String alias = resource.getGump().getAlias();
+        if( null != alias )
+        {
+            return alias;
+        }
+        else
+        {
+            return resource.getKey();
+        }
+    }
+
     private static final ResourceRef[] EMPTY_REFS = new ResourceRef[0];
 
     private final String m_key;
@@ -92,10 +111,6 @@
         return (ResourceRef[]) list.toArray( new ResourceRef[0] );
     }
 
-    // TODO - multiple refs for the same key can be returned here because 
-    // different projects are making different dependency assumptions - some 
-    // optimization is need to eliminate duplicates
-
     protected void getResourceRefs( 
       final Project project, final List list, final int mode, final int tag, final boolean
flag )
     {
@@ -158,7 +173,7 @@
         {
             final String error = 
               "Resource defintion " + this + " contains a unknown resource reference ["
-                 + ure.getKey() + "].";
+                 + ure.getKey() + "] (referenced by project '" + project.getName() + "'.";
             throw new BuildException( error );
         }
     }
@@ -210,18 +225,6 @@
         }
     }
 
-    private String getKeyForResource( Resource resource )
-    {
-        final String alias = resource.getGump().getAlias();
-        if( null != alias ) 
-        {
-            return alias;
-        }
-        else
-        {
-            return resource.getKey();
-        }
-    }
 
     private File get( final Project project, final File target, final String path )
     {

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/XMLDefinitionBuilder.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/XMLDefinitionBuilder.java
(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/XMLDefinitionBuilder.java
Wed Jul  7 08:34:38 2004
@@ -230,7 +230,7 @@
             final Element child = children[i];
             final String key = child.getAttribute( "key" );
             final int tag = ResourceRef.getCategory( child.getAttribute( "tag" ) );
-            final Policy policy = createPolicy( child, false, false, false );
+            final Policy policy = createPolicy( child, false, false );
             refs[i] = new ResourceRef( key, policy, tag );
         }
         return refs;
@@ -238,11 +238,11 @@
 
     private static Policy createPolicy( final Element element )
     {
-        return createPolicy( element, true, true, true );
+        return createPolicy( element, true, true );
     }
 
     private static Policy createPolicy( 
-      final Element element, final boolean defBuild, final boolean defTest, final boolean
defRuntime )
+      final Element element, final boolean defBuild, final boolean defTest )
     {
         final boolean build =
           ElementHelper.getBooleanAttribute( element, "build", defBuild );

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/AbstractDeliverableTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/AbstractDeliverableTask.java
(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/AbstractDeliverableTask.java
Wed Jul  7 08:34:38 2004
@@ -24,7 +24,6 @@
 import org.apache.avalon.tools.model.Home;
 
 import java.io.File;
-import java.io.IOException;
 
 
 /**

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BarTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BarTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BarTask.java	Wed Jul 
7 08:34:38 2004
@@ -25,7 +25,6 @@
 import org.apache.tools.ant.types.FileSet;
 
 import java.io.File;
-import java.io.IOException;
 
 /**
  * Load a goal. 

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	Wed Jul
 7 08:34:38 2004
@@ -20,19 +20,9 @@
 import org.apache.tools.ant.BuildException;
 
 import org.apache.avalon.tools.model.Definition;
-import org.apache.avalon.tools.model.ResourceRef;
-import org.apache.avalon.tools.model.Info;
-import org.apache.avalon.tools.model.Resource;
-import org.apache.avalon.tools.model.Plugin.ListenerDef;
-import org.apache.avalon.tools.model.Plugin.TaskDef;
-import org.apache.avalon.tools.model.Plugin;
-import org.apache.avalon.tools.model.Policy;
 
 import java.io.IOException;
-import java.io.OutputStream;
-import java.io.FileOutputStream;
 import java.io.File;
-import java.io.OutputStreamWriter;
 import java.io.Writer;
 import java.util.List;
 import java.util.ArrayList;
@@ -428,7 +418,7 @@
 
     private File getEmbeddedRoot( String target )
     {
-        if( MAIN.equals( m_target ) )
+        if( MAIN.equals( target ) )
         {
             return getContext().getClassesDirectory();
         }
@@ -495,8 +485,6 @@
     protected void writeContainer( final String pad, final Writer writer, final Definition
def )
         throws IOException
     {
-        final Info info = def.getInfo();
-
         writer.write( "\n\n" + pad + "<container name=\"" + getName( def ) + "\">"
);
 
         if( null != m_service )

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/DeclareTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/DeclareTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/DeclareTask.java	Wed Jul
 7 08:34:38 2004
@@ -33,8 +33,6 @@
 import java.io.File;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
-import java.util.List;
-import java.util.ArrayList;
 
 /**
  * Create meta-data for a plugin.

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/FilterTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/FilterTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/FilterTask.java	Wed Jul
 7 08:34:38 2004
@@ -20,7 +20,6 @@
 import java.io.File;
 
 import org.apache.avalon.tools.model.Definition;
-import org.apache.avalon.tools.model.Policy;
 import org.apache.avalon.tools.model.Resource;
 import org.apache.avalon.tools.model.ResourceRef;
 import org.apache.avalon.tools.model.MagicPath;
@@ -182,6 +181,7 @@
         String root = cache.toString();
         MagicPath path = new MagicPath( getProject() );
         path.setMode( "RUNTIME" );
+        path.setKey( def.getKey() );
         String sequence = path.toString();
         String[] translation = Path.translatePath( getProject(), sequence );
 

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/GumpTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/GumpTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/GumpTask.java	Wed Jul
 7 08:34:38 2004
@@ -465,7 +465,7 @@
                       "\n      <!-- external references -->" );
                 }
                 String key = resource.getKey();
-                String alias = getKeyForResource( resource );
+                String alias = Resource.getKeyForResource( resource );
                 writer.write( 
                    "\n      <depend property=\"gump.resource." + key 
                    + "\" project=\"" + alias + "\"" );

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/HomeTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/HomeTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/HomeTask.java	Wed Jul
 7 08:34:38 2004
@@ -17,16 +17,13 @@
 
 package org.apache.avalon.tools.tasks;
 
-import org.apache.avalon.tools.model.Context;
 import org.apache.avalon.tools.model.Definition;
 import org.apache.avalon.tools.model.Info;
 import org.apache.avalon.tools.model.Home;
 import org.apache.avalon.tools.model.Magic;
-import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 
 /**
  * Load a goal. 

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	Wed
Jul  7 08:34:38 2004
@@ -67,9 +67,7 @@
     private static final String ERROR_KEY = "project.test.error";
     private static final String FAILURE_KEY = "project.test.failure";
 
-    private File m_test;
-
-    public void init() throws BuildException 
+    public void init() throws BuildException
     {
         if( !isInitialized() )
         {
@@ -81,8 +79,6 @@
             project.setNewProperty( TEST_ENV_KEY, "" + TEST_ENV_VALUE );
             project.setNewProperty( HALT_ON_ERROR_KEY, "" + HALT_ON_ERROR_VALUE );
             project.setNewProperty( HALT_ON_FAILURE_KEY, "" + HALT_ON_FAILURE_VALUE );
-
-            m_test = getContext().getTestDirectory();
         }
     }
 

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JarTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JarTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JarTask.java	Wed Jul 
7 08:34:38 2004
@@ -24,7 +24,6 @@
 import org.apache.tools.ant.taskdefs.ManifestException;
 
 import java.io.File;
-import java.io.IOException;
 
 /**
  * Load a goal. 
@@ -108,11 +107,13 @@
             if( null != def.getInfo().getVersion() )
             {
 
-                // TODO: validate that the version is a dewy version
+                // TODO: add the declaration of the spec version
+                // to the Info object and validate that it is a
+                // a dewey decimal
 
-                addAttribute( 
+                addAttribute(
                   main, "Specification-Version", 
-                  def.getInfo().getVersion() );
+                  "0.0.0" );
             }
             else
             {
@@ -125,10 +126,9 @@
               main, "Implementation-Vendor-Id", 
               "org.apache.avalon" );
 
-            // TODO: get a real implementation version id
-            
             addAttribute( 
-              main, "Implementation-Version", "UNKNOWN" ); 
+              main, "Implementation-Version",
+              def.getInfo().getVersion() );
 
             final String classpath = getProject().getProperty( JAR_CLASSPATH_KEY );
             if( null != classpath )

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ReactorTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ReactorTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ReactorTask.java	Wed Jul
 7 08:34:38 2004
@@ -26,18 +26,11 @@
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Ant;
 import org.apache.tools.ant.taskdefs.Sequential;
-import org.apache.tools.ant.types.DirSet;
-import org.apache.tools.ant.types.FileList;
-import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.types.Path;
 
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Properties;
 
 
 /**
@@ -271,11 +264,6 @@
         {
             throw new BuildException( ioe );
         }
-    }
-
-    private Context getContext()
-    {
-        return m_context;
     }
 
     private Home getHome()

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ReplicateTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ReplicateTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ReplicateTask.java	Wed
Jul  7 08:34:38 2004
@@ -18,30 +18,17 @@
 package org.apache.avalon.tools.tasks;
 
 import org.apache.avalon.tools.model.Context;
-import org.apache.avalon.tools.model.Definition;
-import org.apache.avalon.tools.model.ResourceRef;
 import org.apache.avalon.tools.model.Home;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Task;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Ant;
-import org.apache.tools.ant.taskdefs.Sequential;
-import org.apache.tools.ant.types.DirSet;
-import org.apache.tools.ant.types.FileList;
 import org.apache.tools.ant.types.FileSet;
 import org.apache.tools.ant.types.Path;
 import org.apache.tools.ant.taskdefs.Copy;
-import org.apache.tools.ant.types.FileSet;
 import org.apache.tools.ant.taskdefs.Mkdir;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
 
 
 /**
@@ -52,9 +39,6 @@
  */
 public class ReplicateTask extends Task
 {
-    private static final String BANNER = 
-      "------------------------------------------------------------------------";
-
     private File m_todir;
     private String m_id;
     private Context m_context;
@@ -176,11 +160,6 @@
         mkdir.setDir( dir );
         mkdir.init();
         mkdir.execute();
-    }
-
-    private Context getContext()
-    {
-        return m_context;
     }
 
     private Home getHome()

Added: avalon/trunk/tools/magic/src/test/org/apache/avalon/tools/model/test/ContextTestCase.java
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/magic/src/test/org/apache/avalon/tools/model/test/ContextTestCase.java
Wed Jul  7 08:34:38 2004
@@ -0,0 +1,259 @@
+/* 
+ * Copyright 2004 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.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.tools.model.test;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.avalon.tools.model.Context;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.BuildException;
+
+
+/**
+ * ContextTestCase.
+ *
+ * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
+ * @version CVS $ Revision: 1.1 $
+ */
+public class ContextTestCase extends TestCase
+{
+    private Context m_context;
+
+    public void setUp()
+    {
+        Project project = new Project();
+        project.setName( "test" );
+        m_context = Context.getContext( project );
+    }
+
+    public ContextTestCase ( String name )
+    {
+        super( name );
+    }
+
+    public void testCanonicalFile() throws Exception
+    {
+        File abc = new File( "abc" );
+        File xyz = new File( abc, "xyz" );
+        File canonical = Context.getFile( new File( "abc" ), "xyz" );
+        String path = canonical.toString();
+        String alt = xyz.getCanonicalPath();
+        assertEquals( path, alt );
+    }
+
+    public void testCanonicalFileWithCreation() throws Exception
+    {
+        File test = new File( System.getProperty( "project.dir" ));
+        File file = Context.getFile( test, "junk/abc", true );
+        assertTrue( file.getParentFile().exists() );
+    }
+
+    public void testSignature() throws Exception
+    {
+        String signature = Context.getSignature();
+        assertEquals( 15, signature.length() );
+        assertEquals( 8, signature.indexOf( "." ) );
+    }
+
+    public void testDefaultKey() throws Exception
+    {
+        Project project = new Project();
+        project.setName( "test" );
+        Context context = Context.getContext( project );
+        String key = context.getKey();
+        assertTrue( "test".equals( key ) );
+    }
+
+    public void testKeyFromProperty() throws Exception
+    {
+        Project project = new Project();
+        project.setProperty( "project.key", "xyz" );
+        Context context = Context.getContext( project );
+        String key = context.getKey();
+        assertTrue( "xyz".equals( key ) );
+    }
+
+    public void testSrcDirectory() throws Exception
+    {
+        Project project = new Project();
+        project.setName( "test" );
+        Context context = Context.getContext( project );
+        File test = context.getSrcDirectory();
+        File dir = new File( System.getProperty( "user.dir" ) );
+        File src = new File( dir, "src" );
+        assertEquals( src, test );
+    }
+
+    public void testEtcDirectory() throws Exception
+    {
+        Project project = new Project();
+        project.setName( "test" );
+        Context context = Context.getContext( project );
+        File test = context.getEtcDirectory();
+        File dir = new File( System.getProperty( "user.dir" ) );
+        File etc = new File( dir, "etc" );
+        assertEquals( etc, test );
+    }
+
+    public void testBuildDirectory() throws Exception
+    {
+        Project project = new Project();
+        project.setName( "test" );
+        Context context = Context.getContext( project );
+        File test = context.getBuildDirectory();
+        File dir = new File( System.getProperty( "user.dir" ) );
+        File target = new File( dir, "target" );
+        File build = new File( target, "build" );
+        assertEquals( build, test );
+    }
+
+    public void testTargetDirectory() throws Exception
+    {
+        Project project = new Project();
+        project.setName( "test" );
+        Context context = Context.getContext( project );
+        File test = context.getTargetDirectory();
+        File dir = new File( System.getProperty( "user.dir" ) );
+        File target = new File( dir, "target" );
+        assertEquals( target, test );
+    }
+
+    public void testDeliverablesDirectory() throws Exception
+    {
+        Project project = new Project();
+        project.setName( "test" );
+        Context context = Context.getContext( project );
+        File test = context.getDeliverablesDirectory();
+        File dir = new File( System.getProperty( "user.dir" ) );
+        File target = new File( dir, "target" );
+        File deliverables = new File( target, "deliverables" );
+        assertEquals( deliverables, test );
+    }
+
+    public void testClassesDirectory() throws Exception
+    {
+        Project project = new Project();
+        project.setName( "test" );
+        Context context = Context.getContext( project );
+        File test = context.getClassesDirectory();
+        File dir = new File( System.getProperty( "user.dir" ) );
+        File target = new File( dir, "target" );
+        File classes = new File( target, "classes" );
+        assertEquals( classes, test );
+    }
+
+    public void testTestClassesDirectory() throws Exception
+    {
+        Project project = new Project();
+        project.setName( "test" );
+        Context context = Context.getContext( project );
+        File test = context.getTestClassesDirectory();
+        File dir = new File( System.getProperty( "user.dir" ) );
+        File target = new File( dir, "target" );
+        File classes = new File( target, "test-classes" );
+        assertEquals( classes, test );
+    }
+
+    public void testTestReportsDirectory() throws Exception
+    {
+        Project project = new Project();
+        project.setName( "test" );
+        Context context = Context.getContext( project );
+        File test = context.getTestReportsDirectory();
+        File dir = new File( System.getProperty( "user.dir" ) );
+        File target = new File( dir, "target" );
+        File reports = new File( target, "test-reports" );
+        assertEquals( reports, test );
+    }
+
+    public void testTempDirectory() throws Exception
+    {
+        Project project = new Project();
+        project.setName( "test" );
+        Context context = Context.getContext( project );
+        File test = context.getTempDirectory();
+        File dir = new File( System.getProperty( "user.dir" ) );
+        File target = new File( dir, "target" );
+        File temp = new File( target, "temp" );
+        assertEquals( temp, test );
+    }
+
+    public void testTestDirectory() throws Exception
+    {
+        Project project = new Project();
+        project.setName( "test" );
+        Context context = Context.getContext( project );
+        File test = context.getTestDirectory();
+        File dir = new File( System.getProperty( "user.dir" ) );
+        File target = new File( dir, "target" );
+        File testDir = new File( target, "test" );
+        assertEquals( testDir, test );
+    }
+
+    public void testDocsDirectory() throws Exception
+    {
+        Project project = new Project();
+        project.setName( "test" );
+        Context context = Context.getContext( project );
+        File test = context.getDocsDirectory();
+        File dir = new File( System.getProperty( "user.dir" ) );
+        File target = new File( dir, "target" );
+        File docs = new File( target, "docs" );
+        assertEquals( docs, test );
+    }
+
+    public void testPathReservation() throws Exception
+    {
+        Project project = new Project();
+        project.setName( "test" );
+        Context context = Context.getContext( project );
+        File dir = context.setBuildPath( "key", "gizmo" );
+        File reserved = context.getBuildPath( "key" );
+        assertEquals( dir, reserved );
+    }
+
+    public void testImplicitPathReservation() throws Exception
+    {
+        Project project = new Project();
+        project.setName( "test" );
+        Context context = Context.getContext( project );
+        File dir = context.setBuildPath( "gizmo" );
+        File reserved = context.getBuildPath( "gizmo" );
+        assertEquals( dir, reserved );
+    }
+
+    public void testDuplicatePathReservation() throws Exception
+    {
+        Project project = new Project();
+        project.setName( "test" );
+        Context context = Context.getContext( project );
+        File dir = context.setBuildPath( "key", "gizmo" );
+        try
+        {
+            context.setBuildPath( "key", "widget" );
+            fail( "build path reservation failed" );
+        }
+        catch( BuildException be )
+        {
+            // expected
+        }
+    }
+}

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


Mime
View raw message