Search in sources :

Example 16 with ArtifactStub

use of org.apache.maven.plugin.testing.stubs.ArtifactStub 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 17 with ArtifactStub

use of org.apache.maven.plugin.testing.stubs.ArtifactStub 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)

Example 18 with ArtifactStub

use of org.apache.maven.plugin.testing.stubs.ArtifactStub 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 19 with ArtifactStub

use of org.apache.maven.plugin.testing.stubs.ArtifactStub in project maven-plugins by apache.

the class WarExplodedMojoTest method testExplodedWarWithMar.

/**
     * @throws Exception in case of an error.
     */
public void testExplodedWarWithMar() throws Exception {
    // setup test data
    String testId = "ExplodedWarWithMar";
    MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
    File webAppDirectory = new File(getTestDirectory(), testId);
    File webAppSource = createWebAppSource(testId);
    File classesDir = createClassesDir(testId, true);
    // Fake here since the mar artifact handler does not exist: no biggie
    ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
    ArtifactStub marArtifact = new MarArtifactStub(getBasedir(), artifactHandler);
    File marFile = marArtifact.getFile();
    assertTrue("jar not found: " + marFile.toString(), marFile.exists());
    // configure mojo
    project.addArtifact(marArtifact);
    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/modules/marartifact-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) MarArtifactStub(org.apache.maven.plugins.war.stub.MarArtifactStub) 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 20 with ArtifactStub

use of org.apache.maven.plugin.testing.stubs.ArtifactStub in project maven-plugins by apache.

the class WarOverlaysTest method testCacheWithUpdatedOverlay.

public void testCacheWithUpdatedOverlay() throws Exception {
    // setup test data
    final String testId = "cache-updated-overlay";
    // Add an overlay
    final ArtifactStub overlay = buildWarOverlayStub("overlay-one");
    final ArtifactStub overlay2 = buildWarOverlayStub("overlay-two");
    final File webAppDirectory = setUpMojo(testId, new ArtifactStub[] { overlay, overlay2 });
    final List<File> assertedFiles = new ArrayList<File>();
    try {
        // Use the cache
        setVariableValueToObject(mojo, "useCache", Boolean.TRUE);
        setVariableValueToObject(mojo, "cacheFile", new File(mojo.getWorkDirectory(), "cache.xml"));
        final LinkedList<Overlay> overlays = new LinkedList<Overlay>();
        overlays.add(new DefaultOverlay(overlay));
        overlays.add(new DefaultOverlay(overlay2));
        mojo.setOverlays(overlays);
        mojo.execute();
        // Now change the overlay order and make sure the right file is overwritten
        final LinkedList<Overlay> updatedOverlays = new LinkedList<Overlay>();
        updatedOverlays.add(new DefaultOverlay(overlay2));
        updatedOverlays.add(new DefaultOverlay(overlay));
        mojo.setOverlays(updatedOverlays);
        mojo.execute();
        assertedFiles.addAll(assertDefaultContent(webAppDirectory));
        assertedFiles.addAll(assertWebXml(webAppDirectory));
        assertedFiles.addAll(assertCustomContent(webAppDirectory, new String[] { "index.jsp", "login.jsp", "admin.jsp" }, "overlay file not found"));
        // index and login come from overlay2 now
        assertOverlayedFile(webAppDirectory, "overlay-two", "index.jsp");
        assertOverlayedFile(webAppDirectory, "overlay-one", "login.jsp");
        assertOverlayedFile(webAppDirectory, "overlay-two", "admin.jsp");
        // Ok now check that there is no more files/directories
        final FileFilter filter = new FileFilterImpl(webAppDirectory, new String[] { MANIFEST_PATH });
        assertWebAppContent(webAppDirectory, assertedFiles, filter);
    } finally {
        cleanDirectory(webAppDirectory);
    }
}
Also used : DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) ArrayList(java.util.ArrayList) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) Overlay(org.apache.maven.plugins.war.Overlay) DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) FileFilter(java.io.FileFilter) File(java.io.File) LinkedList(java.util.LinkedList)

Aggregations

ArtifactStub (org.apache.maven.plugin.testing.stubs.ArtifactStub)26 File (java.io.File)17 ArrayList (java.util.ArrayList)13 Overlay (org.apache.maven.plugins.war.Overlay)11 DefaultOverlay (org.apache.maven.plugins.war.overlay.DefaultOverlay)11 MavenProjectArtifactsStub (org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub)11 WarArtifactStub (org.apache.maven.plugins.war.stub.WarArtifactStub)10 ArtifactHandler (org.apache.maven.artifact.handler.ArtifactHandler)9 JarArtifactStub (org.apache.maven.plugins.war.stub.JarArtifactStub)9 FileFilter (java.io.FileFilter)6 InvalidOverlayConfigurationException (org.apache.maven.plugins.war.overlay.InvalidOverlayConfigurationException)5 OverlayManager (org.apache.maven.plugins.war.overlay.OverlayManager)5 AarArtifactStub (org.apache.maven.plugins.war.stub.AarArtifactStub)5 EJBArtifactStub (org.apache.maven.plugins.war.stub.EJBArtifactStub)5 EJBClientArtifactStub (org.apache.maven.plugins.war.stub.EJBClientArtifactStub)5 IncludeExcludeWarArtifactStub (org.apache.maven.plugins.war.stub.IncludeExcludeWarArtifactStub)5 MarArtifactStub (org.apache.maven.plugins.war.stub.MarArtifactStub)5 PARArtifactStub (org.apache.maven.plugins.war.stub.PARArtifactStub)5 TLDArtifactStub (org.apache.maven.plugins.war.stub.TLDArtifactStub)5 XarArtifactStub (org.apache.maven.plugins.war.stub.XarArtifactStub)5