From 0cf3828abbc6f478dc5f56a38c2ceb4a3f7e3bc1 Mon Sep 17 00:00:00 2001 From: Jason van Zyl Date: Thu, 15 Jun 2006 06:11:48 +0000 Subject: [PATCH] o removing hardcoding in test git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@414484 13f79535-47bb-0310-9956-ffa450edef68 --- .../DefaultArtifactReportProcessor.java | 2 +- .../reporting/DefaultArtifactReporter.java | 2 +- .../DuplicateArtifactFileReportProcessor.java | 21 ++++++------- ...licateArtifactFileReportProcessorTest.java | 30 +++++++++++++------ 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReportProcessor.java b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReportProcessor.java index e77451353..b869e7e49 100644 --- a/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReportProcessor.java +++ b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReportProcessor.java @@ -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 diff --git a/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReporter.java b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReporter.java index 6136fbf4c..32b4cd755 100644 --- a/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReporter.java +++ b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReporter.java @@ -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 diff --git a/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessor.java b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessor.java index 6c86e3ddb..3d6655531 100644 --- a/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessor.java +++ b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessor.java @@ -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 ) { diff --git a/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessorTest.java b/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessorTest.java index 7c6b31702..b7933d152 100644 --- a/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessorTest.java +++ b/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessorTest.java @@ -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(); - artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "1.0-alpha-1", "jar" ); - model = new Model(); - processor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "duplicate" ); + indexDirectory = getTestFile( "target/indexDirectory" ); - ArtifactRepositoryIndex index = new ArtifactRepositoryIndex( indexPath, repository, digester ); + 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(); + + 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 );