Search in sources :

Example 1 with MavenProjectArtifactsStub

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

the class WarExplodedMojoTest method testExplodedWar_WithPAR.

/**
 * @throws Exception in case of an error.
 */
public void testExplodedWar_WithPAR() throws Exception {
    // setup test data
    String testId = "ExplodedWar_WithPAR";
    MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
    File webAppDirectory = new File(getTestDirectory(), testId);
    File webAppSource = createWebAppSource(testId);
    File classesDir = createClassesDir(testId, true);
    PARArtifactStub parartifact = new PARArtifactStub(getBasedir());
    File parFile = parartifact.getFile();
    assertTrue("par not found: " + parFile.getAbsolutePath(), parFile.exists());
    // configure mojo
    project.addArtifact(parartifact);
    this.configureMojo(mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project);
    mojo.execute();
    // validate operation
    File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
    File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
    // final name form is <artifactId>-<version>.<type>
    File expectedPARArtifact = new File(webAppDirectory, "WEB-INF/lib/parartifact-0.0-Test.jar");
    assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
    assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
    assertTrue("par artifact not found: " + expectedPARArtifact.toString(), expectedPARArtifact.exists());
    // house keeping
    expectedWebSourceFile.delete();
    expectedWebSource2File.delete();
    expectedPARArtifact.delete();
}
Also used : PARArtifactStub(org.apache.maven.plugins.war.stub.PARArtifactStub) MavenProjectArtifactsStub(org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub) File(java.io.File)

Example 2 with MavenProjectArtifactsStub

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

the class WarExplodedMojoTest method testExplodedWarWithJar.

public void testExplodedWarWithJar() throws Exception {
    // setup test data
    String testId = "ExplodedWarWithJar";
    MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
    File webAppDirectory = new File(getTestDirectory(), testId);
    File webAppSource = createWebAppSource(testId);
    File classesDir = createClassesDir(testId, true);
    ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
    ArtifactStub jarArtifact = new JarArtifactStub(getBasedir(), artifactHandler);
    File jarFile = jarArtifact.getFile();
    assertTrue("jar not found: " + jarFile.toString(), jarFile.exists());
    // configure mojo
    project.addArtifact(jarArtifact);
    this.configureMojo(mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project);
    mojo.execute();
    // validate operation
    File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
    File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
    // final name form is <artifactId>-<version>.<type>
    File expectedJarArtifact = new File(webAppDirectory, "WEB-INF/lib/jarartifact-0.0-Test.jar");
    assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
    assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
    assertTrue("jar artifact not found: " + expectedJarArtifact.toString(), expectedJarArtifact.exists());
    // house keeping
    expectedWebSourceFile.delete();
    expectedWebSource2File.delete();
    expectedJarArtifact.delete();
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) JarArtifactStub(org.apache.maven.plugins.war.stub.JarArtifactStub) MavenProjectArtifactsStub(org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub) XarArtifactStub(org.apache.maven.plugins.war.stub.XarArtifactStub) MarArtifactStub(org.apache.maven.plugins.war.stub.MarArtifactStub) EJBArtifactStub(org.apache.maven.plugins.war.stub.EJBArtifactStub) WarArtifactStub(org.apache.maven.plugins.war.stub.WarArtifactStub) PARArtifactStub(org.apache.maven.plugins.war.stub.PARArtifactStub) TLDArtifactStub(org.apache.maven.plugins.war.stub.TLDArtifactStub) IncludeExcludeWarArtifactStub(org.apache.maven.plugins.war.stub.IncludeExcludeWarArtifactStub) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) EJBClientArtifactStub(org.apache.maven.plugins.war.stub.EJBClientArtifactStub) JarArtifactStub(org.apache.maven.plugins.war.stub.JarArtifactStub) AarArtifactStub(org.apache.maven.plugins.war.stub.AarArtifactStub) File(java.io.File)

Example 3 with MavenProjectArtifactsStub

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

the class WarExplodedMojoTest method testExplodedWarWithAar.

/**
 * @throws Exception in case of an error.
 */
public void testExplodedWarWithAar() throws Exception {
    // setup test data
    String testId = "ExplodedWarWithAar";
    MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
    File webAppDirectory = new File(getTestDirectory(), testId);
    File webAppSource = createWebAppSource(testId);
    File classesDir = createClassesDir(testId, true);
    // Fake here since the aar artifact handler does not exist: no biggie
    ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
    ArtifactStub aarArtifact = new AarArtifactStub(getBasedir(), artifactHandler);
    File aarFile = aarArtifact.getFile();
    assertTrue("jar not found: " + aarFile.toString(), aarFile.exists());
    // configure mojo
    project.addArtifact(aarArtifact);
    this.configureMojo(mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project);
    mojo.execute();
    // validate operation
    File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
    File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
    // final name form is <artifactId>-<version>.<type>
    File expectedJarArtifact = new File(webAppDirectory, "WEB-INF/services/aarartifact-0.0-Test.jar");
    assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
    assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
    assertTrue("jar artifact not found: " + expectedJarArtifact.toString(), expectedJarArtifact.exists());
    // house keeping
    expectedWebSourceFile.delete();
    expectedWebSource2File.delete();
    expectedJarArtifact.delete();
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) AarArtifactStub(org.apache.maven.plugins.war.stub.AarArtifactStub) MavenProjectArtifactsStub(org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub) XarArtifactStub(org.apache.maven.plugins.war.stub.XarArtifactStub) MarArtifactStub(org.apache.maven.plugins.war.stub.MarArtifactStub) EJBArtifactStub(org.apache.maven.plugins.war.stub.EJBArtifactStub) WarArtifactStub(org.apache.maven.plugins.war.stub.WarArtifactStub) PARArtifactStub(org.apache.maven.plugins.war.stub.PARArtifactStub) TLDArtifactStub(org.apache.maven.plugins.war.stub.TLDArtifactStub) IncludeExcludeWarArtifactStub(org.apache.maven.plugins.war.stub.IncludeExcludeWarArtifactStub) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) EJBClientArtifactStub(org.apache.maven.plugins.war.stub.EJBClientArtifactStub) JarArtifactStub(org.apache.maven.plugins.war.stub.JarArtifactStub) AarArtifactStub(org.apache.maven.plugins.war.stub.AarArtifactStub) File(java.io.File)

Example 4 with MavenProjectArtifactsStub

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

the class WarExplodedMojoTest method testExplodedWarWithXar.

/**
 * @throws Exception in case of an error.
 */
public void testExplodedWarWithXar() throws Exception {
    // setup test data
    String testId = "ExplodedWarWithXar";
    MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
    File webAppDirectory = new File(getTestDirectory(), testId);
    File webAppSource = createWebAppSource(testId);
    File classesDir = createClassesDir(testId, true);
    // Fake here since the xar artifact handler does not exist: no biggie
    ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
    ArtifactStub xarArtifact = new XarArtifactStub(getBasedir(), artifactHandler);
    File xarFile = xarArtifact.getFile();
    assertTrue("jar not found: " + xarFile.toString(), xarFile.exists());
    // configure mojo
    project.addArtifact(xarArtifact);
    this.configureMojo(mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project);
    mojo.execute();
    // validate operation
    File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
    File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
    // final name form is <artifactId>-<version>.<type>
    File expectedJarArtifact = new File(webAppDirectory, "WEB-INF/extensions/xarartifact-0.0-Test.jar");
    assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
    assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
    assertTrue("jar artifact not found: " + expectedJarArtifact.toString(), expectedJarArtifact.exists());
    // house keeping
    expectedWebSourceFile.delete();
    expectedWebSource2File.delete();
    expectedJarArtifact.delete();
}
Also used : XarArtifactStub(org.apache.maven.plugins.war.stub.XarArtifactStub) ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) MavenProjectArtifactsStub(org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub) XarArtifactStub(org.apache.maven.plugins.war.stub.XarArtifactStub) MarArtifactStub(org.apache.maven.plugins.war.stub.MarArtifactStub) EJBArtifactStub(org.apache.maven.plugins.war.stub.EJBArtifactStub) WarArtifactStub(org.apache.maven.plugins.war.stub.WarArtifactStub) PARArtifactStub(org.apache.maven.plugins.war.stub.PARArtifactStub) TLDArtifactStub(org.apache.maven.plugins.war.stub.TLDArtifactStub) IncludeExcludeWarArtifactStub(org.apache.maven.plugins.war.stub.IncludeExcludeWarArtifactStub) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) EJBClientArtifactStub(org.apache.maven.plugins.war.stub.EJBClientArtifactStub) JarArtifactStub(org.apache.maven.plugins.war.stub.JarArtifactStub) AarArtifactStub(org.apache.maven.plugins.war.stub.AarArtifactStub) File(java.io.File)

Example 5 with MavenProjectArtifactsStub

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

the class WarExplodedMojoTest method testExplodedWarMergeWarLocalFileOverride.

/**
 * Merge a dependent WAR when a file in the war source directory overrides one found in the WAR.
 * @throws Exception in case of an error.
 */
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());
    assertEquals("file incorrect", simpleJSP.toString(), FileUtils.fileRead(expectedFile));
    // house keeping
    expectedFile.delete();
}
Also used : MavenProjectArtifactsStub(org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub) WarArtifactStub(org.apache.maven.plugins.war.stub.WarArtifactStub) IncludeExcludeWarArtifactStub(org.apache.maven.plugins.war.stub.IncludeExcludeWarArtifactStub) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

MavenProjectArtifactsStub (org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub)24 File (java.io.File)18 WarArtifactStub (org.apache.maven.plugins.war.stub.WarArtifactStub)12 ArtifactStub (org.apache.maven.plugin.testing.stubs.ArtifactStub)11 EJBArtifactStub (org.apache.maven.plugins.war.stub.EJBArtifactStub)9 IncludeExcludeWarArtifactStub (org.apache.maven.plugins.war.stub.IncludeExcludeWarArtifactStub)8 ArrayList (java.util.ArrayList)6 ArtifactHandler (org.apache.maven.artifact.handler.ArtifactHandler)6 Overlay (org.apache.maven.plugins.war.Overlay)6 DefaultOverlay (org.apache.maven.plugins.war.overlay.DefaultOverlay)6 InvalidOverlayConfigurationException (org.apache.maven.plugins.war.overlay.InvalidOverlayConfigurationException)6 OverlayManager (org.apache.maven.plugins.war.overlay.OverlayManager)6 EJBClientArtifactStub (org.apache.maven.plugins.war.stub.EJBClientArtifactStub)6 JarArtifactStub (org.apache.maven.plugins.war.stub.JarArtifactStub)6 PARArtifactStub (org.apache.maven.plugins.war.stub.PARArtifactStub)6 TLDArtifactStub (org.apache.maven.plugins.war.stub.TLDArtifactStub)6 AarArtifactStub (org.apache.maven.plugins.war.stub.AarArtifactStub)5 MarArtifactStub (org.apache.maven.plugins.war.stub.MarArtifactStub)5 XarArtifactStub (org.apache.maven.plugins.war.stub.XarArtifactStub)5 JarFile (java.util.jar.JarFile)2