01: /*
02: * OracleMetadataTest.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2007, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.db.oracle;
13:
14: import java.sql.Types;
15: import junit.framework.TestCase;
16:
17: /**
18: * @author support@sql-workbench.net
19: */
20: public class OracleMetadataTest extends TestCase {
21: public OracleMetadataTest(String testName) {
22: super (testName);
23: }
24:
25: public void testGetSqlTypeDisplay() {
26: // Test with BYTE as default semantics
27: OracleMetadata meta = new OracleMetadata(
28: OracleMetadata.BYTE_SEMANTICS, false);
29:
30: // Test non-Varchar types
31: assertEquals("CLOB", meta.getSqlTypeDisplay("CLOB", Types.CLOB,
32: -1, -1, 0));
33: assertEquals("NVARCHAR(300)", meta.getSqlTypeDisplay(
34: "NVARCHAR", Types.VARCHAR, 300, -1, 0));
35: assertEquals("CHAR(5)", meta.getSqlTypeDisplay("CHAR",
36: Types.CHAR, 5, -1, 0));
37: assertEquals("NUMBER(10,2)", meta.getSqlTypeDisplay("NUMBER",
38: Types.NUMERIC, 10, 2, 0));
39:
40: String display = meta.getSqlTypeDisplay("VARCHAR",
41: Types.VARCHAR, 200, 0, OracleMetadata.BYTE_SEMANTICS);
42: assertEquals("VARCHAR(200)", display);
43:
44: display = meta.getSqlTypeDisplay("VARCHAR", Types.VARCHAR, 200,
45: 0, OracleMetadata.CHAR_SEMANTICS);
46: assertEquals("VARCHAR(200 Char)", display);
47:
48: meta = new OracleMetadata(OracleMetadata.CHAR_SEMANTICS, false);
49:
50: display = meta.getSqlTypeDisplay("VARCHAR", Types.VARCHAR, 200,
51: 0, OracleMetadata.BYTE_SEMANTICS);
52: assertEquals("VARCHAR(200 Byte)", display);
53:
54: display = meta.getSqlTypeDisplay("VARCHAR", Types.VARCHAR, 200,
55: 0, OracleMetadata.CHAR_SEMANTICS);
56: assertEquals("VARCHAR(200)", display);
57:
58: meta = new OracleMetadata(OracleMetadata.CHAR_SEMANTICS, true);
59:
60: display = meta.getSqlTypeDisplay("VARCHAR", Types.VARCHAR, 200,
61: 0, OracleMetadata.BYTE_SEMANTICS);
62: assertEquals("VARCHAR(200 Byte)", display);
63:
64: display = meta.getSqlTypeDisplay("VARCHAR", Types.VARCHAR, 200,
65: 0, OracleMetadata.CHAR_SEMANTICS);
66: assertEquals("VARCHAR(200 Char)", display);
67:
68: }
69: }
|