if searching with SearchFields with unknown repo ids do not revert to a search on all index.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1183413 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-10-14 16:32:45 +00:00
parent addd86fec7
commit 08d61568b7
2 changed files with 31 additions and 0 deletions

View File

@ -141,6 +141,13 @@ public class NexusRepositorySearch
List<String> indexingContextIds = addIndexingContexts(searchFields.getRepositories());
// if no index found in the specified one return an empty search result instead of doing a search on all index
// olamy: IMHO doesn't make sense
if (indexingContextIds == null || indexingContextIds.isEmpty() )
{
return new SearchResults();
}
BooleanQuery q = new BooleanQuery();
if ( StringUtils.isNotBlank(searchFields.getGroupId()) )
{

View File

@ -827,4 +827,28 @@ public class NexusRepositorySearchTest
assertTrue( groupIds.contains( "org.apache.felix") );
assertTrue( groupIds.contains( "org.apache.archiva" ) );
}
@Test
public void testSearchWithUnknownRepo()
throws Exception
{
createIndexContainingMoreArtifacts( true );
List<String> selectedRepos = Arrays.asList( "foo" );
SearchFields searchFields = new SearchFields();
searchFields.setClassName( "SomeClass" );
searchFields.setRepositories( selectedRepos );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 );
archivaConfigControl.replay();
SearchResults results = search.search( "user", searchFields, null );
archivaConfigControl.verify();
assertNotNull( results );
assertEquals( 0, results.getHits().size() );
}
}