From 158fea721bd8e57fde4dbc16aa3d1d9703f01d24 Mon Sep 17 00:00:00 2001 From: "Jevica Arianne B. Zurbano" Date: Sat, 15 May 2010 14:41:11 +0000 Subject: [PATCH] * moved the creation of index into its own method * renamed createIndexForQuickSearch to createSimpleIndex to be used in Advanced Search tests git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@944651 13f79535-47bb-0310-9956-ffa450edef68 --- .../search/NexusRepositorySearchTest.java | 110 ++++++------------ 1 file changed, 34 insertions(+), 76 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java index fc03763a9..f180ab0d6 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java @@ -86,7 +86,7 @@ public class NexusRepositorySearchTest config.addManagedRepository( createRepositoryConfig( TEST_REPO_2 ) ); } - private void createIndexForQuickSearch() + private void createSimpleIndex() throws IOException, UnsupportedExistingLuceneIndexException, IllegalArtifactCoordinateException { List files = new ArrayList(); @@ -99,6 +99,28 @@ public class NexusRepositorySearchTest createIndex( TEST_REPO_1, files ); } + + private void createIndexContainingMoreArtifacts() + throws IOException, UnsupportedExistingLuceneIndexException, IllegalArtifactCoordinateException + { + List files = new ArrayList(); + files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + + "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) ); + files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + + "/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar" ) ); + files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + + "/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar" ) ); + files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + + "/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.war" ) ); + files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + + "/com/artifactid-numeric/1.0/artifactid-numeric-1.0.jar" ) ); + files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + + "/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.jar" ) ); + files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + + "/com/classname-search/1.0/classname-search-1.0.jar" ) ); + + createIndex( TEST_REPO_1, files ); + } private ManagedRepositoryConfiguration createRepositoryConfig( String repository ) { @@ -156,7 +178,7 @@ public class NexusRepositorySearchTest public void testQuickSearch() throws Exception { - createIndexForQuickSearch(); + createSimpleIndex(); List selectedRepos = new ArrayList(); selectedRepos.add( TEST_REPO_1 ); @@ -199,7 +221,7 @@ public class NexusRepositorySearchTest public void testQuickSearchWithMultipleKeywords() throws Exception { - createIndexForQuickSearch(); + createSimpleIndex(); List selectedRepos = new ArrayList(); selectedRepos.add( TEST_REPO_1 ); @@ -218,7 +240,7 @@ public class NexusRepositorySearchTest public void testQuickSearchWithPagination() throws Exception { - createIndexForQuickSearch(); + createSimpleIndex(); List selectedRepos = new ArrayList(); selectedRepos.add( TEST_REPO_1 ); @@ -263,7 +285,7 @@ public class NexusRepositorySearchTest public void testArtifactFoundInMultipleRepositories() throws Exception { - createIndexForQuickSearch(); + createSimpleIndex(); List files = new ArrayList(); files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_2 + @@ -304,7 +326,7 @@ public class NexusRepositorySearchTest public void testNoMatchFound() throws Exception { - createIndexForQuickSearch(); + createSimpleIndex(); List selectedRepos = new ArrayList(); selectedRepos.add( TEST_REPO_1 ); @@ -358,7 +380,7 @@ public class NexusRepositorySearchTest public void testSearchWithinSearchResults() throws Exception { - createIndexForQuickSearch(); + createSimpleIndex(); List selectedRepos = new ArrayList(); selectedRepos.add( TEST_REPO_1 ); @@ -424,23 +446,7 @@ public class NexusRepositorySearchTest public void testAdvancedSearchWithPagination() throws Exception { - List files = new ArrayList(); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.war" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/com/artifactid-numeric/1.0/artifactid-numeric-1.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/com/classname-search/1.0/classname-search-1.0.jar" ) ); - - createIndex( TEST_REPO_1, files ); + createIndexContainingMoreArtifacts(); List selectedRepos = new ArrayList(); selectedRepos.add( TEST_REPO_1 ); @@ -596,15 +602,7 @@ public class NexusRepositorySearchTest public void testAdvancedSearchAllSearchCriteriaSpecified() throws Exception { - List files = new ArrayList(); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar" ) ); - - createIndex( TEST_REPO_1, files ); + createSimpleIndex(); List selectedRepos = new ArrayList(); selectedRepos.add( TEST_REPO_1 ); @@ -638,23 +636,7 @@ public class NexusRepositorySearchTest public void testAdvancedSearchJarArtifacts() throws Exception { - List files = new ArrayList(); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.war" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/com/artifactid-numeric/1.0/artifactid-numeric-1.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/com/classname-search/1.0/classname-search-1.0.jar" ) ); - - createIndex( TEST_REPO_1, files ); + createIndexContainingMoreArtifacts(); List selectedRepos = new ArrayList(); selectedRepos.add( TEST_REPO_1 ); @@ -678,15 +660,7 @@ public class NexusRepositorySearchTest public void testAdvancedSearchWithIncorrectPackaging() throws Exception { - List files = new ArrayList(); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar" ) ); - - createIndex( TEST_REPO_1, files ); + createSimpleIndex(); List selectedRepos = new ArrayList(); selectedRepos.add( TEST_REPO_1 ); @@ -712,23 +686,7 @@ public class NexusRepositorySearchTest public void testAdvancedSearchClassname() throws Exception { - List files = new ArrayList(); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.war" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/com/artifactid-numeric/1.0/artifactid-numeric-1.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.jar" ) ); - files.add( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + - "/com/classname-search/1.0/classname-search-1.0.jar" ) ); - - createIndex( TEST_REPO_1, files ); + createIndexContainingMoreArtifacts(); List selectedRepos = new ArrayList(); selectedRepos.add( TEST_REPO_1 ); -- 2.39.5