You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2004/06/30 09:07:06 UTC

svn commit: rev 22310 - in avalon/trunk/runtime: . merlin/unit merlin/unit/etc/main merlin/unit/etc/test merlin/unit/src/java/org/apache/avalon/merlin/unit merlin/unit/src/test/org/apache/avalon/merlin/unit/test

Author: mcconnell
Date: Wed Jun 30 00:07:04 2004
New Revision: 22310

Added:
   avalon/trunk/runtime/merlin/unit/src/test/org/apache/avalon/merlin/unit/test/MerlinTestCase.java
Removed:
   avalon/trunk/runtime/merlin/unit/merlin.properties
   avalon/trunk/runtime/merlin/unit/src/java/org/apache/avalon/merlin/unit/MerlinTestSuite.java
   avalon/trunk/runtime/merlin/unit/src/test/org/apache/avalon/merlin/unit/test/DemoTestCase.java
Modified:
   avalon/trunk/runtime/index.xml
   avalon/trunk/runtime/merlin/unit/   (props changed)
   avalon/trunk/runtime/merlin/unit/build.properties
   avalon/trunk/runtime/merlin/unit/build.xml
   avalon/trunk/runtime/merlin/unit/etc/main/merlin.properties
   avalon/trunk/runtime/merlin/unit/etc/test/merlin.properties
   avalon/trunk/runtime/merlin/unit/src/java/org/apache/avalon/merlin/unit/AbstractMerlinTestCase.java
Log:
put merlin unit into an operational state

Modified: avalon/trunk/runtime/index.xml
==============================================================================
--- avalon/trunk/runtime/index.xml	(original)
+++ avalon/trunk/runtime/index.xml	Wed Jun 30 00:07:04 2004
@@ -784,6 +784,19 @@
     </dependencies>
   </project>
 
+  <project basedir="merlin/unit">
+    <info>
+      <group>avalon/merlin</group>
+      <name>avalon-merlin-unit</name>
+      <version>3.3.1</version>
+      <status>SNAPSHOT</status>
+    </info>
+    <dependencies>
+      <include key="avalon-repository-main"/>
+      <include key="avalon-merlin-impl" build="false"/>
+    </dependencies>
+  </project>
+
   <project basedir="main" key="avalon-runtime">
     <info>
       <group>avalon</group>
@@ -815,19 +828,5 @@
       <include key="jms"/>
     </dependencies>
   </project>
-
-  <!--
-  <project basedir="merlin/unit">
-    <info>
-      <group>avalon/merlin</group>
-      <name>avalon-merlin-unit</name>
-      <version>3.3.0</version>
-    </info>
-    <dependencies>
-      <include key="avalon-repository-main"/>
-      <include key="avalon-merlin-impl" build="false" test="false"/>
-    </dependencies>
-  </project>
-  -->
 
 </index>

Modified: avalon/trunk/runtime/merlin/unit/build.properties
==============================================================================
--- avalon/trunk/runtime/merlin/unit/build.properties	(original)
+++ avalon/trunk/runtime/merlin/unit/build.properties	Wed Jun 30 00:07:04 2004
@@ -1,4 +1,5 @@
 
 project.name = avalon-merlin-unit
+project.system = ../../../central/system
 project.src.main = java
-project.home = ../../../central/system
+project.home = ../..

Modified: avalon/trunk/runtime/merlin/unit/build.xml
==============================================================================
--- avalon/trunk/runtime/merlin/unit/build.xml	(original)
+++ avalon/trunk/runtime/merlin/unit/build.xml	Wed Jun 30 00:07:04 2004
@@ -4,7 +4,7 @@
     xmlns:x="antlib:org.apache.avalon.tools">
 
   <property file="build.properties"/>
-  <import file="${project.home}/build/standard.xml"/>
+  <import file="${project.system}/build/standard.xml"/>
 
   <target name="init" depends="standard.init">
     <x:filter key="avalon-logging-logkit-impl" feature="uri" 

Modified: avalon/trunk/runtime/merlin/unit/etc/main/merlin.properties
==============================================================================
--- avalon/trunk/runtime/merlin/unit/etc/main/merlin.properties	(original)
+++ avalon/trunk/runtime/merlin/unit/etc/main/merlin.properties	Wed Jun 30 00:07:04 2004
@@ -4,11 +4,6 @@
 #----------------------------------------------------------------------
 
 #
-# The default avalon repository root directory. 
-#
-avalon.home = ${user.home}/.avalon
-
-#
 # merlin system implementation
 merlin.implementation = @MERLIN_IMPLEMENTATION@
 

Modified: avalon/trunk/runtime/merlin/unit/etc/test/merlin.properties
==============================================================================
--- avalon/trunk/runtime/merlin/unit/etc/test/merlin.properties	(original)
+++ avalon/trunk/runtime/merlin/unit/etc/test/merlin.properties	Wed Jun 30 00:07:04 2004
@@ -6,7 +6,7 @@
 #
 # The default avalon repository root directory. 
 #
-avalon.home = ${user.home}/.avalon
+#avalon.home = ${user.home}/.avalon
 
 #
 # merlin system implementation
@@ -30,9 +30,9 @@
 
 avalon.repository.cache = @CACHE-DIRECTORY@
 
-merlin.info = true
-merlin.debug = true
-merlin.audit = true
+merlin.info = false
+merlin.debug = false
+merlin.audit = false
 merlin.deployment = hello.block
 merlin.override = override.xml
 merlin.deployment.timeout = 0

Modified: avalon/trunk/runtime/merlin/unit/src/java/org/apache/avalon/merlin/unit/AbstractMerlinTestCase.java
==============================================================================
--- avalon/trunk/runtime/merlin/unit/src/java/org/apache/avalon/merlin/unit/AbstractMerlinTestCase.java	(original)
+++ avalon/trunk/runtime/merlin/unit/src/java/org/apache/avalon/merlin/unit/AbstractMerlinTestCase.java	Wed Jun 30 00:07:04 2004
@@ -54,6 +54,27 @@
 
     private static final String DEPLOYMENT_MODEL_CLASSNAME = 
       "org.apache.avalon.composition.model.DeploymentModel";
+
+    private static File getWorkDir()
+    {
+        String path = System.getProperty( "project.dir" );
+        if( null != path )
+        {
+            return new File( path );
+        }
+        else
+        {
+            path = System.getProperty( "basedir" );
+            if( null != path )
+            {
+                return new File( path );
+            }
+            else
+            {
+                return new File( System.getProperty( "user.dir" ) );
+            }
+        }
+    }
 
     //----------------------------------------------------------
     // immutable state
@@ -72,7 +93,15 @@
 
     //----------------------------------------------------------
     // constructor
-    //----------------------------------------------------------
+    //----------------------------------------------------------
+
+    /**
+     * Constructor for MerlinEmbeddedTest.
+     */
+    public AbstractMerlinTestCase()
+    {
+        super();
+    }
 
     /**
      * Constructor for MerlinEmbeddedTest.
@@ -88,33 +117,29 @@
         ClassLoader classloader = AbstractMerlinTestCase.class.getClassLoader();
 
         try
-        {
-            File repository = new File( getMavenHome(), "repository" );
-            File basedir = getBaseDirectory();
-
-            Artifact artifact = 
-              DefaultBuilder.createImplementationArtifact( 
-                classloader, 
-                getMerlinHome(),
-                basedir, 
-                MERLIN_PROPERTIES, 
-                IMPLEMENTATION_KEY );
-
-            InitialContextFactory icFactory = 
-              new DefaultInitialContextFactory( "merlin", basedir );
-            icFactory.setCacheDirectory( repository );
-            InitialContext context = icFactory.createInitialContext();
-
-            Builder builder = new DefaultBuilder( context, artifact );
-            m_classloader = builder.getClassLoader();
-            Factory factory = builder.getFactory();
-            Map criteria = factory.createDefaultCriteria();
+        {
+            File basedir = getBaseDirectory();
+            File home = getHomeDirectory();
+
+            Artifact artifact = DefaultBuilder.createImplementationArtifact( 
+              classloader, home, basedir, 
+              MERLIN_PROPERTIES, IMPLEMENTATION_KEY );
+
+            InitialContextFactory icFactory = 
+              new DefaultInitialContextFactory( "merlin", basedir );
+            icFactory.setCacheDirectory( getCacheDirectory() );
+
+            InitialContext context = icFactory.createInitialContext();
+
+            Builder builder = new DefaultBuilder( context, artifact );
+            m_classloader = builder.getClassLoader();
+            Factory factory = builder.getFactory();
+            Map criteria = factory.createDefaultCriteria();
 
             //
             // set the defaults
             //
 
-            criteria.put( "merlin.repository", repository );
             criteria.put( "merlin.context", "target" );
             criteria.put( "merlin.server", "true" );
             criteria.put( "merlin.code.security.enabled", "false" );
@@ -238,34 +263,50 @@
     // utilities
     //----------------------------------------------------------------------
 
-    private String buildDefaultOverridePath()
-    {
-        File base = getBaseDirectory();
-        File config = new File( base, "conf/config.xml" );
-        if( config.exists() ) return "conf/config.xml";
-        return null;
-    }
+    private String buildDefaultOverridePath()
+    {
+        File base = getBaseDirectory();
+        File config = new File( base, "config.xml" );
+        if( config.exists() ) return "config.xml";
+        return null;
+    }
 
     private String buildDefaultTestPath()
     {
         File base = getBaseDirectory();
         File classes = new File( base, "target/classes/BLOCK-INF/block.xml" );
-        File tests = new File( base, "target/test-classes/BLOCK-INF/block.xml" );
-        if( classes.exists() && tests.exists() )
-        {
-            return "target/classes,target/test-classes";
-        }
-        else if( classes.exists() )
+        if( classes.exists() )
         {
             return "target/classes";
         }
-        else if( tests.exists() )
-        {
-            return "target/test-classes";
-        }
         return null;
     }
-
+
+    private File getBaseDirectory()
+    {
+        return getWorkDir();
+    }
+
+    private File getHomeDirectory()
+    {
+        return getCacheDirectory().getParentFile();
+    }
+
+    private File getCacheDirectory()
+    {
+        String cache = System.getProperty( "project.repository.cache.path" );
+        if( null != cache )
+        {
+            return new File( cache );
+        }
+        else
+        {
+            throw new IllegalStateException( "don't know what to do yet" );
+        }
+    }
+
+
+    /*
     private static File getMavenHome()
     {
         try
@@ -291,31 +332,25 @@
               ExceptionHelper.packException( error, e, true );
             throw new RuntimeException( message );
         }
-    }
-
-    private File getBaseDirectory()
-    {
-        final String base = System.getProperty( "basedir" );
-        if( null != base )
-        {
-            return new File( base );
-        }
-        return new File( System.getProperty( "user.dir" ) );
-    }
+    }
+    */
 
    /**
     * Return the merlin home directory.
     * @return the merlin install directory
-    */
+    */
+    /*
     private static File getMerlinHome()
     {
         return new File( getMerlinHomePath() );
-    }
+    }
+    */
 
    /**
     * Return the merlin home directory path.
     * @return the merlin install directory path
-    */
+    */
+    /*
     private static String getMerlinHomePath()
     {
         try
@@ -336,6 +371,6 @@
               ExceptionHelper.packException( error, e, true );
             throw new RuntimeException( message );
         }
-    }
-
+    }
+    */
 }

Added: avalon/trunk/runtime/merlin/unit/src/test/org/apache/avalon/merlin/unit/test/MerlinTestCase.java
==============================================================================
--- (empty file)
+++ avalon/trunk/runtime/merlin/unit/src/test/org/apache/avalon/merlin/unit/test/MerlinTestCase.java	Wed Jun 30 00:07:04 2004
@@ -0,0 +1,56 @@
+/* 
+ * 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.merlin.unit.test;
+
+import org.apache.avalon.merlin.unit.AbstractMerlinTestCase;
+
+/**
+ * Test case that usages the repository builder to deploy the 
+ * Merlin default application factory.
+ * 
+ * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
+ * @version $Revision: 1.5 $
+ */
+public class MerlinTestCase extends AbstractMerlinTestCase
+{
+    //----------------------------------------------------------
+    // constructor
+    //----------------------------------------------------------
+
+    /**
+     * Constructor for MerlinTestCase.
+     * @param name the name of the testcase
+     */
+    public MerlinTestCase( String name )
+    {
+        super( name );
+    }
+
+    //----------------------------------------------------------
+    // testcase
+    //----------------------------------------------------------
+
+    public void testHelloAquisition() throws Exception
+    {
+        Object hello = super.resolve( "/tutorial/hello" );
+        assertNotNull( "hello", hello );
+
+        Object hello2 = super.resolve( "/tutorial/hello" );
+        assertNotNull( "hello-2", hello2 );
+    }
+}

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