On 07/08/2009, at 7:00 AM, [email protected] wrote:
+ public void testResolveSnapshotUniqueVersionPresent()
+ throws Exception
+ {
+ VersionedReference ref = new VersionedReference();
+ ref.setGroupId( "org.apache.archiva" );
+ ref.setArtifactId( "unique-version" );
+ ref.setVersion( "1.0-SNAPSHOT" );
+
+ try
+ {
+ ArchivaProjectModel model =
resolver.resolveProjectModel( ref );
+
+ assertNotNull( model );
+ assertEquals( "org.apache.archiva", model.getGroupId() );
+ assertEquals( "unique-version", model.getArtifactId() );
+ assertEquals( "1.0-SNAPSHOT", model.getVersion() );
+ assertEquals( "Unique Version Snapshot - Build 3",
model.getName() );
+ }
+ catch ( Exception e )
+ {
+ fail( "The latest timestamp should have been found!" );
+ }
+ }
Isn't leting the method throw this exception sufficient?
+ public void testResolveNotFound()
+ throws Exception
+ {
+ VersionedReference ref = new VersionedReference();
+ ref.setGroupId( "org.apache.archiva" );
+ ref.setArtifactId( "non-existant" );
+ ref.setVersion( "2.0" );
+
+ try
+ {
+ resolver.resolveProjectModel( ref );
+ fail( "An exception should have been thrown." );
+ }
+ catch( Exception e )
+ {
+ assertTrue( true );
+ }
+ }
This should catch the specifically expected Exception so it doesn't
pass on an NPE, for example.
- Brett