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 2003/11/23 02:58:27 UTC

cvs commit: avalon-sandbox/repository/api/src/test/org/apache/avalon/repository ClassicArtifactTest.java ArtifactTest.java

mcconnell    2003/11/22 17:58:27

  Modified:    repository/api/src/test/org/apache/avalon/repository
                        ArtifactTest.java
  Added:       repository/api/src/test/org/apache/avalon/repository
                        ClassicArtifactTest.java
  Log:
  Add static operations test.
  
  Revision  Changes    Path
  1.2       +63 -2     avalon-sandbox/repository/api/src/test/org/apache/avalon/repository/ArtifactTest.java
  
  Index: ArtifactTest.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/repository/api/src/test/org/apache/avalon/repository/ArtifactTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ArtifactTest.java	19 Nov 2003 17:28:37 -0000	1.1
  +++ ArtifactTest.java	23 Nov 2003 01:58:27 -0000	1.2
  @@ -125,4 +125,65 @@
           assertTrue( "url-1", ref.getURL( "http://abc.def" ).equals( "http://abc.def/aaa/bbb/ccc/xyz" ) );
           assertTrue( "url-2", ref.getURL( "http://abc.def/" ).equals( "http://abc.def/aaa/bbb/ccc/xyz" ) );
       }
  +
  +    public void testStaticOne() throws Exception
  +    {
  +        try
  +        {
  +            Artifact.createArtifact( null, null );
  +            fail( "No null pointer exception (case 1)" );
  +        }
  +        catch( Throwable e )
  +        {
  +            assertTrue( true );
  +        }
  +    }
  +
  +    public void testStaticTwo() throws Exception
  +    {
  +        try
  +        {
  +            Artifact.createArtifact( null, "xxx" );
  +            fail( "No null pointer exception (case 2)" );
  +        }
  +        catch( Throwable e )
  +        {
  +            assertTrue( true );
  +        }
  +    }
  +
  +    public void testStaticThree() throws Exception
  +    {
  +        try
  +        {
  +            Artifact.createArtifact( "xxx", null );
  +            fail( "No null pointer exception (case 3)" );
  +        }
  +        catch( Throwable e )
  +        {
  +            assertTrue( true );
  +        }
  +    }
  +
  +    public void testURLGeneralIntegrity() throws Exception
  +    {
  +        Artifact artifact = Artifact.createArtifact( "xxx", "yyy" );
  +        assertNotNull( artifact );
  +        assertTrue( 
  +          artifact.getURL( "http://dpml.net" ).equals( 
  +            "http://dpml.net/xxx/yyy" ) );
  +    }
  +
  +    public void testURLFromEmptyRepository() throws Exception
  +    {
  +        Artifact artifact = Artifact.createArtifact( "xxx", "yyy" );
  +        assertNotNull( artifact );
  +        assertTrue( artifact.getURL( "" ).equals( "/xxx/yyy" ) );
  +    }
  +
  +    public void testURLFromNullRepository() throws Exception
  +    {
  +        Artifact artifact = Artifact.createArtifact( "xxx", "yyy" );
  +        assertTrue( artifact.getURL( null ).equals( "/xxx/yyy" ) );
  +    }
   }
  
  
  
  1.1                  avalon-sandbox/repository/api/src/test/org/apache/avalon/repository/ClassicArtifactTest.java
  
  Index: ClassicArtifactTest.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.repository;
  
  import java.util.Properties;
  import java.util.Enumeration;
  
  import junit.framework.TestCase;
  
  /**
   * @todo
   * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
   * @author $Author: mcconnell $
   * @version $Revision: 1.1 $
   */
  public class ClassicArtifactTest extends TestCase
  {
  
      /**
       * Constructor for ClassicArtifactTest.
       * @param name 
       */
      public ClassicArtifactTest(String name )
      {
          super( name );
      }
      
      public void testCreateClassicArtifactNullArgumentsOne() throws Exception
      {
          try
          {
              ClassicArtifact.createClassicArtifact( null, null );
              fail( "No null pointer exception (case 1)" );
          }
          catch( Throwable e )
          {
              assertTrue( true );
          }
      }
  
      public void testCreateClassicArtifactNullArgumentsTwo() throws Exception
      {
          try
          {
              ClassicArtifact.createArtifact( null, "xxx" );
              fail( "No null pointer exception (case 2)" );
          }
          catch( Throwable e )
          {
              assertTrue( true );
          }
      }
  
      public void testCreateClassicArtifactNullArgumentsThree() throws Exception
      {
          try
          {
              ClassicArtifact.createArtifact( "xxx", null );
              fail( "No null pointer exception (case 3)" );
          }
          catch( Throwable e )
          {
              assertTrue( true );
          }
      }
  
      public void testCreateSimpleClassicArtifact() throws Exception
      {
          String group = "xxx";
          String name = "yyy";
  
          ClassicArtifact artifact = 
            ClassicArtifact.createClassicArtifact( group, name );
          assertNotNull( artifact );
          assertTrue( artifact.getURL( null ).equals( "/" + group + "/" + name ) );
          assertTrue( "group", group.equals( artifact.getGroup() ) );
          assertTrue( "name", name.equals( artifact.getName() ) );
      }
  
      public void testCreateVersionedClassicArtifact() throws Exception
      {
  
          String group = "xxx";
          String name = "yyy";
          String version = "1.0-dev";
  
          ClassicArtifact artifact = 
            ClassicArtifact.createClassicArtifact( 
              group, name, version );
  
          assertNotNull( artifact );
          assertTrue( 
            artifact.getURL( null ).equals( 
              "/" + group + "/" + name + "-" + version ) );
          assertTrue( "group", group.equals( artifact.getGroup() ) );
          assertTrue( "name", name.equals( artifact.getName() ) );
          assertTrue( "version", version.equals( artifact.getVersion() ) );
      }
  
      public void testCreateTypedArtifact() throws Exception
      {
          String group = "xxx";
          String name = "yyy";
          String version = "1.0-dev";
          String type = "foo";
          ClassicArtifact artifact = 
            ClassicArtifact.createClassicArtifact( 
              group, name, version, type );
  
          assertNotNull( artifact );
          assertTrue( 
            artifact.getURL( null ).equals( 
              "/" + group + "/" + type + "s/" + name 
              + "-" + version + "." + type ) );
          assertTrue( "group", group.equals( artifact.getGroup() ) );
          assertTrue( "name", name.equals( artifact.getName() ) );
          assertTrue( "version", version.equals( artifact.getVersion() ) );
          assertTrue( "type", type.equals( artifact.getType() ) );
      }
  
      public void testJarArtifactCreation() throws Exception
      {
          String group = "xxx";
          String name = "yyy";
          String version = "1.0-dev";
  
          ClassicArtifact artifact = 
            ClassicArtifact.createJarArtifact( group, name, version );
          assertNotNull( artifact );
          assertTrue( "group", group.equals( artifact.getGroup() ) );
          assertTrue( "name", name.equals( artifact.getName() ) );
          assertTrue( "version", version.equals( artifact.getVersion() ) );
          assertTrue( "type", "jar".equals( artifact.getType() ) );
          assertTrue( artifact.getURL( null ).equals( 
            "/" + group + "/jars/" + name + "-" + version + ".jar" ) );
      }
  
      public void testJarArtifactCreationBySimpleSpec() throws Exception
      {
          final String spec = "xxx";
          ClassicArtifact artifact = ClassicArtifact.createJarArtifact( spec );
  
          assertNotNull( artifact );
          assertTrue( "group", "xxx".equals( artifact.getGroup() ) );
          assertTrue( "name", "xxx".equals( artifact.getName() ) );
          assertTrue( "version", artifact.getVersion() == null );
          assertTrue( "type", artifact.getType() == "jar"  );
          assertTrue( "url", artifact.getURL( null ).equals( "/xxx/jars/xxx.jar" ) );
      }
  
      public void testJarArtifactCreationByCompoundSpec() throws Exception
      {
          final String spec = "xxx:yyy";
          ClassicArtifact artifact = ClassicArtifact.createJarArtifact( spec );
          assertNotNull( artifact );
          assertTrue( "group", artifact.getGroup().equals( "xxx" ) );
          assertTrue( "name", artifact.getName().equals( "yyy" ) );
          assertTrue( "type", artifact.getType().equals( "jar" ) );
          assertTrue( "url", artifact.getURL( null ).equals( 
            "/xxx/jars/yyy.jar" ) );
      }
  
      public void testJarArtifactCreationBySpec() throws Exception
      {
          final String spec = "xxx:yyy;zzz";
          ClassicArtifact artifact = ClassicArtifact.createJarArtifact( spec );
          assertNotNull( artifact );
          assertTrue( "group", artifact.getGroup().equals( "xxx" ) );
          assertTrue( "name", artifact.getName().equals( "yyy" ) );
          assertTrue( "version", artifact.getVersion().equals( "zzz" ) );
          assertTrue( "type", artifact.getType().equals( "jar" ) );
          assertTrue( "url", artifact.getURL( null ).equals( 
            "/xxx/jars/yyy-zzz.jar" ) );
      }
  
  }
  
  
  

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