Switching to zip file for index test

This commit is contained in:
Martin Stockhammer 2019-10-14 21:43:23 +02:00
parent 7c683efd5d
commit 08a51f0eff
17 changed files with 35 additions and 32 deletions

View File

@ -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());
}
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());
}

View File

@ -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;
@ -896,20 +896,18 @@ public class MavenRepositorySearchTest
{
Path repo = Paths.get("target/repo-release");
FileUtils.deleteDirectory(repo.toFile());
try {
Path indexDirectory = repo.resolve(".indexer");
FileUtils.copyDirectoryStructure( Paths.get( "src/test/repo-release" ).toFile(), repo.toFile() );
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 );
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);
@ -937,5 +935,8 @@ public class MavenRepositorySearchTest
assertEquals(255, searchResults.getHits().size());
archivaConfigControl.verify();
} finally {
FileUtils.deleteQuietly(repo);
}
}
}