use of org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock in project maven-plugins by apache.
the class AddArtifactTaskTest method testShouldAddArchiveFileWithoutUnpacking.
public void testShouldAddArchiveFileWithoutUnpacking() throws ArchiveCreationException, AssemblyFormattingException, IOException {
String outputLocation = "artifact";
ArtifactMock artifactMock = new ArtifactMock(mockManager, "group", "artifact", "version", "jar", false);
File artifactFile = artifactMock.setNewFile();
mac.expectGetMode(0222, 0222);
mac.expectGetDestFile(new File("junk"));
mac.expectAddFile(artifactFile, outputLocation);
mac.expectInterpolators();
mockManager.replayAll();
AddArtifactTask task = createTask(artifactMock.getArtifact());
task.execute(mac.archiver, mac.configSource);
mockManager.verifyAll();
}
use of org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock in project maven-plugins by apache.
the class AddArtifactTaskTest method testShouldAddArchiveFileWithUnpack.
public void testShouldAddArchiveFileWithUnpack() throws ArchiveCreationException, AssemblyFormattingException, IOException {
mac.expectModeChange(-1, -1, -1, -1, 1);
mac.expectInterpolators();
ArtifactMock artifactMock = new ArtifactMock(mockManager, "group", "artifact", "version", "jar", false);
artifactMock.setNewFile();
mac.expectGetDestFile(new File("junk"));
try {
// mac.archiver.addArchivedFileSet( artifactFile, outputLocation, AddArtifactTask.DEFAULT_INCLUDES_ARRAY,
// null );
mac.archiver.addArchivedFileSet((ArchivedFileSet) anyObject(), (Charset) anyObject());
} catch (ArchiverException e) {
fail("Should never happen.");
}
mockManager.replayAll();
AddArtifactTask task = createTask(artifactMock.getArtifact());
task.setUnpack(true);
task.execute(mac.archiver, mac.configSource);
mockManager.verifyAll();
}
use of org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock in project maven-plugins by apache.
the class AddArtifactTaskTest method testShouldAddArchiveFileWithDefaultOutputLocation.
public void testShouldAddArchiveFileWithDefaultOutputLocation() throws ArchiveCreationException, AssemblyFormattingException, IOException {
String artifactId = "myArtifact";
String version = "1";
String ext = "jar";
String outputDir = "tmp/";
ArtifactMock mock = new ArtifactMock(mockManager, "group", artifactId, version, ext, false);
File file = mock.setNewFile();
mock.setExtension(ext);
mac.expectGetMode(0222, 0222);
mac.expectGetDestFile(new File("junk"));
mac.expectAddFile(file, outputDir + artifactId + "-" + version + "." + ext);
mac.expectInterpolators();
mockManager.replayAll();
AddArtifactTask task = new AddArtifactTask(mock.getArtifact(), new ConsoleLogger(Logger.LEVEL_DEBUG, "test"), null);
task.setOutputDirectory(outputDir);
task.setFileNameMapping(new DependencySet().getOutputFileNameMapping());
Model model = new Model();
model.setArtifactId(artifactId);
model.setVersion(version);
MavenProject project = new MavenProject(model);
task.setProject(project);
task.execute(mac.archiver, mac.configSource);
mockManager.verifyAll();
}
use of org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock in project maven-plugins by apache.
the class AddArtifactTaskTest method testShouldAddArchiveFileWithUnpackIncludesAndExcludes.
public void testShouldAddArchiveFileWithUnpackIncludesAndExcludes() throws ArchiveCreationException, AssemblyFormattingException, IOException {
mac.expectModeChange(-1, -1, -1, -1, 1);
String[] includes = { "**/*.txt" };
String[] excludes = { "**/README.txt" };
ArtifactMock artifactMock = new ArtifactMock(mockManager, "group", "artifact", "version", "jar", false);
artifactMock.setNewFile();
mac.expectGetDestFile(new File("junk"));
mac.expectAddArchivedFileSet();
mac.expectInterpolators();
mockManager.replayAll();
AddArtifactTask task = createTask(artifactMock.getArtifact());
task.setUnpack(true);
task.setIncludes(Arrays.asList(includes));
task.setExcludes(Arrays.asList(excludes));
task.execute(mac.archiver, mac.configSource);
mockManager.verifyAll();
}
use of org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock in project maven-plugins by apache.
the class AddDependencySetsTaskTest method testAddDependencySet_ShouldInterpolateDefaultOutputFileNameMapping.
public void testAddDependencySet_ShouldInterpolateDefaultOutputFileNameMapping() throws AssemblyFormattingException, ArchiveCreationException, InvalidAssemblerConfigurationException, IOException {
final String outDir = "tmp/";
final String mainAid = "main";
final String mainGid = "org.maingrp";
final String mainVer = "9";
final String depAid = "dep";
final String depGid = "org.depgrp";
final String depVer = "1";
final String depExt = "war";
final DependencySet ds = new DependencySet();
ds.setOutputDirectory(outDir);
ds.setDirectoryMode(Integer.toString(10, 8));
ds.setFileMode(Integer.toString(10, 8));
final Model mainModel = new Model();
mainModel.setArtifactId(mainAid);
mainModel.setGroupId(mainGid);
mainModel.setVersion(mainVer);
final MavenProject mainProject = new MavenProject(mainModel);
final ArtifactMock mainArtifactMock = new ArtifactMock(mockManager, mainGid, mainAid, mainVer, "jar", false);
mainProject.setArtifact(mainArtifactMock.getArtifact());
final Model depModel = new Model();
depModel.setArtifactId(depAid);
depModel.setGroupId(depGid);
depModel.setVersion(depVer);
depModel.setPackaging(depExt);
final MavenProject depProject = new MavenProject(depModel);
final ArtifactMock depArtifactMock = new ArtifactMock(mockManager, depGid, depAid, depVer, depExt, false);
final File newFile = depArtifactMock.setNewFile();
depProject.setArtifact(depArtifactMock.getArtifact());
final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mockManager, mainProject);
macTask.expectBuildFromRepository(depProject);
macTask.expectCSGetFinalName(mainAid + "-" + mainVer);
macTask.expectCSGetRepositories(null, null);
macTask.expectGetDestFile(new File("junk"));
macTask.expectAddFile(newFile, outDir + depAid + "-" + depVer + "." + depExt, 10);
// macTask.expectGetSession( null );
macTask.expectGetMode(0222, 0222);
DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
mockManager.replayAll();
final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(ds), Collections.singleton(depArtifactMock.getArtifact()), depProject, macTask.projectBuilder, logger);
task.addDependencySet(ds, macTask.archiver, macTask.configSource);
mockManager.verifyAll();
}
Aggregations