archiva-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brett Porter <br...@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/archiv...
Date Fri, 14 Aug 2009 17:29:12 GMT

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?

>
> +    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


Mime
View raw message