Search in sources :

Example 11 with WarArtifact4CCStub

use of org.apache.maven.plugins.war.stub.WarArtifact4CCStub in project maven-plugins by apache.

the class WarMojoTest method testMetaInfContent.

public void testMetaInfContent() throws Exception {
    String testId = "SimpleWarWithMetaInfContent";
    MavenProject4CopyConstructor project = new MavenProject4CopyConstructor();
    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);
    File xmlSource = createXMLConfigDir(testId, new String[] { "web.xml" });
    // Create the sample config.xml
    final File configFile = new File(webAppSource, "META-INF/config.xml");
    createFile(configFile, "<config></config>");
    project.setArtifact(warArtifact);
    this.configureMojo(mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project);
    setVariableValueToObject(mojo, "outputDirectory", outputDir);
    setVariableValueToObject(mojo, "warName", warName);
    mojo.setWebXml(new File(xmlSource, "web.xml"));
    mojo.execute();
    // validate jar file
    File expectedJarFile = new File(outputDir, "simple.war");
    assertJarContent(expectedJarFile, new String[] { "META-INF/MANIFEST.MF", "META-INF/config.xml", "WEB-INF/web.xml", "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, mojo.getWebXml().toString(), null, null, null, null });
}
Also used : MavenProject4CopyConstructor(org.apache.maven.plugins.war.stub.MavenProject4CopyConstructor) WarArtifact4CCStub(org.apache.maven.plugins.war.stub.WarArtifact4CCStub) JarFile(java.util.jar.JarFile) File(java.io.File)

Example 12 with WarArtifact4CCStub

use of org.apache.maven.plugins.war.stub.WarArtifact4CCStub in project maven-plugins by apache.

the class WarMojoTest method testNotPrimaryArtifact.

public void testNotPrimaryArtifact() throws Exception {
    // use a different pom
    File pom = new File(getBasedir(), "target/test-classes/unit/warmojotest/not-primary-artifact.xml");
    mojo = (WarMojo) lookupMojo("war", pom);
    String testId = "NotPrimaryArtifact";
    MavenProject4CopyConstructor project = new MavenProject4CopyConstructor();
    String outputDir = getTestDirectory().getAbsolutePath() + "/" + testId + "-output";
    File webAppDirectory = new File(getTestDirectory(), testId);
    WarArtifact4CCStub warArtifact = new WarArtifact4CCStub(getBasedir());
    ProjectHelperStub projectHelper = new ProjectHelperStub();
    String warName = "simple";
    File webAppSource = createWebAppSource(testId);
    File classesDir = createClassesDir(testId, true);
    File xmlSource = createXMLConfigDir(testId, new String[] { "web.xml" });
    warArtifact.setFile(new File("error.war"));
    project.setArtifact(warArtifact);
    this.configureMojo(mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project);
    setVariableValueToObject(mojo, "projectHelper", projectHelper);
    setVariableValueToObject(mojo, "outputDirectory", outputDir);
    setVariableValueToObject(mojo, "warName", warName);
    mojo.setWebXml(new File(xmlSource, "web.xml"));
    mojo.execute();
    // validate jar file
    File expectedJarFile = new File(outputDir, "simple.war");
    assertJarContent(expectedJarFile, new String[] { "META-INF/MANIFEST.MF", "WEB-INF/web.xml", "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, mojo.getWebXml().toString(), null, null, null, null });
}
Also used : ProjectHelperStub(org.apache.maven.plugins.war.stub.ProjectHelperStub) MavenProject4CopyConstructor(org.apache.maven.plugins.war.stub.MavenProject4CopyConstructor) WarArtifact4CCStub(org.apache.maven.plugins.war.stub.WarArtifact4CCStub) JarFile(java.util.jar.JarFile) File(java.io.File)

Example 13 with WarArtifact4CCStub

use of org.apache.maven.plugins.war.stub.WarArtifact4CCStub in project maven-plugins by apache.

the class WarMojoTest method testSimpleWar.

public void testSimpleWar() throws Exception {
    String testId = "SimpleWar";
    MavenProject4CopyConstructor project = new MavenProject4CopyConstructor();
    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);
    File xmlSource = createXMLConfigDir(testId, new String[] { "web.xml" });
    project.setArtifact(warArtifact);
    this.configureMojo(mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project);
    setVariableValueToObject(mojo, "outputDirectory", outputDir);
    setVariableValueToObject(mojo, "warName", warName);
    mojo.setWebXml(new File(xmlSource, "web.xml"));
    mojo.execute();
    // validate jar file
    File expectedJarFile = new File(outputDir, "simple.war");
    assertJarContent(expectedJarFile, new String[] { "META-INF/MANIFEST.MF", "WEB-INF/web.xml", "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, mojo.getWebXml().toString(), null, null, null, null });
}
Also used : MavenProject4CopyConstructor(org.apache.maven.plugins.war.stub.MavenProject4CopyConstructor) WarArtifact4CCStub(org.apache.maven.plugins.war.stub.WarArtifact4CCStub) JarFile(java.util.jar.JarFile) File(java.io.File)

Aggregations

File (java.io.File)13 JarFile (java.util.jar.JarFile)13 WarArtifact4CCStub (org.apache.maven.plugins.war.stub.WarArtifact4CCStub)13 MavenProject4CopyConstructor (org.apache.maven.plugins.war.stub.MavenProject4CopyConstructor)11 ProjectHelperStub (org.apache.maven.plugins.war.stub.ProjectHelperStub)3 JarEntry (java.util.jar.JarEntry)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 MavenProjectArtifactsStub (org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub)2 ArtifactHandler (org.apache.maven.artifact.handler.ArtifactHandler)1 JarArtifactStub (org.apache.maven.plugins.war.stub.JarArtifactStub)1