KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > logging > simple > DateTimeCustomConfigTestCase


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.commons.logging.simple;
18
19 import java.util.Date JavaDoc;
20 import java.text.SimpleDateFormat JavaDoc;
21 import java.text.DateFormat JavaDoc;
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     // ----------------------------------------------------------- Constructors
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 JavaDoc name) {
48         super(name);
49     }
50     
51     // ----------------------------------------------------------- Methods
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         // try the formatter
59
Date JavaDoc now = new Date JavaDoc();
60         DateFormat JavaDoc formatter = ((DecoratedSimpleLog) log).getDateTimeFormatter();
61         SimpleDateFormat JavaDoc sampleFormatter = new SimpleDateFormat JavaDoc("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 }
Popular Tags