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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations