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;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @plexus.component role="org.apache.maven.repository.reporting.ArtifactReportProcessor" role-hint="default"
|
||||||
*/
|
*/
|
||||||
public class DefaultArtifactReportProcessor
|
public class DefaultArtifactReportProcessor
|
||||||
implements ArtifactReportProcessor
|
implements ArtifactReportProcessor
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @plexus.component role-hint="default"
|
* @plexus.component role="org.apache.maven.repository.reporting.ArtifactReporter" role-hint="default"
|
||||||
*/
|
*/
|
||||||
public class DefaultArtifactReporter
|
public class DefaultArtifactReporter
|
||||||
implements ArtifactReporter
|
implements ArtifactReporter
|
||||||
|
|
|
@ -54,32 +54,29 @@ public class DuplicateArtifactFileReportProcessor
|
||||||
*/
|
*/
|
||||||
private RepositoryIndexingFactory indexFactory;
|
private RepositoryIndexingFactory indexFactory;
|
||||||
|
|
||||||
//@todo configurable?
|
|
||||||
private String algorithm = RepositoryIndex.FLD_MD5;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @plexus.requirement
|
* @plexus.requirement
|
||||||
*/
|
*/
|
||||||
private RepositoryIndexSearchLayer searchLayer;
|
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,
|
public void processArtifact( Model model, Artifact artifact, ArtifactReporter reporter,
|
||||||
ArtifactRepository repository )
|
ArtifactRepository repository )
|
||||||
throws ReportProcessorException
|
throws ReportProcessorException
|
||||||
{
|
{
|
||||||
if ( artifact.getFile() != null )
|
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;
|
RepositoryIndex index;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
index = indexFactory.createArtifactRepositoryIndex( indexPath, repository );
|
index = indexFactory.createArtifactRepositoryIndex( new File( indexDirectory ), repository );
|
||||||
}
|
}
|
||||||
catch ( RepositoryIndexException e )
|
catch ( RepositoryIndexException e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,30 +41,39 @@ public class DuplicateArtifactFileReportProcessorTest
|
||||||
|
|
||||||
private ArtifactFactory artifactFactory;
|
private ArtifactFactory artifactFactory;
|
||||||
|
|
||||||
private File indexPath = getTestFile( "target/.index" );
|
File indexDirectory;
|
||||||
|
|
||||||
protected void setUp()
|
protected void setUp()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
super.setUp();
|
super.setUp();
|
||||||
artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
|
||||||
Digester digester = (Digester) lookup( Digester.ROLE );
|
Digester digester = (Digester) lookup( Digester.ROLE );
|
||||||
|
|
||||||
reporter = new MockArtifactReporter();
|
indexDirectory = getTestFile( "target/indexDirectory" );
|
||||||
artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "1.0-alpha-1", "jar" );
|
|
||||||
model = new Model();
|
|
||||||
processor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "duplicate" );
|
|
||||||
|
|
||||||
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.indexArtifact( artifact );
|
||||||
index.optimize();
|
index.optimize();
|
||||||
index.close();
|
index.close();
|
||||||
|
|
||||||
|
processor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "duplicate" );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown()
|
protected void tearDown()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
FileUtils.deleteDirectory( indexPath );
|
//FileUtils.deleteDirectory( indexDirectory );
|
||||||
|
|
||||||
processor = null;
|
processor = null;
|
||||||
model = null;
|
model = null;
|
||||||
|
@ -132,7 +141,10 @@ public class DuplicateArtifactFileReportProcessorTest
|
||||||
assertEquals( "Check no failures", 1, reporter.getFailures() );
|
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 )
|
String type )
|
||||||
{
|
{
|
||||||
Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, version, null, type );
|
Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, version, null, type );
|
||||||
|
|
Loading…
Reference in New Issue