Search in sources :

Example 16 with MavenProjectArtifactsStub

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

the class WarExplodedMojoTest method testExplodedWar_WithDuplicateDependencies.

/**
 * @throws Exception in case of an error.
 */
public void testExplodedWar_WithDuplicateDependencies() throws Exception {
    // setup test data
    String testId = "ExplodedWar_WithDuplicateDependencies";
    MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
    File webAppDirectory = new File(getTestDirectory(), testId);
    File webAppSource = createWebAppSource(testId);
    File classesDir = createClassesDir(testId, true);
    EJBArtifactStub ejbArtifact = new EJBArtifactStub(getBasedir());
    EJBArtifactStub ejbArtifactDup = new EJBArtifactStub(getBasedir());
    File ejbFile = ejbArtifact.getFile();
    // ejbArtifact has a hard coded file, only one assert is needed
    assertTrue("ejb not found: " + ejbFile.getAbsolutePath(), ejbFile.exists());
    // configure mojo
    ejbArtifact.setGroupId("org.sample.ejb");
    ejbArtifactDup.setGroupId("org.dup.ejb");
    project.addArtifact(ejbArtifact);
    project.addArtifact(ejbArtifactDup);
    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 expectedEJBArtifact = new File(webAppDirectory, "WEB-INF/lib/org.sample.ejb-ejbartifact-0.0-Test.jar");
    File expectedEJBDupArtifact = new File(webAppDirectory, "WEB-INF/lib/org.dup.ejb-ejbartifact-0.0-Test.jar");
    assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
    assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
    assertTrue("ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists());
    assertTrue("ejb dup artifact not found: " + expectedEJBDupArtifact.toString(), expectedEJBDupArtifact.exists());
    // house keeping
    expectedWebSourceFile.delete();
    expectedWebSource2File.delete();
    expectedEJBArtifact.delete();
    expectedEJBDupArtifact.delete();
}
Also used : MavenProjectArtifactsStub(org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub) EJBArtifactStub(org.apache.maven.plugins.war.stub.EJBArtifactStub) File(java.io.File)

Example 17 with MavenProjectArtifactsStub

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

the class WarExplodedMojoTest method testExplodedWar_WithTLD.

/**
 * @throws Exception in case of an error.
 */
public void testExplodedWar_WithTLD() throws Exception {
    // setup test data
    String testId = "ExplodedWar_WithTLD";
    MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
    File webAppDirectory = new File(getTestDirectory(), testId);
    File webAppSource = createWebAppSource(testId);
    File classesDir = createClassesDir(testId, true);
    TLDArtifactStub tldArtifact = new TLDArtifactStub(getBasedir());
    File tldFile = tldArtifact.getFile();
    assertTrue("tld jar not found: " + tldFile.getAbsolutePath(), tldFile.exists());
    // configure mojo
    project.addArtifact(tldArtifact);
    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 expectedTLDArtifact = new File(webAppDirectory, "WEB-INF/tld/tldartifact-0.0-Test.tld");
    assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
    assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
    assertTrue("tld artifact not found: " + expectedTLDArtifact.toString(), expectedTLDArtifact.exists());
    // house keeping
    expectedWebSourceFile.delete();
    expectedWebSource2File.delete();
    expectedTLDArtifact.delete();
}
Also used : TLDArtifactStub(org.apache.maven.plugins.war.stub.TLDArtifactStub) MavenProjectArtifactsStub(org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub) File(java.io.File)

Example 18 with MavenProjectArtifactsStub

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

the class WarExplodedMojoTest method testExplodedWar_WithSimpleExternalWARFile.

/**
 * @throws Exception in case of an error.
 */
public void testExplodedWar_WithSimpleExternalWARFile() throws Exception {
    // setup test data
    MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
    WarArtifactStub warArtifact = new WarArtifactStub(getBasedir());
    String testId = "ExplodedWar_WithSimpleExternalWARFile";
    File webAppDirectory = new File(getTestDirectory(), testId);
    File webAppSource = createWebAppSource(testId);
    File classesDir = createClassesDir(testId, true);
    File workDirectory = new File(getTestDirectory(), "/war/work-" + testId);
    File simpleWarFile = warArtifact.getFile();
    assertTrue("simple war not found: " + simpleWarFile.toString(), simpleWarFile.exists());
    createDir(workDirectory);
    // configure mojo
    project.addArtifact(warArtifact);
    this.configureMojo(mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project);
    setVariableValueToObject(mojo, "workDirectory", workDirectory);
    mojo.execute();
    // validate operation - META-INF is automatically excluded so remove the file from the list
    File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
    File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
    File expectedWEBXMLFile = new File(webAppDirectory, "WEB-INF/web.xml");
    File expectedWARFile = new File(webAppDirectory, "/org/sample/company/test.jsp");
    assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
    assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
    // check simple.war in the unit test dir under resources to verify the list of files
    assertTrue("web xml not found: " + expectedWEBXMLFile.toString(), expectedWEBXMLFile.exists());
    assertTrue("war file not found: " + expectedWARFile.toString(), expectedWARFile.exists());
    // house keeping
    expectedWebSourceFile.delete();
    expectedWebSource2File.delete();
    expectedWEBXMLFile.delete();
    expectedWARFile.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)

Example 19 with MavenProjectArtifactsStub

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

the class WarExplodedMojoTest method testExplodedWar_DuplicateWithClassifier.

/**
 * @throws Exception in case of an error.
 */
public void testExplodedWar_DuplicateWithClassifier() throws Exception {
    // setup test data
    String testId = "ExplodedWar_DuplicateWithClassifier";
    MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
    File webAppDirectory = new File(getTestDirectory(), testId);
    File webAppSource = createWebAppSource(testId);
    File classesDir = createClassesDir(testId, true);
    EJBArtifactStub ejbArtifact = new EJBArtifactStub(getBasedir());
    EJBArtifactStubWithClassifier ejbArtifactDup = new EJBArtifactStubWithClassifier(getBasedir());
    File ejbFile = ejbArtifact.getFile();
    // ejbArtifact has a hard coded file, only one assert is needed
    assertTrue("ejb not found: " + ejbFile.getAbsolutePath(), ejbFile.exists());
    // configure mojo
    ejbArtifact.setGroupId("org.sample.ejb");
    ejbArtifactDup.setGroupId("org.sample.ejb");
    ejbArtifactDup.setClassifier("classifier");
    project.addArtifact(ejbArtifact);
    project.addArtifact(ejbArtifactDup);
    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 expectedEJBArtifact = new File(webAppDirectory, "WEB-INF/lib/ejbartifact-0.0-Test.jar");
    File expectedEJBDupArtifact = new File(webAppDirectory, "WEB-INF/lib/ejbartifact-0.0-Test-classifier.jar");
    assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
    assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
    assertTrue("ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists());
    assertTrue("ejb dup artifact not found: " + expectedEJBDupArtifact.toString(), expectedEJBDupArtifact.exists());
    // house keeping
    expectedWebSourceFile.delete();
    expectedWebSource2File.delete();
    expectedEJBArtifact.delete();
    expectedEJBDupArtifact.delete();
}
Also used : MavenProjectArtifactsStub(org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub) EJBArtifactStubWithClassifier(org.apache.maven.plugins.war.stub.EJBArtifactStubWithClassifier) EJBArtifactStub(org.apache.maven.plugins.war.stub.EJBArtifactStub) File(java.io.File)

Example 20 with MavenProjectArtifactsStub

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

the class OverlayManagerTest method testUnknonwnOverlay.

public void testUnknonwnOverlay() throws Exception {
    final MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
    final ArtifactStub first = newWarArtifact("test", "test-webapp");
    project.addArtifact(first);
    final List<Overlay> overlays = new ArrayList<Overlay>();
    overlays.add(new Overlay("test", "test-webapp-2"));
    try {
        final Overlay currentProjectOVerlay = Overlay.createInstance();
        new OverlayManager(overlays, project, DEFAULT_INCLUDES, DEFAULT_EXCLUDES, currentProjectOVerlay);
        fail("Should have failed to validate an unknown overlay");
    } catch (InvalidOverlayConfigurationException e) {
    // OK
    }
}
Also used : OverlayManager(org.apache.maven.plugins.war.overlay.OverlayManager) MavenProjectArtifactsStub(org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub) ArrayList(java.util.ArrayList) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) WarArtifactStub(org.apache.maven.plugins.war.stub.WarArtifactStub) Overlay(org.apache.maven.plugins.war.Overlay) DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) InvalidOverlayConfigurationException(org.apache.maven.plugins.war.overlay.InvalidOverlayConfigurationException)

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