Search in sources :

Example 1 with ArtifactItem

use of org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem in project maven-dependency-plugin by apache.

the class TestUnpackMarkerFileHandler method setUp.

protected void setUp() throws Exception {
    super.setUp();
    testDir = new File(getBasedir(), "target" + File.separatorChar + "unit-tests" + File.separatorChar + "unpack-markers" + File.separatorChar);
    DependencyTestUtils.removeDirectory(testDir);
    assertFalse(testDir.exists());
    stubFactory = new DependencyArtifactStubFactory(this.testDir, false);
    Artifact artifact = stubFactory.createArtifact("test", "test", "1");
    ArtifactItem artifactItem;
    stubFactory.getArtifactItem(artifact);
    artifactItems.add(stubFactory.getArtifactItem(stubFactory.createArtifact("test", "test", "1")));
    artifact = stubFactory.createArtifact("test2", "test2", "2");
    artifactItem = new ArtifactItem(artifact);
    artifactItem.setIncludes("**/*.xml");
    artifactItems.add(artifactItem);
    artifact = stubFactory.createArtifact("test3", "test3", "3");
    artifactItem = new ArtifactItem(artifact);
    artifactItem.setExcludes("**/*.class");
    artifactItems.add(artifactItem);
    artifact = stubFactory.createArtifact("test4", "test4", "4");
    artifactItem = new ArtifactItem(artifact);
    artifactItem.setIncludes("**/*.xml");
    artifactItem.setExcludes("**/*.class");
    artifactItems.add(artifactItem);
    outputFolder = new File("target/markers/");
    DependencyTestUtils.removeDirectory(this.outputFolder);
    assertFalse(outputFolder.exists());
}
Also used : ArtifactItem(org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact) DependencyArtifactStubFactory(org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory)

Example 2 with ArtifactItem

use of org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem in project maven-dependency-plugin by apache.

the class TestUnpackMarkerFileHandler method testMarkerTimeStamp.

public void testMarkerTimeStamp() throws MojoExecutionException, IOException, InterruptedException {
    File theFile = new File(outputFolder, "theFile.jar");
    outputFolder.mkdirs();
    theFile.createNewFile();
    ArtifactItem theArtifactItem = artifactItems.get(0);
    Artifact theArtifact = theArtifactItem.getArtifact();
    theArtifact.setFile(theFile);
    UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler(theArtifactItem, this.outputFolder);
    assertFalse(handler.isMarkerSet());
    // if the marker is not set, assume it is infinately older than the
    // artifact.
    assertTrue(handler.isMarkerOlder(theArtifact));
    handler.setMarker();
    assertFalse(handler.isMarkerOlder(theArtifact));
    assertTrue(theFile.setLastModified(theFile.lastModified() + 60000));
    assertTrue(handler.isMarkerOlder(theArtifact));
    theFile.delete();
    handler.clearMarker();
    assertFalse(handler.isMarkerSet());
}
Also used : ArtifactItem(org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact) StubUnpackFileMarkerHandler(org.apache.maven.plugins.dependency.testUtils.stubs.StubUnpackFileMarkerHandler)

Example 3 with ArtifactItem

use of org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem in project maven-plugins by apache.

the class TestUnpackMarkerFileHandler method setUp.

protected void setUp() throws Exception {
    super.setUp();
    testDir = new File(getBasedir(), "target" + File.separatorChar + "unit-tests" + File.separatorChar + "unpack-markers" + File.separatorChar);
    DependencyTestUtils.removeDirectory(testDir);
    assertFalse(testDir.exists());
    stubFactory = new DependencyArtifactStubFactory(this.testDir, false);
    Artifact artifact = stubFactory.createArtifact("test", "test", "1");
    ArtifactItem artifactItem;
    stubFactory.getArtifactItem(artifact);
    artifactItems.add(stubFactory.getArtifactItem(stubFactory.createArtifact("test", "test", "1")));
    artifact = stubFactory.createArtifact("test2", "test2", "2");
    artifactItem = new ArtifactItem(artifact);
    artifactItem.setIncludes("**/*.xml");
    artifactItems.add(artifactItem);
    artifact = stubFactory.createArtifact("test3", "test3", "3");
    artifactItem = new ArtifactItem(artifact);
    artifactItem.setExcludes("**/*.class");
    artifactItems.add(artifactItem);
    artifact = stubFactory.createArtifact("test4", "test4", "4");
    artifactItem = new ArtifactItem(artifact);
    artifactItem.setIncludes("**/*.xml");
    artifactItem.setExcludes("**/*.class");
    artifactItems.add(artifactItem);
    outputFolder = new File("target/markers/");
    DependencyTestUtils.removeDirectory(this.outputFolder);
    assertFalse(outputFolder.exists());
}
Also used : ArtifactItem(org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact) DependencyArtifactStubFactory(org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory)

Example 4 with ArtifactItem

use of org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem in project maven-plugins by apache.

the class TestUnpackMarkerFileHandler method testMarkerTimeStamp.

public void testMarkerTimeStamp() throws MojoExecutionException, IOException, InterruptedException {
    File theFile = new File(outputFolder, "theFile.jar");
    outputFolder.mkdirs();
    theFile.createNewFile();
    ArtifactItem theArtifactItem = artifactItems.get(0);
    Artifact theArtifact = theArtifactItem.getArtifact();
    theArtifact.setFile(theFile);
    UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler(theArtifactItem, this.outputFolder);
    assertFalse(handler.isMarkerSet());
    // if the marker is not set, assume it is infinately older than the
    // artifact.
    assertTrue(handler.isMarkerOlder(theArtifact));
    handler.setMarker();
    assertFalse(handler.isMarkerOlder(theArtifact));
    assertTrue(theFile.setLastModified(theFile.lastModified() + 60000));
    assertTrue(handler.isMarkerOlder(theArtifact));
    theFile.delete();
    handler.clearMarker();
    assertFalse(handler.isMarkerSet());
}
Also used : ArtifactItem(org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact) StubUnpackFileMarkerHandler(org.apache.maven.plugins.dependency.testUtils.stubs.StubUnpackFileMarkerHandler)

Aggregations

File (java.io.File)4 Artifact (org.apache.maven.artifact.Artifact)4 ArtifactItem (org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem)4 DependencyArtifactStubFactory (org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory)2 StubUnpackFileMarkerHandler (org.apache.maven.plugins.dependency.testUtils.stubs.StubUnpackFileMarkerHandler)2