*/
public void testExplodedWarMergeWarLocalFileOverride()
throws Exception
{
// setup test data
MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
WarArtifactStub warArtifact = new WarArtifactStub( getBasedir() );
String testId = "testExplodedWarMergeWarLocalFileOverride";
File webAppDirectory = new File( getTestDirectory(), testId );
File webAppSource = getWebAppSource( testId );
File simpleJSP = new File( webAppSource, "org/sample/company/test.jsp" );
createFile( simpleJSP );
File workDirectory = new File( getTestDirectory(), "/war/work-" + testId );
createDir( workDirectory );
File classesDir = createClassesDir( testId, true );
// configure mojo
project.addArtifact( warArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
setVariableValueToObject( mojo, "workDirectory", workDirectory );
mojo.execute();
// validate operation
File expectedFile = new File( webAppDirectory, "/org/sample/company/test.jsp" );
assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );
assertEquals( "file incorrect", simpleJSP.toString(), FileUtils.fileRead( expectedFile ) );
// check when the merged war file is newer - so set an old time on the local file
long time = new SimpleDateFormat( "yyyy-MM-dd", Locale.US ).parse( "2005-1-1" ).getTime();
simpleJSP.setLastModified( time );
expectedFile.setLastModified( time );
project.addArtifact( warArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
setVariableValueToObject( mojo, "workDirectory", workDirectory );
mojo.execute();
assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );