[logback-dev] svn commit: r1927 - in logback/trunk/logback-classic/src/test: input/joran java/ch/qos/logback/classic/net
noreply.ceki at qos.ch
noreply.ceki at qos.ch
Fri Oct 31 19:58:24 CET 2008
Author: ceki
Date: Fri Oct 31 19:58:24 2008
New Revision: 1927
Added:
logback/trunk/logback-classic/src/test/input/joran/syslog_LBCLASSIC_50.xml
- copied unchanged from r1899, /logback/trunk/logback-classic/src/test/input/joran/syslog_147.xml
Removed:
logback/trunk/logback-classic/src/test/input/joran/syslog_147.xml
Modified:
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java
Log:
- fixed SyslogAppenderTest failing on machines with . in their names. Reported by Thorbjørn
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java Fri Oct 31 19:58:24 2008
@@ -25,7 +25,6 @@
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.net.SyslogConstants;
import ch.qos.logback.core.testUtil.RandomUtil;
-import ch.qos.logback.core.util.StatusPrinter;
public class SyslogAppenderTest {
@@ -40,7 +39,7 @@
@Test
public void basic() throws InterruptedException {
int port = RandomUtil.getRandomServerPort();
-
+
MockSyslogServer mockServer = new MockSyslogServer(1, port);
mockServer.start();
// give MockSyslogServer head start
@@ -62,7 +61,6 @@
logger.addAppender(sa);
String logMsg = "hello";
logger.debug(logMsg);
- // StatusPrinter.print(lc.getStatusManager());
// wait max 2 seconds for mock server to finish. However, it should
// much sooner than that.
@@ -71,14 +69,13 @@
assertEquals(1, mockServer.getMessageList().size());
String msg = mockServer.getMessageList().get(0);
+ String threadName = Thread.currentThread().getName();
+
String expected = "<"
+ (SyslogConstants.LOG_MAIL + SyslogConstants.DEBUG_SEVERITY) + ">";
assertTrue(msg.startsWith(expected));
- String first = "<\\d{2}>\\w{3} \\d{2} \\d{2}(:\\d{2}){2} \\w* ";
- String threadName = Thread.currentThread().getName();
- System.out.println("msg is \""+msg+"\"");
- System.out.println("threadName is \""+threadName+"\"");
+ String first = "<\\d{2}>\\w{3} \\d{2} \\d{2}(:\\d{2}){2} [\\w.]* ";
assertTrue(msg.matches(first + "\\[" + threadName + "\\] " + loggerName
+ " " + logMsg));
@@ -87,7 +84,7 @@
@Test
public void tException() throws InterruptedException {
int port = RandomUtil.getRandomServerPort();
-
+
MockSyslogServer mockServer = new MockSyslogServer(21, port);
mockServer.start();
// give MockSyslogServer head start
@@ -130,7 +127,7 @@
+ (SyslogConstants.LOG_MAIL + SyslogConstants.DEBUG_SEVERITY) + ">";
assertTrue(msg.startsWith(expected));
- String expectedPrefix = "<\\d{2}>\\w{3} \\d{2} \\d{2}(:\\d{2}){2} \\w* ";
+ String expectedPrefix = "<\\d{2}>\\w{3} \\d{2} \\d{2}(:\\d{2}){2} [\\w.]* ";
String threadName = Thread.currentThread().getName();
String expectedResult = expectedPrefix + "\\[" + threadName + "\\] "
+ loggerName + " " + logMsg;
@@ -138,7 +135,7 @@
}
@Test
- public void bug147() throws JoranException {
+ public void LBCLASSIC_50() throws JoranException {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
@@ -146,10 +143,9 @@
configurator.setContext(lc);
lc.shutdownAndReset();
configurator.doConfigure(TestConstants.JORAN_ONPUT_PREFIX
- + "/syslog_147.xml");
+ + "/syslog_LBCLASSIC_50.xml");
org.slf4j.Logger logger = LoggerFactory.getLogger(this.getClass());
logger.info("hello");
- StatusPrinter.print(lc);
}
}
More information about the logback-dev
mailing list