use of org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub in project maven-plugins by apache.
the class WarExplodedMojoTest method testExplodedWar_WithPAR.
/**
* @throws Exception in case of an error.
*/
public void testExplodedWar_WithPAR() throws Exception {
// setup test data
String testId = "ExplodedWar_WithPAR";
MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
File webAppDirectory = new File(getTestDirectory(), testId);
File webAppSource = createWebAppSource(testId);
File classesDir = createClassesDir(testId, true);
PARArtifactStub parartifact = new PARArtifactStub(getBasedir());
File parFile = parartifact.getFile();
assertTrue("par not found: " + parFile.getAbsolutePath(), parFile.exists());
// configure mojo
project.addArtifact(parartifact);
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 expectedPARArtifact = new File(webAppDirectory, "WEB-INF/lib/parartifact-0.0-Test.jar");
assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
assertTrue("par artifact not found: " + expectedPARArtifact.toString(), expectedPARArtifact.exists());
// house keeping
expectedWebSourceFile.delete();
expectedWebSource2File.delete();
expectedPARArtifact.delete();
}
use of org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub 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.MavenProjectArtifactsStub in project maven-plugins by apache.
the class WarExplodedMojoTest method testExplodedWarWithAar.
/**
* @throws Exception in case of an error.
*/
public void testExplodedWarWithAar() throws Exception {
// setup test data
String testId = "ExplodedWarWithAar";
MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
File webAppDirectory = new File(getTestDirectory(), testId);
File webAppSource = createWebAppSource(testId);
File classesDir = createClassesDir(testId, true);
// Fake here since the aar artifact handler does not exist: no biggie
ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
ArtifactStub aarArtifact = new AarArtifactStub(getBasedir(), artifactHandler);
File aarFile = aarArtifact.getFile();
assertTrue("jar not found: " + aarFile.toString(), aarFile.exists());
// configure mojo
project.addArtifact(aarArtifact);
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/services/aarartifact-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.MavenProjectArtifactsStub in project maven-plugins by apache.
the class WarExplodedMojoTest method testExplodedWarWithXar.
/**
* @throws Exception in case of an error.
*/
public void testExplodedWarWithXar() throws Exception {
// setup test data
String testId = "ExplodedWarWithXar";
MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
File webAppDirectory = new File(getTestDirectory(), testId);
File webAppSource = createWebAppSource(testId);
File classesDir = createClassesDir(testId, true);
// Fake here since the xar artifact handler does not exist: no biggie
ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
ArtifactStub xarArtifact = new XarArtifactStub(getBasedir(), artifactHandler);
File xarFile = xarArtifact.getFile();
assertTrue("jar not found: " + xarFile.toString(), xarFile.exists());
// configure mojo
project.addArtifact(xarArtifact);
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/extensions/xarartifact-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.MavenProjectArtifactsStub in project maven-plugins by apache.
the class WarExplodedMojoTest method testExplodedWarMergeWarLocalFileOverride.
/**
* Merge a dependent WAR when a file in the war source directory overrides one found in the WAR.
* @throws Exception in case of an error.
*/
public void testExplodedWarMergeWarLocalFileOverride() throws Exception {
// setup test data
MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
WarArtifactStub warArtifact = new WarArtifactStub(getBasedir());
String testId = "testExplodedWarMergeWarLocalFileOverride";
File webAppDirectory = new File(getTestDirectory(), testId);
File webAppSource = getWebAppSource(testId);
File simpleJSP = new File(webAppSource, "org/sample/company/test.jsp");
createFile(simpleJSP);
File workDirectory = new File(getTestDirectory(), "/war/work-" + testId);
createDir(workDirectory);
File classesDir = createClassesDir(testId, true);
// configure mojo
project.addArtifact(warArtifact);
this.configureMojo(mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project);
setVariableValueToObject(mojo, "workDirectory", workDirectory);
mojo.execute();
// validate operation
File expectedFile = new File(webAppDirectory, "/org/sample/company/test.jsp");
assertTrue("file not found: " + expectedFile.toString(), expectedFile.exists());
assertEquals("file incorrect", simpleJSP.toString(), FileUtils.fileRead(expectedFile));
// check when the merged war file is newer - so set an old time on the local file
long time = new SimpleDateFormat("yyyy-MM-dd", Locale.US).parse("2005-1-1").getTime();
simpleJSP.setLastModified(time);
expectedFile.setLastModified(time);
project.addArtifact(warArtifact);
this.configureMojo(mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project);
setVariableValueToObject(mojo, "workDirectory", workDirectory);
mojo.execute();
assertTrue("file not found: " + expectedFile.toString(), expectedFile.exists());
assertEquals("file incorrect", simpleJSP.toString(), FileUtils.fileRead(expectedFile));
// house keeping
expectedFile.delete();
}
Aggregations