PR: MRM-35

Submitted by: Maria Odea Ching

Added more unit tests

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@369655 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Edwin L. Punzalan 2006-01-17 03:24:59 +00:00
parent 12e8c4d60d
commit 05f70157b7
2 changed files with 54 additions and 1 deletions

View File

@ -114,7 +114,7 @@ public class MetadataRepositoryIndexingTest
*
* @throws Exception
*/
public void testSearchSingle()
public void testSearch()
throws Exception
{
createTestIndex();
@ -181,6 +181,50 @@ public class MetadataRepositoryIndexingTest
indexer.close();
}
public void testExceptions()
throws Exception
{
//test when the object passed in the index(..) method is not a RepositoryMetadat instance
RepositoryIndexingFactory factory = ( RepositoryIndexingFactory ) lookup( RepositoryIndexingFactory.ROLE );
indexer = factory.createMetadataRepositoryIndex( indexPath, repository );
try
{
Artifact artifact = getArtifact("org.apache.maven", "maven-artifact", "2.0.1");
indexer.index( artifact );
fail( "Must throw exception when the passed object is not a RepositoryMetadata object." );
}
catch( Exception e )
{
}
indexer.optimize();
indexer.close();
//test when the plugin prefix is blank
factory = ( RepositoryIndexingFactory ) lookup( RepositoryIndexingFactory.ROLE );
indexer = factory.createMetadataRepositoryIndex( indexPath, repository );
try
{
RepositoryMetadata repoMetadata = getMetadata( "test", null, null, "maven-metadata.xml", GROUP_TYPE );
indexer.index( repoMetadata );
}
catch( Exception e )
{
}
indexer.optimize();
indexer.close();
//test when the index is closed
try
{
RepositoryMetadata repoMetadata = getMetadata( "org.apache.maven", null, null, "maven-metadata.xml", GROUP_TYPE );
indexer.index( repoMetadata );
fail( "Must throw exception when a metadata is added to the index while the indexer is still closed." );
}
catch( Exception e )
{
}
}
/**
* Create RepositoryMetadata object.
*

View File

@ -0,0 +1,9 @@
<metadata>
<groupId>test</groupId>
<plugins>
<plugin>
<prefix></prefix>
<artifactId>test-test-plugin</artifactId>
</plugin>
</plugins>
</metadata>