mcconnell    2003/11/17 03:41:27

  Modified:    repository/api/src/java/org/apache/avalon/repository
                        ArtifactReference.java
               repository/api/src/test/org/apache/avalon/repository
                        ArtifactFactoryTest.java
  Log:
  Factory enhancement and testcase improvement.
  
  Revision  Changes    Path
  1.3       +12 -5     
avalon-sandbox/repository/api/src/java/org/apache/avalon/repository/ArtifactReference.java
  
  Index: ArtifactReference.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/repository/api/src/java/org/apache/avalon/repository/ArtifactReference.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ArtifactReference.java    17 Nov 2003 11:20:05 -0000      1.2
  +++ ArtifactReference.java    17 Nov 2003 11:41:27 -0000      1.3
  @@ -201,18 +201,25 @@
        */
       public String getURL( final String repository )
       {
  -        if( repository.endsWith( SEP ) )
  +        if( null == repository )
           {
  -            return repository + getPath();
  +            return getURL( "" );
           }
           else
           {
  -            return repository + SEP + getPath();
  +            if( repository.endsWith( SEP ) )
  +            {
  +                return repository + getPath();
  +            }
  +            else
  +            {
  +                return repository + SEP + getPath();
  +            }
           }
       }
   
      /**
  -    * Remove leading and trainly seperators.
  +    * Remove leading and trailing seperators.
       * @param the path value to clean
       * @return the clean path
       */
  
  
  
  1.2       +31 -3     
avalon-sandbox/repository/api/src/test/org/apache/avalon/repository/ArtifactFactoryTest.java
  
  Index: ArtifactFactoryTest.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/repository/api/src/test/org/apache/avalon/repository/ArtifactFactoryTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ArtifactFactoryTest.java  17 Nov 2003 11:20:05 -0000      1.1
  +++ ArtifactFactoryTest.java  17 Nov 2003 11:41:27 -0000      1.2
  @@ -51,6 +51,8 @@
   package org.apache.avalon.repository;
   
   import java.util.Properties;
  +import java.util.Enumeration;
  +
   import junit.framework.TestCase;
   
   
  @@ -116,17 +118,43 @@
           }
       }
   
  -    public void testIntegrity() throws Exception
  +    public void testURLGeneralIntegrity() throws Exception
       {
           Artifact artifact = ArtifactFactory.createArtifact( "xxx", "yyy" );
           assertNotNull( artifact );
  -        assertTrue( artifact.getURL( "http://dpml.net"; ).equals( 
"http://dpml.net/xxx/yyy"; ) );
  +        assertTrue( 
  +          artifact.getURL( "http://dpml.net"; ).equals( 
  +            "http://dpml.net/xxx/yyy"; ) );
       }
   
  -    public void testIntegrityTwo() throws Exception
  +    public void testURLFromEmptyRepository() throws Exception
       {
           Artifact artifact = ArtifactFactory.createArtifact( "xxx", "yyy" );
           assertNotNull( artifact );
           assertTrue( artifact.getURL( "" ).equals( "/xxx/yyy" ) );
  +    }
  +
  +    public void testURLFromNullRepository() throws Exception
  +    {
  +        Artifact artifact = ArtifactFactory.createArtifact( "xxx", "yyy" );
  +        assertTrue( artifact.getURL( null ).equals( "/xxx/yyy" ) );
  +    }
  +
  +    public void testArtifactProperties() throws Exception
  +    {
  +        Properties p = new Properties();
  +        p.setProperty( "aaa", "Aaa" );
  +        p.setProperty( "bbb", "Bbb" );
  +        Artifact artifact = ArtifactFactory.createArtifact( "xxx", "yyy", p );
  +        assertTrue( artifact.getProperty( "aaa" ).equals( "Aaa" ) );
  +        assertTrue( artifact.getProperty( "bbb" ).equals( "Bbb" ) );
  +        Enumeration e = artifact.getPropertyNames();
  +        int n = 0;
  +        while( e.hasMoreElements() )
  +        {
  +            final String name = (String) e.nextElement();
  +            n++;
  +        }
  +        assertTrue( n == 2 );
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to