Search in sources :

Example 1 with JarArtifactStub

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();
}
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) XarArtifactStub(org.apache.maven.plugins.war.stub.XarArtifactStub) MarArtifactStub(org.apache.maven.plugins.war.stub.MarArtifactStub) EJBArtifactStub(org.apache.maven.plugins.war.stub.EJBArtifactStub) WarArtifactStub(org.apache.maven.plugins.war.stub.WarArtifactStub) PARArtifactStub(org.apache.maven.plugins.war.stub.PARArtifactStub) TLDArtifactStub(org.apache.maven.plugins.war.stub.TLDArtifactStub) IncludeExcludeWarArtifactStub(org.apache.maven.plugins.war.stub.IncludeExcludeWarArtifactStub) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) EJBClientArtifactStub(org.apache.maven.plugins.war.stub.EJBClientArtifactStub) JarArtifactStub(org.apache.maven.plugins.war.stub.JarArtifactStub) AarArtifactStub(org.apache.maven.plugins.war.stub.AarArtifactStub) File(java.io.File)

Example 2 with JarArtifactStub

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();
}
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) XarArtifactStub(org.apache.maven.plugins.war.stub.XarArtifactStub) MarArtifactStub(org.apache.maven.plugins.war.stub.MarArtifactStub) EJBArtifactStub(org.apache.maven.plugins.war.stub.EJBArtifactStub) WarArtifactStub(org.apache.maven.plugins.war.stub.WarArtifactStub) PARArtifactStub(org.apache.maven.plugins.war.stub.PARArtifactStub) TLDArtifactStub(org.apache.maven.plugins.war.stub.TLDArtifactStub) IncludeExcludeWarArtifactStub(org.apache.maven.plugins.war.stub.IncludeExcludeWarArtifactStub) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) EJBClientArtifactStub(org.apache.maven.plugins.war.stub.EJBClientArtifactStub) JarArtifactStub(org.apache.maven.plugins.war.stub.JarArtifactStub) AarArtifactStub(org.apache.maven.plugins.war.stub.AarArtifactStub) File(java.io.File)

Example 3 with JarArtifactStub

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);
}
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 4 with JarArtifactStub

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" });
}
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 5 with JarArtifactStub

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" });
}
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)

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