use of org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub in project maven-plugins 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.stubs.DependencyProjectStub in project maven-plugins by apache.
the class TestAnalyzeDepMgt method testMojo.
public void testMojo() throws IOException {
mojo.setIgnoreDirect(false);
try {
// test with nothing in depMgt
mojo.execute();
} catch (Exception e) {
e.printStackTrace();
fail("Caught Unexpected Exception:" + e.getLocalizedMessage());
}
try {
DependencyProjectStub project = (DependencyProjectStub) mojo.getProject();
project.setDependencyManagement(depMgt);
// test with exclusion
mojo.execute();
} catch (Exception e) {
e.printStackTrace();
fail("Caught Unexpected Exception:" + e.getLocalizedMessage());
}
try {
DependencyProjectStub project = (DependencyProjectStub) mojo.getProject();
project.setDependencyManagement(depMgt);
// test with exclusion
mojo.setFailBuild(true);
mojo.execute();
fail("Expected exception to fail the build.");
} catch (Exception e) {
System.out.println("Caught Expected Exception:" + e.getLocalizedMessage());
}
try {
DependencyProjectStub project = (DependencyProjectStub) mojo.getProject();
project.setDependencyManagement(depMgt);
// test with exclusion
mojo.setFailBuild(true);
mojo.setIgnoreDirect(true);
mojo.execute();
} catch (Exception e) {
e.printStackTrace();
fail("Caught Unexpected Exception:" + e.getLocalizedMessage());
}
}
Aggregations