[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
This commit is contained in:
Maria Odea B. Ching 2009-10-09 10:28:52 +00:00
parent 3390708c18
commit ecb90855a1
5 changed files with 70 additions and 1 deletions

View File

@ -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<File> files = new ArrayList<File>();
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<String> selectedRepos = new ArrayList<String>();
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
}

View File

@ -0,0 +1,17 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com</groupId>
<artifactId>artifactid-numeric</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>ArtifactID numeric - NOT</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,17 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com</groupId>
<artifactId>artifactid-numeric123</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>ArtifactID numeric</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>