1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.logging.simple;
18
19 import java.util.Date;
20 import java.text.SimpleDateFormat;
21 import java.text.DateFormat;
22
23 import junit.framework.Test;
24 import junit.framework.TestSuite;
25
26
27 /***
28 * Tests custom date time format configuration
29 */
30 public class DateTimeCustomConfigTestCase extends CustomConfigTestCase {
31
32
33
34 /***
35 * Return the tests included in this test suite.
36 */
37 public static Test suite() {
38 return (new TestSuite(DateTimeCustomConfigTestCase.class));
39 }
40
41
42 /***
43 * <p>Construct a new instance of this test case.</p>
44 *
45 * @param name Name of the test case
46 */
47 public DateTimeCustomConfigTestCase(String name) {
48 super(name);
49 }
50
51
52
53 /*** Checks that the date time format has been successfully set */
54 protected void checkDecoratedDateTime() {
55 assertEquals("Expected date format to be set", "dd.mm.yyyy",
56 ((DecoratedSimpleLog) log).getDateTimeFormat());
57
58
59 Date now = new Date();
60 DateFormat formatter = ((DecoratedSimpleLog) log).getDateTimeFormatter();
61 SimpleDateFormat sampleFormatter = new SimpleDateFormat("dd.mm.yyyy");
62 assertEquals("Date should be formatters to pattern dd.mm.yyyy", sampleFormatter.format(now), formatter.format(now));
63 }
64
65 /*** Hook for subclassses */
66 protected void checkShowDateTime() {
67 assertTrue(((DecoratedSimpleLog) log).getShowDateTime());
68 }
69
70 }