List of usage examples for java.util.logging Level getLocalizedName
public String getLocalizedName()
From source file:org.apache.tomee.jul.formatter.SimpleTomEEFormatterTest.java
@Test public void formatNullThrown() throws Exception { final String previousLineSeparatorProperty = System.getProperty(LINE_SEPARATOR_KEY); try {/*w ww .j a v a 2 s . co m*/ final String lineSeparatorValue = "\n"; final String logMessage = "An example log record"; final Level level = Level.FINEST; System.setProperty(LINE_SEPARATOR_KEY, lineSeparatorValue); final LogRecord logRecordInput = new LogRecord(level, logMessage); logRecordInput.setThrown(null); final Formatter formatter = new SimpleTomEEFormatter(); final String actualFormatOutput = formatter.format(logRecordInput); final String expectedFormatOutput = level.getLocalizedName() + " - " + logMessage + "\n"; assertEquals(expectedFormatOutput, actualFormatOutput); } finally { System.setProperty(LINE_SEPARATOR_KEY, previousLineSeparatorProperty); } }
From source file:org.apache.tomee.jul.formatter.SimpleTomEEFormatterTest.java
@Test public void formatNotNullThrown() throws Exception { final String previousLineSeparatorProperty = System.getProperty(LINE_SEPARATOR_KEY); try {/*w ww .j a va 2s . co m*/ final String lineSeparatorValue = "\n"; final String logMessage = "An example log record"; final Level level = Level.CONFIG; final String exceptionMessage = "An example exception"; final Throwable thrown = new Exception(exceptionMessage); System.setProperty(LINE_SEPARATOR_KEY, lineSeparatorValue); final LogRecord logRecordInput = new LogRecord(level, logMessage); logRecordInput.setThrown(thrown); final Formatter formatter = new SimpleTomEEFormatter(); final String actualFormatOutput = formatter.format(logRecordInput); final String expectedFormatOutput = level.getLocalizedName() + " - " + logMessage + lineSeparatorValue + ExceptionUtils.getStackTrace(thrown); assertEquals(expectedFormatOutput, actualFormatOutput); } finally { System.setProperty(LINE_SEPARATOR_KEY, previousLineSeparatorProperty); } }
From source file:org.apache.tomee.util.SimpleTomEEFormatterTest.java
@Test public void formatNullThrown() throws Exception { final String previousLineSeparatorProperty = System.getProperty(LINE_SEPARATOR_KEY); try {//from w ww.j a va2 s .c o m final String lineSeparatorValue = "\n"; final String logMessage = "An example log record"; final Level level = Level.FINEST; System.setProperty(LINE_SEPARATOR_KEY, lineSeparatorValue); final LogRecord logRecordInput = new LogRecord(level, logMessage); logRecordInput.setThrown(null); final Formatter formatter = new SimpleTomEEFormatter(); final String actualFormatOutput = formatter.format(logRecordInput); final StringBuilder expectedFormatOutputSb = new StringBuilder(level.getLocalizedName()); expectedFormatOutputSb.append(" - ").append(logMessage).append("\n"); final String expectedFormatOutput = expectedFormatOutputSb.toString(); assertEquals(expectedFormatOutput, actualFormatOutput); } finally { System.setProperty(LINE_SEPARATOR_KEY, previousLineSeparatorProperty); } }
From source file:org.apache.tomee.util.SimpleTomEEFormatterTest.java
@Test public void formatNotNullThrown() throws Exception { final String previousLineSeparatorProperty = System.getProperty(LINE_SEPARATOR_KEY); try {//from w ww .j a va 2s. c om final String lineSeparatorValue = "\n"; final String logMessage = "An example log record"; final Level level = Level.CONFIG; final String exceptionMessage = "An example exception"; final Throwable thrown = new Exception(exceptionMessage); System.setProperty(LINE_SEPARATOR_KEY, lineSeparatorValue); final LogRecord logRecordInput = new LogRecord(level, logMessage); logRecordInput.setThrown(thrown); final Formatter formatter = new SimpleTomEEFormatter(); final String actualFormatOutput = formatter.format(logRecordInput); final StringBuilder expectedFormatOutputSb = new StringBuilder(level.getLocalizedName()); expectedFormatOutputSb.append(" - ").append(logMessage).append(lineSeparatorValue); expectedFormatOutputSb.append(ExceptionUtils.getStackTrace(thrown)); final String expectedFormatOutput = expectedFormatOutputSb.toString(); assertEquals(expectedFormatOutput, actualFormatOutput); } finally { System.setProperty(LINE_SEPARATOR_KEY, previousLineSeparatorProperty); } }