use of org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory in project maven-dependency-plugin by apache.
the class TestAnalyzeDepMgt method setUp.
protected void setUp() throws Exception {
mojo = new AnalyzeDepMgt();
MavenProject project = new DependencyProjectStub();
stubFactory = new DependencyArtifactStubFactory(new File(""), false);
Set<Artifact> allArtifacts = stubFactory.getMixedArtifacts();
Set<Artifact> directArtifacts = stubFactory.getClassifiedArtifacts();
exclusionArtifact = stubFactory.getReleaseArtifact();
directArtifacts.add(exclusionArtifact);
ex = new Exclusion();
ex.setArtifactId(exclusionArtifact.getArtifactId());
ex.setGroupId(exclusionArtifact.getGroupId());
exclusion = new Dependency();
exclusion.setArtifactId(exclusionArtifact.getArtifactId());
exclusion.setGroupId(exclusionArtifact.getGroupId());
exclusion.setType(exclusionArtifact.getType());
exclusion.setClassifier("");
exclusion.setVersion("3.0");
exclusion.addExclusion(ex);
List<Dependency> list = new ArrayList<Dependency>();
list.add(exclusion);
depMgt = new DependencyManagement();
depMgt.setDependencies(list);
project.setArtifacts(allArtifacts);
project.setDependencyArtifacts(directArtifacts);
mojo.setProject(project);
}
use of org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory in project maven-dependency-plugin by apache.
the class TestClassifierTypeTranslator method setUp.
protected void setUp() throws Exception {
super.setUp("classifiertype-translator", false);
artifactHandlerManager = new DefaultArtifactHandlerManager();
this.setVariableValueToObject(artifactHandlerManager, "artifactHandlers", new HashMap());
artifactFactory = new DefaultArtifactFactory();
this.setVariableValueToObject(artifactFactory, "artifactHandlerManager", artifactHandlerManager);
artifactRepository = new StubArtifactRepository(null);
DependencyArtifactStubFactory factory = new DependencyArtifactStubFactory(null, false);
artifacts = factory.getMixedArtifacts();
repoManager = lookup(RepositoryManager.class);
MavenSession session = newMavenSession(new MavenProjectStub());
buildingRequest = session.getProjectBuildingRequest();
DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) session.getRepositorySession();
repoSession.setLocalRepositoryManager(new SimpleLocalRepositoryManager(stubFactory.getWorkingDir()));
}
use of org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory in project maven-dependency-plugin by apache.
the class TestMarkerFileFilter 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();
}
use of org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory in project maven-dependency-plugin 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());
}
use of org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory 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());
}
Aggregations