Search in sources :

Example 6 with JarArtifactStub

use of org.apache.maven.plugins.war.stub.JarArtifactStub 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);
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) JarArtifactStub(org.apache.maven.plugins.war.stub.JarArtifactStub) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) JarArtifactStub(org.apache.maven.plugins.war.stub.JarArtifactStub)

Example 7 with JarArtifactStub

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

the class WarMojoTest method testFailOnMissingWebXmlNotSpecifiedAndServlet30Used.

public void testFailOnMissingWebXmlNotSpecifiedAndServlet30Used() throws Exception {
    String testId = "SimpleWarUnderServlet30";
    MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
    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);
    final ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
    JarArtifactStub jarArtifactStub = new JarArtifactStub(getBasedir(), artifactHandler);
    jarArtifactStub.setFile(new File(getBasedir(), "/target/test-classes/unit/sample_wars/javax.servlet-api-3.0.1.jar"));
    jarArtifactStub.setScope(Artifact.SCOPE_PROVIDED);
    project.addArtifact(jarArtifactStub);
    project.setArtifact(warArtifact);
    project.setFile(warArtifact.getFile());
    this.configureMojo(mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project);
    setVariableValueToObject(mojo, "outputDirectory", outputDir);
    setVariableValueToObject(mojo, "warName", warName);
    mojo.execute();
    // validate war file
    File expectedWarFile = new File(outputDir, "simple.war");
    final Map<String, JarEntry> jarContent = assertJarContent(expectedWarFile, new String[] { "META-INF/MANIFEST.MF", "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, null, null, null });
    assertFalse("web.xml should be missing", jarContent.containsKey("WEB-INF/web.xml"));
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) JarArtifactStub(org.apache.maven.plugins.war.stub.JarArtifactStub) MavenProjectArtifactsStub(org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub) WarArtifact4CCStub(org.apache.maven.plugins.war.stub.WarArtifact4CCStub) JarEntry(java.util.jar.JarEntry) JarFile(java.util.jar.JarFile) File(java.io.File)

Aggregations

ArtifactHandler (org.apache.maven.artifact.handler.ArtifactHandler)7 JarArtifactStub (org.apache.maven.plugins.war.stub.JarArtifactStub)7 ArtifactStub (org.apache.maven.plugin.testing.stubs.ArtifactStub)6 File (java.io.File)3 MavenProjectArtifactsStub (org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub)3 AarArtifactStub (org.apache.maven.plugins.war.stub.AarArtifactStub)2 EJBArtifactStub (org.apache.maven.plugins.war.stub.EJBArtifactStub)2 EJBClientArtifactStub (org.apache.maven.plugins.war.stub.EJBClientArtifactStub)2 IncludeExcludeWarArtifactStub (org.apache.maven.plugins.war.stub.IncludeExcludeWarArtifactStub)2 MarArtifactStub (org.apache.maven.plugins.war.stub.MarArtifactStub)2 PARArtifactStub (org.apache.maven.plugins.war.stub.PARArtifactStub)2 TLDArtifactStub (org.apache.maven.plugins.war.stub.TLDArtifactStub)2 WarArtifactStub (org.apache.maven.plugins.war.stub.WarArtifactStub)2 XarArtifactStub (org.apache.maven.plugins.war.stub.XarArtifactStub)2 JarEntry (java.util.jar.JarEntry)1 JarFile (java.util.jar.JarFile)1 WarArtifact4CCStub (org.apache.maven.plugins.war.stub.WarArtifact4CCStub)1