use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.
the class DefaultAssemblyArchiverTest method testCreateArchiver_ShouldCreateWarArchiverWithIgnoreWebxmlSetToFalse.
@Test
public void testCreateArchiver_ShouldCreateWarArchiverWithIgnoreWebxmlSetToFalse() throws NoSuchArchiverException, ArchiverException {
final EasyMockSupport mm = new EasyMockSupport();
final TestWarArchiver twArchiver = new TestWarArchiver();
final MockAndControlForAssemblyArchiver macArchiverManager = new MockAndControlForAssemblyArchiver(mm);
macArchiverManager.expectGetArchiver("war", twArchiver);
final AssemblerConfigurationSource configSource = mm.createMock(AssemblerConfigurationSource.class);
expect(configSource.isDryRun()).andReturn(false).anyTimes();
expect(configSource.getArchiverConfig()).andReturn(null).anyTimes();
expect(configSource.getMavenSession()).andReturn(null).anyTimes();
final DefaultAssemblyArchiver subject = setupStdExpectations(mm, macArchiverManager, configSource);
subject.createArchiver("war", false, null, configSource, null, false, null);
assertFalse(twArchiver.ignoreWebxml);
}
use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.
the class DefaultAssemblyArchiverTest method testCreateTarArchiver_TgzFormat_ShouldInitializeGZipCompression.
@Test
public void testCreateTarArchiver_TgzFormat_ShouldInitializeGZipCompression() throws NoSuchArchiverException, ArchiverException {
final EasyMockSupport mm = new EasyMockSupport();
final TestTarArchiver ttArchiver = new TestTarArchiver();
final DefaultAssemblyArchiver subject = createSubject(mm, ttArchiver);
subject.createTarArchiver("tgz", TarLongFileMode.fail);
assertEquals(TarArchiver.TarCompressionMethod.gzip, ttArchiver.compressionMethod);
assertEquals(TarLongFileMode.fail, ttArchiver.longFileMode);
mm.verifyAll();
}
use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.
the class AssemblyProxyArchiverTest method addFile_NoPerms_CallAcceptFilesOnlyOnce.
@Test
public void addFile_NoPerms_CallAcceptFilesOnlyOnce() throws IOException, ArchiverException {
EasyMockSupport mm = new EasyMockSupport();
final Archiver delegate = mm.createMock(Archiver.class);
delegate.addFile((File) anyObject(), (String) anyObject());
EasyMock.expectLastCall().anyTimes();
delegate.setForced(true);
EasyMock.expectLastCall().anyTimes();
final CounterSelector counter = new CounterSelector(true);
final List<FileSelector> selectors = new ArrayList<FileSelector>();
selectors.add(counter);
mm.replayAll();
final AssemblyProxyArchiver archiver = new AssemblyProxyArchiver("", delegate, null, selectors, null, new File("."), new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
archiver.setForced(true);
final File inputFile = fileManager.createTempFile();
archiver.addFile(inputFile, "file.txt");
assertEquals(1, counter.getCount());
mm.verifyAll();
}
use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.
the class FileItemAssemblyPhaseTest method testExecute_WithOutputDirectoryAndDestName.
public void testExecute_WithOutputDirectoryAndDestName() 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.setDestName("README_renamed.txt");
readmeFileItem.setFiltered(false);
readmeFileItem.setLineEnding("keep");
readmeFileItem.setFileMode("777");
final FileItem licenseFileItem = new FileItem();
licenseFileItem.setSource("LICENSE.txt");
licenseFileItem.setOutputDirectory("/");
licenseFileItem.setDestName("LICENSE_renamed.txt");
licenseFileItem.setFiltered(false);
licenseFileItem.setLineEnding("keep");
licenseFileItem.setFileMode("777");
final FileItem configFileItem = new FileItem();
configFileItem.setSource("config/config.txt");
configFileItem.setDestName("config_renamed.txt");
configFileItem.setOutputDirectory("config");
configFileItem.setFiltered(false);
configFileItem.setLineEnding("keep");
configFileItem.setFileMode("777");
macArchiver.expectAddFile(readmeFile, "README_renamed.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
macArchiver.expectAddFile(licenseFile, "LICENSE_renamed.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
macArchiver.expectAddFile(configFile, "config/config_renamed.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 ModuleSetAssemblyPhaseTest method testGetModuleProjects_ShouldExcludeModuleAndDescendentsTransitively.
public void testGetModuleProjects_ShouldExcludeModuleAndDescendentsTransitively() throws ArchiveCreationException {
final EasyMockSupport mm = new EasyMockSupport();
final MavenProject project = createProject("group", "artifact", "version", null);
final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mm, project);
addArtifact(project, mm, false);
final MavenProject project2 = createProject("group", "artifact2", "version", project);
addArtifact(project2, mm, false);
final MavenProject project3 = createProject("group", "artifact3", "version", project2);
addArtifact(project3, mm, true);
final List<MavenProject> projects = new ArrayList<MavenProject>();
projects.add(project);
projects.add(project2);
projects.add(project3);
macTask.expectGetReactorProjects(projects);
final ModuleSet moduleSet = new ModuleSet();
moduleSet.setIncludeSubModules(true);
moduleSet.addExclude("group:artifact2");
mm.replayAll();
final Set<MavenProject> moduleProjects = ModuleSetAssemblyPhase.getModuleProjects(moduleSet, macTask.configSource, logger);
assertTrue(moduleProjects.isEmpty());
mm.verifyAll();
}
Aggregations