}
public void testPath() throws Exception
{
File testPom = new File( getBasedir(), "target/test-classes/unit/build-classpath-test/plugin-config.xml" );
BuildClasspathMojo mojo = (BuildClasspathMojo) lookupMojo( "build-classpath", testPom );
assertNotNull( mojo );
assertNotNull( mojo.getProject() );
ArtifactRepository local = new StubArtifactRepository( stubFactory.getWorkingDir().getPath() );
mojo.setLocal( local );
Artifact artifact = stubFactory.getReleaseArtifact();
StringBuilder sb = new StringBuilder();
mojo.setPrefix( null );
mojo.setStripVersion( false );
mojo.appendArtifactPath( artifact, sb );
assertEquals( artifact.getFile().getPath(), sb.toString() );
mojo.setLocalRepoProperty( "$M2_REPO" );
sb.setLength( 0 );
mojo.appendArtifactPath( artifact, sb );
assertEquals( "$M2_REPO" + File.separator + artifact.getFile().getName(), sb.toString() );
mojo.setLocalRepoProperty( "%M2_REPO%" );
sb.setLength( 0 );
mojo.appendArtifactPath( artifact, sb );
assertEquals( "%M2_REPO%" + File.separator + artifact.getFile().getName(), sb.toString() );
mojo.setLocalRepoProperty( "%M2_REPO%" );
sb.setLength( 0 );
mojo.setPrependGroupId( true );
mojo.appendArtifactPath( artifact, sb );
assertEquals("If prefix is null, prependGroupId has no impact ", "%M2_REPO%"+File.separator
+ DependencyUtil.getFormattedFileName( artifact, false, false ), sb.toString());
mojo.setLocalRepoProperty( "" );
mojo.setPrefix( "prefix" );
sb.setLength( 0 );
mojo.setPrependGroupId( true );
mojo.appendArtifactPath( artifact, sb );
assertEquals("prefix"+File.separator+DependencyUtil.getFormattedFileName( artifact, false, true ),
sb.toString());
mojo.setPrependGroupId( false );
mojo.setLocalRepoProperty( "" );
mojo.setPrefix( "prefix" );
sb.setLength( 0 );
mojo.appendArtifactPath( artifact, sb );
assertEquals("prefix"+File.separator+artifact.getFile().getName(),sb.toString());
mojo.setPrefix( "prefix" );
mojo.setStripVersion( true );
sb.setLength( 0 );
mojo.appendArtifactPath( artifact, sb );
assertEquals( "prefix" + File.separator + DependencyUtil.getFormattedFileName( artifact, true ), sb.toString() );
}