On Sat, Aug 15, 2009 at 1:29 AM, Brett Porter <
brett@...> wrote:
>
> On 07/08/2009, at 7:00 AM,
oching@... 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?
>
Not for all I think. I want the test to fail explicitly and not show in
error when a ProjectModelException is thrown so I added a check for the type
of exception instead. If the exception is not an instance of
ProjectModelException, I just propagated the error. (see commit -r804909)
>
>
>
>> + 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.
Fixed :)
Thanks,
Deng