mirror of https://github.com/apache/archiva.git
o removing hardcoding in test
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@414484 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
369ed5bd43
commit
0cf3828abb
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue