KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > woody > datatype > convertor > EnumConvertorTestCase


1 /*
2  * Copyright 1999-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 package org.apache.cocoon.woody.datatype.convertor;
17
18 import java.util.Locale JavaDoc;
19
20 import org.apache.cocoon.woody.datatype.Sex;
21
22 import junit.framework.TestCase;
23
24 /**
25  * Test case for the {@link EnumConvertor} class.
26  *
27  * @version CVS $Id: EnumConvertorTestCase.java 30932 2004-07-29 17:35:38Z vgritsenko $
28  */

29 public class EnumConvertorTestCase extends TestCase {
30
31     public EnumConvertorTestCase(String JavaDoc name) {
32         super(name);
33     }
34
35     /**
36      * Test the {@link EnumConvertor#convertFromString(java.lang.String, java.util.Locale, org.apache.cocoon.woody.datatype.convertor.Convertor.FormatCache)
37      * method.
38      */

39     public void testConvertFromString() {
40         EnumConvertor convertor = new EnumConvertor("org.apache.cocoon.woody.datatype.Sex");
41         Object JavaDoc sex = convertor.convertFromString
42             (Sex.class.getName() + ".FEMALE", Locale.getDefault(), null);
43         assertSame("Returned sex must be FEMALE", Sex.FEMALE, sex);
44     }
45     
46     /**
47      * Test the {@link EnumConvertor##convertToString(java.lang.Object, java.util.Locale, org.apache.cocoon.woody.datatype.convertor.Convertor.FormatCache)
48      * method.
49      */

50     public void testConvertToString() {
51         EnumConvertor convertor = new EnumConvertor("org.apache.cocoon.woody.datatype.Sex");
52         assertEquals("Converted value must match string",
53                 Sex.class.getName() + ".MALE",
54                 convertor.convertToString
55                     (Sex.MALE, Locale.getDefault(), null));
56     }
57 }
58
Popular Tags