Author: brett Date: Thu Dec 29 19:41:35 2005 New Revision: 359977 URL: http://svn.apache.org/viewcvs?rev=359977&view=rev Log: move the test search index into a reproducable place - tests were failing on multiple runs without a clean
Added: maven/repository-manager/trunk/maven-repository-indexer/src/test/index/ maven/repository-manager/trunk/maven-repository-indexer/src/test/index/_2.cfs (with props) maven/repository-manager/trunk/maven-repository-indexer/src/test/index/_4.cfs (with props) maven/repository-manager/trunk/maven-repository-indexer/src/test/index/deletable (with props) maven/repository-manager/trunk/maven-repository-indexer/src/test/index/segments (with props) Modified: maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java Added: maven/repository-manager/trunk/maven-repository-indexer/src/test/index/_2.cfs URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-indexer/src/test/index/_2.cfs?rev=359977&view=auto ============================================================================== Binary file - no diff available. Propchange: maven/repository-manager/trunk/maven-repository-indexer/src/test/index/_2.cfs ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: maven/repository-manager/trunk/maven-repository-indexer/src/test/index/_4.cfs URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-indexer/src/test/index/_4.cfs?rev=359977&view=auto ============================================================================== Binary file - no diff available. Propchange: maven/repository-manager/trunk/maven-repository-indexer/src/test/index/_4.cfs ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: maven/repository-manager/trunk/maven-repository-indexer/src/test/index/deletable URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-indexer/src/test/index/deletable?rev=359977&view=auto ============================================================================== Binary file - no diff available. Propchange: maven/repository-manager/trunk/maven-repository-indexer/src/test/index/deletable ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: maven/repository-manager/trunk/maven-repository-indexer/src/test/index/segments URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-indexer/src/test/index/segments?rev=359977&view=auto ============================================================================== Binary file - no diff available. Propchange: maven/repository-manager/trunk/maven-repository-indexer/src/test/index/segments ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java?rev=359977&r1=359976&r2=359977&view=diff ============================================================================== --- maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java (original) +++ maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java Thu Dec 29 19:41:35 2005 @@ -17,17 +17,17 @@ * 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 @@ 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 @@ repository = repoFactory.createArtifactRepository( "test", repoDir, layout, null, null ); indexPath = "target/index"; + + FileUtils.deleteDirectory( indexPath ); } - + public void testIndexerExceptions() throws Exception { @@ -93,7 +106,7 @@ //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 @@ 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 @@ 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 @@ 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() ); } @@ -211,12 +224,5 @@ } return artifactFactory.createBuildArtifact( groupId, artifactId, version, "jar" ); - } - - protected void tearDown() throws Exception - { - super.tearDown(); - - //release( indexer ); } }