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/02/15 02:24:51 UTC

cvs commit: avalon/repository/api/src/test/org/apache/avalon/repository ArtifactURLTest.java

mcconnell    2004/02/14 17:24:51

  Modified:    repository/api/src/java/org/apache/avalon/repository
                        AbstractURLConnection.java
  Added:       repository/api/src/test/org/apache/avalon/repository
                        ArtifactURLTest.java
  Log:
  Improve the url handling and add a test case.
  
  Revision  Changes    Path
  1.2       +1 -0      avalon/repository/api/src/java/org/apache/avalon/repository/AbstractURLConnection.java
  
  Index: AbstractURLConnection.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/api/src/java/org/apache/avalon/repository/AbstractURLConnection.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractURLConnection.java	24 Jan 2004 23:20:04 -0000	1.1
  +++ AbstractURLConnection.java	15 Feb 2004 01:24:50 -0000	1.2
  @@ -102,6 +102,7 @@
        */
        protected String getVersion( URL url )
        {
  +         if( null != url.getRef() ) return url.getRef();
            return getQueryField( url, "version", null );
        } 
   
  
  
  
  1.1                  avalon/repository/api/src/test/org/apache/avalon/repository/ArtifactURLTest.java
  
  Index: ArtifactURLTest.java
  ===================================================================
  /* 
   * 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.repository;
  
  
  import junit.framework.TestCase;
  
  
  /**
   * Create of a new Artifact test case.
   *
   * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
   * @version $Revision: 1.1 $
   */
  public class ArtifactURLTest extends TestCase
  {
      /**
       * Constructor for ArtifactURLTest.
       * @param name the test name
       */
      public ArtifactURLTest( String name )
      {
          super( name );
      }
      
      public void testArtifactURLGroup() throws Exception
      {
          Artifact artifact = 
            Artifact.createArtifact( "artifact:peter/rabbit" );
          assertTrue( "peter".equals( artifact.getGroup() ) );
      }
  
      public void testArtifactURLCompositeGroup() throws Exception
      {
          Artifact artifact = 
            Artifact.createArtifact( "artifact:the/peter/rabbit" );
          assertTrue( "the/peter".equals( artifact.getGroup() ) );
      }
  
      public void testArtifactURLName() throws Exception
      {
          Artifact artifact = 
            Artifact.createArtifact( "artifact:peter/rabbit" );
          assertTrue( "rabbit".equals( artifact.getName() ) );
      }
  
      public void testArtifactURLType() throws Exception
      {
          Artifact artifact = 
            Artifact.createArtifact( "artifact:peter/rabbit" );
          assertTrue( "jar".equals( artifact.getType() ) );
      }
  
      public void testArtifactURLNullVersion() throws Exception
      {
          Artifact artifact = 
            Artifact.createArtifact( "artifact:peter/rabbit" );
          assertNull( artifact.getVersion() );
      }
  
      public void testArtifactRefVersionURL() throws Exception
      {
          Artifact artifact = 
            Artifact.createArtifact( "artifact:peter/rabbit#1.1" );
          assertTrue( "1.1".equals( artifact.getVersion() ) );
      }
  
  }
  
  
  

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