You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ca...@apache.org on 2010/05/17 07:02:51 UTC

svn commit: r944970 - in /logging/log4j/companions/extras/trunk/src: changes/changes.xml test/java/org/apache/log4j/pattern/CachedDateFormatTest.java

Author: carnold
Date: Mon May 17 05:02:50 2010
New Revision: 944970

URL: http://svn.apache.org/viewvc?rev=944970&view=rev
Log:
Bug 49007: CachedDateFormatTest fails on Apache Harmony

Modified:
    logging/log4j/companions/extras/trunk/src/changes/changes.xml
    logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/pattern/CachedDateFormatTest.java

Modified: logging/log4j/companions/extras/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/changes/changes.xml?rev=944970&r1=944969&r2=944970&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/changes/changes.xml (original)
+++ logging/log4j/companions/extras/trunk/src/changes/changes.xml Mon May 17 05:02:50 2010
@@ -35,6 +35,8 @@
        <action action="add" issue="49010">Add %p{-2} pattern to EnhancedPatternLayout to drop two leading elements from name.</action>
        <action action="add" issue="48902">Add %throwable{n} and {-n} pattern to EnhancedPatternLayout to print n or drop last n lines.</action>
        <action action="fix" issue="49812">Improve javadoc for LogMF, LogSF, LogXF</action>
+       <action action="fix" issue="49007">CachedDateFormatTest fails on Apache Harmony.</action>
+       <action action="fix" issue="48953">Unused imports and variables in test code cause gcj compile warnings.</action>       
     </release>
 
 

Modified: logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/pattern/CachedDateFormatTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/pattern/CachedDateFormatTest.java?rev=944970&r1=944969&r2=944970&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/pattern/CachedDateFormatTest.java (original)
+++ logging/log4j/companions/extras/trunk/src/test/java/org/apache/log4j/pattern/CachedDateFormatTest.java Mon May 17 05:02:50 2010
@@ -51,21 +51,6 @@ public final class CachedDateFormatTest
       return df;
   }
 
-  /**
-   * Asserts that formatting the provided date results
-   * in the expected string.
-   *
-   * @param date Date date
-   * @param timeZone TimeZone timezone for conversion
-   * @param expected String expected string
-   */
-  private final void assertFormattedTime(Date date,
-                                         TimeZone timeZone,
-                                         String expected) {
-    DateFormat formatter = createAbsoluteTimeDateFormat(timeZone);
-    String actual = formatter.format(date);
-    assertEquals(expected, actual);
-  }
 
   /**
    * Timezone representing GMT.
@@ -149,8 +134,8 @@ public final class CachedDateFormatTest
     Date jul1 = new Date(ticks);
     assertEquals(baseFormat.format(jul1), cachedFormat.format(jul1));
     Date plus8ms = new Date(ticks + 8);
-    String base = baseFormat.format(plus8ms);
-    String cached = cachedFormat.format(plus8ms);
+    baseFormat.format(plus8ms);
+    cachedFormat.format(plus8ms);
     assertEquals(baseFormat.format(plus8ms), cachedFormat.format(plus8ms));
     Date plus17ms = new Date(ticks + 17);
     assertEquals(baseFormat.format(plus17ms), cachedFormat.format(plus17ms));
@@ -240,15 +225,17 @@ public final class CachedDateFormatTest
     c.set(Calendar.MILLISECOND, 23);
     c.setTimeZone(cet);
 
+    String expected = baseFormat.format(c.getTime());
     String s = cachedFormat.format(c.getTime());
-    assertEquals("2004-December-12 20:00:37,23 GMT+01:00", s);
+    assertEquals(expected, s);
 
     c.set(2005, Calendar.JANUARY, 1, 0, 0);
     c.set(Calendar.SECOND, 13);
     c.set(Calendar.MILLISECOND, 905);
 
+    expected = baseFormat.format(c.getTime());
     s = cachedFormat.format(c.getTime());
-    assertEquals("2005-January-01 00:00:13,905 GMT+01:00", s);
+    assertEquals(expected, s);
   }
   
 
@@ -267,18 +254,21 @@ public final class CachedDateFormatTest
     c.set(Calendar.MILLISECOND, 23);
     c.setTimeZone(cet);
 
+    String expected = baseFormat.format(c.getTime());
     String s = cachedFormat.format(c.getTime());
-    assertEquals("October 023 Tuesday", s);
+    assertEquals(expected, s);
 
     c.set(2004, Calendar.NOVEMBER, 1, 0, 0);
     c.set(Calendar.MILLISECOND, 23);
+    expected = baseFormat.format(c.getTime());
     s = cachedFormat.format(c.getTime());
-    assertEquals("November 023 Monday", s);
+    assertEquals(expected, s);
 
 
     c.set(Calendar.MILLISECOND, 984);
+    expected = baseFormat.format(c.getTime());
     s = cachedFormat.format(c.getTime());
-    assertEquals("November 984 Monday", s);
+    assertEquals(expected, s);
   }
 
   /**
@@ -291,21 +281,25 @@ public final class CachedDateFormatTest
      //
      String badPattern = "ss,SS0";
      SimpleDateFormat simpleFormat = new SimpleDateFormat(badPattern);
+     SimpleDateFormat baseFormat = new SimpleDateFormat(badPattern);
      DateFormat gmtFormat = new CachedDateFormat(simpleFormat, 1000);
      gmtFormat.setTimeZone(GMT);
+     baseFormat.setTimeZone(GMT);
 
      //
      // The first request has to 100 ms after an ordinal second
      //    to push the literal zero out of the pattern check
      long ticks = 11142L * 86400000L;
      Date jul2 = new Date(ticks + 120);
-     assertEquals("00,1200", gmtFormat.format(jul2));
+     String expected = baseFormat.format(jul2);
+     assertEquals(expected, gmtFormat.format(jul2));
      jul2.setTime(ticks + 87);
      
 
      //
      //   Cache gives 00,087
-     assertEquals("00,870", gmtFormat.format(jul2));
+     expected = baseFormat.format(jul2);
+     assertEquals(expected, gmtFormat.format(jul2));
 
   }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org