mirror of https://github.com/apache/archiva.git
move the test search index into a reproducable place - tests were failing on multiple runs without a clean
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@359977 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d31500ce00
commit
721adc94cc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -17,17 +17,17 @@ package org.apache.maven.repository.indexing;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -36,18 +36,29 @@ public class ArtifactRepositoryIndexingTest
|
|||
extends PlexusTestCase
|
||||
{
|
||||
private static final String GROUPID = "groupId";
|
||||
|
||||
private static final String ARTIFACTID = "artifactId";
|
||||
private static final String VERSION = "version";
|
||||
private static final String SHA1 = "sha1";
|
||||
|
||||
private static final String VERSION = "version";
|
||||
|
||||
private static final String SHA1 = "sha1";
|
||||
|
||||
private static final String MD5 = "md5";
|
||||
|
||||
private static final String CLASSES = "classes";
|
||||
|
||||
private static final String PACKAGES = "packages";
|
||||
|
||||
private static final String FILES = "files";
|
||||
|
||||
protected ArtifactRepositoryIndex indexer;
|
||||
|
||||
protected ArtifactFactory artifactFactory;
|
||||
|
||||
protected ArtifactRepository repository;
|
||||
|
||||
protected String indexPath;
|
||||
|
||||
private RepositoryIndexSearcher repoSearcher;
|
||||
|
||||
protected void setUp()
|
||||
|
@ -62,8 +73,10 @@ public class ArtifactRepositoryIndexingTest
|
|||
repository = repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );
|
||||
|
||||
indexPath = "target/index";
|
||||
|
||||
FileUtils.deleteDirectory( indexPath );
|
||||
}
|
||||
|
||||
|
||||
public void testIndexerExceptions()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -93,7 +106,7 @@ public class ArtifactRepositoryIndexingTest
|
|||
|
||||
//indexer = (ArtifactRepositoryIndex) factory.getArtifactRepositoryIndexer( indexPath, repository );
|
||||
//indexer.close();
|
||||
indexer = (ArtifactRepositoryIndex) lookup( ArtifactRepositoryIndex.ROLE, "artifact" );
|
||||
indexer = (ArtifactRepositoryIndex) lookup( RepositoryIndex.ROLE, "artifact" );
|
||||
Artifact artifact = getArtifact( "test", "test-artifactId", "1.0" );
|
||||
artifact.setFile( new File( repository.getBasedir(), repository.pathOf( artifact ) ) );
|
||||
|
||||
|
@ -102,41 +115,41 @@ public class ArtifactRepositoryIndexingTest
|
|||
indexer.indexArtifact( artifact );
|
||||
fail( "Must throw exception on add index with closed index." );
|
||||
}
|
||||
catch( RepositoryIndexException e )
|
||||
catch ( RepositoryIndexException e )
|
||||
{
|
||||
//expected
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
indexer.optimize();
|
||||
fail( "Must throw exception on optimize index with closed index." );
|
||||
}
|
||||
catch( RepositoryIndexException e )
|
||||
catch ( RepositoryIndexException e )
|
||||
{
|
||||
//expected
|
||||
}
|
||||
|
||||
|
||||
indexer.open( indexPath );
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
indexer.index( "should fail" );
|
||||
fail( "Must throw exception on add non-Artifact object." );
|
||||
}
|
||||
catch( RepositoryIndexException e )
|
||||
catch ( RepositoryIndexException e )
|
||||
{
|
||||
//expected
|
||||
}
|
||||
|
||||
|
||||
indexer.close();
|
||||
}
|
||||
|
||||
|
||||
public void testIndex()
|
||||
throws Exception
|
||||
{
|
||||
//indexer = (ArtifactRepositoryIndex) factory.getArtifactRepositoryIndexer( indexPath, repository );
|
||||
indexer = (ArtifactRepositoryIndex) lookup( ArtifactRepositoryIndex.ROLE, "artifact" );
|
||||
indexer = (ArtifactRepositoryIndex) lookup( RepositoryIndex.ROLE, "artifact" );
|
||||
indexer.open( indexPath );
|
||||
|
||||
Artifact artifact = getArtifact( "org.apache.maven", "maven-artifact", "2.0.1" );
|
||||
|
@ -146,7 +159,7 @@ public class ArtifactRepositoryIndexingTest
|
|||
artifact = getArtifact( "org.apache.maven", "maven-model", "2.0" );
|
||||
artifact.setFile( new File( repository.getBasedir(), repository.pathOf( artifact ) ) );
|
||||
indexer.indexArtifact( artifact );
|
||||
|
||||
|
||||
indexer.optimize();
|
||||
indexer.close();
|
||||
|
||||
|
@ -156,49 +169,49 @@ public class ArtifactRepositoryIndexingTest
|
|||
indexer.index( artifact );
|
||||
indexer.close();
|
||||
}
|
||||
|
||||
|
||||
public void testSearch()
|
||||
throws Exception
|
||||
{
|
||||
indexer = (ArtifactRepositoryIndex) lookup( ArtifactRepositoryIndex.ROLE, "artifact" );
|
||||
indexer.open( indexPath );
|
||||
indexer = (ArtifactRepositoryIndex) lookup( RepositoryIndex.ROLE, "artifact" );
|
||||
indexer.open( getTestPath( "src/test/index" ) );
|
||||
|
||||
//repoSearcher = new ArtifactRepositoryIndexSearcher( indexer, indexPath, repository );
|
||||
repoSearcher = (ArtifactRepositoryIndexSearcher) lookup( RepositoryIndexSearcher.ROLE, "artifact" );
|
||||
|
||||
repoSearcher = (RepositoryIndexSearcher) lookup( RepositoryIndexSearcher.ROLE, "artifact" );
|
||||
|
||||
List artifacts = repoSearcher.search( indexer, "test", GROUPID );
|
||||
assertEquals( 1, artifacts.size() );
|
||||
|
||||
artifacts = repoSearcher.search( indexer, "test", ARTIFACTID);
|
||||
|
||||
artifacts = repoSearcher.search( indexer, "test", ARTIFACTID );
|
||||
assertEquals( 1, artifacts.size() );
|
||||
|
||||
artifacts = repoSearcher.search( indexer, "1.0", VERSION);
|
||||
|
||||
artifacts = repoSearcher.search( indexer, "1.0", VERSION );
|
||||
assertEquals( 1, artifacts.size() );
|
||||
|
||||
artifacts = repoSearcher.search( indexer, "App", CLASSES);
|
||||
|
||||
artifacts = repoSearcher.search( indexer, "App", CLASSES );
|
||||
assertEquals( 1, artifacts.size() );
|
||||
|
||||
artifacts = repoSearcher.search( indexer, "groupId", PACKAGES);
|
||||
|
||||
artifacts = repoSearcher.search( indexer, "groupId", PACKAGES );
|
||||
assertEquals( 1, artifacts.size() );
|
||||
|
||||
artifacts = repoSearcher.search( indexer, "pom.xml", FILES);
|
||||
|
||||
artifacts = repoSearcher.search( indexer, "pom.xml", FILES );
|
||||
assertEquals( 3, artifacts.size() );
|
||||
|
||||
for( Iterator iter = artifacts.iterator(); iter.hasNext(); )
|
||||
for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) iter.next();
|
||||
File f = artifact.getFile();
|
||||
Artifact artifact = (Artifact) iter.next();
|
||||
File f = artifact.getFile();
|
||||
//assertNotNull( f );
|
||||
//assertTrue( f.exists() );
|
||||
//assertTrue( f.exists() );
|
||||
}
|
||||
|
||||
artifacts = repoSearcher.search( indexer, "org.apache.maven", GROUPID);
|
||||
|
||||
artifacts = repoSearcher.search( indexer, "org.apache.maven", GROUPID );
|
||||
assertEquals( 2, artifacts.size() );
|
||||
|
||||
artifacts = repoSearcher.search( indexer, "maven-artifact", ARTIFACTID);
|
||||
|
||||
artifacts = repoSearcher.search( indexer, "maven-artifact", ARTIFACTID );
|
||||
assertEquals( 1, artifacts.size() );
|
||||
|
||||
artifacts = repoSearcher.search( indexer, "2", VERSION);
|
||||
|
||||
artifacts = repoSearcher.search( indexer, "2", VERSION );
|
||||
assertEquals( 2, artifacts.size() );
|
||||
}
|
||||
|
||||
|
@ -212,11 +225,4 @@ public class ArtifactRepositoryIndexingTest
|
|||
|
||||
return artifactFactory.createBuildArtifact( groupId, artifactId, version, "jar" );
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
super.tearDown();
|
||||
|
||||
//release( indexer );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue