diff options
author | Maria Odea B. Ching <oching@apache.org> | 2009-10-12 08:44:10 +0000 |
---|---|---|
committer | Maria Odea B. Ching <oching@apache.org> | 2009-10-12 08:44:10 +0000 |
commit | 88f79fe1e7688750f3236feb71a5288e6891abe1 (patch) | |
tree | 8cc1ba715373a9cd1dcfcdc169b093e6fff8bb22 /archiva-modules | |
parent | 16b13f831a1d41139e59bdeb89086357e88bf70a (diff) | |
download | archiva-88f79fe1e7688750f3236feb71a5288e6891abe1.tar.gz archiva-88f79fe1e7688750f3236feb71a5288e6891abe1.zip |
[MRM-1080] Update SearchServiceImplTest so that it uses the new search API
submitted by Gwen Harold Autencio
o added tests for quick search (with search hits and with no search hits)
additional changes to the patch:
o updated testQuickSearchArtifactRegularSearch() to conform to the recent changes in SearchServiceImpl from MRM-1230
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@824259 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules')
-rw-r--r-- | archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java | 120 |
1 files changed, 77 insertions, 43 deletions
diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java index e83c685cf..6f28bf008 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java @@ -272,49 +272,83 @@ public class SearchServiceImplTest // assertNotNull( artifacts ); // assertEquals( 1, artifacts.size() ); // } -// -// public void testQuickSearchArtifactRegularSearch() -// throws Exception -// { -// List<String> observableRepoIds = new ArrayList<String>(); -// observableRepoIds.add( "repo1.mirror" ); -// observableRepoIds.add( "public.releases" ); -// -// userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds ); -// -// Date whenGathered = new Date(); -// SearchResults results = new SearchResults(); -// ArchivaArtifact artifact = new ArchivaArtifact( "org.apache.archiva", "archiva-test", "1.0", "", "jar", "public.releases" ); -// artifact.getModel().setWhenGathered( whenGathered ); -// -// -// SearchResultHit resultHit = new SearchResultHit(); -// resultHit.setArtifact(artifact); -// resultHit.setRepositoryId("repo1.mirror"); -// results.addHit(SearchUtil.getHitId(artifact.getGroupId(), artifact.getArtifactId()), resultHit); -// -// SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES ); -// -// searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ), results ); -// -// archivaDAOControl.expectAndReturn( archivaDAO.getArtifactDAO(), artifactDAO ); -// artifactDAOControl.expectAndReturn( artifactDAO.getArtifact( "org.apache.archiva", "archiva-test", "1.0", "", "pom", "public.releases" ), artifact ); -// -// userReposControl.replay(); -// searchControl.replay(); -// archivaDAOControl.replay(); -// artifactDAOControl.replay(); -// -// List<Artifact> artifacts = searchService.quickSearch( "archiva" ); -// -// userReposControl.verify(); -// searchControl.verify(); -// archivaDAOControl.verify(); -// artifactDAOControl.verify(); -// -// assertNotNull( artifacts ); -// assertEquals( 1, artifacts.size() ); -// } + + public void testQuickSearchArtifactRegularSearch() + throws Exception + { + List<String> observableRepoIds = new ArrayList<String>(); + observableRepoIds.add( "repo1.mirror" ); + observableRepoIds.add( "public.releases" ); + + userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds ); + + SearchResults results = new SearchResults(); + List<String> versions = new ArrayList<String>(); + versions.add( "1.0" ); + + SearchResultHit resultHit = new SearchResultHit(); + resultHit.setGroupId( "org.apache.archiva" ); + resultHit.setArtifactId( "archiva-test" ); + resultHit.setVersions( versions ); + resultHit.setRepositoryId("repo1.mirror"); + + results.addHit( SearchUtil.getHitId( resultHit.getGroupId(), resultHit.getArtifactId() ), resultHit ); + + archivaDAOControl.expectAndReturn( archivaDAO.query( new UniqueVersionConstraint( observableRepoIds, resultHit.getGroupId(), + resultHit.getArtifactId() ) ), null ); + + SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES ); + + searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ), results ); + + ArchivaProjectModel model = new ArchivaProjectModel(); + model.setGroupId( "org.apache.archiva" ); + model.setArtifactId( "archiva-test" ); + model.setVersion( "1.0" ); + model.setPackaging( "jar" ); + + repoBrowsingControl.expectAndReturn( repoBrowsing.selectVersion( "", observableRepoIds, "org.apache.archiva", "archiva-test", "1.0" ), model ); + + userReposControl.replay(); + searchControl.replay(); + archivaDAOControl.replay(); + repoBrowsingControl.replay(); + + List<Artifact> artifacts = searchService.quickSearch( "archiva" ); + + userReposControl.verify(); + searchControl.verify(); + archivaDAOControl.verify(); + repoBrowsingControl.verify(); + + assertNotNull( artifacts ); + assertEquals( 1, artifacts.size() ); + } + + public void testQuickSearchNoResults( ) + throws Exception + { + List<String> observableRepoIds = new ArrayList<String>(); + observableRepoIds.add( "repo1.mirror" ); + observableRepoIds.add( "public.releases" ); + + userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds ); + + SearchResults results = new SearchResults(); + SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES ); + + searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "non-existent", limits, null ), results ); + userReposControl.replay(); + searchControl.replay(); + + List<Artifact> artifacts = searchService.quickSearch( "test" ); + + userReposControl.verify(); + searchControl.verify(); + + assertNotNull( artifacts ); + assertEquals( 0, artifacts.size() ); + } /* query artifact by checksum */ |