use of org.apache.maven.plugins.war.stub.JarArtifactStub in project maven-plugins by apache.
the class WarExplodedMojoTest method testExplodedWarWithOutputFileNameMapping.
/**
* @throws Exception in case of an error.
*/
public void testExplodedWarWithOutputFileNameMapping() throws Exception {
// setup test data
String testId = "ExplodedWarWithFileNameMapping";
MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
File webAppDirectory = new File(getTestDirectory(), testId);
File webAppSource = createWebAppSource(testId);
File classesDir = createClassesDir(testId, true);
ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
ArtifactStub jarArtifact = new JarArtifactStub(getBasedir(), artifactHandler);
File jarFile = jarArtifact.getFile();
assertTrue("jar not found: " + jarFile.toString(), jarFile.exists());
// configure mojo
project.addArtifact(jarArtifact);
mojo.setOutputFileNameMapping("@{artifactId}@.@{extension}@");
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/lib/jarartifact.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.plugins.war.stub.JarArtifactStub in project maven-plugins by apache.
the class WarExplodedMojoTest method testExplodedWarWithJar.
public void testExplodedWarWithJar() throws Exception {
// setup test data
String testId = "ExplodedWarWithJar";
MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
File webAppDirectory = new File(getTestDirectory(), testId);
File webAppSource = createWebAppSource(testId);
File classesDir = createClassesDir(testId, true);
ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
ArtifactStub jarArtifact = new JarArtifactStub(getBasedir(), artifactHandler);
File jarFile = jarArtifact.getFile();
assertTrue("jar not found: " + jarFile.toString(), jarFile.exists());
// configure mojo
project.addArtifact(jarArtifact);
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/lib/jarartifact-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.plugins.war.stub.JarArtifactStub in project maven-plugins by apache.
the class WarDependenciesAnalysisTest method testRemovedDependency.
public void testRemovedDependency() throws Exception {
// setup test data
final String testId = "remove-dependency";
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 }, null, new String[] { "WEB-INF/lib/lib-test-1.0.jar" }, null);
}
use of org.apache.maven.plugins.war.stub.JarArtifactStub 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.plugins.war.stub.JarArtifactStub 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" });
}
Aggregations