//TODO: search for class & package names
}
+ // search for existing artifact using multiple keywords
+ public void testQuickSearchWithMultipleKeywords()
+ throws Exception
+ {
+ createIndexForQuickSearch();
+
+ List<String> selectedRepos = new ArrayList<String>();
+ selectedRepos.add( TEST_REPO_1 );
+
+ archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
+ archivaConfigControl.replay();
+
+ SearchResults results = search.search( "user", selectedRepos, "archiva search", null, null );
+
+ archivaConfigControl.verify();
+
+ assertNotNull( results );
+ assertEquals( 0, results.getTotalHits() );
+ }
+
public void testQuickSearchWithPagination()
throws Exception
{
}
}
+ public void testAdvancedSearchAllSearchCriteriaSpecified()
+ throws Exception
+ {
+ List<File> files = new ArrayList<File>();
+ 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 );
+
+ List<String> selectedRepos = new ArrayList<String>();
+ selectedRepos.add( TEST_REPO_1 );
+
+ SearchFields searchFields = new SearchFields();
+ searchFields.setGroupId( "org.apache.archiva" );
+ searchFields.setArtifactId( "archiva-test" );
+ searchFields.setVersion( "2.0" );
+ searchFields.setPackaging( "jar" );
+ searchFields.setClassName( "org.apache.archiva.test.App" );
+ searchFields.setRepositories( selectedRepos );
+
+ archivaConfigControl.expectAndDefaultReturn( archivaConfig.getConfiguration(), config );
+
+ archivaConfigControl.replay();
+
+ SearchResults results = search.search( "user", searchFields, null );
+
+ archivaConfigControl.verify();
+
+ assertNotNull( results );
+
+ assertEquals( 1, results.getTotalHits() );
+
+ SearchResultHit hit = results.getHits().get( 0 );
+ assertEquals( "org.apache.archiva", hit.getGroupId() );
+ assertEquals( "archiva-test", hit.getArtifactId() );
+ assertEquals( "2.0", hit.getVersions().get( 0 ) );
+ }
+
public void testAdvancedSearchJarArtifacts()
throws Exception
{
assertEquals( 5, results.getTotalHits() );
}
+ public void testAdvancedSearchWithIncorrectPackaging()
+ throws Exception
+ {
+ List<File> files = new ArrayList<File>();
+ 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 );
+
+ List<String> selectedRepos = new ArrayList<String>();
+ selectedRepos.add( TEST_REPO_1 );
+
+ SearchFields searchFields = new SearchFields();
+ searchFields.setGroupId( "org.apache.archiva" );
+ searchFields.setArtifactId( "archiva-test" );
+ searchFields.setVersion( "2.0" );
+ searchFields.setPackaging( "war" );
+ searchFields.setRepositories( selectedRepos );
+
+ archivaConfigControl.expectAndDefaultReturn( archivaConfig.getConfiguration(), config );
+ archivaConfigControl.replay();
+
+ SearchResults results = search.search( "user", searchFields, null );
+
+ archivaConfigControl.verify();
+
+ assertNotNull( results );
+ assertEquals( 0, results.getTotalHits() );
+ }
+
public void testAdvancedSearchClassname()
throws Exception
{
clickLinkWithText( getProperty( "ARTIFACT_VERSION" ) + "/" );
assertPage( "Apache Archiva \\ Browse Repository" );
}
+
+ public void testSearchWithMultipleKeywords()
+ {
+ String groupId = getProperty( "ADD_REMOVE_GROUPID" );
+ String version = getProperty( "SNAPSHOT_VERSION" );
+ String packaging = getProperty( "SNAPSHOT_PACKAGING" );
+ String filePath = getProperty( "SNAPSHOT_ARTIFACTFILEPATH" );
+ String repoId = getProperty( "SNAPSHOT_REPOSITORYID" );
+
+ String existingArtifactId = getProperty( "ADD_REMOVE_ARTIFACTID" );
+ String multiKeywords = existingArtifactId.replace( "-", " " );
+
+ addArtifact( groupId, existingArtifactId, version, packaging, filePath, repoId );
+
+ // verify artifact is existing
+ searchForArtifact( existingArtifactId );
+ assertTextPresent( "Results" );
+ assertTextPresent( "Hits: 1 to 1 of 1" );
+ assertLinkPresent( existingArtifactId );
+
+ // search for existing artifact using multiple keywords
+ searchForArtifact( multiKeywords );
+ assertTextPresent( "No results found" );
+ }
public void testSearchNonExistingArtifactInAdvancedSearch()
{
assertLinkPresent( "test" );
}
+ public void testSearchExistingArtifactAllCriteriaSpecifiedInAdvancedSearch()
+ {
+ searchForArtifactAdvancedSearch( getProperty( "GROUPID" ), getProperty( "ARTIFACT_ARTIFACTID" ) , getProperty( "ARTIFACT_VERSION" ),
+ getProperty( "REPOSITORYID" ), getProperty( "ARTIFACT_CLASSNAME" ), null );
+ assertTextPresent( "Results" );
+ assertTextPresent( "Hits: 1 to 1 of 1" );
+ assertLinkPresent( "test" );
+ }
+
public void testSearchExistingArtifactUsingAdvancedSearchNotInRepository()
{
searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null, "snapshots", null, null );