View Javadoc
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.ext.oracle;
22  
23  import org.dbunit.dataset.datatype.AbstractDataTypeFactoryTest;
24  import org.dbunit.dataset.datatype.DataType;
25  import org.dbunit.dataset.datatype.IDataTypeFactory;
26  
27  import java.sql.Types;
28  
29  /**
30   * @author Manuel Laflamme
31   * @since Aug 13, 2003
32   * @version $Revision$
33   */
34  public class OracleDataTypeFactoryTest extends AbstractDataTypeFactoryTest
35  {
36      public OracleDataTypeFactoryTest(String s)
37      {
38          super(s);
39      }
40  
41      public IDataTypeFactory createFactory() throws Exception
42      {
43          return new OracleDataTypeFactory();
44      }
45  
46      public void testCreateBlobDataType() throws Exception
47      {
48          int sqlType = Types.OTHER;
49          String sqlTypeName = "BLOB";
50  
51          DataType expected = OracleDataTypeFactory.ORACLE_BLOB;
52          DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
53          assertSame("type", expected, actual);
54      }
55  
56      public void testCreateClobDataType() throws Exception
57      {
58          int sqlType = Types.OTHER;
59          String sqlTypeName = "CLOB";
60  
61          DataType expected = OracleDataTypeFactory.ORACLE_CLOB;
62          DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
63          assertSame("type", expected, actual);
64      }
65  
66      public void testCreateNClobDataType() throws Exception
67      {
68          int sqlType = Types.OTHER;
69          String sqlTypeName = "NCLOB";
70  
71          DataType expected = OracleDataTypeFactory.ORACLE_NCLOB;
72          DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
73          assertSame("type", expected, actual);
74      }
75  
76      public void testCreateLongRawDataType() throws Exception
77      {
78          int sqlType = Types.LONGVARBINARY;
79          String sqlTypeName = "LONG RAW";
80  
81          DataType expected = OracleDataTypeFactory.LONG_RAW;
82          DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
83          assertSame("type", expected, actual);
84      }
85  
86      public void testCreateTimestampDataType() throws Exception
87      {
88          int sqlType = Types.OTHER;
89          String sqlTypeName = "TIMESTAMP(6)";
90  
91          DataType expected = DataType.TIMESTAMP;
92          DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
93          assertSame("type", expected, actual);
94      }
95  
96      public void testCreateDateDataType() throws Exception
97      {
98          int sqlType = Types.DATE;
99          String sqlTypeName = "DATE";
100 
101         DataType expected = DataType.TIMESTAMP;
102         DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
103         assertSame("type", expected, actual);
104     }
105 
106     public void testCreateNChar2DataType() throws Exception
107     {
108         int sqlType = Types.OTHER;
109         String sqlTypeName = "NCHAR2";
110 
111         DataType expected = DataType.CHAR;
112         DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
113         assertSame("type", expected, actual);
114     }
115 
116     public void testCreateNVarChar2DataType() throws Exception
117     {
118         int sqlType = Types.OTHER;
119         String sqlTypeName = "NVARCHAR2";
120 
121         DataType expected = DataType.VARCHAR;
122         DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
123         assertSame("type", expected, actual);
124     }
125 
126     public void testCreateFloatDataType() throws Exception
127     {
128         int sqlType = Types.OTHER;
129         String sqlTypeName = "FLOAT";
130 
131         DataType expected = DataType.FLOAT;
132         DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
133         assertSame("type", expected, actual);
134     }
135 
136     public void testCreateBinaryDoubleDataType() throws Exception
137     {
138         int sqlType = Types.OTHER;
139         String sqlTypeName = "BINARY_DOUBLE";
140 
141         DataType expected = DataType.DOUBLE;
142         DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
143         assertSame("type", expected, actual);
144     }
145 
146     public void testCreateBinaryFloatDataType() throws Exception
147     {
148         int sqlType = Types.OTHER;
149         String sqlTypeName = "BINARY_FLOAT";
150 
151         DataType expected = DataType.FLOAT;
152         DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
153         assertSame("type", expected, actual);
154     }
155 
156     public void testCreateSdoGeometryDataType() throws Exception
157     {
158         int sqlType = Types.STRUCT;
159         String sqlTypeName = "SDO_GEOMETRY";
160 
161         DataType expected = OracleDataTypeFactory.ORACLE_SDO_GEOMETRY_TYPE;
162         DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
163         assertSame("type", expected, actual);
164     }
165 
166 }