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());
}
}
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());
}
}
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());
}
}
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"));
}
Aggregations