[logback-dev] svn commit: r2410 - in logback/trunk/logback-core/src: main/java/ch/qos/logback/core/rolling/helper test/java/ch/qos/logback/core/rolling test/java/ch/qos/logback/core/rolling/helper

noreply.ceki at qos.ch noreply.ceki at qos.ch
Tue Aug 4 23:18:43 CEST 2009


Author: ceki
Date: Tue Aug  4 23:18:43 2009
New Revision: 2410

Modified:
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DateTokenConverter.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileNamePattern.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/SDFToken.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_Test.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/DatePatternToRegexTest.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileNamePatternTest.java

Log:
- next step is to test SizeAndTimeBasedFANTP with stop and restart...

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DateTokenConverter.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DateTokenConverter.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/DateTokenConverter.java	Tue Aug  4 23:18:43 2009
@@ -20,7 +20,7 @@
  * 
  * @author Ceki Gücü
  */
-public class DateTokenConverter extends DynamicConverter implements MonoTypedConverter {
+public class DateTokenConverter<E> extends DynamicConverter<E> implements MonoTypedConverter {
 
   /**
    * The conversion word/character with which this converter is registered.

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileNamePattern.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileNamePattern.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileNamePattern.java	Tue Aug  4 23:18:43 2009
@@ -36,8 +36,10 @@
 
   static final Map<String, String> CONVERTER_MAP = new HashMap<String, String>();
   static {
-    CONVERTER_MAP.put(IntegerTokenConverter.CONVERTER_KEY, IntegerTokenConverter.class.getName());
-    CONVERTER_MAP.put(DateTokenConverter.CONVERTER_KEY, DateTokenConverter.class.getName());
+    CONVERTER_MAP.put(IntegerTokenConverter.CONVERTER_KEY,
+        IntegerTokenConverter.class.getName());
+    CONVERTER_MAP.put(DateTokenConverter.CONVERTER_KEY,
+        DateTokenConverter.class.getName());
   }
 
   String pattern;
@@ -93,15 +95,14 @@
     return null;
   }
 
-  
   public String convertMultipleArguments(Object... objectList) {
     StringBuilder buf = new StringBuilder();
     Converter<Object> c = headTokenConverter;
     while (c != null) {
-      if(c instanceof MonoTypedConverter) {
+      if (c instanceof MonoTypedConverter) {
         MonoTypedConverter monoTyped = (MonoTypedConverter) c;
-        for(Object o: objectList) {
-          if(monoTyped.isApplicable(o)) {
+        for (Object o : objectList) {
+          if (monoTyped.isApplicable(o)) {
             buf.append(c.convert(o));
           }
         }
@@ -110,9 +111,9 @@
       }
       c = c.getNext();
     }
-   return buf.toString();
+    return buf.toString();
   }
-  
+
   public String convert(Object o) {
     StringBuilder buf = new StringBuilder();
     Converter<Object> p = headTokenConverter;
@@ -138,37 +139,36 @@
   public String getPattern() {
     return pattern;
   }
-  
 
-  // Given date, convert this instance to  a regular expression 
+  // Given date, convert this instance to a regular expression
   String asRegex(Date date) {
     StringBuilder buf = new StringBuilder();
     Converter<Object> p = headTokenConverter;
     while (p != null) {
-      if(p instanceof LiteralConverter) {
+      if (p instanceof LiteralConverter) {
         buf.append(p.convert(null));
       } else if (p instanceof IntegerTokenConverter) {
         buf.append("\\d{1,2}");
-      } else if(p instanceof DateTokenConverter) {
+      } else if (p instanceof DateTokenConverter) {
         buf.append(p.convert(date));
       }
       p = p.getNext();
     }
     return buf.toString();
   }
-  
-  // Given date, convert this instance to  a regular expression 
+
+  // Given date, convert this instance to a regular expression
   String asRegex() {
     StringBuilder buf = new StringBuilder();
     Converter<Object> p = headTokenConverter;
     while (p != null) {
-      if(p instanceof LiteralConverter) {
+      if (p instanceof LiteralConverter) {
         buf.append(p.convert(null));
       } else if (p instanceof IntegerTokenConverter) {
         buf.append("\\d{1,2}");
-      } else if(p instanceof DateTokenConverter) {
-        DateTokenConverter dtc = (DateTokenConverter) p;
-        xbuf.append(dtc.asRegex());
+      } else if (p instanceof DateTokenConverter) {
+        DateTokenConverter<Object> dtc = (DateTokenConverter<Object>) p;
+        buf.append(dtc.asRegex());
       }
       p = p.getNext();
     }

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/SDFToken.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/SDFToken.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/SDFToken.java	Tue Aug  4 23:18:43 2009
@@ -54,6 +54,8 @@
       return ".*";
     case 'Z':
       return "(\\+|-)\\d{4}";
+    case '.':
+      return "\\.";
     default:
       if (occurrences == 1) {
         return "" + c;

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_Test.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_Test.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_Test.java	Tue Aug  4 23:18:43 2009
@@ -119,6 +119,10 @@
     sortedContentCheck(randomOutputDir, runLength, prefix);
   }
 
+  @Test
+  public void noCompression_FileNotSet_WithRestart_3() throws Exception {
+    fail("d");
+  }
   void massageExpectedFilesToCorresponToCurrentTarget(String file) {
     // we added one too many files by date
     expectedFilenameList.remove(expectedFilenameList.size() - 1);

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/DatePatternToRegexTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/DatePatternToRegexTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/DatePatternToRegexTest.java	Tue Aug  4 23:18:43 2009
@@ -46,6 +46,12 @@
     doTest("yyyy-MMMM-dd", CAL_2009_08_3_NIGHT);
   }
 
+
+  @Test
+  public void dot() {
+    doTest("yyyy.MMM.dd", CAL_2009_08_3_NIGHT);;
+  }
+  
   @Test
   public void timeZone() {
     doTest("yyyy-MMM-dd HH:mm:ss z", CAL_2009_08_3_NIGHT);

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileNamePatternTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileNamePatternTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileNamePatternTest.java	Tue Aug  4 23:18:43 2009
@@ -121,7 +121,7 @@
     cal.set(2003, 4, 20, 17, 55);
     FileNamePattern fnp = new FileNamePattern("foo-%d{yyyy.MM.dd}-%i.txt", context);
     String regex = fnp.asRegex();
-    assertEquals("foo-2003.05.20-\\d{1,2}.txt", regex);
+    assertEquals("foo-\\d{4}\\.\\d{2}\\.\\d{2}-\\d{1,2}.txt", regex);
   }
 
 


More information about the logback-dev mailing list