1   package org.apache.torque.engine.database.model;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.sql.Types;
23  
24  import junit.framework.TestCase;
25  
26  /***
27   * Tests for TypeMap.
28   *
29   * @author <a href="mailto:mpoeschl@marmot.at>Martin Poeschl</a>
30   */
31  public class TypeMapTest extends TestCase {
32  
33      public void testGetJavaObject() {
34          assertEquals(TypeMap.getJavaObject(SchemaType.INTEGER), "new Integer(0)");
35      }
36  
37      public void testGetJavaNative() {
38          assertEquals(TypeMap.getJavaNative(SchemaType.INTEGER), "int");
39      }
40  
41      public void testGetJavaNativeObject() {
42          assertEquals(TypeMap.getJavaNativeObject(SchemaType.INTEGER), "Integer");
43      }
44  
45      public void testGetVillageMethod() {
46          assertEquals(TypeMap.getVillageMethod(SchemaType.INTEGER), "asInt()");
47      }
48  
49      public void testGetVillageObjectMethod() {
50          assertEquals(TypeMap.getVillageObjectMethod(SchemaType.INTEGER), "asIntegerObj()");
51      }
52  
53      public void testGetPPMethod() {
54          assertEquals(TypeMap.getPPMethod(SchemaType.INTEGER), "getInt(ppKey)");
55      }
56  
57      public void testGetTorqueType() {
58          assertEquals(TypeMap.getTorqueType(new Integer(Types.FLOAT)),
59                  SchemaType.FLOAT);
60          assertEquals(TypeMap.getTorqueType(new Integer(Types.CHAR)),
61                  SchemaType.CHAR);
62      }
63  
64      public void testIsBooleanInt() {
65          assertFalse(TypeMap.isBooleanInt(SchemaType.FLOAT));
66          assertTrue(TypeMap.isBooleanInt(SchemaType.BOOLEANINT));
67      }
68  
69      public void testIsBooleanChar() {
70          assertFalse(TypeMap.isBooleanChar(SchemaType.FLOAT));
71          assertTrue(TypeMap.isBooleanChar(SchemaType.BOOLEANCHAR));
72      }
73  
74      public void testIsTextType() {
75          assertFalse(TypeMap.isTextType(SchemaType.FLOAT));
76          assertTrue(TypeMap.isTextType(SchemaType.CHAR));
77      }
78  
79  }