You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jv...@apache.org on 2003/05/23 17:57:52 UTC

cvs commit: maven-new/core/src/test/org/apache/maven/artifact/factory DefaultArtifactFactoryTest.java

jvanzyl     2003/05/23 08:57:52

  Modified:    core/src/test/org/apache/maven/artifact/factory
                        DefaultArtifactFactoryTest.java
  Log:
  o We always want to use the component method of testing. We will always use components.
    Even when we separate the code to allow people to embed the download mechanism in
    other tools (as promised) under the covers plexus and components will be used.
  
  Revision  Changes    Path
  1.2       +28 -33    maven-new/core/src/test/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java
  
  Index: DefaultArtifactFactoryTest.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/test/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultArtifactFactoryTest.java	23 May 2003 12:53:26 -0000	1.1
  +++ DefaultArtifactFactoryTest.java	23 May 2003 15:57:52 -0000	1.2
  @@ -55,79 +55,74 @@
    */
   package org.apache.maven.artifact.factory;
   
  -import java.util.List;
  -
  -import junit.framework.TestCase;
  -
  -import org.apache.maven.TestUtils;
  -import org.apache.maven.artifact.layout.DefaultRepositoryLayout;
   import org.apache.maven.project.Project;
  +import org.apache.maven.project.builder.ProjectBuilder;
  +import org.apache.plexus.PlexusTestCase;
  +
  +import java.io.File;
  +import java.util.List;
   
   /**
  - * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a> 
  + * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
    * @version $Id$
    */
  -public class DefaultArtifactFactoryTest extends TestCase
  +public class DefaultArtifactFactoryTest
  +    extends PlexusTestCase
   {
  -
  -    private DefaultArtifactFactory artifactFactory = null;
  +    private ArtifactFactory artifactFactory;
  +    private ProjectBuilder builder;
   
       /**
        * Constructor for DefaultArtifactFactoryTest.
  -     * @param String testName
  +     * @param testName
        */
  -    public DefaultArtifactFactoryTest(String testName)
  +    public DefaultArtifactFactoryTest( String testName )
       {
  -        super(testName);
  -    }
  -
  -    private Object lookup(String role)
  -    {
  -        return null;
  +        super( testName );
       }
   
       /**
        * @see junit.framework.TestCase#setUp()
        */
  -    public void setUp() throws Exception
  +    public void setUp()
  +        throws Exception
       {
           super.setUp();
  -        artifactFactory = new DefaultArtifactFactory();
  -        DefaultRepositoryLayout repositoryLayout =
  -            new DefaultRepositoryLayout();
  -        repositoryLayout.initialize();
  -        artifactFactory.setRepositoryLayout(repositoryLayout);
  +
  +        artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
  +        builder = (ProjectBuilder) lookup( ProjectBuilder.ROLE );
       }
   
       public void testCreateArtifacts()
       {
           Project project = null;
  +
           try
           {
  -            project = TestUtils.getProjectSample("/src/test-input/project.xml");
  +            project = builder.build( new File( getTestFile( "src/test-input/project.xml" ) ) );
           }
  -        catch (Exception e)
  +        catch ( Exception e )
           {
               String msg = "Cannot get project sample: " + e.getMessage();
  -            fail(msg);
  +            fail( msg );
           }
           List artifacts = null;
           try
           {
  -            artifacts = artifactFactory.createArtifacts(project);
  +            artifacts = artifactFactory.createArtifacts( project );
           }
  -        catch (Exception e)
  +        catch ( Exception e )
           {
               String msg =
                   "Failed to create list of artifacts: " + e.getMessage();
  -            fail(msg);
  +            fail( msg );
           }
   
           // Check if we have required number of artifacts
           int expectedNumberOfArtifacts = 4;
  -        int actualNumberOfArtifacts  = artifacts.size();
  +        int actualNumberOfArtifacts = artifacts.size();
           String msg1 = "Artifact list has unexpected size";
  -        assertEquals(msg1, expectedNumberOfArtifacts, actualNumberOfArtifacts);
  +        assertEquals( msg1, expectedNumberOfArtifacts, actualNumberOfArtifacts );
   
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org