KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > ojb > tests > ModifyInheritedTagColumnDocumentationAttributeTests


1 package xdoclet.modules.ojb.tests;
2
3 /* Copyright 2003-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /**
19  * Tests for the ojb.modify-inherited tag with the column-documentation attribute.
20  *
21  * @author <a HREF="mailto:tomdz@apache.org">Thomas Dudziak</a>
22  */

23 public class ModifyInheritedTagColumnDocumentationAttributeTests extends OjbTestBase
24 {
25     public ModifyInheritedTagColumnDocumentationAttributeTests(String JavaDoc name)
26     {
27         super(name);
28     }
29
30     // Test: modifying the column-documentation attribute of a field in a direct base class
31
public void testDocumentation1()
32     {
33         addClass(
34             "test.A",
35             "package test;\n"+
36             "/** @ojb.class */\n" +
37             "public class A {\n"+
38             " /** @ojb.field */\n"+
39             " private int attr;\n"+
40             "}");
41         addClass(
42             "test.B",
43             "package test;\n"+
44             "/** @ojb.class\n" +
45             " * @ojb.modify-inherited name=\"attr\"\n"+
46             " * column-documentation=\"Some documentation\"\n"+
47             " */\n"+
48             "public class B extends A {}\n");
49
50         assertEqualsOjbDescriptorFile(
51             "<class-descriptor\n"+
52             " class=\"test.A\"\n"+
53             " table=\"A\"\n"+
54             ">\n"+
55             " <extent-class class-ref=\"test.B\"/>\n"+
56             " <field-descriptor\n"+
57             " name=\"attr\"\n"+
58             " column=\"attr\"\n"+
59             " jdbc-type=\"INTEGER\"\n"+
60             " >\n"+
61             " </field-descriptor>\n"+
62             "</class-descriptor>\n"+
63             "<class-descriptor\n"+
64             " class=\"test.B\"\n"+
65             " table=\"B\"\n"+
66             ">\n"+
67             " <field-descriptor\n"+
68             " name=\"attr\"\n"+
69             " column=\"attr\"\n"+
70             " jdbc-type=\"INTEGER\"\n"+
71             " >\n"+
72             " </field-descriptor>\n"+
73             "</class-descriptor>",
74             runOjbXDoclet(OJB_DEST_FILE));
75         assertEqualsTorqueSchemaFile(
76             "<database name=\"ojbtest\">\n"+
77             " <table name=\"A\">\n"+
78             " <column name=\"attr\"\n"+
79             " javaName=\"attr\"\n"+
80             " type=\"INTEGER\"\n"+
81             " />\n"+
82             " </table>\n"+
83             " <table name=\"B\">\n"+
84             " <column name=\"attr\"\n"+
85             " javaName=\"attr\"\n"+
86             " type=\"INTEGER\"\n"+
87             " description=\"Some documentation\"\n"+
88             " />\n"+
89             " </table>\n"+
90             "</database>",
91             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
92     }
93
94     // Test: modifying the column-documentation attribute of an anonymous field in an indirect base class
95
public void testDocumentation2()
96     {
97         addClass(
98             "test.A",
99             "package test;\n"+
100             "/** @ojb.class\n"+
101             " * @ojb.field name=\"attr\"\n"+
102             " * jdbc-type=\"INTEGER\"\n"+
103             " * column-documentation=\"Some documentation\"\n"+
104             " */\n" +
105             "public class A {}");
106         addClass(
107             "test.B",
108             "package test;\n"+
109             "public class B extends A {}");
110         addClass(
111             "test.C",
112             "package test;\n"+
113             "/** @ojb.class */\n" +
114             "public class C extends B {}");
115         addClass(
116             "test.D",
117             "package test;\n"+
118             "/** @ojb.class\n" +
119             " * @ojb.modify-inherited name=\"attr\"\n"+
120             " * column-documentation=\"Some other documentation\"\n"+
121             " */\n"+
122             "public class D extends C {}\n");
123
124         assertEqualsOjbDescriptorFile(
125             "<class-descriptor\n"+
126             " class=\"test.A\"\n"+
127             " table=\"A\"\n"+
128             ">\n"+
129             " <extent-class class-ref=\"test.C\"/>\n"+
130             " <field-descriptor\n"+
131             " name=\"attr\"\n"+
132             " column=\"attr\"\n"+
133             " jdbc-type=\"INTEGER\"\n"+
134             " access=\"anonymous\"\n"+
135             " >\n"+
136             " </field-descriptor>\n"+
137             "</class-descriptor>\n"+
138             "<class-descriptor\n"+
139             " class=\"test.C\"\n"+
140             " table=\"C\"\n"+
141             ">\n"+
142             " <extent-class class-ref=\"test.D\"/>\n"+
143             " <field-descriptor\n"+
144             " name=\"attr\"\n"+
145             " column=\"attr\"\n"+
146             " jdbc-type=\"INTEGER\"\n"+
147             " access=\"anonymous\"\n"+
148             " >\n"+
149             " </field-descriptor>\n"+
150             "</class-descriptor>\n"+
151             "<class-descriptor\n"+
152             " class=\"test.D\"\n"+
153             " table=\"D\"\n"+
154             ">\n"+
155             " <field-descriptor\n"+
156             " name=\"attr\"\n"+
157             " column=\"attr\"\n"+
158             " jdbc-type=\"INTEGER\"\n"+
159             " access=\"anonymous\"\n"+
160             " >\n"+
161             " </field-descriptor>\n"+
162             "</class-descriptor>",
163             runOjbXDoclet(OJB_DEST_FILE));
164         assertEqualsTorqueSchemaFile(
165             "<database name=\"ojbtest\">\n"+
166             " <table name=\"A\">\n"+
167             " <column name=\"attr\"\n"+
168             " javaName=\"attr\"\n"+
169             " type=\"INTEGER\"\n"+
170             " description=\"Some documentation\"\n"+
171             " />\n"+
172             " </table>\n"+
173             " <table name=\"C\">\n"+
174             " <column name=\"attr\"\n"+
175             " javaName=\"attr\"\n"+
176             " type=\"INTEGER\"\n"+
177             " description=\"Some documentation\"\n"+
178             " />\n"+
179             " </table>\n"+
180             " <table name=\"D\">\n"+
181             " <column name=\"attr\"\n"+
182             " javaName=\"attr\"\n"+
183             " type=\"INTEGER\"\n"+
184             " description=\"Some other documentation\"\n"+
185             " />\n"+
186             " </table>\n"+
187             "</database>",
188             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
189     }
190
191     // Test: unsetting the column-documentation attribute of an anonymous field in a direct base class
192
public void testDocumentation3()
193     {
194         addClass(
195             "test.A",
196             "package test;\n"+
197             "/** @ojb.class\n"+
198             " * @ojb.field name=\"attr\"\n"+
199             " * jdbc-type=\"INTEGER\"\n"+
200             " * documentation=\"Some field documentation\"\n"+
201             " * column-documentation=\"Some column documentation\"\n"+
202             " */\n" +
203             "public class A {}");
204         addClass(
205             "test.B",
206             "package test;\n"+
207             "/** @ojb.class\n" +
208             " * @ojb.modify-inherited name=\"attr\"\n"+
209             " * column-documentation=\"\"\n"+
210             " */\n"+
211             "public class B extends A {}\n");
212
213         assertEqualsOjbDescriptorFile(
214             "<class-descriptor\n"+
215             " class=\"test.A\"\n"+
216             " table=\"A\"\n"+
217             ">\n"+
218             " <extent-class class-ref=\"test.B\"/>\n"+
219             " <field-descriptor\n"+
220             " name=\"attr\"\n"+
221             " column=\"attr\"\n"+
222             " jdbc-type=\"INTEGER\"\n"+
223             " access=\"anonymous\"\n"+
224             " >\n"+
225             " <documentation>Some field documentation</documentation>\n"+
226             " </field-descriptor>\n"+
227             "</class-descriptor>\n"+
228             "<class-descriptor\n"+
229             " class=\"test.B\"\n"+
230             " table=\"B\"\n"+
231             ">\n"+
232             " <field-descriptor\n"+
233             " name=\"attr\"\n"+
234             " column=\"attr\"\n"+
235             " jdbc-type=\"INTEGER\"\n"+
236             " access=\"anonymous\"\n"+
237             " >\n"+
238             " <documentation>Some field documentation</documentation>\n"+
239             " </field-descriptor>\n"+
240             "</class-descriptor>",
241             runOjbXDoclet(OJB_DEST_FILE));
242         assertEqualsTorqueSchemaFile(
243             "<database name=\"ojbtest\">\n"+
244             " <table name=\"A\">\n"+
245             " <column name=\"attr\"\n"+
246             " javaName=\"attr\"\n"+
247             " type=\"INTEGER\"\n"+
248             " description=\"Some column documentation\"\n"+
249             " />\n"+
250             " </table>\n"+
251             " <table name=\"B\">\n"+
252             " <column name=\"attr\"\n"+
253             " javaName=\"attr\"\n"+
254             " type=\"INTEGER\"\n"+
255             " description=\"Some field documentation\"\n"+
256             " />\n"+
257             " </table>\n"+
258             "</database>",
259             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
260     }
261
262     // Test: setting the column-documentation attribute of an inherited field which has a documentation attribute
263
public void testDocumentation4()
264     {
265         addClass(
266             "test.A",
267             "package test;\n"+
268             "/** @ojb.class */\n" +
269             "public class A {\n"+
270             " /** @ojb.field documentation=\"Some documentation\"*/\n"+
271             " private int attr;\n"+
272             "}");
273         addClass(
274             "test.B",
275             "package test;\n"+
276             "/** @ojb.class\n" +
277             " * @ojb.modify-inherited name=\"attr\"\n"+
278             " * column-documentation=\"Some other documentation\"\n"+
279             " */\n"+
280             "public class B extends A {}\n");
281
282         assertEqualsOjbDescriptorFile(
283             "<class-descriptor\n"+
284             " class=\"test.A\"\n"+
285             " table=\"A\"\n"+
286             ">\n"+
287             " <extent-class class-ref=\"test.B\"/>\n"+
288             " <field-descriptor\n"+
289             " name=\"attr\"\n"+
290             " column=\"attr\"\n"+
291             " jdbc-type=\"INTEGER\"\n"+
292             " >\n"+
293             " <documentation>Some documentation</documentation>\n"+
294             " </field-descriptor>\n"+
295             "</class-descriptor>\n"+
296             "<class-descriptor\n"+
297             " class=\"test.B\"\n"+
298             " table=\"B\"\n"+
299             ">\n"+
300             " <field-descriptor\n"+
301             " name=\"attr\"\n"+
302             " column=\"attr\"\n"+
303             " jdbc-type=\"INTEGER\"\n"+
304             " >\n"+
305             " <documentation>Some documentation</documentation>\n"+
306             " </field-descriptor>\n"+
307             "</class-descriptor>",
308             runOjbXDoclet(OJB_DEST_FILE));
309         assertEqualsTorqueSchemaFile(
310             "<database name=\"ojbtest\">\n"+
311             " <table name=\"A\">\n"+
312             " <column name=\"attr\"\n"+
313             " javaName=\"attr\"\n"+
314             " type=\"INTEGER\"\n"+
315             " description=\"Some documentation\"\n"+
316             " />\n"+
317             " </table>\n"+
318             " <table name=\"B\">\n"+
319             " <column name=\"attr\"\n"+
320             " javaName=\"attr\"\n"+
321             " type=\"INTEGER\"\n"+
322             " description=\"Some other documentation\"\n"+
323             " />\n"+
324             " </table>\n"+
325             "</database>",
326             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
327     }
328
329     // Test: setting the documentation attribute of an inherited field which has a column-documentation attribute
330
public void testDocumentation5()
331     {
332         addClass(
333             "test.A",
334             "package test;\n"+
335             "/** @ojb.class */\n" +
336             "public class A {\n"+
337             " /** @ojb.field column-documentation=\"Some documentation\"*/\n"+
338             " private int attr;\n"+
339             "}");
340         addClass(
341             "test.B",
342             "package test;\n"+
343             "/** @ojb.class\n" +
344             " * @ojb.modify-inherited name=\"attr\"\n"+
345             " * documentation=\"Some other documentation\"\n"+
346             " */\n"+
347             "public class B extends A {}\n");
348
349         assertEqualsOjbDescriptorFile(
350             "<class-descriptor\n"+
351             " class=\"test.A\"\n"+
352             " table=\"A\"\n"+
353             ">\n"+
354             " <extent-class class-ref=\"test.B\"/>\n"+
355             " <field-descriptor\n"+
356             " name=\"attr\"\n"+
357             " column=\"attr\"\n"+
358             " jdbc-type=\"INTEGER\"\n"+
359             " >\n"+
360             " </field-descriptor>\n"+
361             "</class-descriptor>\n"+
362             "<class-descriptor\n"+
363             " class=\"test.B\"\n"+
364             " table=\"B\"\n"+
365             ">\n"+
366             " <field-descriptor\n"+
367             " name=\"attr\"\n"+
368             " column=\"attr\"\n"+
369             " jdbc-type=\"INTEGER\"\n"+
370             " >\n"+
371             " <documentation>Some other documentation</documentation>\n"+
372             " </field-descriptor>\n"+
373             "</class-descriptor>",
374             runOjbXDoclet(OJB_DEST_FILE));
375         assertEqualsTorqueSchemaFile(
376             "<database name=\"ojbtest\">\n"+
377             " <table name=\"A\">\n"+
378             " <column name=\"attr\"\n"+
379             " javaName=\"attr\"\n"+
380             " type=\"INTEGER\"\n"+
381             " description=\"Some documentation\"\n"+
382             " />\n"+
383             " </table>\n"+
384             " <table name=\"B\">\n"+
385             " <column name=\"attr\"\n"+
386             " javaName=\"attr\"\n"+
387             " type=\"INTEGER\"\n"+
388             " description=\"Some documentation\"\n"+
389             " />\n"+
390             " </table>\n"+
391             "</database>",
392             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
393     }
394 }
395
Popular Tags