use of org.apache.maven.plugin.testing.stubs.ArtifactStub in project maven-plugins by apache.
the class WarOverlaysTest method testOverlaysIncludesExcludesWithMultipleDefinitions.
public void testOverlaysIncludesExcludesWithMultipleDefinitions() throws Exception {
// setup test data
final String testId = "overlays-includes-excludes-multiple-defs";
// 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");
Overlay over2 = new DefaultOverlay(overlay1);
over2.setIncludes("jsp/d/*");
over2.setExcludes("jsp/d/a.jsp");
Overlay over3 = new DefaultOverlay(overlay3);
over3.setIncludes("**/*.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");
assertOverlayedFile(webAppDirectory, "overlay-full-3", "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);
}
}
use of org.apache.maven.plugin.testing.stubs.ArtifactStub in project maven-plugins by apache.
the class WarOverlaysTest method testDefaultOverlays.
public void testDefaultOverlays() throws Exception {
// setup test data
final String testId = "default-overlays";
// Add an overlay
final ArtifactStub overlay = buildWarOverlayStub("overlay-one");
final ArtifactStub overlay2 = buildWarOverlayStub("overlay-two");
final File webAppDirectory = setUpMojo(testId, new ArtifactStub[] { overlay, overlay2 });
final List<File> assertedFiles = new ArrayList<File>();
try {
mojo.execute();
assertedFiles.addAll(assertDefaultContent(webAppDirectory));
assertedFiles.addAll(assertWebXml(webAppDirectory));
assertedFiles.addAll(assertCustomContent(webAppDirectory, new String[] { "index.jsp", "login.jsp", "admin.jsp" }, "overlay file not found"));
// index and login come from overlay1
assertOverlayedFile(webAppDirectory, "overlay-one", "index.jsp");
assertOverlayedFile(webAppDirectory, "overlay-one", "login.jsp");
// admin comes from overlay2
// index and login comes from overlay1
assertOverlayedFile(webAppDirectory, "overlay-two", "admin.jsp");
// 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);
}
}
use of org.apache.maven.plugin.testing.stubs.ArtifactStub in project maven-plugins by apache.
the class WarOverlaysTest method testScenarioOneWithDefaulSettings.
/**
* Merge a dependent WAR when a file in the war source directory overrides one found in the WAR.
*
* It also tests completeness of the resulting war as well as the proper order of dependencies.
*
* @throws Exception if any error occurs
*/
public void testScenarioOneWithDefaulSettings() throws Exception {
// setup test data
final String testId = "scenario-one-default-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" });
assertScenariOne(testId, webAppDirectory);
}
use of org.apache.maven.plugin.testing.stubs.ArtifactStub 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
}
}
use of org.apache.maven.plugin.testing.stubs.ArtifactStub 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());
}
}
Aggregations