michal      2003/05/30 03:12:26

  Modified:    core/src/test/org/apache/maven/artifact/satisfy
                        DefaultDependencySatisfierTest.java
  Log:
  minor corretions
  
  Revision  Changes    Path
  1.5       +40 -101   
maven-new/core/src/test/org/apache/maven/artifact/satisfy/DefaultDependencySatisfierTest.java
  
  Index: DefaultDependencySatisfierTest.java
  ===================================================================
  RCS file: 
/home/cvs/maven-new/core/src/test/org/apache/maven/artifact/satisfy/DefaultDependencySatisfierTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultDependencySatisfierTest.java       29 May 2003 20:26:21 -0000      1.4
  +++ DefaultDependencySatisfierTest.java       30 May 2003 10:12:25 -0000      1.5
  @@ -82,7 +82,7 @@
        */
       public DefaultDependencySatisfierTest(String testName)
       {
  -        super( testName );
  +        super(testName);
       }
   
       /**
  @@ -92,10 +92,10 @@
       {
           super.setUp();
           dependencySatisfier =
  -            ( DependencySatisfier ) lookup( DependencySatisfier.ROLE );
  +            (DependencySatisfier) lookup(DependencySatisfier.ROLE);
   
  -        builder = ( ProjectBuilder ) lookup( ProjectBuilder.ROLE );
  -        artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
  +        builder = (ProjectBuilder) lookup(ProjectBuilder.ROLE);
  +        artifactFactory = (ArtifactFactory) lookup(ArtifactFactory.ROLE);
   
           // We are setting the value of the test local repository because if a value 
is set
           // it will be used. If you have maven.repo.local set in your 
~/build.properties then
  @@ -103,17 +103,16 @@
           // should set this up to always use our test repo.
   
           artifactFactory.setMavenRepoLocal(
  -            getTestFile( "src/test-input/maven-repo-local" ) );
  +            getTestFile("src/test-input/maven-repo-local"));
           MockArtifactDownloader.clear();
       }
   
  -    
       /**
        * 
        * @param file
        * @return
        */
  -    private Project getProject( String file )
  +    private Project getProject(String file)
       {
   
           Project project = null;
  @@ -126,6 +125,17 @@
               String msg = "Cannot get project sample: " + e.getMessage();
               fail(msg);
           }
  +        try
  +        {
  +            artifactFactory.createArtifacts(project);
  +        }
  +        catch (Exception e)
  +        {
  +            String msg =
  +                "Cannot build artifact list for a project: " + e.getMessage();
  +            fail(msg);
  +        }
  +
           return project;
   
       }
  @@ -138,18 +148,7 @@
       {
   
           Project project =
  -            getProject("src/test-input/artifact-satisfier/all-in-repo/project.xml");
  -        try
  -        {
  -            artifactFactory.createArtifacts(project);
  -        }
  -        catch (Exception e)
  -        {
  -            String msg =
  -                "Cannot build artifact list for a project: " + e.getMessage();
  -            fail(msg);
  -        }
  -
  +            
getProject("src/test-input/artifact-satisfier/all-in-repo/project.xml");        
           try
           {
               dependencySatisfier.satisfyDependencies(project);
  @@ -176,20 +175,9 @@
        */
       public void testUnsatisfedDependenciesAreDownloaded()
       {
  -
           Project project =
               getProject("src/test-input/artifact-satisfier/missed-deps/project.xml");
  -        project.setOnline(Boolean.TRUE);
  -        try
  -        {
  -            artifactFactory.createArtifacts(project);
  -        }
  -        catch (Exception e)
  -        {
  -            String msg =
  -                "Cannot build artifact list for a project: " + e.getMessage();
  -            fail(msg);
  -        }
  +        project.setOnline(Boolean.TRUE);        
           try
           {
               dependencySatisfier.satisfyDependencies(project);
  @@ -223,23 +211,14 @@
   
       /**
        * 
  -     *
  +     * Test is there is an attempt made to downalod missing dependencies
  +     * if they are not found in the local repository
        */
  -    public void testNotReachableDependencies()
  +    public void testUnsatisfiedsDependencies()
       {
           Project project =
  -            getProject( 
"src/test-input/artifact-satisfier/missed-deps/project.xml");
  -        project.setOnline( Boolean.TRUE );
  -        try
  -        {
  -            artifactFactory.createArtifacts( project );
  -        }
  -        catch ( Exception e )
  -        {
  -            String msg =
  -                "Cannot build artifact list for a project: " + e.getMessage();
  -            fail(msg);
  -        }
  +            getProject("src/test-input/artifact-satisfier/missed-deps/project.xml");
  +        project.setOnline(Boolean.TRUE);        
           Artifact testA = (Artifact) project.getArtifacts().get(0);
           Artifact testB = (Artifact) project.getArtifacts().get(1);
   
  @@ -262,99 +241,59 @@
                       + e.getMessage();
               fail(msg);
           }
  +
  +        // now check if the expected dependecy failed
           Set deps = MockArtifactDownloader.getDownloadedDependencies();
           int expectedNumOfDownloads = 1;
           int actualNumOfDownloads = deps.size();
           assertEquals(
               "Download of unsatisfied dependicies was successful "
  -                + " expected number of times",
  +                + " unexpected number of times",
               expectedNumOfDownloads,
               actualNumOfDownloads);
   
  -    }
  -
  -    /**
  -     * 
  -     *
  -     */
  -    public void testDependecyResolving()
  -    {
  -        Project project = getProject( 
"src/test-input/artifact-satisfier/all-in-repo/project.xml" );        
  -        
  -        Artifact testA = (Artifact) project.getArtifacts().get(0);
  -        Artifact testB = (Artifact) project.getArtifacts().get(1);
  -        
           boolean testAWasDownloaded =
               MockArtifactDownloader.wasArtifactDownloaded(testA);
           boolean testBWasDownloaded =
               MockArtifactDownloader.wasArtifactDownloaded(testB);
   
  -
           assertTrue(
  -            "There was no attempt made to download required artifact: "
  -                + testA,
  +            "Artifact should have been downloaded:" + testA,
               testAWasDownloaded);
  -
           assertFalse(
  -            " The failure was expected for: " + testB,
  +            "Artifact should't have been downloaded: " + testB,
               testBWasDownloaded);
   
       }
   
       /**
        * 
  -     * If we are online snapshot dependencies should be downloaded
  +     * If we are online snapshot dependencies they should be downloaded
  +     * when on line
        */
  -    public void testSnapshotDependenciesOnLine()
  +    public void testSnapshotsAreFailedDependenciesWhenOnLine()
       {
           Project project =
  -            getProject( "src/test-input/artifact-satisfier/snapshots/project.xml" );
  +            getProject("src/test-input/artifact-satisfier/snapshots/project.xml");
   
  -        project.setOnline( Boolean.TRUE );
  -        try
  -        {
  -            artifactFactory.createArtifacts( project );
  -        }
  -        catch ( Exception e )
  -        {
  -            String msg =
  -                "Cannot build artifact list for a project: " + e.getMessage();
  -            fail( msg );       
  -        }
  +        project.setOnline(Boolean.TRUE);
           try
           {
               dependencySatisfier.satisfyDependencies(project);
           }
  -        catch ( Exception e )
  +        catch (Exception e)
           {
               String msg =
                   "Unexpected error occurred in 'satisfyDependencies': "
                       + e.getMessage();
  -            fail( msg );
  +            fail(msg);
           }
  +
           Set deps = MockArtifactDownloader.getDownloadedDependencies();
  -        int expectedNumOfDownloads = 0;
  -        int actualNumOfDownloads = deps.size();
  -        assertEquals(
  -            "No dependecy should be downloaded",
  -            expectedNumOfDownloads,
  -            actualNumOfDownloads );   
  -        try
  -        {
  -            dependencySatisfier.satisfyDependencies( project );
  -        }
  -        catch ( Exception e )
  -        {
  -            String msg =
  -                "Unexpected error occurred in 'satisfyDependencies': "
  -                    + e.getMessage();
  -            fail( msg );
  -        }
  -        Set deps1 = MockArtifactDownloader.getDownloadedDependencies();
           int expectedNumOfDownloads1 = 2;
  -        int actualNumOfDownloads1 = deps1.size();
  +        int actualNumOfDownloads1 = deps.size();
           assertEquals(
  -            "Download of unsatisfied dependicies was not requeset"
  +            "Download of snapshot dependicies was not requeset"
                   + " expected number of times",
               expectedNumOfDownloads1,
               actualNumOfDownloads1);
  
  
  

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

Reply via email to