KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbunit > dataset > datatype > AbstractDataTypeFactoryTest


1 /*
2  *
3  * The DbUnit Database Testing Framework
4  * Copyright (C)2002-2004, DbUnit.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */

21 package org.dbunit.dataset.datatype;
22
23 import junit.framework.TestCase;
24
25 import java.sql.Types JavaDoc;
26
27 /**
28  * @author Manuel Laflamme
29  * @since Aug 13, 2003
30  * @version $Revision: 1.3 $
31  */

32 public class AbstractDataTypeFactoryTest extends TestCase
33 {
34     public AbstractDataTypeFactoryTest(String JavaDoc s)
35     {
36         super(s);
37     }
38
39     public IDataTypeFactory createFactory() throws Exception JavaDoc
40     {
41         return new DefaultDataTypeFactory();
42     }
43
44     public void testCreateDataType() throws Exception JavaDoc
45     {
46         DataType[] expectedTypes = new DataType[] {
47             DataType.UNKNOWN,
48             DataType.CHAR,
49             DataType.VARCHAR,
50             DataType.LONGVARCHAR,
51 // DataType.CLOB,
52
DataType.NUMERIC,
53             DataType.DECIMAL,
54             DataType.BOOLEAN,
55             DataType.TINYINT,
56             DataType.SMALLINT,
57             DataType.INTEGER,
58             DataType.BIGINT,
59             DataType.REAL,
60             DataType.FLOAT,
61             DataType.DOUBLE,
62 // DataType.DATE,
63
DataType.TIME,
64             DataType.TIMESTAMP,
65             DataType.BINARY,
66             DataType.VARBINARY,
67             DataType.LONGVARBINARY,
68 // DataType.BLOB,
69
};
70
71         IDataTypeFactory factory = createFactory();
72         for (int i = 0; i < expectedTypes.length; i++)
73         {
74             DataType expected = expectedTypes[i];
75             DataType actual = factory.createDataType(expected.getSqlType(), expected.toString());
76             assertSame("type", expected, actual);
77         }
78     }
79
80     public void testCreateDateDataType() throws Exception JavaDoc
81     {
82         int sqlType = Types.DATE;
83         String JavaDoc sqlTypeName = "DATE";
84
85         DataType expected = DataType.DATE;
86         DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
87         assertSame("type", expected, actual);
88     }
89
90     public void testCreateBlobDataType() throws Exception JavaDoc
91     {
92         int sqlType = Types.BLOB;
93         String JavaDoc sqlTypeName = "BLOB";
94
95         DataType expected = DataType.BLOB;
96         DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
97         assertSame("type", expected, actual);
98     }
99
100     public void testCreateClobDataType() throws Exception JavaDoc
101     {
102         int sqlType = Types.CLOB;
103         String JavaDoc sqlTypeName = "CLOB";
104
105         DataType expected = DataType.CLOB;
106         DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
107         assertSame("type", expected, actual);
108     }
109
110 }
111
Popular Tags