1
2
3
4 package org.melati.poem.dbms.test;
5
6 import org.melati.poem.BigDecimalPoemType;
7 import org.melati.poem.BinaryPoemType;
8 import org.melati.poem.BooleanPoemType;
9 import org.melati.poem.DatePoemType;
10 import org.melati.poem.DoublePoemType;
11 import org.melati.poem.IntegerPoemType;
12 import org.melati.poem.LongPoemType;
13 import org.melati.poem.StringPoemType;
14 import org.melati.poem.TimestampPoemType;
15 import org.melati.poem.dbms.DbmsFactory;
16 import org.melati.poem.dbms.Mimer;
17
18
19
20
21
22
23 public class MimerTest extends DbmsSpec {
24
25
26
27
28
29 public MimerTest(String name) {
30 super(name);
31 }
32
33
34
35
36
37 protected void setUp() throws Exception {
38 super.setUp();
39 }
40
41
42
43
44
45 protected void tearDown() throws Exception {
46 super.tearDown();
47 }
48
49 protected void setObjectUnderTest() {
50 it = DbmsFactory.getDbms("org.melati.poem.dbms.Mimer");
51 }
52
53
54
55
56
57 public void testGetStringSqlDefinition() throws Exception {
58 assertEquals("VARCHAR(2500)", it.getStringSqlDefinition(-1));
59 assertEquals("VARCHAR(0)", it.getStringSqlDefinition(0));
60 }
61
62
63
64
65
66
67 public void testGetSqlDefinition() throws Exception {
68 assertEquals("INT", it.getSqlDefinition("BOOLEAN"));
69 assertEquals("DOUBLE PRECISION", it.getSqlDefinition("DOUBLE PRECISION"));
70 assertEquals("INT8", it.getSqlDefinition("INT8"));
71 assertEquals("Big Decimal", it.getSqlDefinition("Big Decimal"));
72 }
73
74
75
76
77
78 public void testCanRepresent() {
79 assertNull(it.canRepresent(StringPoemType.nullableInstance, IntegerPoemType.nullableInstance));
80 assertNull(it.canRepresent(IntegerPoemType.nullableInstance,StringPoemType.nullableInstance));
81
82 assertNull(it.canRepresent(new BigDecimalPoemType(false),new BigDecimalPoemType(true)));
83 assertTrue(it.canRepresent(new BigDecimalPoemType(true),new BigDecimalPoemType(false))
84 instanceof BigDecimalPoemType);
85
86 assertNull(it.canRepresent(new StringPoemType(true, 255), new StringPoemType(true, -1)));
87
88 assertTrue(it.canRepresent(
89 new StringPoemType(true, Mimer.mimerTextHack), new StringPoemType(true, -1))
90 instanceof StringPoemType);
91 assertTrue(it.canRepresent(
92 new StringPoemType(true, -1), new StringPoemType(true, -1))
93 instanceof StringPoemType);
94
95 assertNull(it.canRepresent(new TimestampPoemType(true), new DatePoemType(true)));
96
97 assertTrue(it.canRepresent(
98 new BooleanPoemType(true), new BooleanPoemType(false))
99 instanceof BooleanPoemType);
100
101 assertNull(it.canRepresent(new DoublePoemType(false), new BigDecimalPoemType(true)));
102
103 assertNull(it.canRepresent(new DoublePoemType(true), new BigDecimalPoemType(false)));
104
105 assertNull(it.canRepresent(new IntegerPoemType(false), new LongPoemType(true)));
106
107 assertNull(it.canRepresent(new IntegerPoemType(true), new LongPoemType(false)));
108
109
110 assertNull(it.canRepresent(new BinaryPoemType(false,10), new BinaryPoemType(true,10)));
111 assertNull(it.canRepresent(new BinaryPoemType(true,10), new BinaryPoemType(true,11)));
112 assertTrue(it.canRepresent(
113 new BinaryPoemType(true,-1),
114 new BinaryPoemType(true,-1)) instanceof BinaryPoemType);
115 assertTrue(it.canRepresent(
116 new BinaryPoemType(true,2500),
117 new BinaryPoemType(true,10)) instanceof BinaryPoemType);
118
119 assertTrue(it.canRepresent(
120 new IntegerPoemType(true),
121 new BooleanPoemType(true)) instanceof BooleanPoemType);
122
123
124
125 }
126
127
128
129 }