Search in sources :

Example 46 with EasyMockSupport

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

the class DefaultAssemblyArchiverTest method testCreateTarArchiver_TarBz2Format_ShouldInitializeBZipCompression.

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

Example 47 with EasyMockSupport

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

the class DefaultAssemblyArchiverTest method testCreateTarArchiver_TarXzFormat_ShouldInitializeXzCompression.

@Test
public void testCreateTarArchiver_TarXzFormat_ShouldInitializeXzCompression() throws NoSuchArchiverException, ArchiverException {
    final EasyMockSupport mm = new EasyMockSupport();
    final TestTarArchiver ttArchiver = new TestTarArchiver();
    final DefaultAssemblyArchiver subject = createSubject(mm, ttArchiver);
    subject.createTarArchiver("tar.xz", 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 48 with EasyMockSupport

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

the class DefaultAssemblyReaderTest method setUp.

@Override
public void setUp() {
    fileManager = new TestFileManager("assembly-reader.test.", ".xml");
    mockManager = new EasyMockSupport();
    configSource = mockManager.createMock(AssemblerConfigurationSource.class);
    ArtifactRepository localRepo = mockManager.createMock(ArtifactRepository.class);
    expect(localRepo.getBasedir()).andReturn("/path/to/local/repo").anyTimes();
    expect(configSource.getLocalRepository()).andReturn(localRepo).anyTimes();
    expect(configSource.getRemoteRepositories()).andReturn(Collections.<ArtifactRepository>emptyList()).anyTimes();
    expect(configSource.getMavenSession()).andReturn(null).anyTimes();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) TestFileManager(org.apache.maven.plugins.assembly.testutils.TestFileManager) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) AssemblerConfigurationSource(org.apache.maven.plugins.assembly.AssemblerConfigurationSource)

Example 49 with EasyMockSupport

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

the class AssemblyExpressionEvaluatorTest method testShouldResolveContextValueBeforeModelPropertyOrModelGroupIdInAssemblyId.

public void testShouldResolveContextValueBeforeModelPropertyOrModelGroupIdInAssemblyId() throws ExpressionEvaluationException {
    final Model model = new Model();
    model.setArtifactId("artifact-id");
    model.setGroupId("group.id");
    model.setVersion("1");
    model.setPackaging("jar");
    final Properties props = new Properties();
    props.setProperty("groupId", "other.id");
    model.setProperties(props);
    final EasyMockSupport mm = new EasyMockSupport();
    MavenSession session = mm.createControl().createMock(MavenSession.class);
    final Properties execProps = new Properties();
    execProps.setProperty("groupId", "still.another.id");
    PropertiesBasedValueSource cliProps = new PropertiesBasedValueSource(execProps);
    expect(session.getExecutionProperties()).andReturn(execProps).anyTimes();
    expect(session.getUserProperties()).andReturn(new Properties()).anyTimes();
    AssemblerConfigurationSource cs = mm.createControl().createMock(AssemblerConfigurationSource.class);
    expect(cs.getCommandLinePropsInterpolator()).andReturn(FixedStringSearchInterpolator.create(cliProps)).anyTimes();
    expect(cs.getRepositoryInterpolator()).andReturn(FixedStringSearchInterpolator.create()).anyTimes();
    expect(cs.getEnvInterpolator()).andReturn(FixedStringSearchInterpolator.create()).anyTimes();
    expect(cs.getMavenSession()).andReturn(session).anyTimes();
    expect(cs.getProject()).andReturn(new MavenProject(model));
    final IMocksControl lrCtl = mm.createControl();
    final ArtifactRepository lr = lrCtl.createMock(ArtifactRepository.class);
    expect(lr.getBasedir()).andReturn("/path/to/local/repo").anyTimes();
    expect(cs.getLocalRepository()).andReturn(lr).anyTimes();
    mm.replayAll();
    final Object result = new AssemblyExpressionEvaluator(cs).evaluate("assembly.${groupId}");
    assertEquals("assembly.still.another.id", result);
    mm.verifyAll();
}
Also used : IMocksControl(org.easymock.classextension.IMocksControl) MavenSession(org.apache.maven.execution.MavenSession) EasyMockSupport(org.easymock.classextension.EasyMockSupport) MavenProject(org.apache.maven.project.MavenProject) Model(org.apache.maven.model.Model) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) AssemblerConfigurationSource(org.apache.maven.plugins.assembly.AssemblerConfigurationSource) Properties(java.util.Properties) PropertiesBasedValueSource(org.codehaus.plexus.interpolation.fixed.PropertiesBasedValueSource)

Example 50 with EasyMockSupport

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

the class AssemblyFileUtilsTest method testUnpack_ShouldSetSourceAndDestinationAndCallExtract.

public void testUnpack_ShouldSetSourceAndDestinationAndCallExtract() throws IOException, ArchiveExpansionException, NoSuchArchiverException {
    EasyMockSupport mockManager = new EasyMockSupport();
    File source = fileManager.createTempFile();
    File destDir = fileManager.createTempDir();
    UnArchiver unarchiver = mockManager.createMock(UnArchiver.class);
    ArchiverManager archiverManager = mockManager.createMock(ArchiverManager.class);
    try {
        expect(archiverManager.getUnArchiver(source)).andReturn(unarchiver);
    } catch (NoSuchArchiverException e) {
        fail("Should never happen.");
    }
    unarchiver.setSourceFile(source);
    unarchiver.setDestDirectory(destDir);
    try {
        unarchiver.extract();
    } catch (ArchiverException e) {
        fail("Should never happen.");
    }
    mockManager.replayAll();
    AssemblyFileUtils.unpack(source, destDir, archiverManager);
    mockManager.verifyAll();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) ArchiverManager(org.codehaus.plexus.archiver.manager.ArchiverManager) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) NoSuchArchiverException(org.codehaus.plexus.archiver.manager.NoSuchArchiverException) File(java.io.File) UnArchiver(org.codehaus.plexus.archiver.UnArchiver) NoSuchArchiverException(org.codehaus.plexus.archiver.manager.NoSuchArchiverException)

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