archiva-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Deng Ching <och...@apache.org>
Subject Re: svn commit: r801946 - in /archiva/trunk/archiva-modules/archiva-base/archiva-repository-layer/src: main/java/org/apache/maven/archiva/repository/content/ main/java/org/apache/maven/archiva/repository/project/resolvers/ test/java/org/apache/maven/
Date Mon, 17 Aug 2009 09:40:59 GMT
On Sat, Aug 15, 2009 at 1:29 AM, Brett Porter <brett@apache.org> wrote:

>
> On 07/08/2009, at 7:00 AM, oching@apache.org 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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message