use of org.codehaus.plexus.logging.console.ConsoleLogger 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.codehaus.plexus.logging.console.ConsoleLogger in project maven-plugins by apache.
the class TypeConversionUtilsTest method checkFileModeSanity.
private void checkFileModeSanity(final String mode, final boolean isSane, final List<String> messagesToCheckIfInsane) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final PrintStream ps = new PrintStream(baos);
final PrintStream oldOut = System.out;
final PrintStream oldErr = System.err;
try {
System.setOut(ps);
System.setErr(ps);
assertEquals("Mode sanity should be: " + isSane, isSane, TypeConversionUtils.verifyModeSanity(Integer.parseInt(mode, 8), new ConsoleLogger(Logger.LEVEL_WARN, "test")));
} finally {
System.setOut(oldOut);
System.setErr(oldErr);
}
if (!isSane && messagesToCheckIfInsane != null && !messagesToCheckIfInsane.isEmpty()) {
final String message = new String(baos.toByteArray());
for (final String checkMessage : messagesToCheckIfInsane) {
assertTrue("\'" + checkMessage + "\' is not present in output.", message.contains(checkMessage));
}
}
}
use of org.codehaus.plexus.logging.console.ConsoleLogger in project maven-plugins by apache.
the class TypeConversionUtilsTest method testModeToInt_FailOnInvalidOctalValue.
public void testModeToInt_FailOnInvalidOctalValue() {
try {
TypeConversionUtils.modeToInt("493", new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
fail("'493' is an invalid mode and should trigger an exception.");
} catch (final AssemblyFormattingException e) {
// expected.
}
}
use of org.codehaus.plexus.logging.console.ConsoleLogger in project maven-plugins by apache.
the class TypeConversionUtilsTest method testModeToInt_InterpretAsOctalWithoutLeadingZero.
public void testModeToInt_InterpretAsOctalWithoutLeadingZero() throws AssemblyFormattingException {
final int check = Integer.decode("0777");
final int test = TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
assertEquals(check, test);
}
use of org.codehaus.plexus.logging.console.ConsoleLogger in project maven-plugins by apache.
the class TypeConversionUtilsTest method testModeToInt_InterpretValuesWithLeadingZeroAsOctal.
public void testModeToInt_InterpretValuesWithLeadingZeroAsOctal() throws AssemblyFormattingException {
final int check = Integer.decode("0777");
final int test = TypeConversionUtils.modeToInt("0777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
assertEquals(check, test);
}
Aggregations