Search in sources :

Example 6 with EasyMockSupport

use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.

the class DefaultAssemblyArchiverTest method testCreateTarArchiver_TXzFormat_ShouldInitializeXzCompression.

@Test
public void testCreateTarArchiver_TXzFormat_ShouldInitializeXzCompression() throws NoSuchArchiverException, ArchiverException {
    final EasyMockSupport mm = new EasyMockSupport();
    final TestTarArchiver ttArchiver = new TestTarArchiver();
    final DefaultAssemblyArchiver subject = createSubject(mm, ttArchiver);
    subject.createTarArchiver("txz", TarLongFileMode.fail);
    assertEquals(TarArchiver.TarCompressionMethod.xz, ttArchiver.compressionMethod);
    assertEquals(TarLongFileMode.fail, ttArchiver.longFileMode);
    mm.verifyAll();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) Test(org.junit.Test)

Example 7 with EasyMockSupport

use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.

the class DefaultAssemblyArchiverTest method failWhenAssemblyIdIsNull.

@Test(expected = InvalidAssemblerConfigurationException.class)
public void failWhenAssemblyIdIsNull() throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForAssemblyArchiver macMgr = new MockAndControlForAssemblyArchiver(mm);
    final AssemblerConfigurationSource configSource = mm.createControl().createMock(AssemblerConfigurationSource.class);
    mm.replayAll();
    final DefaultAssemblyArchiver archiver = createSubject(macMgr, null, null);
    archiver.createArchive(new Assembly(), "full-name", "zip", configSource, false, null);
    mm.verifyAll();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) AssemblerConfigurationSource(org.apache.maven.plugins.assembly.AssemblerConfigurationSource) Assembly(org.apache.maven.plugins.assembly.model.Assembly) Test(org.junit.Test)

Example 8 with EasyMockSupport

use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.

the class DefaultAssemblyArchiverTest method testCreateTarArchiver_InvalidFormat_ShouldFailWithInvalidCompression.

@Test
public void testCreateTarArchiver_InvalidFormat_ShouldFailWithInvalidCompression() throws NoSuchArchiverException, ArchiverException {
    final EasyMockSupport mm = new EasyMockSupport();
    final TestTarArchiver ttArchiver = new TestTarArchiver();
    final DefaultAssemblyArchiver subject = createSubject(mm, ttArchiver);
    try {
        subject.createTarArchiver("tar.Z", null);
        fail("Invalid compression formats should throw an error.");
    } catch (final IllegalArgumentException e) {
    // expected.
    }
    mm.verifyAll();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) Test(org.junit.Test)

Example 9 with EasyMockSupport

use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.

the class DefaultAssemblyArchiverTest method testCreateArchive.

@Test
public void testCreateArchive() throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException, IOException, DependencyResolutionException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForAssemblyArchiver macMgr = new MockAndControlForAssemblyArchiver(mm);
    macMgr.expectGetArchiver("zip", Archiver.class);
    macMgr.expectGetDestFile(new File("test"));
    final AssemblyArchiverPhase phase = mm.createControl().createMock(AssemblyArchiverPhase.class);
    phase.execute((Assembly) anyObject(), (Archiver) anyObject(), (AssemblerConfigurationSource) anyObject());
    final AssemblerConfigurationSource configSource = mm.createControl().createMock(AssemblerConfigurationSource.class);
    final File tempDir = fileManager.createTempDir();
    FileUtils.deleteDirectory(tempDir);
    expect(configSource.getTemporaryRootDirectory()).andReturn(tempDir).anyTimes();
    expect(configSource.isDryRun()).andReturn(false).anyTimes();
    expect(configSource.isIgnoreDirFormatExtensions()).andReturn(false).anyTimes();
    final File outDir = fileManager.createTempDir();
    macMgr.archiver.setDestFile(new File(outDir, "full-name.zip"));
    try {
        macMgr.archiver.createArchive();
    } catch (final ArchiverException e) {
        fail("Should never happen");
    } catch (final IOException e) {
        fail("Should never happen");
    }
    expect(configSource.getOutputDirectory()).andReturn(outDir);
    expect(configSource.getFinalName()).andReturn("finalName");
    expect(configSource.getArchiverConfig()).andReturn(null).anyTimes();
    expect(configSource.getWorkingDirectory()).andReturn(new File(".")).anyTimes();
    expect(configSource.isUpdateOnly()).andReturn(false).anyTimes();
    expect(configSource.isIgnorePermissions()).andReturn(false).anyTimes();
    final Assembly assembly = new Assembly();
    assembly.setId("id");
    // try
    // {
    //         expect( macMgr.dependencyResolver.resolve( (Assembly) anyObject(), (AssemblerConfigurationSource)
    // anyObject() )).andReturn( new HashSet<Artifact>(  ) );
    //            macMgr.dependencyResolverControl.setMatcher( MockControl.ALWAYS_MATCHER );
    //     }
    //  catch ( final DependencyResolutionException e )
    // {
    //    fail( "Should never happen" );
    // }
    mm.replayAll();
    final DefaultAssemblyArchiver subject = createSubject(macMgr, Collections.singletonList(phase), null);
    subject.createArchive(assembly, "full-name", "zip", configSource, false, null);
    mm.verifyAll();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) NoSuchArchiverException(org.codehaus.plexus.archiver.manager.NoSuchArchiverException) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) AssemblerConfigurationSource(org.apache.maven.plugins.assembly.AssemblerConfigurationSource) IOException(java.io.IOException) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly) AssemblyArchiverPhase(org.apache.maven.plugins.assembly.archive.phase.AssemblyArchiverPhase) Test(org.junit.Test)

Example 10 with EasyMockSupport

use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.

the class DefaultAssemblyArchiverTest method testCreateTarArchiver_ShouldNotInitializeCompression.

@Test
public void testCreateTarArchiver_ShouldNotInitializeCompression() throws NoSuchArchiverException, ArchiverException {
    final EasyMockSupport mm = new EasyMockSupport();
    final TestTarArchiver ttArchiver = new TestTarArchiver();
    final DefaultAssemblyArchiver subject = createSubject(mm, ttArchiver);
    subject.createTarArchiver("tar", TarLongFileMode.fail);
    assertNull(ttArchiver.compressionMethod);
    assertEquals(TarLongFileMode.fail, ttArchiver.longFileMode);
    mm.verifyAll();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) Test(org.junit.Test)

Aggregations

EasyMockSupport (org.easymock.classextension.EasyMockSupport)50 MavenProject (org.apache.maven.project.MavenProject)27 File (java.io.File)21 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)21 Test (org.junit.Test)16 Model (org.apache.maven.model.Model)14 Assembly (org.apache.maven.plugins.assembly.model.Assembly)13 ArtifactMock (org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock)11 MockAndControlForAddArtifactTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask)10 AssemblerConfigurationSource (org.apache.maven.plugins.assembly.AssemblerConfigurationSource)9 ArrayList (java.util.ArrayList)7 ModuleBinaries (org.apache.maven.plugins.assembly.model.ModuleBinaries)7 ModuleSet (org.apache.maven.plugins.assembly.model.ModuleSet)7 MockAndControlForAddDependencySetsTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)5 FileItem (org.apache.maven.plugins.assembly.model.FileItem)5 Logger (org.codehaus.plexus.logging.Logger)5 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)4 AssemblyArchiverPhase (org.apache.maven.plugins.assembly.archive.phase.AssemblyArchiverPhase)4 FileSet (org.apache.maven.plugins.assembly.model.FileSet)4 ModuleSources (org.apache.maven.plugins.assembly.model.ModuleSources)4