Search in sources :

Example 26 with ArtifactMock

use of org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock in project maven-plugins by apache.

the class AddDependencySetsTaskTest method testAddDependencySet_ShouldNotAddDependenciesWhenProjectIsStubbed.

// TODO: Find a better way of testing the project-stubbing behavior when a ProjectBuildingException takes place.
public void testAddDependencySet_ShouldNotAddDependenciesWhenProjectIsStubbed() throws AssemblyFormattingException, ArchiveCreationException, InvalidAssemblerConfigurationException, IOException {
    final MavenProject project = new MavenProject(new Model());
    final ProjectBuildingException pbe = new ProjectBuildingException("test", "Test error.", new Throwable());
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mockManager, new MavenProject(new Model()));
    final String gid = "org.test";
    final String aid = "test-dep";
    final String version = "2.0-SNAPSHOT";
    final String type = "jar";
    final File file = new File("dep-artifact.jar");
    final ArtifactMock depMock = new ArtifactMock(mockManager, gid, aid, version, type, true);
    depMock.setBaseVersion(version);
    depMock.setFile(file);
    final File destFile = new File("assembly-dep-set.zip");
    macTask.expectGetDestFile(destFile);
    macTask.expectBuildFromRepository(pbe);
    macTask.expectCSGetRepositories(null, null);
    macTask.expectCSGetFinalName("final-name");
    macTask.expectAddFile(file, "out/" + aid + "-" + version + "." + type);
    macTask.expectGetMode(0222, 0222);
    final DependencySet ds = new DependencySet();
    ds.setOutputDirectory("/out");
    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(depMock.getArtifact()), project, macTask.projectBuilder, logger);
    task.addDependencySet(ds, macTask.archiver, macTask.configSource);
    mockManager.verifyAll();
}
Also used : MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask) ProjectBuildingException(org.apache.maven.project.ProjectBuildingException) 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