protected void setUp() throws Exception { super.setUp("unpack", true); File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-test/plugin-config.xml"); mojo = (UnpackMojo) lookupMojo("unpack", testPom); mojo.setOutputDirectory(new File(this.testDir, "outputDirectory")); mojo.setMarkersDirectory(new File(this.testDir, "markers")); setSilent(mojo, true); assertNotNull(mojo); assertNotNull(mojo.getProject()); // MavenProject project = mojo.getProject(); // init classifier things // it needs to get the archivermanager stubFactory.setUnpackableFile(mojo.getArchiverManager()); // i'm using one file repeatedly to archive so I can test the name // programmatically. stubFactory.setSrcFile( new File( getBasedir() + File.separatorChar + "target/test-classes/unit/unpack-dependencies-test/test.txt")); mojo.setFactory(DependencyTestUtils.getArtifactFactory()); mojo.setResolver(new StubArtifactResolver(stubFactory, false, false)); mojo.setLocal(new StubArtifactRepository(this.testDir.getAbsolutePath())); mojo.setArtifactCollector(new StubArtifactCollector()); mojo.setUseJvmChmod(true); }
public void testMissingVersionFromDependencyMgtWithClassifier() throws Exception { ArtifactItem item = new ArtifactItem(); item.setArtifactId("artifactId"); item.setClassifier("classifier"); item.setGroupId("groupId"); item.setType("jar"); MavenProject project = mojo.getProject(); project.setDependencies(getDependencyList(item)); item = new ArtifactItem(); item.setArtifactId("artifactId-2"); item.setClassifier("classifier"); item.setGroupId("groupId"); item.setType("jar"); List<ArtifactItem> list = new ArrayList<ArtifactItem>(); list.add(item); mojo.setArtifactItems(list); project.getDependencyManagement().setDependencies(getDependencyMgtList(item)); mojo.execute(); assertMarkerFile(true, item); assertEquals("3.1", item.getVersion()); }