]> source.dussan.org Git - archiva.git/commitdiff
o removing hardcoding in test
authorJason van Zyl <jvanzyl@apache.org>
Thu, 15 Jun 2006 06:11:48 +0000 (06:11 +0000)
committerJason van Zyl <jvanzyl@apache.org>
Thu, 15 Jun 2006 06:11:48 +0000 (06:11 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@414484 13f79535-47bb-0310-9956-ffa450edef68

maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReportProcessor.java
maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReporter.java
maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessor.java
maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessorTest.java

index e774513534fffd139fb8f81d41fb59775c329abf..b869e7e49ab6873691ee8baa2917ca4bc1ee99ad 100644 (file)
@@ -26,7 +26,7 @@ import java.util.Iterator;
 import java.util.List;
 
 /**
- * 
+ * @plexus.component role="org.apache.maven.repository.reporting.ArtifactReportProcessor" role-hint="default"
  */
 public class DefaultArtifactReportProcessor
     implements ArtifactReportProcessor
index 6136fbf4c44e3384f857e27d7b8f2c1bc2f7a06f..32b4cd7554b0bdfedf0078bf72717b143a45ed53 100644 (file)
@@ -24,7 +24,7 @@ import java.util.Iterator;
 import java.util.List;
 
 /**
- * @plexus.component role-hint="default"
+ * @plexus.component role="org.apache.maven.repository.reporting.ArtifactReporter" role-hint="default"
  */
 public class DefaultArtifactReporter
     implements ArtifactReporter
index 6c86e3ddb4ac18cbbdeba7cef0ce402087adb980..3d665553101d78e33578654ecfb0df283f6c9e78 100644 (file)
@@ -54,32 +54,29 @@ public class DuplicateArtifactFileReportProcessor
      */
     private RepositoryIndexingFactory indexFactory;
 
-    //@todo configurable?
-    private String algorithm = RepositoryIndex.FLD_MD5;
-
     /**
      * @plexus.requirement
      */
     private RepositoryIndexSearchLayer searchLayer;
 
+    /**
+     * @plexus.configuration
+     */
+    private String indexDirectory;
+
+    //@todo configurable?
+    private String algorithm = RepositoryIndex.FLD_MD5;
+
     public void processArtifact( Model model, Artifact artifact, ArtifactReporter reporter,
                                  ArtifactRepository repository )
         throws ReportProcessorException
     {
         if ( artifact.getFile() != null )
         {
-            //@todo remove hard-coded value; current value enables tests to pass!
-            File indexPath = new File( "target/.index" );
-
-            if ( !indexPath.exists() )
-            {
-                indexPath.mkdirs();
-            }
-
             RepositoryIndex index;
             try
             {
-                index = indexFactory.createArtifactRepositoryIndex( indexPath, repository );
+                index = indexFactory.createArtifactRepositoryIndex( new File( indexDirectory ), repository );
             }
             catch ( RepositoryIndexException e )
             {
index 7c6b317023eb7a94696fcfd7808b872ab4f64bcf..b7933d152af7c53fb390ecd6e7b0a7e2dafd6788 100644 (file)
@@ -41,30 +41,39 @@ public class DuplicateArtifactFileReportProcessorTest
 
     private ArtifactFactory artifactFactory;
 
-    private File indexPath = getTestFile( "target/.index" );
+    File indexDirectory;
 
     protected void setUp()
         throws Exception
     {
         super.setUp();
-        artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
+
         Digester digester = (Digester) lookup( Digester.ROLE );
 
-        reporter = new MockArtifactReporter();
+        indexDirectory = getTestFile( "target/indexDirectory" );
+
+        if ( !indexDirectory.exists() )
+        {
+            indexDirectory.mkdirs();
+        }
+
+        artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
         artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "1.0-alpha-1", "jar" );
+        reporter = new MockArtifactReporter();
         model = new Model();
-        processor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "duplicate" );
 
-        ArtifactRepositoryIndex index = new ArtifactRepositoryIndex( indexPath, repository, digester );
+        ArtifactRepositoryIndex index = new ArtifactRepositoryIndex( indexDirectory, repository, digester );
         index.indexArtifact( artifact );
         index.optimize();
         index.close();
+
+        processor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "duplicate" );
     }
 
     protected void tearDown()
         throws Exception
     {
-        FileUtils.deleteDirectory( indexPath );
+        //FileUtils.deleteDirectory( indexDirectory );
 
         processor = null;
         model = null;
@@ -132,7 +141,10 @@ public class DuplicateArtifactFileReportProcessorTest
         assertEquals( "Check no failures", 1, reporter.getFailures() );
     }
 
-    private Artifact createArtifact( String groupId, String artifactId, String baseVersion, String version,
+    private Artifact createArtifact( String groupId,
+                                     String artifactId,
+                                     String baseVersion,
+                                     String version,
                                      String type )
     {
         Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, version, null, type );