mirror of https://github.com/apache/archiva.git
Switching to zip file for index test
This commit is contained in:
parent
7c683efd5d
commit
08a51f0eff
|
@ -201,10 +201,10 @@ public abstract class AbstractMavenRepositorySearch
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -246,9 +246,11 @@ public abstract class AbstractMavenRepositorySearch
|
|||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.archiva.indexer.maven.search;
|
|||
* 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;
|
||||
|
@ -27,7 +28,6 @@ import org.apache.archiva.indexer.search.SearchResults;
|
|||
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;
|
||||
|
@ -895,47 +895,48 @@ public class MavenRepositorySearchTest
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue