Search in sources :

Example 21 with MavenProjectArtifactsStub

use of org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub 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 22 with MavenProjectArtifactsStub

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

Example 23 with MavenProjectArtifactsStub

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

the class OverlayManagerTest method testCustomCurrentProject.

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

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

the class WarMojoTest method testFailOnMissingWebXmlNotSpecifiedAndServlet30Used.

public void testFailOnMissingWebXmlNotSpecifiedAndServlet30Used() throws Exception {
    String testId = "SimpleWarUnderServlet30";
    MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
    String outputDir = getTestDirectory().getAbsolutePath() + "/" + testId + "-output";
    File webAppDirectory = new File(getTestDirectory(), testId);
    WarArtifact4CCStub warArtifact = new WarArtifact4CCStub(getBasedir());
    String warName = "simple";
    File webAppSource = createWebAppSource(testId);
    File classesDir = createClassesDir(testId, true);
    final ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
    JarArtifactStub jarArtifactStub = new JarArtifactStub(getBasedir(), artifactHandler);
    jarArtifactStub.setFile(new File(getBasedir(), "/target/test-classes/unit/sample_wars/javax.servlet-api-3.0.1.jar"));
    jarArtifactStub.setScope(Artifact.SCOPE_PROVIDED);
    project.addArtifact(jarArtifactStub);
    project.setArtifact(warArtifact);
    project.setFile(warArtifact.getFile());
    this.configureMojo(mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project);
    setVariableValueToObject(mojo, "outputDirectory", outputDir);
    setVariableValueToObject(mojo, "warName", warName);
    mojo.execute();
    // validate war file
    File expectedWarFile = new File(outputDir, "simple.war");
    final Map<String, JarEntry> jarContent = assertJarContent(expectedWarFile, new String[] { "META-INF/MANIFEST.MF", "pansit.jsp", "org/web/app/last-exile.jsp", "META-INF/maven/org.apache.maven.plugin.test/maven-war-plugin-test/pom.xml", "META-INF/maven/org.apache.maven.plugin.test/maven-war-plugin-test/pom.properties" }, new String[] { null, null, null, null, null });
    assertFalse("web.xml should be missing", jarContent.containsKey("WEB-INF/web.xml"));
}
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) WarArtifact4CCStub(org.apache.maven.plugins.war.stub.WarArtifact4CCStub) JarEntry(java.util.jar.JarEntry) JarFile(java.util.jar.JarFile) File(java.io.File)

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