Search in sources :

Example 11 with ArtifactStub

use of org.apache.maven.plugin.testing.stubs.ArtifactStub in project maven-plugins by apache.

the class WarOverlaysTest method testScenarioOneWithOverlaySettings.

/**
     * Tests that specifying the overlay explicitely has the same behavior as the default (i.e. order, etc).
     * 
     * The default project is not specified in this case so it is processed first by default
     *
     * @throws Exception if an error occurs
     */
public void testScenarioOneWithOverlaySettings() throws Exception {
    // setup test data
    final String testId = "scenario-one-overlay-settings";
    // Add an overlay
    final ArtifactStub overlay1 = buildWarOverlayStub("overlay-full-1");
    final ArtifactStub overlay2 = buildWarOverlayStub("overlay-full-2");
    final ArtifactStub overlay3 = buildWarOverlayStub("overlay-full-3");
    final File webAppDirectory = setUpMojo(testId, new ArtifactStub[] { overlay1, overlay2, overlay3 }, new String[] { "org/sample/company/test.jsp", "jsp/b.jsp" });
    // Add the tags
    final List<Overlay> overlays = new ArrayList<Overlay>();
    overlays.add(new DefaultOverlay(overlay1));
    overlays.add(new DefaultOverlay(overlay2));
    overlays.add(new DefaultOverlay(overlay3));
    mojo.setOverlays(overlays);
    // current project ignored. Should be on top of the list
    assertScenariOne(testId, webAppDirectory);
}
Also used : DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) ArrayList(java.util.ArrayList) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) Overlay(org.apache.maven.plugins.war.Overlay) DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) File(java.io.File)

Example 12 with ArtifactStub

use of org.apache.maven.plugin.testing.stubs.ArtifactStub in project maven-plugins by apache.

the class WarOverlaysTest method testOverlaysIncludesExcludesWithMultipleDefinitions2.

public void testOverlaysIncludesExcludesWithMultipleDefinitions2() throws Exception {
    // setup test data
    final String testId = "overlays-includes-excludes-multiple-defs2";
    // Add an overlay
    final ArtifactStub overlay1 = buildWarOverlayStub("overlay-full-1");
    final ArtifactStub overlay2 = buildWarOverlayStub("overlay-full-2");
    final ArtifactStub overlay3 = buildWarOverlayStub("overlay-full-3");
    final File webAppDirectory = setUpMojo(testId, new ArtifactStub[] { overlay1, overlay2, overlay3 }, new String[] { "org/sample/company/test.jsp", "jsp/b.jsp" });
    Overlay over1 = new DefaultOverlay(overlay3);
    over1.setExcludes("**/a.*,**/c.*,**/*.xml,jsp/b.jsp");
    Overlay over2 = new DefaultOverlay(overlay1);
    over2.setIncludes("jsp/d/*");
    over2.setExcludes("jsp/d/a.jsp");
    Overlay over3 = new DefaultOverlay(overlay3);
    over3.setIncludes("**/*.jsp");
    over3.setExcludes("jsp/b.jsp");
    Overlay over4 = new DefaultOverlay(overlay2);
    mojo.setOverlays(new LinkedList<Overlay>());
    mojo.addOverlay(over1);
    mojo.addOverlay(over2);
    mojo.addOverlay(over3);
    mojo.addOverlay(mojo.getCurrentProjectOverlay());
    mojo.addOverlay(over4);
    final List<File> assertedFiles = new ArrayList<File>();
    try {
        mojo.execute();
        assertedFiles.addAll(assertWebXml(webAppDirectory));
        assertedFiles.addAll(assertCustomContent(webAppDirectory, new String[] { "jsp/a.jsp", "jsp/b.jsp", "jsp/c.jsp", "jsp/d/a.jsp", "jsp/d/b.jsp", "jsp/d/c.jsp", "org/sample/company/test.jsp", "WEB-INF/classes/a.class", "WEB-INF/classes/b.class", "WEB-INF/classes/c.class", "WEB-INF/lib/a.jar", "WEB-INF/lib/b.jar", "WEB-INF/lib/c.jar" }, "overlay file not found"));
        assertOverlayedFile(webAppDirectory, "overlay-full-3", "jsp/a.jsp");
        assertDefaultFileContent(testId, webAppDirectory, "jsp/b.jsp");
        assertOverlayedFile(webAppDirectory, "overlay-full-3", "jsp/c.jsp");
        assertOverlayedFile(webAppDirectory, "overlay-full-3", "jsp/d/a.jsp");
        assertOverlayedFile(webAppDirectory, "overlay-full-3", "jsp/d/b.jsp");
        assertOverlayedFile(webAppDirectory, "overlay-full-1", "jsp/d/c.jsp");
        assertDefaultFileContent(testId, webAppDirectory, "org/sample/company/test.jsp");
        assertOverlayedFile(webAppDirectory, "overlay-full-2", "WEB-INF/web.xml");
        assertOverlayedFile(webAppDirectory, "overlay-full-2", "WEB-INF/classes/a.class");
        assertOverlayedFile(webAppDirectory, "overlay-full-3", "WEB-INF/classes/b.class");
        assertOverlayedFile(webAppDirectory, "overlay-full-2", "WEB-INF/classes/c.class");
        assertOverlayedFile(webAppDirectory, "overlay-full-2", "WEB-INF/lib/a.jar");
        assertOverlayedFile(webAppDirectory, "overlay-full-3", "WEB-INF/lib/b.jar");
        assertOverlayedFile(webAppDirectory, "overlay-full-2", "WEB-INF/lib/c.jar");
        // Ok now check that there is no more files/directories
        final FileFilter filter = new FileFilterImpl(webAppDirectory, new String[] { MANIFEST_PATH });
        assertWebAppContent(webAppDirectory, assertedFiles, filter);
    } finally {
        cleanDirectory(webAppDirectory);
    }
}
Also used : DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) ArrayList(java.util.ArrayList) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) Overlay(org.apache.maven.plugins.war.Overlay) DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) FileFilter(java.io.FileFilter) File(java.io.File)

Example 13 with ArtifactStub

use of org.apache.maven.plugin.testing.stubs.ArtifactStub 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 14 with ArtifactStub

use of org.apache.maven.plugin.testing.stubs.ArtifactStub in project aries by apache.

the class EsaMavenProjectStub7 method getArtifact.

@Override
public Artifact getArtifact() {
    ArtifactStub artfct = (ArtifactStub) super.getArtifact();
    artfct.setFile(new File(getBasedir(), "src/test/resources/unit/basic-esa-test-with-pgk-type/target/maven-esa-test-1.0-SNAPSHOT.jar"));
    artfct.setType("jar");
    return artfct;
}
Also used : ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) File(java.io.File)

Example 15 with ArtifactStub

use of org.apache.maven.plugin.testing.stubs.ArtifactStub in project maven-plugins by apache.

the class WarDependenciesAnalysisTest method testRemovedDependency.

public void testRemovedDependency() throws Exception {
    // setup test data
    final String testId = "remove-dependency";
    final ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
    ArtifactStub jarArtifact = new JarArtifactStub(getBasedir(), artifactHandler);
    jarArtifact.setArtifactId("lib-test");
    jarArtifact.setVersion("1.0");
    doTestTwiceWithUpdatedDependency(testId, new ArtifactStub[] { jarArtifact }, null, new String[] { "WEB-INF/lib/lib-test-1.0.jar" }, null);
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) JarArtifactStub(org.apache.maven.plugins.war.stub.JarArtifactStub) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) JarArtifactStub(org.apache.maven.plugins.war.stub.JarArtifactStub)

Aggregations

ArtifactStub (org.apache.maven.plugin.testing.stubs.ArtifactStub)26 File (java.io.File)17 ArrayList (java.util.ArrayList)13 Overlay (org.apache.maven.plugins.war.Overlay)11 DefaultOverlay (org.apache.maven.plugins.war.overlay.DefaultOverlay)11 MavenProjectArtifactsStub (org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub)11 WarArtifactStub (org.apache.maven.plugins.war.stub.WarArtifactStub)10 ArtifactHandler (org.apache.maven.artifact.handler.ArtifactHandler)9 JarArtifactStub (org.apache.maven.plugins.war.stub.JarArtifactStub)9 FileFilter (java.io.FileFilter)6 InvalidOverlayConfigurationException (org.apache.maven.plugins.war.overlay.InvalidOverlayConfigurationException)5 OverlayManager (org.apache.maven.plugins.war.overlay.OverlayManager)5 AarArtifactStub (org.apache.maven.plugins.war.stub.AarArtifactStub)5 EJBArtifactStub (org.apache.maven.plugins.war.stub.EJBArtifactStub)5 EJBClientArtifactStub (org.apache.maven.plugins.war.stub.EJBClientArtifactStub)5 IncludeExcludeWarArtifactStub (org.apache.maven.plugins.war.stub.IncludeExcludeWarArtifactStub)5 MarArtifactStub (org.apache.maven.plugins.war.stub.MarArtifactStub)5 PARArtifactStub (org.apache.maven.plugins.war.stub.PARArtifactStub)5 TLDArtifactStub (org.apache.maven.plugins.war.stub.TLDArtifactStub)5 XarArtifactStub (org.apache.maven.plugins.war.stub.XarArtifactStub)5