r1852 - in trunk/main/transit/core/src/test/net/dpml/transit: . test

mcconnell at BerliOS mcconnell at mail.berlios.de
Thu Feb 8 20:24:10 EST 2007


Author: mcconnell
Date: 2007-02-09 02:24:09 +0100 (Fri, 09 Feb 2007)
New Revision: 1852

Removed:
   trunk/main/transit/core/src/test/net/dpml/transit/test/ConstructTestCase.java
   trunk/main/transit/core/src/test/net/dpml/transit/test/DisposalTestCase.java
   trunk/main/transit/core/src/test/net/dpml/transit/test/MimeHandlerTestCase.java
Modified:
   trunk/main/transit/core/src/test/net/dpml/transit/PropertyResolverTestCase.java
   trunk/main/transit/core/src/test/net/dpml/transit/test/ArtifactTestCase.java
   trunk/main/transit/core/src/test/net/dpml/transit/test/LinkTestCase.java
   trunk/main/transit/core/src/test/net/dpml/transit/test/OfflineTestCase.java
   trunk/main/transit/core/src/test/net/dpml/transit/test/OnlineTestCase.java
Log:
SDK 2.X staged commit.

Modified: trunk/main/transit/core/src/test/net/dpml/transit/PropertyResolverTestCase.java
===================================================================
--- trunk/main/transit/core/src/test/net/dpml/transit/PropertyResolverTestCase.java	2007-02-09 01:22:24 UTC (rev 1851)
+++ trunk/main/transit/core/src/test/net/dpml/transit/PropertyResolverTestCase.java	2007-02-09 01:24:09 UTC (rev 1852)
@@ -23,7 +23,7 @@
 
 import java.util.Properties;
 
-import net.dpml.util.PropertyResolver;
+import dpml.util.PropertyResolver;
 
 /**
  * Testcases for the PropertyResolver
@@ -50,15 +50,6 @@
     }
 
    /**
-    * Testcase constructor.
-    * @param name the testcase name
-    */
-    public PropertyResolverTestCase( String name )
-    {
-        super( name );
-    }
-
-   /**
     * Test simple property resolution.
     * @exception Exception if an error occurs
     */
@@ -122,11 +113,47 @@
     * Test escaped property resolution.
     * @exception Exception if an error occurs
     */
+    public void testNonDeclaredSymbol() throws Exception
+    {
+        String src = "${batman}";
+        String result = PropertyResolver.resolve( m_properties, src );
+        String expected = "${batman}";
+        assertEquals( expected, result );
+    }
+
+   /**
+    * Test escaped property resolution.
+    * @exception Exception if an error occurs
+    */
     public void testEscapedSymbol() throws Exception
     {
-        String src = "$${alpha}";
+        String src = "$${abc}";
         String result = PropertyResolver.resolve( m_properties, src );
-        String expected = "${alpha}";
+        String expected = "${abc}";
         assertEquals( expected, result );
     }
+    
+   /**
+    * Test escaped property resolution with a system property symbol.
+    * @exception Exception if an error occurs
+    */
+    public void testSystemProperty() throws Exception
+    {
+        String src = "${user.dir}";
+        String result = PropertyResolver.resolve( System.getProperties(), src );
+        String expected = System.getProperty( "user.dir" );
+        assertEquals( expected, result );
+    }
+
+   /**
+    * Test escaped property resolution with a system property symbol.
+    * @exception Exception if an error occurs
+    */
+    public void testEscapedSystemProperty() throws Exception
+    {
+        String src = "$${user.dir}";
+        String result = PropertyResolver.resolve( System.getProperties(), src );
+        String expected = "${user.dir}";
+        assertEquals( expected, result );
+    }
 }

Modified: trunk/main/transit/core/src/test/net/dpml/transit/test/ArtifactTestCase.java
===================================================================
--- trunk/main/transit/core/src/test/net/dpml/transit/test/ArtifactTestCase.java	2007-02-09 01:22:24 UTC (rev 1851)
+++ trunk/main/transit/core/src/test/net/dpml/transit/test/ArtifactTestCase.java	2007-02-09 01:24:09 UTC (rev 1852)
@@ -18,9 +18,11 @@
 
 package net.dpml.transit.test;
 
+import java.net.URI;
+
 import junit.framework.TestCase;
 
-import net.dpml.transit.ClassicLayout;
+import net.dpml.transit.layout.ClassicLayout;
 import net.dpml.transit.Layout;
 import net.dpml.transit.Artifact;
 
@@ -33,15 +35,6 @@
 public class ArtifactTestCase extends TestCase
 {
    /**
-    * Constructor for ArtifactReferenceTest.
-    * @param name the test name
-    */
-    public ArtifactTestCase( String name )
-    {
-        super( name );
-    }
-
-   /**
     * Test invalid null path argument.
     * @exception Exception if an unexpected error occurs
     */
@@ -50,9 +43,9 @@
         try
         {
             Artifact artifact = Artifact.createArtifact( (String) null );
-            fail( "No IllegalArgumentException thrown for null uri spec: " + artifact );
+            fail( "No NullPointerException thrown for null uri spec: " + artifact );
         }
-        catch( IllegalArgumentException e )
+        catch( NullPointerException e )
         {
             assertTrue( true );
         }

Deleted: trunk/main/transit/core/src/test/net/dpml/transit/test/ConstructTestCase.java
===================================================================
--- trunk/main/transit/core/src/test/net/dpml/transit/test/ConstructTestCase.java	2007-02-09 01:22:24 UTC (rev 1851)
+++ trunk/main/transit/core/src/test/net/dpml/transit/test/ConstructTestCase.java	2007-02-09 01:24:09 UTC (rev 1852)
@@ -1,376 +0,0 @@
-/*
- * Copyright 2004-2006 Stephen J. McConnell.
- *
- * 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 net.dpml.transit.test;
-
-import java.awt.Color;
-import java.io.File;
-import java.util.Date;
-import java.util.Map;
-import java.util.Hashtable;
-import java.util.Arrays;
-
-import net.dpml.lang.Value;
-import net.dpml.lang.Construct;
-
-/**
- * Construct testcase.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class ConstructTestCase extends AbstractEncodingTestCase
-{
-   /**
-    * Test creation of a simple construct.
-    * @exception Exception if an unexpected error occurs.
-    */
-    public void testSimpleConstruct() throws Exception
-    {
-        Construct construct = new Construct( "fred" );
-        Object value = construct.resolve();
-        if( null == value )
-        {
-            throw new NullPointerException( "value" );
-        }
-        assertEquals( "isa-string", value.getClass(), String.class );
-        assertEquals( "simple construct value", value, "fred" );
-    }
-
-   /**
-    * Test creation of a construct using a null value.
-    * @exception Exception if an unexpected error occurs.
-    */
-    public void testNullArgConstruct() throws Exception
-    {
-        Construct construct = new Construct( Date.class.getName(), (String) null );
-        Object value = construct.resolve();
-        assertEquals( "isa-data", value.getClass(), Date.class );
-    }
-
-   /**
-    * Test creation of a construct using a primitive type.
-    * @exception Exception if an unexpected error occurs.
-    */
-    public void testPrimitiveConstruct() throws Exception
-    {
-        Construct construct = new Construct( "int", "10" );
-        ClassLoader cl = ConstructTestCase.class.getClassLoader();
-        Object value = construct.resolve();
-        assertEquals( "isa-Integer", Integer.class, value.getClass() );
-    }
-
-   /**
-    * Test creation of a construct using a single typed argument.
-    * @exception Exception if an unexpected error occurs.
-    */
-    public void testSingleArgConstruct() throws Exception
-    {
-        Construct construct = new Construct( File.class.getName(), "abc" );
-        Object value = construct.resolve();
-        assertEquals( "isa-file", value.getClass(), File.class );
-        assertEquals( "file", value, new File( "abc" ) );
-    }
-
-   /**
-    * Test creation of a construct using a multiple primitate arguments.
-    * @exception Exception if an unexpected error occurs.
-    */
-    public void testPrimitiveMultiArgConstruct() throws Exception
-    {
-        Value a = new Construct( "int", "100" );
-        Value b = new Construct( "boolean", "true" );
-        Value c = new Construct( Context2.class.getName(), new Value[]{a, b} );
-        Object value = c.resolve();
-        assertEquals( "isa-context", value.getClass(), Context2.class );
-        Context2 context = (Context2) value;
-        if( !( context.getNumber() == 100 ) )
-        {
-            System.out.println( "# number: " + context.getNumber() );
-            fail( "context2 number return value is not 100" );
-        }
-        if( !context.getLogical() )
-        {
-            System.out.println( "# logical: " + context.getLogical() );
-            fail( "context2 logical return value is not 'true'" );
-        }
-    }
-    
-   /**
-    * Test creation of a construct using a static method operator.
-    * @exception Exception if an unexpected error occurs.
-    */
-    public void testStaticMethod() throws Exception
-    {
-        Value v = new Construct( Context2.class.getName(), "create", new Value[0] );
-        Object value = v.resolve();
-        assertEquals( "isa-context", value.getClass(), Context2.class );
-        Context2 context = (Context2) value;
-        if( !( context.getNumber() == 100 ) )
-        {
-            System.out.println( "# number: " + context.getNumber() );
-            fail( "context2 number return value is not 100" );
-        }
-        if( !context.getLogical() )
-        {
-            System.out.println( "# logical: " + context.getLogical() );
-            fail( "context2 logical return value is not 'true'" );
-        }
-    }
-    
-   /**
-    * Test creation of a construct using a static field operator.
-    * @exception Exception if an unexpected error occurs.
-    */
-    public void testStaticField() throws Exception
-    {
-        Value v = new Construct( Color.class.getName(), "RED", (String) null );
-        Object value = v.resolve();
-        assertEquals( "color", Color.RED, value );
-    }
-
-   /**
-    * Test creation of a composite construct using a static field operator.
-    * @exception Exception if an unexpected error occurs.
-    */
-    public void testStaticFieldInComposite() throws Exception
-    {
-        Value v = new Construct( Color.class.getName(), "RED", new Value[0] );
-        Object value = v.resolve();
-        assertEquals( "color", Color.RED, value );
-    }
-
-   /**
-    * Test creation of a construct using a symbolic reference.
-    * @exception Exception if an unexpected error occurs.
-    */
-    public void testSymbolicReference() throws Exception
-    {
-        Map map = new Hashtable();
-        File file = new File( "somewhere" );
-        map.put( "test", file );
-        Value construct = new Construct( "${test}" );
-        Object value = construct.resolve( map );
-        assertEquals( "value", file, value );
-    }
-    
-   /**
-    * Test creation of a construct using a typed symbolic reference.
-    * @exception Exception if an unexpected error occurs.
-    */
-    public void testTypedSymbolicReference() throws Exception
-    {
-        Map map = new Hashtable();
-        map.put( "number", new Integer( 100 ) );
-        map.put( "logical", new Boolean( true ) );
-        
-        Value number = new Construct( "int", "${number}" );
-        Value logical = new Construct( "boolean", "${logical}" );
-        Value construct = new Construct( Context2.class.getName(), new Value[]{number, logical} );
-        Object value = construct.resolve( map );
-        
-        assertEquals( "isa-context", value.getClass(), Context2.class );
-        Context2 context = (Context2) value;
-        if( !( context.getNumber() == 100 ) )
-        {
-            System.out.println( "# number: " + context.getNumber() );
-            fail( "context2 number return value is not 100" );
-        }
-        if( !context.getLogical() )
-        {
-            System.out.println( "# logical: " + context.getLogical() );
-            fail( "context2 logical return value is not true" );
-        }
-    }
-    
-   /**
-    * Test array return type.
-    * @exception Exception if an unexpected error occurs.
-    */
-    public void testSimpleArray() throws Exception
-    {
-        String[] args = new String[]{"aaa", "bbb"};
-        Value s1 = new Construct( "aaa" );
-        Value s2 = new Construct( "bbb" );
-        Value construct = new Construct( args.getClass().getName(), new Value[]{s1, s2} );
-        String[] result = (String[]) construct.resolve();
-        boolean equal = Arrays.equals( args, result );
-        assertTrue( "simple-array", equal );
-    }
-    
-   /**
-    * Test array with zero entries.
-    * @exception Exception if an unexpected error occurs.
-    */
-    public void testZeroLengthArray() throws Exception
-    {
-        String[] args = new String[0];
-        Value construct = new Construct( args.getClass().getName(), new Value[0] );
-        String[] result = (String[]) construct.resolve();
-        boolean equal = Arrays.equals( args, result );
-        assertTrue( "zero-length-array", equal );
-    }
-    
-   /**
-    * Test creation of a simple construct.
-    * @exception Exception if an unexpected error occurs.
-    */
-    public void testArrayAsCompositeArgument() throws Exception
-    {
-        Construct a = new Construct( "Hello " );
-        Construct b = new Construct( "World!" );
-        Construct array = new Construct( String[].class.getName(), new Value[]{a, b} );
-        Construct construct = new Construct( Demo.class.getName(), new Value[]{array} );
-        Demo demo = (Demo) construct.resolve();
-        assertNotNull( "demo", demo );
-    }
-    
-   /**
-    * Test creation of a simple construct.
-    * @exception Exception if an unexpected error occurs.
-    */
-    public void testPrimitiveArray() throws Exception
-    {
-        int[] args = new int[]{1, 2, 3};
-        Value p1 = new Construct( "int", "1" );
-        Value p2 = new Construct( "int", "2" );
-        Value p3 = new Construct( "int", "3" );
-        Value construct = new Construct( "int[]", new Value[]{p1, p2, p3} );
-        Object result = construct.resolve();
-        int[] array = (int[]) construct.resolve();
-        boolean equal = Arrays.equals( args, array );
-        assertTrue( "primitive-array", equal );
-    }
-
-   /**
-    * Test construct encoding.
-    * @exception Exception if an unexpected error occurs.
-    */
-    public void testEncoding() throws Exception
-    {
-        Value number = new Construct( "int", "${number}" );
-        Value logical = new Construct( "boolean", "${logical}" );
-        Value construct = new Construct( Context2.class.getName(), new Value[]{number, logical} );
-        Value result = (Value) executeEncodingTest( construct );
-        assertEquals( "encoding", construct, result );
-    }
-
-   /**
-    * Test class.
-    */
-    public static class Demo
-    {
-       /**
-        * Create a new demo class.
-        * @param args the args
-        */
-        public Demo( String[] args )
-        {
-            for( int i=0; i<args.length; i++ )
-            {
-                System.out.print( args[i] );
-            }
-            System.out.println( "" );
-        }
-    }
-    
-   /**
-    * Mock class.
-    */
-    public static class Context 
-    {
-        private File m_a;
-        private File m_b;
-
-       /**
-        * Creation of a mock composite argument object.
-        * @param a the primary argument
-        * @param b the secondary argument
-        */
-        public Context( File a, File b )
-        {
-            m_a = a;
-            m_b = b;
-        }
-
-       /**
-        * Return the primary argument.
-        * @return the primary argument value
-        */
-        public File getA()
-        {
-            return m_a;
-        }
-
-       /**
-        * Return the secondary argument.
-        * @return the secondary argument value
-        */
-        public File getB()
-        {
-            return m_b;
-        }
-    }
-
-   /**
-    * Another mock class.
-    */
-    public static class Context2 
-    {
-        private int m_number;
-        private boolean m_logical;
-        
-       /**
-        * Static constructor method.
-        * @return an instance
-        */
-        public static Context2 create()
-        {
-            return new Context2( 100, true );
-        }
-
-       /**
-        * Creation of a mock object using primiative arguments.
-        * @param number a primitive number
-        * @param logical a boolean value
-        */
-        public Context2( int number, boolean logical )
-        {
-            m_number = number;
-            m_logical = logical;
-        }
-
-       /**
-        * Return the number.
-        * @return the number
-        */
-        public int getNumber()
-        {
-            return m_number;
-        }
-
-       /**
-        * Return the boolean.
-        * @return the boolean
-        */
-        public boolean getLogical()
-        {
-            return m_logical;
-        }
-    }
-}

Deleted: trunk/main/transit/core/src/test/net/dpml/transit/test/DisposalTestCase.java
===================================================================
--- trunk/main/transit/core/src/test/net/dpml/transit/test/DisposalTestCase.java	2007-02-09 01:22:24 UTC (rev 1851)
+++ trunk/main/transit/core/src/test/net/dpml/transit/test/DisposalTestCase.java	2007-02-09 01:24:09 UTC (rev 1852)
@@ -1,64 +0,0 @@
-/*
- * Copyright 2006 Stephen J. McConnell.
- *
- * 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 net.dpml.transit.test;
-
-import junit.framework.TestCase;
-
-import net.dpml.transit.DefaultTransitModel;
-import net.dpml.transit.Transit;
-
-/**
- * Test execution of the disposal of the Transit model.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class DisposalTestCase extends TestCase
-{
-    private DefaultTransitModel m_model;
-    
-   /**
-    * Setup the testcase during which an instance of DefaultTransitModel
-    * is created and cached so that we can invoke model tear-down on 
-    * completion of the test.
-    * @exception Exception if something goes pear-shaped
-    */
-    public void setUp() throws Exception
-    {
-        m_model = DefaultTransitModel.getDefaultModel();
-        Transit.getInstance( m_model );
-    }
-    
-   /**
-    * Nothing here - ant's Junit requires at least a single test but the
-    * real testing is in no exceptions under setup and teardown.
-    */
-    public void testSetupAndTearDown()
-    {
-        // trigger setup and teardown
-    }
-
-   /**
-    * Dispose of the transit model.
-    */
-    public void tearDown()
-    {
-        m_model.dispose();
-    }
-}

Modified: trunk/main/transit/core/src/test/net/dpml/transit/test/LinkTestCase.java
===================================================================
--- trunk/main/transit/core/src/test/net/dpml/transit/test/LinkTestCase.java	2007-02-09 01:22:24 UTC (rev 1851)
+++ trunk/main/transit/core/src/test/net/dpml/transit/test/LinkTestCase.java	2007-02-09 01:24:09 UTC (rev 1852)
@@ -1,6 +1,6 @@
 /*
  * Copyright 2005 Niclas Hedhman
- * Copyright 2005-2006 Stephen J. McConnell.
+ * Copyright 2005-2007 Stephen J. McConnell.
  *
  * Licensed  under the  Apache License,  Version 2.0  (the "License");
  * you may not use  this file  except in  compliance with the License.
@@ -19,25 +19,23 @@
 
 package net.dpml.transit.test;
 
+import dpml.transit.StreamUtils;
+
 import java.io.File;
 import java.io.InputStream;
+import java.io.FileOutputStream;
 import java.net.URI;
 import java.net.URL;
 
 import junit.framework.TestCase;
 
+import net.dpml.transit.ArtifactNotFoundException;
+import net.dpml.transit.LinkManager;
 import net.dpml.transit.Transit;
-import net.dpml.transit.DefaultTransitModel;
-import net.dpml.transit.artifact.ArtifactNotFoundException;
-import net.dpml.transit.link.Link;
-import net.dpml.transit.info.CacheDirective;
-import net.dpml.transit.info.TransitDirective;
-import net.dpml.transit.info.LayoutDirective;
-import net.dpml.transit.info.HostDirective;
-import net.dpml.transit.monitor.LoggingAdapter;
-import net.dpml.transit.model.TransitModel;
 
-import net.dpml.util.StreamUtils;
+import dpml.transit.info.CacheDirective;
+import dpml.transit.info.TransitDirective;
+import dpml.transit.info.HostDirective;
 
 /**
  * LinkTestCase.
@@ -47,13 +45,14 @@
 public class LinkTestCase extends TestCase
 {
     static final Transit TRANSIT = setupTransit();
+    static final LinkManager LINK = TRANSIT.getLinkManager();
     
    /**
     * Static Transit setup.
     */
     private static Transit setupTransit()
     {
-        System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit" );
+        System.setProperty( "java.protocol.handler.pkgs", "dpml.transit" );
         try
         {
             new File( "target/test/cache" ).delete();
@@ -63,12 +62,14 @@
                 CacheDirective.CACHE_LAYOUT,
                 "file:${user.dir}/target/test/trusted",
                 "classic",
-                new LayoutDirective[0],
                 new HostDirective[0] );
             TransitDirective directive = new TransitDirective( null, cache );
-            LoggingAdapter logger = new LoggingAdapter( "test" );
-            TransitModel model = new DefaultTransitModel( logger, directive );
-            return Transit.getInstance( model );
+            File basedir = new File( System.getProperty( "user.dir" ) );
+            File config = new File( basedir, "target/test/link.config" );
+            FileOutputStream out = new FileOutputStream( config );
+            TransitDirective.encode( directive, out );
+            System.setProperty( "dpml.transit.profile", config.toURI().toASCIIString() );
+            return Transit.getInstance();
         }
         catch( Throwable e )
         {
@@ -87,119 +88,96 @@
         {
             throw new IllegalStateException( "TRANSIT" );
         }
-    } 
-
-    /**
-     * Creation of a new link testcase.
-     * @param name the test name
-     */
-    public LinkTestCase( String name )
-    {
-        super( name );
     }
-
+    
    /**
     * Test default target value.
     * @exception Exception if an error occurs
     */
-    public void testDefaultValue() throws Exception
+    public void testLinkCreation() throws Exception
     {
-        URL url = new URL( "link:blob:transit/test/aaa/bbb" );
-        Class[] args = new Class[]{Link.class};
-        Link link = (Link) url.getContent( args );
-        URI defUri = URI.create( "artifact:bla:abc/def#142" );
-        URI uri = link.getTargetURI( defUri );
-        assertEquals( "default", defUri, uri );
+        URI link = URI.create( "link:blob:transit/test/aaa/bbb" );
+        URI target = URI.create( "artifact:bla:abc/def#142" );
+        LINK.setTargetURI( link, target );
+        URI value = LINK.getTargetURI( link );
+        assertEquals( "target", target, value );
     }
 
    /**
-    * Test content value.
-    * @exception Exception if an error occurs
-    */ 
-    public void testContentUri() throws Exception
+    * Validate that a content request on a link with the URL class 
+    * argument returns the link URI value.
+    * @exception Exception if an error in test execution occurs
+    */
+    public void testURIContent() throws Exception
     {
-        URI orig = URI.create( "link:blob:transit/test/aaa/bbb" );
-        URL url = orig.toURL();
+        URI link = URI.create( "link:blob:transit/test/aaa/bbb" );
+        URI target = URI.create( "artifact:bla:abc/def#142" );
+        LINK.setTargetURI( link, target );
+        URL url = link.toURL();
         Class[] args = new Class[]{URI.class};
-        URI found = (URI) url.getContent( args );
-        assertEquals( "default", orig, found );
+        URI content = (URI) url.getContent( args );
+        assertEquals( "content", link, content );
     }
 
    /**
-    * Test value assignment.
+    * Test link target reset.
     * @exception Exception if an error occurs
-    */ 
-    public void testSetValue() throws Exception
-    {
-        URL url = new URL( "link:blob:transit/test/aaa/ccc" );
-        Class[] args = new Class[]{Link.class};
-        Link link = (Link) url.getContent( args );
-        URI newUri = URI.create( "artifact:testfile:dpml/test/abc#1.0.1" );
-        link.setTargetURI( newUri );
-
-        url = new URL( "link:blob:transit/test/aaa/ccc" );
-        link = (Link) url.getContent( args );
-        URI defUri = URI.create( "artifact:bla:ccc/ddd#222" );
-        URI uri = link.getTargetURI( defUri );
-
-        assertEquals( "setting", newUri, uri );
-    }
-
-   /**
-    * Test value reset.
-    * @exception Exception if an error occurs
-    */ 
+    */
     public void testResetValue() throws Exception
     {
-        URL url = new URL( "link:blob:transit/test/example" );
-        Class[] args = new Class[]{Link.class};
-        Link link = (Link) url.getContent( args );
-        URI newUri = URI.create( "artifact:testfile:dpml/test/abc#1.0" );
-        link.setTargetURI( newUri );
-        URI newerUri = URI.create( "artifact:testfile:dpml/test/abc#2.0" );
-        link.setTargetURI( newerUri );
+        // create initial link
+        
+        URI link = URI.create( "link:blob:transit/test/example" );
+        URI target = URI.create( "artifact:testfile:dpml/test/abc#1.0" );
+        LINK.setTargetURI( link, target );
+        URI value = LINK.getTargetURI( link );
+        assertEquals( "target", target, value );
+        
+        // reset the link to a new target
+        
+        URI alt = URI.create( "artifact:testfile:dpml/test/abc#2.0" );
+        LINK.setTargetURI( link, alt );
+        URI newValue = LINK.getTargetURI( link );
+        assertEquals( "target", alt, newValue );
     }
 
    /**
     * Test get value.
     * @exception Exception if an error occurs
-    */ 
-    public void testGetValue() throws Exception
+    */
+    public void testInputStrreamValue() throws Exception
     {
-        URL url = new URL( "link:blob:transit/test/aaa/xxx" );
-        Class[] args = new Class[]{Link.class};
-        Link link = (Link) url.getContent( args );
-        URI newUri = URI.create( "artifact:testfile:dpml/test/abc#1.0.1" );
-        link.setTargetURI( newUri );
-
-        url = new URL( "link:blob:transit/test/aaa/xxx" );
-        URL original = newUri.toURL();
-        InputStream in1 = url.openConnection().getInputStream();
-        InputStream in2 = original.openConnection().getInputStream();
-        assertTrue( "different content", StreamUtils.compareStreams( in1, in2 ) );
+        URI link = URI.create( "link:blob:transit/test/aaa/xxx" );
+        URI targetUri = URI.create( "artifact:testfile:dpml/test/abc#1.0.1" );
+        LINK.setTargetURI( link, targetUri );
+        
+        URL linkURL = link.toURL();
+        URL targetURL = targetUri.toURL();
+        
+        InputStream linkIs = linkURL.openConnection().getInputStream();
+        InputStream targetIS = targetURL.openConnection().getInputStream();
+        assertTrue( "different content", StreamUtils.compareStreams( linkIs, targetIS ) );
     }
-
+    
    /**
     * Test illegal link artifact.
     * @exception Exception if an error occurs
-    */ 
+    */
     public void testIllegalArtifact()
         throws Exception
     {
-        URL url = new URL( "link:blob:transit/test/errors/aaa" );
-        Class[] args = new Class[]{Link.class};
-        URI newUri = URI.create( "artifact:abc:does/not/exist" );
+        URI link = URI.create( "link:blob:transit/test/errors/aaa" );
+        URI targetUri = URI.create( "artifact:abc:does/not/exist" );
+        LINK.setTargetURI( link, targetUri );
+        URL url = link.toURL();
         try
         {
-            Link link = (Link) url.getContent( args );
-            link.setTargetURI( newUri );
             url.getContent();
             fail( "ArtifactNotFoundException was not thrown." );
         } 
         catch( ArtifactNotFoundException e )
         {
-            // should throw an exception if we try to read against a
-            // non existent artifact.
+            // success
         }
     }
 }

Deleted: trunk/main/transit/core/src/test/net/dpml/transit/test/MimeHandlerTestCase.java
===================================================================
--- trunk/main/transit/core/src/test/net/dpml/transit/test/MimeHandlerTestCase.java	2007-02-09 01:22:24 UTC (rev 1851)
+++ trunk/main/transit/core/src/test/net/dpml/transit/test/MimeHandlerTestCase.java	2007-02-09 01:24:09 UTC (rev 1852)
@@ -1,98 +0,0 @@
-/*
- * Copyright 2004 Niclas Hedhman.
- * Copyright 2006 Stephen J. McConnell.
- *
- * 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 net.dpml.transit.test;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import net.dpml.util.MimeTypeHandler;
-
-/**
- * MimeHandlerTestCase.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class MimeHandlerTestCase extends TestCase
-{
-    private static final String[][] TESTS = new String[][]
-    {
-        {"plugin", "text/x-dpml-plugin"},
-        {"conf", "text/x-dpml-conf"},
-        {"jar", "application/x-jar"},
-        {"zip", "application/x-zip"},
-        {"pdf", "application/pdf"},
-        {"png", "image/png"},
-        {"jpg", "image/jpg"},
-        {"gif", "image/gif"},
-        {"link", "application/x-dpml-link"},
-        {"part", "application/x-dpml-part"}
-    };
-
-   /**
-    * Return the test suite.
-    * @return the test
-    */
-    public static Test suite()
-    {
-        TestSuite tests = new TestSuite();
-        for( int i = 0; i<TESTS.length; i++ )
-        {
-            String lookup = TESTS[i][0];
-            String expected = TESTS[i][1];
-            String name = "testLookup";
-            TestCase testcase = new MimeHandlerTestCase( name, lookup, expected );
-            tests.addTest( testcase );
-        }
-        String name = "testSize";
-        TestCase testcase = new MimeHandlerTestCase( name, null, null );
-        tests.addTest( testcase );
-        return tests;
-    }
-
-    private String m_lookup;
-    private String m_expected;
-
-    private MimeHandlerTestCase( String name, String lookup, String expected )
-    {
-        super( name );
-        m_lookup = lookup;
-        m_expected = expected;
-    }
-
-   /**
-    * Test mime type lookup.
-    * @exception Exception if an error occurs
-    */
-    public void testLookup()
-        throws Exception
-    {
-        String mime = MimeTypeHandler.getMimeType( m_lookup );
-        assertEquals( m_lookup, m_expected, mime );
-    }
-
-   /**
-    * Test mime map size.
-    */
-    public void testSize()
-    {
-        assertEquals( "Map Size", TESTS.length, MimeTypeHandler.getMimeTypesSize() );
-    }
-}

Modified: trunk/main/transit/core/src/test/net/dpml/transit/test/OfflineTestCase.java
===================================================================
--- trunk/main/transit/core/src/test/net/dpml/transit/test/OfflineTestCase.java	2007-02-09 01:22:24 UTC (rev 1851)
+++ trunk/main/transit/core/src/test/net/dpml/transit/test/OfflineTestCase.java	2007-02-09 01:24:09 UTC (rev 1852)
@@ -24,20 +24,18 @@
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
+import java.io.FileOutputStream;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.Date;
 
 import junit.framework.TestCase;
 
-import net.dpml.transit.info.CacheDirective;
-import net.dpml.transit.info.TransitDirective;
-import net.dpml.transit.info.LayoutDirective;
-import net.dpml.transit.info.HostDirective;
-import net.dpml.transit.monitor.LoggingAdapter;
-import net.dpml.transit.model.TransitModel;
+import dpml.transit.info.CacheDirective;
+import dpml.transit.info.TransitDirective;
+import dpml.transit.info.HostDirective;
+
 import net.dpml.transit.Transit;
-import net.dpml.transit.DefaultTransitModel;
 
 /**
  * URL Handler TestCase for Offline operations.
@@ -51,22 +49,23 @@
     
     private static Transit setupTransit()
     {
-        System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit" );
         try
         {
-            new File( "target/test/cache" ).delete();
+            File basedir = new File( System.getProperty( "basedir" ) );
+            new File( basedir, "target/test/cache" ).delete();
             CacheDirective cache =
               new CacheDirective(
                 "${user.dir}/target/test/cache",
                 CacheDirective.CACHE_LAYOUT,
                 "file:${user.dir}/target/test/trusted",
                 "classic",
-                new LayoutDirective[0],
                 new HostDirective[0] );
             TransitDirective directive = new TransitDirective( null, cache );
-            LoggingAdapter logger = new LoggingAdapter( "test" );
-            TransitModel model = new DefaultTransitModel( logger, directive );
-            return Transit.getInstance( model );
+            File config = new File( basedir, "target/test/offline.config" );
+            FileOutputStream out = new FileOutputStream( config );
+            TransitDirective.encode( directive, out );
+            System.setProperty( "dpml.transit.profile", config.toURI().toASCIIString() );
+            return Transit.getInstance();
         }
         catch( Throwable e )
         {

Modified: trunk/main/transit/core/src/test/net/dpml/transit/test/OnlineTestCase.java
===================================================================
--- trunk/main/transit/core/src/test/net/dpml/transit/test/OnlineTestCase.java	2007-02-09 01:22:24 UTC (rev 1851)
+++ trunk/main/transit/core/src/test/net/dpml/transit/test/OnlineTestCase.java	2007-02-09 01:24:09 UTC (rev 1852)
@@ -23,20 +23,18 @@
 import java.io.BufferedReader;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.FileOutputStream;
 
 import java.net.URL;
 import java.net.URLClassLoader;
 
 import junit.framework.TestCase;
 
-import net.dpml.transit.info.CacheDirective;
-import net.dpml.transit.info.TransitDirective;
-import net.dpml.transit.info.LayoutDirective;
-import net.dpml.transit.info.HostDirective;
-import net.dpml.transit.monitor.LoggingAdapter;
-import net.dpml.transit.model.TransitModel;
+import dpml.transit.info.CacheDirective;
+import dpml.transit.info.TransitDirective;
+import dpml.transit.info.HostDirective;
+
 import net.dpml.transit.Transit;
-import net.dpml.transit.DefaultTransitModel;
 
 /**
  * URL Handler TestCase for online operations.
@@ -50,22 +48,23 @@
     
     private static final Transit setupTransit()
     {
-        System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit" );
         try
         {
-            new File( "target/test/cache" ).delete();
+            File basedir = new File( System.getProperty( "basedir" ) );
+            new File( basedir, "target/test/cache" ).delete();
             CacheDirective cache =
               new CacheDirective(
                 "${user.dir}/target/test/cache",
                 CacheDirective.CACHE_LAYOUT,
                 "file:${user.dir}/target/test/trusted",
                 CacheDirective.LOCAL_LAYOUT,
-                new LayoutDirective[0],
                 new HostDirective[0] );
             TransitDirective directive = new TransitDirective( null, cache );
-            LoggingAdapter logger = new LoggingAdapter( "test" );
-            TransitModel model = new DefaultTransitModel( logger, directive );
-            return Transit.getInstance( model );
+            File config = new File( basedir, "target/test/online.config" );
+            FileOutputStream out = new FileOutputStream( config );
+            TransitDirective.encode( directive, out );
+            System.setProperty( "dpml.transit.profile", config.toURI().toASCIIString() );
+            return Transit.getInstance();
         }
         catch( Throwable e )
         {




More information about the notify-dpml mailing list