1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.dbunit.dataset.datatype;
22
23 import junit.framework.TestCase;
24
25 import java.sql.Types;
26
27
28
29
30
31
32 public class AbstractDataTypeFactoryTest extends TestCase
33 {
34 public AbstractDataTypeFactoryTest(String s)
35 {
36 super(s);
37 }
38
39 public IDataTypeFactory createFactory() throws Exception
40 {
41 return new DefaultDataTypeFactory();
42 }
43
44 public void testCreateDataType() throws Exception
45 {
46 DataType[] expectedTypes = new DataType[] {
47 DataType.UNKNOWN,
48 DataType.CHAR,
49 DataType.VARCHAR,
50 DataType.LONGVARCHAR,
51
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
63 DataType.TIME,
64 DataType.TIMESTAMP,
65 DataType.BINARY,
66 DataType.VARBINARY,
67 DataType.LONGVARBINARY,
68
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
81 {
82 int sqlType = Types.DATE;
83 String 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
91 {
92 int sqlType = Types.BLOB;
93 String 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
101 {
102 int sqlType = Types.CLOB;
103 String sqlTypeName = "CLOB";
104
105 DataType expected = DataType.CLOB;
106 DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
107 assertSame("type", expected, actual);
108 }
109
110 }