From ecb90855a173b16fffff0fb37e48a5afc85a11fe Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Fri, 9 Oct 2009 10:28:52 +0000 Subject: [PATCH] [MRM-1254] Add more unit tests for searching artifacts o added test for searching artifacts with numeric values in the artifactId using advanced search (MRM-981) git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@823505 13f79535-47bb-0310-9956-ffa450edef68 --- .../search/NexusRepositorySearchTest.java | 37 ++++++++++++++++++- .../1.0/artifactid-numeric-1.0.jar | 0 .../1.0/artifactid-numeric-1.0.pom | 17 +++++++++ .../1.0/artifactid-numeric123-1.0.jar | 0 .../1.0/artifactid-numeric123-1.0.pom | 17 +++++++++ 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 archiva-modules/archiva-base/archiva-indexer/src/test/resources/nexus-search-test-repo/com/artifactid-numeric/1.0/artifactid-numeric-1.0.jar create mode 100644 archiva-modules/archiva-base/archiva-indexer/src/test/resources/nexus-search-test-repo/com/artifactid-numeric/1.0/artifactid-numeric-1.0.pom create mode 100644 archiva-modules/archiva-base/archiva-indexer/src/test/resources/nexus-search-test-repo/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.jar create mode 100644 archiva-modules/archiva-base/archiva-indexer/src/test/resources/nexus-search-test-repo/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.pom 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 8d11c8157..fcdb2ba23 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 @@ -182,7 +182,7 @@ public class NexusRepositorySearchTest //TODO: search for class & package names } - + public void testQuickSearchWithPagination() throws Exception { @@ -425,6 +425,41 @@ public class NexusRepositorySearchTest FileUtils.deleteDirectory( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_2 + "/.indexer" ) ); assertFalse( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_2 + "/.indexer" ).exists() ); } + + // MRM-981 - artifactIds with numeric characters aren't found in advanced search + public void testAdvancedSearchArtifactIdHasNumericChar() + throws Exception + { + List files = new ArrayList(); + 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" ) ); + createIndex( TEST_REPO_1, files ); + + List selectedRepos = new ArrayList(); + selectedRepos.add( TEST_REPO_1 ); + + config.addManagedRepository( createRepositoryConfig( TEST_REPO_1 ) ); + + SearchFields searchFields = new SearchFields(); + searchFields.setArtifactId( "artifactid-numeric" ); + searchFields.setRepositories( selectedRepos ); + + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1 ); + + archivaConfigControl.replay(); + + SearchResults results = search.search( "user", searchFields, null ); + + archivaConfigControl.verify(); + + assertNotNull( results ); + assertEquals( 2, results.getTotalHits() ); + + FileUtils.deleteDirectory( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + "/.indexer" ) ); + assertFalse( new File( getBasedir(), "/target/test-classes/" + TEST_REPO_1 + "/.indexer" ).exists() ); + } // TODO: add test when an existing index already exists } diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/resources/nexus-search-test-repo/com/artifactid-numeric/1.0/artifactid-numeric-1.0.jar b/archiva-modules/archiva-base/archiva-indexer/src/test/resources/nexus-search-test-repo/com/artifactid-numeric/1.0/artifactid-numeric-1.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/resources/nexus-search-test-repo/com/artifactid-numeric/1.0/artifactid-numeric-1.0.pom b/archiva-modules/archiva-base/archiva-indexer/src/test/resources/nexus-search-test-repo/com/artifactid-numeric/1.0/artifactid-numeric-1.0.pom new file mode 100644 index 000000000..3ef0bb6c9 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/resources/nexus-search-test-repo/com/artifactid-numeric/1.0/artifactid-numeric-1.0.pom @@ -0,0 +1,17 @@ + + 4.0.0 + com + artifactid-numeric + jar + 1.0 + ArtifactID numeric - NOT + + + junit + junit + 3.8.1 + test + + + diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/resources/nexus-search-test-repo/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.jar b/archiva-modules/archiva-base/archiva-indexer/src/test/resources/nexus-search-test-repo/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/resources/nexus-search-test-repo/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.pom b/archiva-modules/archiva-base/archiva-indexer/src/test/resources/nexus-search-test-repo/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.pom new file mode 100644 index 000000000..5d87546da --- /dev/null +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/resources/nexus-search-test-repo/com/artifactid-numeric123/1.0/artifactid-numeric123-1.0.pom @@ -0,0 +1,17 @@ + + 4.0.0 + com + artifactid-numeric123 + jar + 1.0 + ArtifactID numeric + + + junit + junit + 3.8.1 + test + + +