use of org.apache.maven.plugin.testing.stubs.ArtifactStub in project maven-plugins by apache.
the class WarDependenciesAnalysisTest method testDependencyWithUpdatedVersion.
public void testDependencyWithUpdatedVersion() throws Exception {
// setup test data
final String testId = "dependency-update-version";
final ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
ArtifactStub jarArtifact = new JarArtifactStub(getBasedir(), artifactHandler);
jarArtifact.setArtifactId("lib-test");
jarArtifact.setVersion("1.0");
ArtifactStub jarArtifact2 = new JarArtifactStub(getBasedir(), artifactHandler);
jarArtifact2.setArtifactId("lib-test");
jarArtifact2.setVersion("2.0");
doTestTwiceWithUpdatedDependency(testId, new ArtifactStub[] { jarArtifact }, new ArtifactStub[] { jarArtifact2 }, new String[] { "WEB-INF/lib/lib-test-1.0.jar" }, new String[] { "WEB-INF/lib/lib-test-2.0.jar" });
}
use of org.apache.maven.plugin.testing.stubs.ArtifactStub in project maven-plugins by apache.
the class WarDependenciesAnalysisTest method testNoChange.
public void testNoChange() throws Exception {
// setup test data
final String testId = "no-change";
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 }, new ArtifactStub[] { jarArtifact }, new String[] { "WEB-INF/lib/lib-test-1.0.jar" }, new String[] { "WEB-INF/lib/lib-test-1.0.jar" });
}
use of org.apache.maven.plugin.testing.stubs.ArtifactStub in project maven-plugins by apache.
the class WarDependenciesAnalysisTest method testDependencyNowProvided.
public void testDependencyNowProvided() throws Exception {
// setup test data
final String testId = "dependency-now-provided";
final ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
ArtifactStub jarArtifact = new JarArtifactStub(getBasedir(), artifactHandler);
jarArtifact.setArtifactId("lib-test");
jarArtifact.setVersion("1.0");
ArtifactStub jarArtifact2 = new JarArtifactStub(getBasedir(), artifactHandler);
jarArtifact2.setArtifactId("lib-test");
jarArtifact2.setVersion("1.0");
jarArtifact2.setScope(Artifact.SCOPE_PROVIDED);
doTestTwiceWithUpdatedDependency(testId, new ArtifactStub[] { jarArtifact }, new ArtifactStub[] { jarArtifact2 }, new String[] { "WEB-INF/lib/lib-test-1.0.jar" }, null);
}
use of org.apache.maven.plugin.testing.stubs.ArtifactStub in project maven-plugins by apache.
the class WarExplodedMojoTest method testExplodedWarWithMar.
/**
* @throws Exception in case of an error.
*/
public void testExplodedWarWithMar() throws Exception {
// setup test data
String testId = "ExplodedWarWithMar";
MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
File webAppDirectory = new File(getTestDirectory(), testId);
File webAppSource = createWebAppSource(testId);
File classesDir = createClassesDir(testId, true);
// Fake here since the mar artifact handler does not exist: no biggie
ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
ArtifactStub marArtifact = new MarArtifactStub(getBasedir(), artifactHandler);
File marFile = marArtifact.getFile();
assertTrue("jar not found: " + marFile.toString(), marFile.exists());
// configure mojo
project.addArtifact(marArtifact);
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/modules/marartifact-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();
}
use of org.apache.maven.plugin.testing.stubs.ArtifactStub in project maven-plugins by apache.
the class WarOverlaysTest method testCacheWithUpdatedOverlay.
public void testCacheWithUpdatedOverlay() throws Exception {
// setup test data
final String testId = "cache-updated-overlay";
// 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 {
// Use the cache
setVariableValueToObject(mojo, "useCache", Boolean.TRUE);
setVariableValueToObject(mojo, "cacheFile", new File(mojo.getWorkDirectory(), "cache.xml"));
final LinkedList<Overlay> overlays = new LinkedList<Overlay>();
overlays.add(new DefaultOverlay(overlay));
overlays.add(new DefaultOverlay(overlay2));
mojo.setOverlays(overlays);
mojo.execute();
// Now change the overlay order and make sure the right file is overwritten
final LinkedList<Overlay> updatedOverlays = new LinkedList<Overlay>();
updatedOverlays.add(new DefaultOverlay(overlay2));
updatedOverlays.add(new DefaultOverlay(overlay));
mojo.setOverlays(updatedOverlays);
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 overlay2 now
assertOverlayedFile(webAppDirectory, "overlay-two", "index.jsp");
assertOverlayedFile(webAppDirectory, "overlay-one", "login.jsp");
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);
}
}
Aggregations