View Javadoc
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  
21  import junit.framework.TestSuite;
22  
23  /**
24   * Test Case for the CalendarConverter class.
25   *
26   * @version $Id$
27   */
28  public class CalendarConverterTestCase extends DateConverterTestBase {
29  
30      /**
31       * Construct a new Calendar test case.
32       * @param name Test Name
33       */
34      public CalendarConverterTestCase(final String name) {
35          super(name);
36      }
37  
38      // ------------------------------------------------------------------------
39  
40      /**
41       * Create Test Suite
42       * @return test suite
43       */
44      public static TestSuite suite() {
45          return new TestSuite(CalendarConverterTestCase.class);
46      }
47  
48      // ------------------------------------------------------------------------
49      /**
50       * Create the Converter with no default value.
51       * @return A new Converter
52       */
53      @Override
54      protected DateTimeConverter makeConverter() {
55          return new CalendarConverter();
56      }
57  
58      /**
59       * Create the Converter with a default value.
60       * @param defaultValue The default value
61       * @return A new Converter
62       */
63      @Override
64      protected DateTimeConverter makeConverter(final Object defaultValue) {
65          return new CalendarConverter(defaultValue);
66      }
67  
68      /**
69       * Return the expected type
70       * @return The expected type
71       */
72      @Override
73      protected Class<?> getExpectedType() {
74          return Calendar.class;
75      }
76  
77      /**
78       * Convert from a java.util.Date to the Converter's type.
79       *
80       * @param value The Date value to convert
81       * @return The converted value
82       */
83      @Override
84      protected Object toType(final Calendar value) {
85          return value;
86     }
87  
88  }