Search in sources :

Example 1 with IncludeExcludeWarArtifactStub

use of org.apache.maven.plugins.war.stub.IncludeExcludeWarArtifactStub in project maven-plugins by apache.

the class WarExplodedMojoTest method testExplodedWar_WithWarDependencyIncludeExclude.

/**
 * @throws Exception in case of an error.
 */
public void testExplodedWar_WithWarDependencyIncludeExclude() throws Exception {
    // setup test data
    String testId = "ExplodedWar_WithWarDependencyIncludeExclude";
    MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
    IncludeExcludeWarArtifactStub includeexcludeWarArtifact = new IncludeExcludeWarArtifactStub(getBasedir());
    File webAppDirectory = new File(getTestDirectory(), testId);
    File webAppSource = createWebAppSource(testId);
    File classesDir = createClassesDir(testId, true);
    File workDirectory = new File(getTestDirectory(), "/war/work-" + testId);
    File includeExcludeWarFile = includeexcludeWarArtifact.getFile();
    assertTrue("war not found: " + includeExcludeWarFile.toString(), includeExcludeWarFile.exists());
    createDir(workDirectory);
    // configure mojo
    project.addArtifact(includeexcludeWarArtifact);
    this.configureMojo(mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project);
    setVariableValueToObject(mojo, "dependentWarIncludes", "**/*Include.jsp,**/*.xml");
    setVariableValueToObject(mojo, "dependentWarExcludes", "**/*Exclude*,**/MANIFEST.MF");
    setVariableValueToObject(mojo, "workDirectory", workDirectory);
    mojo.execute();
    // validate operation
    File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
    File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
    File expectedManifestFile = new File(webAppDirectory, "META-INF/MANIFEST.MF");
    File expectedWEBXMLFile = new File(webAppDirectory, "WEB-INF/web.xml");
    File expectedIncludedWARFile = new File(webAppDirectory, "/org/sample/company/testInclude.jsp");
    File expectedExcludedWarfile = new File(webAppDirectory, "/org/sample/companyExclude/test.jsp");
    assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
    assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
    // check include-exclude.war in the unit test dir under resources to verify the list of files
    assertTrue("web xml not found: " + expectedWEBXMLFile.toString(), expectedWEBXMLFile.exists());
    assertFalse("manifest file found: " + expectedManifestFile.toString(), expectedManifestFile.exists());
    assertTrue("war file not found: " + expectedIncludedWARFile.toString(), expectedIncludedWARFile.exists());
    assertFalse("war file not found: " + expectedExcludedWarfile.toString(), expectedExcludedWarfile.exists());
    // house keeping
    expectedWebSourceFile.delete();
    expectedWebSource2File.delete();
    expectedManifestFile.delete();
    expectedWEBXMLFile.delete();
    expectedIncludedWARFile.delete();
    expectedExcludedWarfile.delete();
}
Also used : MavenProjectArtifactsStub(org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub) File(java.io.File) IncludeExcludeWarArtifactStub(org.apache.maven.plugins.war.stub.IncludeExcludeWarArtifactStub)

Aggregations

File (java.io.File)1 IncludeExcludeWarArtifactStub (org.apache.maven.plugins.war.stub.IncludeExcludeWarArtifactStub)1 MavenProjectArtifactsStub (org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub)1