}
protected void createIndex( String repository, List<Path> filesToBeIndexed, boolean scan) throws Exception {
- createIndex(repository, filesToBeIndexed, scan, null);
+ createIndex(repository, filesToBeIndexed, scan, null, true);
}
- protected void createIndex( String repository, List<Path> filesToBeIndexed, boolean scan, Path indexDir)
+ protected void createIndex( String repository, List<Path> filesToBeIndexed, boolean scan, Path indexDir, boolean copyFiles)
throws Exception
{
Repository rRepo = repositoryRegistry.getRepository(repository);
icf.setIndexPath(indexDir.toUri());
}
- Path repo = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + repository );
- assertTrue( Files.exists(repo) );
- org.apache.commons.io.FileUtils.copyDirectory(repo.toFile(), repoDir.toFile());
+ if (copyFiles) {
+ Path repo = Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "src/test/" + repository);
+ assertTrue(Files.exists(repo));
+ org.apache.commons.io.FileUtils.copyDirectory(repo.toFile(), repoDir.toFile());
+ }
* under the License.
*/
+import org.apache.archiva.common.utils.FileUtils;
import org.apache.archiva.indexer.search.RepositorySearchException;
import org.apache.archiva.indexer.search.SearchFields;
import org.apache.archiva.indexer.search.SearchResultHit;
import org.apache.archiva.indexer.util.SearchUtil;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.maven.index_shaded.lucene.index.IndexUpgrader;
-import org.codehaus.plexus.util.FileUtils;
import org.easymock.EasyMock;
import org.junit.Test;
import org.junit.runner.RunWith;
throws Exception
{
- Path repo = Paths.get( "target/repo-release" );
- FileUtils.deleteDirectory(repo.toFile());
- Path indexDirectory = repo.resolve(".indexer" );
- FileUtils.copyDirectoryStructure( Paths.get( "src/test/repo-release" ).toFile(), repo.toFile() );
-
- IndexUpgrader.main( new String[]{ indexDirectory.toAbsolutePath().toString() } );
-
- createIndex(REPO_RELEASE, Collections.emptyList(), false, indexDirectory );
+ Path repo = Paths.get("target/repo-release");
+ try {
+ Path indexDirectory = repo.resolve(".indexer");
+ Path zipFile = Paths.get(Thread.currentThread().getContextClassLoader().getResource("repo-release.zip").toURI());
+ FileUtils.unzip(zipFile, repo.getParent());
+ IndexUpgrader.main(new String[]{indexDirectory.toAbsolutePath().toString()});
+ createIndex(REPO_RELEASE, Collections.emptyList(), false, indexDirectory, false);
// indexer.addIndexingContext( REPO_RELEASE, REPO_RELEASE, repo.toFile(), indexDirectory.toFile(),
// repo.toUri().toURL().toExternalForm(),
// indexDirectory.toUri().toURL().toString(), indexCreators );
+ SearchResultLimits limits = new SearchResultLimits(SearchResultLimits.ALL_PAGES);
+ limits.setPageSize(300);
- SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES );
- limits.setPageSize( 300 );
+ // EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
+ EasyMock.expect(archivaConfig.getConfiguration()).andReturn(config).anyTimes();
- // EasyMock.expect( archivaConfig.getDefaultLocale() ).andReturn( Locale.getDefault( ) ).anyTimes();
- EasyMock.expect( archivaConfig.getConfiguration()).andReturn(config).anyTimes();
+ archivaConfigControl.replay();
- archivaConfigControl.replay();
+ SearchResults searchResults = search.search(null, Arrays.asList(REPO_RELEASE), //
+ "org.example", limits, //
+ Collections.emptyList());
- SearchResults searchResults = search.search( null, Arrays.asList( REPO_RELEASE ), //
- "org.example", limits, //
- Collections.emptyList() );
+ log.info("results: {}", searchResults.getHits().size());
- log.info( "results: {}", searchResults.getHits().size() );
+ assertEquals(255, searchResults.getHits().size());
- assertEquals( 255, searchResults.getHits().size() );
+ SearchFields searchFields = new SearchFields();
+ searchFields.setGroupId("org.example");
+ searchFields.setRepositories(Arrays.asList(REPO_RELEASE));
- SearchFields searchFields = new SearchFields();
- searchFields.setGroupId( "org.example" );
- searchFields.setRepositories( Arrays.asList( REPO_RELEASE ) );
-
- searchResults = search.search( null, searchFields, limits );
+ searchResults = search.search(null, searchFields, limits);
- log.info( "results: {}", searchResults.getHits().size() );
+ log.info("results: {}", searchResults.getHits().size());
- assertEquals( 255, searchResults.getHits().size() );
+ assertEquals(255, searchResults.getHits().size());
- archivaConfigControl.verify();
+ archivaConfigControl.verify();
+ } finally {
+ FileUtils.deleteQuietly(repo);
+ }
}
}