Search in sources :

Example 16 with ArtifactMock

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();
}
Also used : MockAndControlForAddArtifactTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) File(java.io.File)

Example 17 with ArtifactMock

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();
}
Also used : ArchiverException(org.codehaus.plexus.archiver.ArchiverException) MockAndControlForAddArtifactTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) File(java.io.File)

Example 18 with ArtifactMock

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();
}
Also used : MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Model(org.apache.maven.model.Model) MockAndControlForAddArtifactTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask) DependencySet(org.apache.maven.plugins.assembly.model.DependencySet) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) File(java.io.File)

Example 19 with ArtifactMock

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();
}
Also used : MockAndControlForAddArtifactTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) File(java.io.File)

Example 20 with ArtifactMock

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();
}
Also used : MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask) MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Model(org.apache.maven.model.Model) DependencySet(org.apache.maven.plugins.assembly.model.DependencySet) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Logger(org.codehaus.plexus.logging.Logger) File(java.io.File) MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)

Aggregations

ArtifactMock (org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock)26 MavenProject (org.apache.maven.project.MavenProject)20 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)20 File (java.io.File)16 MockAndControlForAddArtifactTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask)14 Logger (org.codehaus.plexus.logging.Logger)12 EasyMockSupport (org.easymock.classextension.EasyMockSupport)11 Model (org.apache.maven.model.Model)10 DependencySet (org.apache.maven.plugins.assembly.model.DependencySet)8 MockAndControlForAddDependencySetsTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)7 ModuleBinaries (org.apache.maven.plugins.assembly.model.ModuleBinaries)6 FileSet (org.apache.maven.plugins.assembly.model.FileSet)4 ModuleSources (org.apache.maven.plugins.assembly.model.ModuleSources)4 Artifact (org.apache.maven.artifact.Artifact)3 HashSet (java.util.HashSet)2 Properties (java.util.Properties)2 MavenSession (org.apache.maven.execution.MavenSession)2 AssemblerConfigurationSource (org.apache.maven.plugins.assembly.AssemblerConfigurationSource)2 Assembly (org.apache.maven.plugins.assembly.model.Assembly)2 ArchiverException (org.codehaus.plexus.archiver.ArchiverException)2