View Javadoc
1   package org.dbunit.ext.mssql;
2   
3   import java.sql.Types;
4   
5   import org.dbunit.dataset.datatype.DataType;
6   import org.dbunit.dataset.datatype.IDataTypeFactory;
7   import junit.framework.TestCase;
8   
9   /**
10   * Created By:   fede
11   * Date:         8-set-2004 
12   * Time:         15.08.55
13   *
14   * Last Checkin: $Author$
15   * Date:         $Date$
16   * Revision:     $Revision$
17   */
18  public class MsSqlDataTypeFactoryTest extends TestCase {
19      public MsSqlDataTypeFactoryTest(String s)
20      {
21          super(s);
22      }
23  
24      public IDataTypeFactory createFactory() throws Exception
25      {
26          return new MsSqlDataTypeFactory();
27      }
28  
29      public void testCreateCharDataType() throws Exception
30      {
31      	int sqlType = MsSqlDataTypeFactory.NCHAR;
32      	String sqlTypeName = "nchar";
33  
34      	DataType expected = DataType.CHAR;
35      	DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
36      	assertEquals("type", expected, actual);
37      }
38  
39      public void testCreateVarcharDataType() throws Exception
40      {
41      	int sqlType = MsSqlDataTypeFactory.NVARCHAR;
42      	String sqlTypeName = "nvarchar";
43  
44      	DataType expected = DataType.VARCHAR;
45      	DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
46      	assertEquals("type", expected, actual);
47      }
48  
49      public void testCreateLongVarcharDataTypeFromNtext() throws Exception
50      {
51      	int sqlType = MsSqlDataTypeFactory.NTEXT;
52      	String sqlTypeName = "ntext";
53  
54      	DataType expected = DataType.LONGVARCHAR;
55      	DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
56      	assertEquals("type", expected, actual);
57      }
58      
59      public void testCreateLongVarcharDataTypeFromNtextMsSql2005() throws Exception
60      {
61      	int sqlType = MsSqlDataTypeFactory.NTEXT_MSSQL_2005;
62      	String sqlTypeName = "ntext";
63  
64      	DataType expected = DataType.LONGVARCHAR;
65      	DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
66      	assertEquals("type", expected, actual);
67      }
68  
69      public void testCreateUniqueIdentifierType() throws Exception {
70          int sqlType = Types.CHAR;
71          String sqlTypeName = UniqueIdentifierType.UNIQUE_IDENTIFIER_TYPE;
72  
73          DataType actual = createFactory().createDataType(sqlType, sqlTypeName);
74          assertTrue(actual instanceof UniqueIdentifierType);
75      }
76  }