public void testExplodedWar_WithResourceFiltering()
throws Exception
{
// setup test data
String testId = "ExplodedWar_WithResourceFiltering";
MavenProjectBasicStub project = new MavenProjectBasicStub();
File webAppDirectory = new File( getTestDirectory(), testId );
File webAppSource = createWebAppSource( testId );
File classesDir = createClassesDir( testId, false );
File webAppResource = new File( getTestDirectory(), testId + "-test-data/resources" );
File sampleResource = new File( webAppResource, "custom-setting.cfg" );
File sampleResourceWDir = new File( webAppResource, "custom-config/custom-setting.cfg" );
List<String> filterList = new LinkedList<String>();
ResourceStub[] resources = new ResourceStub[] { new ResourceStub() };
createFile( sampleResource );
createFile( sampleResourceWDir );
String ls = System.getProperty( "line.separator" );
final String comment = "# this is comment created by author@somewhere@";
// prepare web resources
String content = comment + ls;
content += "system_key_1=${user.dir}" + ls;
content += "system_key_2=@user.dir@" + ls;
content += "project_key_1=${is_this_simple}" + ls;
content += "project_key_2=@is_this_simple@" + ls;
content += "project_name_1=${project.name}" + ls;
content += "project_name_2=@project.name@" + ls;
content += "system_property_1=${system.property}" + ls;
content += "system_property_2=@system.property@" + ls;
FileUtils.fileWrite( sampleResourceWDir.getAbsolutePath(), content );
FileUtils.fileWrite( sampleResource.getAbsolutePath(), content );
System.setProperty( "system.property", "system-property-value" );
// configure mojo
project.addProperty( "is_this_simple", "i_think_so" );
resources[0].setDirectory( webAppResource.getAbsolutePath() );
resources[0].setFiltering( true );
this.configureMojo( mojo, filterList, classesDir, webAppSource, webAppDirectory, project );
setVariableValueToObject( mojo, "webResources", resources );
mojo.execute();