use of org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock in project maven-plugins by apache.
the class AddDependencySetsTaskTest method testGetDependencyArtifacts_ShouldIgnoreTransitivePathFilteringWhenIncludeNotTransitive.
public void testGetDependencyArtifacts_ShouldIgnoreTransitivePathFilteringWhenIncludeNotTransitive() throws ArchiveCreationException, InvalidAssemblerConfigurationException {
final MavenProject project = new MavenProject(new Model());
final Set<Artifact> artifacts = new HashSet<Artifact>();
final ArtifactMock am = new ArtifactMock(mockManager, "group", "artifact", "1.0", "jar", false);
artifacts.add(am.getArtifact());
final ArtifactMock am2 = new ArtifactMock(mockManager, "group2", "artifact2", "1.0", "jar", false);
artifacts.add(am2.getArtifact());
final DependencySet dependencySet = new DependencySet();
dependencySet.addInclude("group:artifact");
dependencySet.setUseTransitiveFiltering(false);
final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
mockManager.replayAll();
final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(dependencySet), artifacts, project, null, logger);
final Set<Artifact> result = task.resolveDependencyArtifacts(dependencySet);
assertNotNull(result);
assertEquals(1, result.size());
assertSame(am.getArtifact(), result.iterator().next());
mockManager.verifyAll();
}
use of org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock in project maven-plugins by apache.
the class ModuleSetAssemblyPhaseTest method testAddModuleArtifact_ShouldThrowExceptionWhenArtifactFileIsNull.
public void testAddModuleArtifact_ShouldThrowExceptionWhenArtifactFileIsNull() throws AssemblyFormattingException, IOException {
final EasyMockSupport mm = new EasyMockSupport();
final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "artifact", "version", "type", false);
artifactMock.setNullFile();
mm.replayAll();
try {
createPhase(new ConsoleLogger(Logger.LEVEL_DEBUG, "test"), null).addModuleArtifact(artifactMock.getArtifact(), null, null, null, null);
fail("Expected ArchiveCreationException since artifact file is null.");
} catch (final ArchiveCreationException e) {
// expected
}
mm.verifyAll();
}
use of org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock in project maven-plugins by apache.
the class ModuleSetAssemblyPhaseTest method testAddModuleArtifact_ShouldAddOneArtifact.
public void testAddModuleArtifact_ShouldAddOneArtifact() throws AssemblyFormattingException, IOException, ArchiveCreationException {
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask(mm);
final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "artifact", "version", "type", false);
final File artifactFile = artifactMock.setNewFile();
final MavenProject project = createProject("group", "artifact", "version", null);
project.setArtifact(artifactMock.getArtifact());
macTask.expectGetFinalName("final-name");
macTask.expectGetDestFile(new File("junk"));
macTask.expectGetMode(0222, 0222);
macTask.expectAddFile(artifactFile, "out/artifact", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
final ModuleBinaries binaries = new ModuleBinaries();
binaries.setOutputDirectory("out");
binaries.setOutputFileNameMapping("artifact");
binaries.setUnpack(false);
binaries.setFileMode("777");
DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
mm.replayAll();
createPhase(new ConsoleLogger(Logger.LEVEL_DEBUG, "test"), null).addModuleArtifact(artifactMock.getArtifact(), project, macTask.archiver, macTask.configSource, binaries);
mm.verifyAll();
}
use of org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock in project maven-plugins by apache.
the class ModuleSetAssemblyPhaseTest method testAddModuleBinaries_ShouldAddOneModuleArtifactAndNoDeps.
public void testAddModuleBinaries_ShouldAddOneModuleArtifactAndNoDeps() throws ArchiveCreationException, AssemblyFormattingException, IOException, InvalidAssemblerConfigurationException, DependencyResolutionException {
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask(mm);
final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "artifact", "version", "jar", false);
final File artifactFile = artifactMock.setNewFile();
macTask.expectGetFinalName("final-name");
macTask.expectGetDestFile(new File("junk"));
macTask.expectAddFile(artifactFile, "out/artifact", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
macTask.expectGetMode(0222, 0222);
final ModuleBinaries binaries = new ModuleBinaries();
binaries.setIncludeDependencies(false);
binaries.setUnpack(false);
binaries.setFileMode("777");
binaries.setOutputDirectory("out");
binaries.setOutputFileNameMapping("artifact");
final MavenProject project = createProject("group", "artifact", "version", null);
project.setArtifact(artifactMock.getArtifact());
final Set<MavenProject> projects = singleton(project);
macTask.expectResolveDependencySets();
DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
mm.replayAll();
final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
createPhase(logger, macTask.dependencyResolver, null).addModuleBinaries(null, null, binaries, projects, macTask.archiver, macTask.configSource);
mm.verifyAll();
}
use of org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock in project maven-plugins by apache.
the class AssemblyFormatUtilsTest method verifyEvalFileNameMapping.
private void verifyEvalFileNameMapping(final String expression, final String classifier, final String extension, final MavenProject mainProject, final MavenProject moduleProject, final MavenProject artifactProject, final String checkValue) throws AssemblyFormattingException {
final ArtifactMock artifactMock = new ArtifactMock(mockManager, artifactProject.getGroupId(), artifactProject.getArtifactId(), artifactProject.getVersion(), extension, classifier, false, null);
final ArtifactMock moduleArtifactMock = new ArtifactMock(mockManager, moduleProject.getGroupId(), moduleProject.getArtifactId(), moduleProject.getVersion(), "jar", false, null);
final MavenSession session = mockManager.createMock(MavenSession.class);
expect(session.getExecutionProperties()).andReturn(System.getProperties()).anyTimes();
expect(session.getUserProperties()).andReturn(new Properties()).anyTimes();
final AssemblerConfigurationSource cs = mockManager.createMock(AssemblerConfigurationSource.class);
expect(cs.getMavenSession()).andReturn(session).anyTimes();
DefaultAssemblyArchiverTest.setupInterpolators(cs, mainProject);
mockManager.replayAll();
final String result = AssemblyFormatUtils.evaluateFileNameMapping(expression, artifactMock.getArtifact(), mainProject, moduleArtifactMock.getArtifact(), cs, AssemblyFormatUtils.moduleProjectInterpolator(moduleProject), AssemblyFormatUtils.artifactProjectInterpolator(artifactProject));
/*
final String result =
AssemblyFormatUtils.evaluateFileNameMapping( expression,
moduleArtifactInterpolator( moduleArtifactMock.getArtifact() ),
moduleProjectInterpolator( moduleProject ),
artifactInterpolator( artifactMock.getArtifact() ),
artifactProjectInterpolator( artifactProject ),
mainArtifactPropsOnly( mainProject ),
classifierRules( artifactMock.getArtifact() ),
FixedStringSearchInterpolator.create( new
PropertiesBasedValueSource( System.getProperties() )) );
*/
assertEquals(checkValue, result);
mockManager.verifyAll();
// clear out for next call.
mockManager.resetAll();
}
Aggregations