]> source.dussan.org Git - archiva.git/commitdiff
Switching to zip file for index test
authorMartin Stockhammer <martin_s@apache.org>
Mon, 14 Oct 2019 19:43:23 +0000 (21:43 +0200)
committerMartin Stockhammer <martin_s@apache.org>
Mon, 14 Oct 2019 19:43:23 +0000 (21:43 +0200)
17 files changed:
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/java/org/apache/archiva/indexer/maven/search/AbstractMavenRepositorySearch.java
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/java/org/apache/archiva/indexer/maven/search/MavenRepositorySearchTest.java
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.fdt [deleted file]
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.fdx [deleted file]
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.fnm [deleted file]
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.nvd [deleted file]
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.nvm [deleted file]
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.si [deleted file]
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8_Lucene41_0.doc [deleted file]
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8_Lucene41_0.pos [deleted file]
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8_Lucene41_0.tim [deleted file]
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8_Lucene41_0.tip [deleted file]
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/segments.gen [deleted file]
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/segments_9 [deleted file]
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/timestamp [deleted file]
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/write.lock [deleted file]
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/resources/repo-release.zip [new file with mode: 0644]

index 91669c5de627b54c2a4c4b5d5f93cbd34c88c0ca..542681e421cfff31ea6d8dd873449b0636706c7e 100644 (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());
         }
-        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());
+        }
 
 
 
index 261c1f76577ce8d78e4c7444fee1748c8cfb4406..40914faea4ec0d65234d79489b43198fff55fbbe 100644 (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;
@@ -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);
+        }
     }
 }
diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.fdt b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.fdt
deleted file mode 100644 (file)
index 9ab6d4d..0000000
Binary files a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.fdt and /dev/null differ
diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.fdx b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.fdx
deleted file mode 100644 (file)
index a26fbfa..0000000
Binary files a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.fdx and /dev/null differ
diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.fnm b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.fnm
deleted file mode 100644 (file)
index b9f9243..0000000
Binary files a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.fnm and /dev/null differ
diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.nvd b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.nvd
deleted file mode 100644 (file)
index d832c2f..0000000
Binary files a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.nvd and /dev/null differ
diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.nvm b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.nvm
deleted file mode 100644 (file)
index a27cff8..0000000
Binary files a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.nvm and /dev/null differ
diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.si b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.si
deleted file mode 100644 (file)
index 2539c76..0000000
Binary files a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8.si and /dev/null differ
diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8_Lucene41_0.doc b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8_Lucene41_0.doc
deleted file mode 100644 (file)
index 0a2394b..0000000
Binary files a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8_Lucene41_0.doc and /dev/null differ
diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8_Lucene41_0.pos b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8_Lucene41_0.pos
deleted file mode 100644 (file)
index 4d9bbaa..0000000
Binary files a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8_Lucene41_0.pos and /dev/null differ
diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8_Lucene41_0.tim b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8_Lucene41_0.tim
deleted file mode 100644 (file)
index ac84752..0000000
Binary files a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8_Lucene41_0.tim and /dev/null differ
diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8_Lucene41_0.tip b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8_Lucene41_0.tip
deleted file mode 100644 (file)
index d94d9c9..0000000
Binary files a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/_8_Lucene41_0.tip and /dev/null differ
diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/segments.gen b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/segments.gen
deleted file mode 100644 (file)
index 077a451..0000000
Binary files a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/segments.gen and /dev/null differ
diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/segments_9 b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/segments_9
deleted file mode 100644 (file)
index a01b84f..0000000
Binary files a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/segments_9 and /dev/null differ
diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/timestamp b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/timestamp
deleted file mode 100644 (file)
index 9028164..0000000
Binary files a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/timestamp and /dev/null differ
diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/write.lock b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/repo-release/.indexer/write.lock
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/resources/repo-release.zip b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/resources/repo-release.zip
new file mode 100644 (file)
index 0000000..027e68e
Binary files /dev/null and b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/resources/repo-release.zip differ