1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.beanutils.converters;
18  
19  import java.util.Calendar;
20  import java.util.Date;
21  
22  import junit.framework.TestSuite;
23  
24  /***
25   * Test Case for the DateConverter class.
26   *
27   * @version $Revision: 471352 $
28   */
29  public class DateConverterTestCase extends DateConverterTestBase {
30  
31      /***
32       * Construct a new Date test case.
33       * @param name Test Name
34       */
35      public DateConverterTestCase(String name) {
36          super(name);
37      }
38  
39      // ------------------------------------------------------------------------
40  
41      /***
42       * Create Test Suite
43       * @return test suite
44       */
45      public static TestSuite suite() {
46          return new TestSuite(DateConverterTestCase.class);        
47      }
48  
49      /*** Set Up */
50      public void setUp() throws Exception {
51      }
52  
53      /*** Tear Down */
54      public void tearDown() throws Exception {
55      }
56  
57      // ------------------------------------------------------------------------
58      
59      /***
60       * Create the Converter with no default value.
61       * @return A new Converter
62       */
63      protected DateTimeConverter makeConverter() {
64          return new DateConverter();
65      }
66      
67      /***
68       * Create the Converter with a default value.
69       * @param defaultValue The default value
70       * @return A new Converter
71       */
72      protected DateTimeConverter makeConverter(Object defaultValue) {
73          return new DateConverter(defaultValue);
74      }
75  
76      /***
77       * Return the expected type
78       * @return The expected type
79       */
80      protected Class getExpectedType() {
81          return Date.class;
82      }
83  
84      /***
85       * Convert from a Calendar to the appropriate Date type
86       * 
87       * @param value The Calendar value to convert
88       * @return The converted value
89       */
90      protected Object toType(Calendar value) {
91          return value.getTime();
92      }
93  }