use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.
the class FileItemAssemblyPhaseTest method testExecute_ShouldAddRelativeFileNoFilterNoLineEndingConversion.
public void testExecute_ShouldAddRelativeFileNoFilterNoLineEndingConversion() throws ArchiveCreationException, AssemblyFormattingException, IOException {
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource(mm);
final File basedir = fileManager.createTempDir();
final File file = fileManager.createFile(basedir, "file.txt", "This is a test file.");
macCS.expectGetBasedir(basedir);
macCS.expectGetProject(new MavenProject(new Model()));
macCS.expectGetFinalName("final-name");
macCS.expectInterpolators();
final MockAndControlForLogger macLogger = new MockAndControlForLogger(mm);
final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver(mm);
final Assembly assembly = new Assembly();
assembly.setId("test");
final FileItem fi = new FileItem();
fi.setSource("file.txt");
fi.setFiltered(false);
fi.setLineEnding("keep");
fi.setFileMode("777");
macArchiver.expectAddFile(file, "file.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
assembly.addFile(fi);
mm.replayAll();
createPhase(macLogger.logger).execute(assembly, macArchiver.archiver, macCS.configSource);
mm.verifyAll();
}
use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.
the class FileItemAssemblyPhaseTest method testExecute_WithOutputDirectory.
public void testExecute_WithOutputDirectory() throws Exception {
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource(mm);
final File basedir = fileManager.createTempDir();
final File readmeFile = fileManager.createFile(basedir, "README.txt", "This is a test file for README.txt.");
final File licenseFile = fileManager.createFile(basedir, "LICENSE.txt", "This is a test file for LICENSE.txt.");
final File configFile = fileManager.createFile(basedir, "config/config.txt", "This is a test file for config/config.txt");
macCS.expectGetBasedir(basedir);
macCS.expectGetProject(new MavenProject(new Model()));
macCS.expectGetFinalName("final-name");
macCS.expectInterpolators();
final MockAndControlForLogger macLogger = new MockAndControlForLogger(mm);
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
macLogger.logger.error("OS=Windows and the assembly descriptor contains a *nix-specific " + "root-relative-reference (starting with slash) /");
} else {
macLogger.logger.warn((String) anyObject());
}
final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver(mm);
final Assembly assembly = new Assembly();
assembly.setId("test");
assembly.setIncludeBaseDirectory(true);
final FileItem readmeFileItem = new FileItem();
readmeFileItem.setSource("README.txt");
readmeFileItem.setOutputDirectory("");
readmeFileItem.setFiltered(false);
readmeFileItem.setLineEnding("keep");
readmeFileItem.setFileMode("777");
final FileItem licenseFileItem = new FileItem();
licenseFileItem.setSource("LICENSE.txt");
licenseFileItem.setOutputDirectory("/");
licenseFileItem.setFiltered(false);
licenseFileItem.setLineEnding("keep");
licenseFileItem.setFileMode("777");
final FileItem configFileItem = new FileItem();
configFileItem.setSource("config/config.txt");
configFileItem.setOutputDirectory("config");
configFileItem.setFiltered(false);
configFileItem.setLineEnding("keep");
configFileItem.setFileMode("777");
macArchiver.expectAddFile(readmeFile, "README.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
macArchiver.expectAddFile(licenseFile, "LICENSE.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
macArchiver.expectAddFile(configFile, "config/config.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
assembly.addFile(readmeFileItem);
assembly.addFile(licenseFileItem);
assembly.addFile(configFileItem);
mm.replayAll();
createPhase(macLogger.logger).execute(assembly, macArchiver.archiver, macCS.configSource);
mm.verifyAll();
}
use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.
the class FileItemAssemblyPhaseTest method testExecute_ShouldAddNothingWhenNoFileItemsArePresent.
public void testExecute_ShouldAddNothingWhenNoFileItemsArePresent() throws ArchiveCreationException, AssemblyFormattingException {
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource(mm);
final File basedir = fileManager.createTempDir();
macCS.expectGetBasedir(basedir);
final MockAndControlForLogger macLogger = new MockAndControlForLogger(mm);
final Assembly assembly = new Assembly();
assembly.setId("test");
mm.replayAll();
createPhase(macLogger.logger).execute(assembly, null, macCS.configSource);
mm.verifyAll();
}
use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.
the class DefaultAssemblyArchiverTest method testCreateArchiver_ShouldConfigureArchiver.
@Test
public void testCreateArchiver_ShouldConfigureArchiver() throws NoSuchArchiverException, ArchiverException {
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForAssemblyArchiver macArchiverManager = new MockAndControlForAssemblyArchiver(mm);
final TestArchiverWithConfig archiver = new TestArchiverWithConfig();
macArchiverManager.expectGetArchiver("dummy", archiver);
final AssemblerConfigurationSource configSource = mm.createMock(AssemblerConfigurationSource.class);
final String simpleConfig = "value";
expect(configSource.getArchiverConfig()).andReturn("<configuration><simpleConfig>" + simpleConfig + "</simpleConfig></configuration>").anyTimes();
final MavenProject project = new MavenProject(new Model());
expect(configSource.getProject()).andReturn(project).anyTimes();
expect(configSource.getMavenSession()).andReturn(null).anyTimes();
expect(configSource.isDryRun()).andReturn(false).anyTimes();
expect(configSource.getWorkingDirectory()).andReturn(new File(".")).anyTimes();
expect(configSource.isUpdateOnly()).andReturn(false).anyTimes();
final ArtifactRepository lr = mm.createMock(ArtifactRepository.class);
expect(lr.getBasedir()).andReturn("/path/to/local/repo").anyTimes();
expect(configSource.getLocalRepository()).andReturn(lr).anyTimes();
expect(configSource.isIgnorePermissions()).andReturn(true);
setupInterpolators(configSource, project);
mm.replayAll();
final DefaultAssemblyArchiver subject = createSubject(macArchiverManager, new ArrayList<AssemblyArchiverPhase>(), null);
subject.createArchiver("dummy", false, "finalName", configSource, null, false, null);
assertEquals(simpleConfig, archiver.getSimpleConfig());
mm.verifyAll();
}
use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.
the class DefaultAssemblyArchiverTest method testCreateArchiver_ShouldCreateTarArchiverWithNoCompression.
@Test
public void testCreateArchiver_ShouldCreateTarArchiverWithNoCompression() throws NoSuchArchiverException, ArchiverException {
final EasyMockSupport mm = new EasyMockSupport();
final TestTarArchiver ttArchiver = new TestTarArchiver();
final MockAndControlForAssemblyArchiver macArchiverManager = new MockAndControlForAssemblyArchiver(mm);
macArchiverManager.expectGetArchiver("tar", ttArchiver);
final AssemblerConfigurationSource configSource = mm.createMock(AssemblerConfigurationSource.class);
expect(configSource.getTarLongFileMode()).andReturn(TarLongFileMode.fail.toString()).anyTimes();
expect(configSource.isDryRun()).andReturn(false).anyTimes();
expect(configSource.getArchiverConfig()).andReturn(null).anyTimes();
final DefaultAssemblyArchiver subject = setupStdExpectations(mm, macArchiverManager, configSource);
subject.createArchiver("tar", false, "finalName", configSource, null, false, null);
assertNull(ttArchiver.compressionMethod);
assertEquals(TarLongFileMode.fail, ttArchiver.longFileMode);
mm.verifyAll();
}
Aggregations