1
2
3
4 package org.melati.poem.test;
5
6 import java.util.Enumeration;
7
8 import org.melati.poem.Column;
9 import org.melati.poem.ColumnInfo;
10 import org.melati.poem.DisplayLevel;
11 import org.melati.poem.Field;
12 import org.melati.poem.PoemTypeFactory;
13 import org.melati.poem.Searchability;
14
15
16
17
18
19
20 public class ColumnInfoTest extends PoemTestCase {
21
22 public ColumnInfoTest(String name) {
23 super(name);
24 }
25
26 protected void setUp() throws Exception {
27 super.setUp();
28 }
29
30 protected void tearDown() throws Exception {
31 super.tearDown();
32 }
33
34
35
36
37 public void testAssertCanReadAccessToken() {
38
39 }
40
41
42
43
44 public void testSetTableinfoTroid() {
45 ColumnInfo ci = getDb().getUserTable().getNameColumn().getColumnInfo();
46 try {
47 ci.setTableinfoTroid(new Integer(99));
48 fail("Should have bombed");
49 } catch (IllegalArgumentException e) {
50 e = null;
51 }
52 }
53
54
55
56
57 public void testSetName() {
58
59 }
60
61
62
63
64
65 public void testSetDisplaylevelIndex() {
66 Enumeration<Column<?>> them = getDb().getUserTable().getSummaryDisplayColumns();
67 int counter = 0;
68 while (them.hasMoreElements()) {
69 them.nextElement();
70 counter++;
71 }
72 assertEquals(2, counter);
73
74
75 ColumnInfo passwordCI = getDb().getUserTable().getPasswordColumn().getColumnInfo();
76 ColumnInfo nameCI = getDb().getUserTable().getNameColumn().getColumnInfo();
77 assertEquals(DisplayLevel.record, passwordCI.getDisplaylevel());
78 assertEquals(DisplayLevel.primary, nameCI.getDisplaylevel());
79
80 assertEquals("name", getDb().getUserTable().displayColumn().getName());
81
82 passwordCI.setDisplaylevelIndex(DisplayLevel.primary.getIndex());
83 assertEquals(DisplayLevel.primary, passwordCI.getDisplaylevel());
84 assertEquals(DisplayLevel.summary,
85 getDb().getUserTable().getNameColumn().getDisplayLevel());
86 assertEquals("password", getDb().getUserTable().displayColumn().getName());
87 getDb().getUserTable().getNameColumn().getColumnInfo().
88 setDisplaylevelIndex(DisplayLevel.primary.getIndex());
89 assertEquals(DisplayLevel.summary, passwordCI.getDisplaylevel());
90
91 passwordCI.setDisplaylevelIndex(DisplayLevel.record.getIndex());
92 assertEquals(DisplayLevel.record, passwordCI.getDisplaylevel());
93
94 them = getDb().getUserTable().getSummaryDisplayColumns();
95 counter = 0;
96 while (them.hasMoreElements()) {
97 them.nextElement();
98 counter++;
99 }
100 assertEquals(2, counter);
101
102 }
103
104
105
106
107
108
109
110
111
112
113 public void testProgramaticCreation() {
114 ColumnInfo odd = (ColumnInfo)getDb().getColumnInfoTable().newPersistent();
115 odd.setName("odd");
116 odd.setDisplayname("Odd");
117 odd.setUsereditable(true);
118 odd.setUsercreateable(true);
119 odd.setDisplaylevel(DisplayLevel.primary);
120 odd.setSearchability(Searchability.primary);
121 odd.setIndexed(true);
122 odd.setUnique(true);
123 odd.setTypefactory(PoemTypeFactory.STRING);
124 odd.setNullable(true);
125 odd.setSize(-1);
126 odd.setWidth(10);
127 odd.setHeight(1);
128 odd.setPrecision(22);
129 odd.setScale(2);
130 odd.setDisplayorder(1);
131 odd.setTableinfo(getDb().getColumnInfoTable().getTableInfo());
132 getDb().getColumnInfoTable().create(odd);
133
134
135
136 odd.setDisplaylevelIndex(DisplayLevel.primary.getIndex());
137
138
139 odd.delete();
140 }
141
142
143
144
145 public void testGetDsdQualifiers() {
146 ColumnInfo ci = getDb().getUserTable().getPasswordColumn().getColumnInfo();
147 Enumeration<Field<?>> them = ci.getDsdQualifiers();
148 int counter = 0;
149 while (them.hasMoreElements()) {
150 counter++;
151 them.nextElement();
152 }
153 assertEquals(18, counter);
154 }
155
156
157
158
159 public void testGetDsdQualifiers2() {
160 ColumnInfo ci = getDb().getUserTable().getIdColumn().getColumnInfo();
161 Enumeration<Field<?>> them = ci.getDsdQualifiers();
162 int counter = 0;
163 while (them.hasMoreElements()) {
164 counter++;
165 them.nextElement();
166 }
167 assertEquals(15, counter);
168 }
169
170
171
172
173
174 public void putativeTestUnsetColumn() {
175 ColumnInfo ci = (ColumnInfo)getDb().getColumnInfoTable().newPersistent();
176 ci.setId(0);
177 ci.setName("testcolinfo");
178 ci.setDescription("test colinfo");
179 ci.setDisplayname("test colinfo");
180 ci.setDisplayorder(1);
181 ci.setDisplaylevel(DisplayLevel.primary);
182 ci.setSearchability(Searchability.primary);
183 ci.setUsercreateable(true);
184 ci.setUnique(false);
185 ci.setIndexed(true);
186 ci.setUsereditable(true);
187 ci.setTypefactory(PoemTypeFactory.TROID);
188 ci.setNullable(false);
189 ci.setSize(16);
190 ci.setHeight(1);
191 ci.setWidth(20);
192 ci.setPrecision(22);
193 ci.setScale(2);
194 ci.setTableinfo(getDb().getColumnInfoTable().getTableInfo());
195
196 ci.makePersistent();
197 try {
198 ci.getDsdQualifiers();
199 } catch (NullPointerException e) {
200 e = null;
201 }
202 ci.delete();
203 }
204 }