[logback-dev] svn commit: r2399 - logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net

noreply.ceki at qos.ch noreply.ceki at qos.ch
Fri Jul 31 19:53:21 CEST 2009


Author: ceki
Date: Fri Jul 31 19:53:21 2009
New Revision: 2399

Modified:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java

Log:
- better error reporting on regex match failure 
- added "-" to the set of possible characters in a hostname

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 Jul 31 19:53:21 2009
@@ -75,9 +75,9 @@
         + (SyslogConstants.LOG_MAIL + SyslogConstants.DEBUG_SEVERITY) + ">";
     assertTrue(msg.startsWith(expected));
 
-    String first = "<\\d{2}>\\w{3} \\d{2} \\d{2}(:\\d{2}){2} [\\w.]* ";
-    assertTrue(msg.matches(first + "\\[" + threadName + "\\] " + loggerName
-        + " " + logMsg));
+    String first = "<\\d{2}>\\w{3} \\d{2} \\d{2}(:\\d{2}){2} [\\w.-]* ";
+    checkRegexMatch(msg, first + "\\[" + threadName + "\\] " + loggerName
+        + " " + logMsg);
 
   }
 
@@ -127,11 +127,15 @@
         + (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 + "\\] "
+    String regex = expectedPrefix + "\\[" + threadName + "\\] "
         + loggerName + " " + logMsg;
-    assertTrue(msg.matches(expectedResult));
+    checkRegexMatch(msg, regex);
+  }
+  
+  private void checkRegexMatch(String s, String regex) {
+    assertTrue("The string ["+s+"] did not match regex ["+regex+"]", s.matches(regex));
   }
 
   @Test


More information about the logback-dev mailing list