Search in sources :

Example 6 with DependencyArtifactStubFactory

use of org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory in project maven-dependency-plugin by apache.

the class TestDestFileFilter method setUp.

protected void setUp() throws Exception {
    super.setUp();
    outputFolder = new File("target/markers/");
    DependencyTestUtils.removeDirectory(outputFolder);
    assertFalse(outputFolder.exists());
    this.fact = new DependencyArtifactStubFactory(outputFolder, false);
    artifacts = fact.getReleaseAndSnapshotArtifacts();
}
Also used : File(java.io.File) DependencyArtifactStubFactory(org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory)

Example 7 with DependencyArtifactStubFactory

use of org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory in project maven-dependency-plugin by apache.

the class TestResolveMarkerFileFilter method setUp.

protected void setUp() throws Exception {
    super.setUp();
    outputFolder = new File("target/markers/");
    DependencyTestUtils.removeDirectory(outputFolder);
    assertFalse(outputFolder.exists());
    this.fact = new DependencyArtifactStubFactory(outputFolder, false);
    artifacts = fact.getReleaseAndSnapshotArtifacts();
}
Also used : File(java.io.File) DependencyArtifactStubFactory(org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory)

Example 8 with DependencyArtifactStubFactory

use of org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory in project maven-plugins by apache.

the class TestMarkerFileFilter method testMarkerTimestamp.

public void testMarkerTimestamp() throws IOException, MojoExecutionException, ArtifactFilterException {
    // filter includes release artifact because no marker present
    // filter includes snapshot artifact becaues it is newer than marker
    DependencyArtifactStubFactory fileFact = new DependencyArtifactStubFactory(outputFolder, true);
    Artifact snap = fileFact.getSnapshotArtifact();
    Artifact release = fileFact.getReleaseArtifact();
    Set<Artifact> tempArtifacts = new HashSet<Artifact>();
    tempArtifacts.add(snap);
    tempArtifacts.add(release);
    DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler(snap, outputFolder);
    handler.setMarker();
    assertTrue(snap.getFile().setLastModified(snap.getFile().lastModified() + 1500));
    MarkerFileFilter filter = new MarkerFileFilter(false, false, true, new DefaultFileMarkerHandler(outputFolder));
    Set<Artifact> result = filter.filter(tempArtifacts);
    assertEquals(2, result.size());
    // update marker; filter won't include snapshot because timestamps equal
    handler.setMarker();
    result = filter.filter(tempArtifacts);
    assertEquals(1, result.size());
    // filter won't include snapshot because it is older than marker
    assertTrue(snap.getFile().setLastModified(snap.getFile().lastModified() - 10000));
    result = filter.filter(tempArtifacts);
    assertEquals(1, result.size());
    assertTrue(handler.clearMarker());
    assertFalse(handler.isMarkerSet());
    snap.getFile().delete();
    release.getFile().delete();
    DependencyTestUtils.removeDirectory(outputFolder);
    assertFalse(outputFolder.exists());
}
Also used : DefaultFileMarkerHandler(org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler) Artifact(org.apache.maven.artifact.Artifact) DependencyArtifactStubFactory(org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory) HashSet(java.util.HashSet)

Example 9 with DependencyArtifactStubFactory

use of org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory in project maven-plugins by apache.

the class AbstractDependencyMojoTestCase method setUp.

protected void setUp(String testDirStr, boolean createFiles, boolean flattenedPath) throws Exception {
    // required for mojo lookups to work
    super.setUp();
    testDir = new File(getBasedir(), "target" + File.separatorChar + "unit-tests" + File.separatorChar + testDirStr + File.separatorChar);
    DependencyTestUtils.removeDirectory(testDir);
    assertFalse(testDir.exists());
    stubFactory = new DependencyArtifactStubFactory(this.testDir, createFiles, flattenedPath);
}
Also used : File(java.io.File) DependencyArtifactStubFactory(org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory)

Example 10 with DependencyArtifactStubFactory

use of org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory 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)

Aggregations

DependencyArtifactStubFactory (org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory)16 File (java.io.File)12 Artifact (org.apache.maven.artifact.Artifact)6 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 DefaultArtifactFactory (org.apache.maven.artifact.factory.DefaultArtifactFactory)2 DefaultArtifactHandlerManager (org.apache.maven.artifact.handler.manager.DefaultArtifactHandlerManager)2 MavenSession (org.apache.maven.execution.MavenSession)2 Dependency (org.apache.maven.model.Dependency)2 DependencyManagement (org.apache.maven.model.DependencyManagement)2 Exclusion (org.apache.maven.model.Exclusion)2 MavenProjectStub (org.apache.maven.plugin.testing.stubs.MavenProjectStub)2 StubArtifactRepository (org.apache.maven.plugin.testing.stubs.StubArtifactRepository)2 AnalyzeDepMgt (org.apache.maven.plugins.dependency.analyze.AnalyzeDepMgt)2 ArtifactItem (org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem)2 DependencyProjectStub (org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub)2 DefaultFileMarkerHandler (org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler)2 MavenProject (org.apache.maven.project.MavenProject)2 RepositoryManager (org.apache.maven.shared.repository.RepositoryManager)2