Author: fmeschbe
Date: Thu Jun 12 03:22:11 2008
New Revision: 667030
URL: http://svn.apache.org/viewvc?rev=667030&view=rev
Log:
Adapt to modified SlingLoggerConfig methods
Modified:
incubator/sling/trunk/commons/log/src/test/java/org/apache/sling/commons/log/slf4j/SlingLoggerTest.java
Modified:
incubator/sling/trunk/commons/log/src/test/java/org/apache/sling/commons/log/slf4j/SlingLoggerTest.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/commons/log/src/test/java/org/apache/sling/commons/log/slf4j/SlingLoggerTest.java?rev=667030&r1=667029&r2=667030&view=diff
==============================================================================
---
incubator/sling/trunk/commons/log/src/test/java/org/apache/sling/commons/log/slf4j/SlingLoggerTest.java
(original)
+++
incubator/sling/trunk/commons/log/src/test/java/org/apache/sling/commons/log/slf4j/SlingLoggerTest.java
Thu Jun 12 03:22:11 2008
@@ -20,7 +20,6 @@
import java.io.IOException;
import java.io.StringWriter;
-import java.text.MessageFormat;
import java.util.HashSet;
import junit.framework.TestCase;
@@ -39,6 +38,7 @@
private String messageOnly = "{5}";
private SlingLoggerConfig config;
+
private SlingLogger logger;
@Override
@@ -47,9 +47,9 @@
config = new SlingLoggerConfig(getClass().getName(), "",
new HashSet<String>(), SlingLoggerLevel.DEBUG, output);
-
+
logger = new SlingLogger("sample");
- logger.configure(config);
+ logger.setLoggerConfig(config);
}
@Override
@@ -58,45 +58,6 @@
super.tearDown();
}
- public void testSetLogLevel() {
-
- // prevent real output, set output delegatee to null
- try {
- output.close();
- } catch (IOException ignore) {
- }
-
- // initial assertion
- config.setLogLevel(SlingLoggerLevel.DEBUG);
- assertEquals(SlingLoggerLevel.DEBUG, config.getLogLevel());
-
- // valid as is
- config.setLogLevel("INFO");
- assertEquals(SlingLoggerLevel.INFO, config.getLogLevel());
-
- // valid internal conversion to upper case
- config.setLogLevel("warn");
- assertEquals(SlingLoggerLevel.WARN, config.getLogLevel());
- config.setLogLevel("ErrOr");
- assertEquals(SlingLoggerLevel.ERROR, config.getLogLevel());
-
- // reset log level to debug
- config.setLogLevel(SlingLoggerLevel.DEBUG);
- assertEquals(SlingLoggerLevel.DEBUG, config.getLogLevel());
-
- // invalid, last level is still set
- config.setLogLevel((String) null);
- assertEquals(SlingLoggerLevel.DEBUG, config.getLogLevel());
-
- // invalid, last level is still set
- config.setLogLevel("");
- assertEquals(SlingLoggerLevel.DEBUG, config.getLogLevel());
-
- // invalid, last level is still set
- config.setLogLevel("gurk");
- assertEquals(SlingLoggerLevel.DEBUG, config.getLogLevel());
- }
-
public void testCheckLogLevelTrace() {
// initial assertion
config.setLogLevel(SlingLoggerLevel.TRACE);
@@ -178,7 +139,8 @@
output.setDelegatee(w);
// a single message
- config.configure(messageOnly, new HashSet<String>(),
SlingLoggerLevel.DEBUG, output);
+ config.configure(messageOnly, new HashSet<String>(),
+ SlingLoggerLevel.DEBUG, output);
String message = "This is a message";
logger.warn(message);
@@ -186,7 +148,8 @@
// reset output buffer and format with logger name and message
w.getBuffer().delete(0, w.getBuffer().length());
- config.configure("{3}|{5}", new HashSet<String>(),
SlingLoggerLevel.DEBUG, output);
+ config.configure("{3}|{5}", new HashSet<String>(),
+ SlingLoggerLevel.DEBUG, output);
logger.warn(message);
assertEquals(logger.getName() + "|" + message, w.toString());
@@ -194,7 +157,8 @@
// reset output buffer and format with logger name, level, thread and
// message
w.getBuffer().delete(0, w.getBuffer().length());
- config.configure("{2}|{3}|{4}|{5}", new HashSet<String>(),
SlingLoggerLevel.DEBUG, output);
+ config.configure("{2}|{3}|{4}|{5}", new HashSet<String>(),
+ SlingLoggerLevel.DEBUG, output);
logger.warn(message);
assertEquals(Thread.currentThread().getName() + "|" + logger.getName()
+ "|" + SlingLoggerLevel.WARN + "|" + message, w.toString());