Search in sources :

Example 11 with Overlay

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

the class WarZipTest method testOneZipWithTargetPathOverlay.

public void testOneZipWithTargetPathOverlay() throws Exception {
    File webAppDirectory = configureMojo("one-zip-overlay-targetPath");
    Overlay overlay = new DefaultOverlay(buildZipArtifact());
    overlay.setSkip(false);
    overlay.setType("zip");
    overlay.setTargetPath("overridePath");
    mojo.addOverlay(overlay);
    mojo.execute();
    File foo = new File(webAppDirectory.getPath() + File.separatorChar + "overridePath", "foo.txt");
    assertTrue("foo.txt not exists", foo.exists());
    assertTrue("foo.txt not a file", foo.isFile());
    File barDirectory = new File(webAppDirectory.getPath() + File.separatorChar + "overridePath", "bar");
    assertTrue("bar directory not exists", barDirectory.exists());
    assertTrue("bar not a directory", barDirectory.isDirectory());
    File bar = new File(barDirectory, "bar.txt");
    assertTrue("bar/bar.txt not exists", bar.exists());
    assertTrue("bar/bar.txt not a file", bar.isFile());
}
Also used : DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) Overlay(org.apache.maven.plugins.war.Overlay) DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) File(java.io.File)

Example 12 with Overlay

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

the class WarZipTest method testOneZipWithNoSkip.

public void testOneZipWithNoSkip() throws Exception {
    File webAppDirectory = configureMojo("one-zip");
    Overlay overlay = new DefaultOverlay(buildZipArtifact());
    // overlay.setSkip( false );
    overlay.setType("zip");
    mojo.addOverlay(overlay);
    mojo.execute();
    File foo = new File(webAppDirectory, "foo.txt");
    assertTrue("foo.txt not exists", foo.exists());
    assertTrue("foo.txt not a file", foo.isFile());
    File barDirectory = new File(webAppDirectory, "bar");
    assertTrue("bar directory not exists", barDirectory.exists());
    assertTrue("bar not a directory", barDirectory.isDirectory());
    File bar = new File(barDirectory, "bar.txt");
    assertTrue("bar/bar.txt not exists", bar.exists());
    assertTrue("bar/bar.txt not a file", bar.isFile());
}
Also used : DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) Overlay(org.apache.maven.plugins.war.Overlay) DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) File(java.io.File)

Example 13 with Overlay

use of org.apache.maven.plugins.war.Overlay 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)

Example 14 with Overlay

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

the class OverlayManagerTest method testAutodetectSimpleOverlay.

public void testAutodetectSimpleOverlay(Overlay currentProjectOverlay) throws Exception {
    final MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
    final ArtifactStub first = newWarArtifact("test", "test-webapp");
    project.addArtifact(first);
    final List<Overlay> overlays = new ArrayList<Overlay>();
    try {
        final Overlay overlay = currentProjectOverlay;
        OverlayManager manager = new OverlayManager(overlays, project, DEFAULT_INCLUDES, DEFAULT_EXCLUDES, overlay);
        assertNotNull(manager.getOverlays());
        assertEquals(2, manager.getOverlays().size());
        assertEquals(overlay, manager.getOverlays().get(0));
        assertEquals(new DefaultOverlay(first), manager.getOverlays().get(1));
    } catch (InvalidOverlayConfigurationException e) {
        e.printStackTrace();
        fail("Should not have failed to validate a valid overlay config " + e.getMessage());
    }
}
Also used : OverlayManager(org.apache.maven.plugins.war.overlay.OverlayManager) DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) 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)

Example 15 with Overlay

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

the class OverlayManagerTest method testEmptyProject.

public void testEmptyProject() throws Exception {
    final MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
    final List<Overlay> overlays = new ArrayList<Overlay>();
    try {
        final Overlay currentProjectOVerlay = Overlay.createInstance();
        OverlayManager manager = new OverlayManager(overlays, project, DEFAULT_INCLUDES, DEFAULT_EXCLUDES, currentProjectOVerlay);
        assertNotNull(manager.getOverlays());
        assertEquals(1, manager.getOverlays().size());
        assertEquals(currentProjectOVerlay, manager.getOverlays().get(0));
    } catch (InvalidOverlayConfigurationException e) {
        e.printStackTrace();
        fail("Should not have failed to validate a valid overly config " + e.getMessage());
    }
}
Also used : OverlayManager(org.apache.maven.plugins.war.overlay.OverlayManager) MavenProjectArtifactsStub(org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub) ArrayList(java.util.ArrayList) Overlay(org.apache.maven.plugins.war.Overlay) DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) InvalidOverlayConfigurationException(org.apache.maven.plugins.war.overlay.InvalidOverlayConfigurationException)

Aggregations

Overlay (org.apache.maven.plugins.war.Overlay)16 DefaultOverlay (org.apache.maven.plugins.war.overlay.DefaultOverlay)15 ArrayList (java.util.ArrayList)13 ArtifactStub (org.apache.maven.plugin.testing.stubs.ArtifactStub)11 File (java.io.File)9 InvalidOverlayConfigurationException (org.apache.maven.plugins.war.overlay.InvalidOverlayConfigurationException)6 OverlayManager (org.apache.maven.plugins.war.overlay.OverlayManager)6 MavenProjectArtifactsStub (org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub)6 WarArtifactStub (org.apache.maven.plugins.war.stub.WarArtifactStub)5 FileFilter (java.io.FileFilter)4 LinkedList (java.util.LinkedList)2 Artifact (org.apache.maven.artifact.Artifact)1