{
// specifically testing the default operation that getFormattedFileName
// returns
// the actual name of the file if available unless remove version is
// set.
ArtifactHandler ah = new DefaultArtifactHandlerStub( "war", "sources" );
VersionRange vr = VersionRange.createFromVersion( "1.1-SNAPSHOT" );
Artifact artifact = new DefaultArtifact( "test", "two", vr, Artifact.SCOPE_PROVIDED, "war", "sources", ah,
false );
File file = new File( "/target", "test-file-name.jar" );
artifact.setFile( file );
String name = DependencyUtil.getFormattedFileName( artifact, false );
String expectedResult = "two-1.1-SNAPSHOT-sources.war";
assertEquals( expectedResult, name );
name = DependencyUtil.getFormattedFileName( artifact, true );
expectedResult = "two-sources.war";
assertEquals( expectedResult, name );
artifact = new DefaultArtifact( "test", "two", vr, Artifact.SCOPE_PROVIDED, "war", "", ah, false );
name = DependencyUtil.getFormattedFileName( artifact, true );
expectedResult = "two.war";
assertEquals( expectedResult, name );
// test that we pickup the correct extension in the file name if set.
ah = new DefaultArtifactHandlerStub( "jar", null );
artifact = new DefaultArtifact( "test", "two", vr, Artifact.SCOPE_PROVIDED, "war", "", ah, false );
name = DependencyUtil.getFormattedFileName( artifact, true );
expectedResult = "two.jar";
assertEquals( expectedResult, name );