KickJava   Java API By Example, From Geeks To Geeks.

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


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.field tag without attributes.
20  *
21  * @author <a HREF="mailto:tomdz@users.sourceforge.net">Thomas Dudziak (tomdz@users.sourceforge.net)</a>
22  */

23 public class FieldTagSimpleTests extends OjbTestBase
24 {
25     public FieldTagSimpleTests(String JavaDoc name)
26     {
27         super(name);
28     }
29
30     // Basic test: no attributes, type is boolean
31
public void testSimple1()
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 boolean attr;\n"+
40             "}\n");
41
42         assertEqualsOjbDescriptorFile(
43             "<class-descriptor\n"+
44             " class=\"test.A\"\n"+
45             " table=\"A\"\n"+
46             ">\n"+
47             " <field-descriptor\n"+
48             " name=\"attr\"\n"+
49             " column=\"attr\"\n"+
50             " jdbc-type=\"BIT\"\n"+
51             " >\n"+
52             " </field-descriptor>\n"+
53             "</class-descriptor>",
54             runOjbXDoclet(OJB_DEST_FILE));
55         assertEqualsTorqueSchemaFile(
56             "<database name=\"ojbtest\">\n"+
57             " <table name=\"A\">\n"+
58             " <column name=\"attr\"\n"+
59             " javaName=\"attr\"\n"+
60             " type=\"BIT\"\n"+
61             " />\n"+
62             " </table>\n"+
63             "</database>",
64             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
65     }
66
67     // Basic test: no attributes, type is byte
68
public void testSimple2()
69     {
70         addClass(
71             "test.A",
72             "package test;\n"+
73             "/** @ojb.class */\n"+
74             "public class A {\n"+
75             "/** @ojb.field */\n"+
76             " private byte attr;\n"+
77             "}\n");
78
79         assertEqualsOjbDescriptorFile(
80             "<class-descriptor\n"+
81             " class=\"test.A\"\n"+
82             " table=\"A\"\n"+
83             ">\n"+
84             " <field-descriptor\n"+
85             " name=\"attr\"\n"+
86             " column=\"attr\"\n"+
87             " jdbc-type=\"TINYINT\"\n"+
88             " >\n"+
89             " </field-descriptor>\n"+
90             "</class-descriptor>",
91             runOjbXDoclet(OJB_DEST_FILE));
92         assertEqualsTorqueSchemaFile(
93             "<database name=\"ojbtest\">\n"+
94             " <table name=\"A\">\n"+
95             " <column name=\"attr\"\n"+
96             " javaName=\"attr\"\n"+
97             " type=\"TINYINT\"\n"+
98             " />\n"+
99             " </table>\n"+
100             "</database>",
101             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
102     }
103
104     // Basic test: no attributes, type is short
105
public void testSimple3()
106     {
107         addClass(
108             "test.A",
109             "package test;\n"+
110             "/** @ojb.class */\n"+
111             "public class A {\n"+
112             "/** @ojb.field */\n"+
113             " private short attr;\n"+
114             "}\n");
115
116         assertEqualsOjbDescriptorFile(
117             "<class-descriptor\n"+
118             " class=\"test.A\"\n"+
119             " table=\"A\"\n"+
120             ">\n"+
121             " <field-descriptor\n"+
122             " name=\"attr\"\n"+
123             " column=\"attr\"\n"+
124             " jdbc-type=\"SMALLINT\"\n"+
125             " >\n"+
126             " </field-descriptor>\n"+
127             "</class-descriptor>",
128             runOjbXDoclet(OJB_DEST_FILE));
129         assertEqualsTorqueSchemaFile(
130             "<database name=\"ojbtest\">\n"+
131             " <table name=\"A\">\n"+
132             " <column name=\"attr\"\n"+
133             " javaName=\"attr\"\n"+
134             " type=\"SMALLINT\"\n"+
135             " />\n"+
136             " </table>\n"+
137             "</database>",
138             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
139     }
140
141     // Basic test: no attributes, type is int
142
public void testSimple4()
143     {
144         addClass(
145             "test.A",
146             "package test;\n"+
147             "/** @ojb.class */\n"+
148             "public class A {\n"+
149             "/** @ojb.field */\n"+
150             " private int attr;\n"+
151             "}\n");
152
153         assertEqualsOjbDescriptorFile(
154             "<class-descriptor\n"+
155             " class=\"test.A\"\n"+
156             " table=\"A\"\n"+
157             ">\n"+
158             " <field-descriptor\n"+
159             " name=\"attr\"\n"+
160             " column=\"attr\"\n"+
161             " jdbc-type=\"INTEGER\"\n"+
162             " >\n"+
163             " </field-descriptor>\n"+
164             "</class-descriptor>",
165             runOjbXDoclet(OJB_DEST_FILE));
166         assertEqualsTorqueSchemaFile(
167             "<database name=\"ojbtest\">\n"+
168             " <table name=\"A\">\n"+
169             " <column name=\"attr\"\n"+
170             " javaName=\"attr\"\n"+
171             " type=\"INTEGER\"\n"+
172             " />\n"+
173             " </table>\n"+
174             "</database>",
175             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
176     }
177
178     // Basic test: no attributes, type is long
179
public void testSimple5()
180     {
181         addClass(
182             "test.A",
183             "package test;\n"+
184             "/** @ojb.class */\n"+
185             "public class A {\n"+
186             "/** @ojb.field */\n"+
187             " private long attr;\n"+
188             "}\n");
189
190         assertEqualsOjbDescriptorFile(
191             "<class-descriptor\n"+
192             " class=\"test.A\"\n"+
193             " table=\"A\"\n"+
194             ">\n"+
195             " <field-descriptor\n"+
196             " name=\"attr\"\n"+
197             " column=\"attr\"\n"+
198             " jdbc-type=\"BIGINT\"\n"+
199             " >\n"+
200             " </field-descriptor>\n"+
201             "</class-descriptor>",
202             runOjbXDoclet(OJB_DEST_FILE));
203         assertEqualsTorqueSchemaFile(
204             "<database name=\"ojbtest\">\n"+
205             " <table name=\"A\">\n"+
206             " <column name=\"attr\"\n"+
207             " javaName=\"attr\"\n"+
208             " type=\"BIGINT\"\n"+
209             " />\n"+
210             " </table>\n"+
211             "</database>",
212             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
213     }
214
215     // Basic test: no attributes, type is char
216
public void testSimple6()
217     {
218         addClass(
219             "test.A",
220             "package test;\n"+
221             "/** @ojb.class */\n"+
222             "public class A {\n"+
223             "/** @ojb.field */\n"+
224             " private char attr;\n"+
225             "}\n");
226
227         assertEqualsOjbDescriptorFile(
228             "<class-descriptor\n"+
229             " class=\"test.A\"\n"+
230             " table=\"A\"\n"+
231             ">\n"+
232             " <field-descriptor\n"+
233             " name=\"attr\"\n"+
234             " column=\"attr\"\n"+
235             " jdbc-type=\"CHAR\"\n"+
236             " length=\"1\"\n"+
237             " >\n"+
238             " </field-descriptor>\n"+
239             "</class-descriptor>",
240             runOjbXDoclet(OJB_DEST_FILE));
241         assertEqualsTorqueSchemaFile(
242             "<database name=\"ojbtest\">\n"+
243             " <table name=\"A\">\n"+
244             " <column name=\"attr\"\n"+
245             " javaName=\"attr\"\n"+
246             " type=\"CHAR\"\n"+
247             " size=\"1\"\n"+
248             " />\n"+
249             " </table>\n"+
250             "</database>",
251             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
252     }
253
254     // Basic test: no attributes, type is float
255
public void testSimple7()
256     {
257         addClass(
258             "test.A",
259             "package test;\n"+
260             "/** @ojb.class */\n"+
261             "public class A {\n"+
262             "/** @ojb.field */\n"+
263             " private float attr;\n"+
264             "}\n");
265
266         assertEqualsOjbDescriptorFile(
267             "<class-descriptor\n"+
268             " class=\"test.A\"\n"+
269             " table=\"A\"\n"+
270             ">\n"+
271             " <field-descriptor\n"+
272             " name=\"attr\"\n"+
273             " column=\"attr\"\n"+
274             " jdbc-type=\"REAL\"\n"+
275             " >\n"+
276             " </field-descriptor>\n"+
277             "</class-descriptor>",
278             runOjbXDoclet(OJB_DEST_FILE));
279         assertEqualsTorqueSchemaFile(
280             "<database name=\"ojbtest\">\n"+
281             " <table name=\"A\">\n"+
282             " <column name=\"attr\"\n"+
283             " javaName=\"attr\"\n"+
284             " type=\"REAL\"\n"+
285             " />\n"+
286             " </table>\n"+
287             "</database>",
288             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
289     }
290
291     // Basic test: no attributes, type is double
292
public void testSimple8()
293     {
294         addClass(
295             "test.A",
296             "package test;\n"+
297             "/** @ojb.class */\n"+
298             "public class A {\n"+
299             "/** @ojb.field */\n"+
300             " private double attr;\n"+
301             "}\n");
302
303         assertEqualsOjbDescriptorFile(
304             "<class-descriptor\n"+
305             " class=\"test.A\"\n"+
306             " table=\"A\"\n"+
307             ">\n"+
308             " <field-descriptor\n"+
309             " name=\"attr\"\n"+
310             " column=\"attr\"\n"+
311             " jdbc-type=\"FLOAT\"\n"+
312             " >\n"+
313             " </field-descriptor>\n"+
314             "</class-descriptor>",
315             runOjbXDoclet(OJB_DEST_FILE));
316         assertEqualsTorqueSchemaFile(
317             "<database name=\"ojbtest\">\n"+
318             " <table name=\"A\">\n"+
319             " <column name=\"attr\"\n"+
320             " javaName=\"attr\"\n"+
321             " type=\"FLOAT\"\n"+
322             " />\n"+
323             " </table>\n"+
324             "</database>",
325             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
326     }
327
328     // Basic test: no attributes, type is Boolean
329
public void testSimple9()
330     {
331         addClass(
332             "test.A",
333             "package test;\n"+
334             "/** @ojb.class */\n"+
335             "public class A {\n"+
336             "/** @ojb.field */\n"+
337             " private Boolean attr;\n"+
338             "}\n");
339
340         assertEqualsOjbDescriptorFile(
341             "<class-descriptor\n"+
342             " class=\"test.A\"\n"+
343             " table=\"A\"\n"+
344             ">\n"+
345             " <field-descriptor\n"+
346             " name=\"attr\"\n"+
347             " column=\"attr\"\n"+
348             " jdbc-type=\"BIT\"\n"+
349             " >\n"+
350             " </field-descriptor>\n"+
351             "</class-descriptor>",
352             runOjbXDoclet(OJB_DEST_FILE));
353         assertEqualsTorqueSchemaFile(
354             "<database name=\"ojbtest\">\n"+
355             " <table name=\"A\">\n"+
356             " <column name=\"attr\"\n"+
357             " javaName=\"attr\"\n"+
358             " type=\"BIT\"\n"+
359             " />\n"+
360             " </table>\n"+
361             "</database>",
362             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
363     }
364
365     // Basic test: no attributes, type is Byte
366
public void testSimple10()
367     {
368         addClass(
369             "test.A",
370             "package test;\n"+
371             "/** @ojb.class */\n"+
372             "public class A {\n"+
373             "/** @ojb.field */\n"+
374             " private Byte attr;\n"+
375             "}\n");
376
377         assertEqualsOjbDescriptorFile(
378             "<class-descriptor\n"+
379             " class=\"test.A\"\n"+
380             " table=\"A\"\n"+
381             ">\n"+
382             " <field-descriptor\n"+
383             " name=\"attr\"\n"+
384             " column=\"attr\"\n"+
385             " jdbc-type=\"TINYINT\"\n"+
386             " >\n"+
387             " </field-descriptor>\n"+
388             "</class-descriptor>",
389             runOjbXDoclet(OJB_DEST_FILE));
390         assertEqualsTorqueSchemaFile(
391             "<database name=\"ojbtest\">\n"+
392             " <table name=\"A\">\n"+
393             " <column name=\"attr\"\n"+
394             " javaName=\"attr\"\n"+
395             " type=\"TINYINT\"\n"+
396             " />\n"+
397             " </table>\n"+
398             "</database>",
399             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
400     }
401
402     // Basic test: no attributes, type is Short
403
public void testSimple11()
404     {
405         addClass(
406             "test.A",
407             "package test;\n"+
408             "/** @ojb.class */\n"+
409             "public class A {\n"+
410             "/** @ojb.field */\n"+
411             " private Short attr;\n"+
412             "}\n");
413
414         assertEqualsOjbDescriptorFile(
415             "<class-descriptor\n"+
416             " class=\"test.A\"\n"+
417             " table=\"A\"\n"+
418             ">\n"+
419             " <field-descriptor\n"+
420             " name=\"attr\"\n"+
421             " column=\"attr\"\n"+
422             " jdbc-type=\"SMALLINT\"\n"+
423             " >\n"+
424             " </field-descriptor>\n"+
425             "</class-descriptor>",
426             runOjbXDoclet(OJB_DEST_FILE));
427         assertEqualsTorqueSchemaFile(
428             "<database name=\"ojbtest\">\n"+
429             " <table name=\"A\">\n"+
430             " <column name=\"attr\"\n"+
431             " javaName=\"attr\"\n"+
432             " type=\"SMALLINT\"\n"+
433             " />\n"+
434             " </table>\n"+
435             "</database>",
436             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
437     }
438
439     // Basic test: no attributes, type is Integer
440
public void testSimple12()
441     {
442         addClass(
443             "test.A",
444             "package test;\n"+
445             "/** @ojb.class */\n"+
446             "public class A {\n"+
447             "/** @ojb.field */\n"+
448             " private Integer attr;\n"+
449             "}\n");
450
451         assertEqualsOjbDescriptorFile(
452             "<class-descriptor\n"+
453             " class=\"test.A\"\n"+
454             " table=\"A\"\n"+
455             ">\n"+
456             " <field-descriptor\n"+
457             " name=\"attr\"\n"+
458             " column=\"attr\"\n"+
459             " jdbc-type=\"INTEGER\"\n"+
460             " >\n"+
461             " </field-descriptor>\n"+
462             "</class-descriptor>",
463             runOjbXDoclet(OJB_DEST_FILE));
464         assertEqualsTorqueSchemaFile(
465             "<database name=\"ojbtest\">\n"+
466             " <table name=\"A\">\n"+
467             " <column name=\"attr\"\n"+
468             " javaName=\"attr\"\n"+
469             " type=\"INTEGER\"\n"+
470             " />\n"+
471             " </table>\n"+
472             "</database>",
473             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
474     }
475
476     // Basic test: no attributes, type is Long
477
public void testSimple13()
478     {
479         addClass(
480             "test.A",
481             "package test;\n"+
482             "/** @ojb.class */\n"+
483             "public class A {\n"+
484             "/** @ojb.field */\n"+
485             " private Long attr;\n"+
486             "}\n");
487
488         assertEqualsOjbDescriptorFile(
489             "<class-descriptor\n"+
490             " class=\"test.A\"\n"+
491             " table=\"A\"\n"+
492             ">\n"+
493             " <field-descriptor\n"+
494             " name=\"attr\"\n"+
495             " column=\"attr\"\n"+
496             " jdbc-type=\"BIGINT\"\n"+
497             " >\n"+
498             " </field-descriptor>\n"+
499             "</class-descriptor>",
500             runOjbXDoclet(OJB_DEST_FILE));
501         assertEqualsTorqueSchemaFile(
502             "<database name=\"ojbtest\">\n"+
503             " <table name=\"A\">\n"+
504             " <column name=\"attr\"\n"+
505             " javaName=\"attr\"\n"+
506             " type=\"BIGINT\"\n"+
507             " />\n"+
508             " </table>\n"+
509             "</database>",
510             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
511     }
512
513     // Basic test: no attributes, type is Character
514
public void testSimple14()
515     {
516         addClass(
517             "test.A",
518             "package test;\n"+
519             "/** @ojb.class */\n"+
520             "public class A {\n"+
521             "/** @ojb.field */\n"+
522             " private Character attr;\n"+
523             "}\n");
524
525         assertEqualsOjbDescriptorFile(
526             "<class-descriptor\n"+
527             " class=\"test.A\"\n"+
528             " table=\"A\"\n"+
529             ">\n"+
530             " <field-descriptor\n"+
531             " name=\"attr\"\n"+
532             " column=\"attr\"\n"+
533             " jdbc-type=\"CHAR\"\n"+
534             " length=\"1\"\n"+
535             " >\n"+
536             " </field-descriptor>\n"+
537             "</class-descriptor>",
538             runOjbXDoclet(OJB_DEST_FILE));
539         assertEqualsTorqueSchemaFile(
540             "<database name=\"ojbtest\">\n"+
541             " <table name=\"A\">\n"+
542             " <column name=\"attr\"\n"+
543             " javaName=\"attr\"\n"+
544             " type=\"CHAR\"\n"+
545             " size=\"1\"\n"+
546             " />\n"+
547             " </table>\n"+
548             "</database>",
549             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
550     }
551
552     // Basic test: no attributes, type is Float
553
public void testSimple15()
554     {
555         addClass(
556             "test.A",
557             "package test;\n"+
558             "/** @ojb.class */\n"+
559             "public class A {\n"+
560             "/** @ojb.field */\n"+
561             " private Float attr;\n"+
562             "}\n");
563
564         assertEqualsOjbDescriptorFile(
565             "<class-descriptor\n"+
566             " class=\"test.A\"\n"+
567             " table=\"A\"\n"+
568             ">\n"+
569             " <field-descriptor\n"+
570             " name=\"attr\"\n"+
571             " column=\"attr\"\n"+
572             " jdbc-type=\"REAL\"\n"+
573             " >\n"+
574             " </field-descriptor>\n"+
575             "</class-descriptor>",
576             runOjbXDoclet(OJB_DEST_FILE));
577         assertEqualsTorqueSchemaFile(
578             "<database name=\"ojbtest\">\n"+
579             " <table name=\"A\">\n"+
580             " <column name=\"attr\"\n"+
581             " javaName=\"attr\"\n"+
582             " type=\"REAL\"\n"+
583             " />\n"+
584             " </table>\n"+
585             "</database>",
586             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
587     }
588
589     // Basic test: no attributes, type is Double
590
public void testSimple16()
591     {
592         addClass(
593             "test.A",
594             "package test;\n"+
595             "/** @ojb.class */\n"+
596             "public class A {\n"+
597             "/** @ojb.field */\n"+
598             " private Double attr;\n"+
599             "}\n");
600
601         assertEqualsOjbDescriptorFile(
602             "<class-descriptor\n"+
603             " class=\"test.A\"\n"+
604             " table=\"A\"\n"+
605             ">\n"+
606             " <field-descriptor\n"+
607             " name=\"attr\"\n"+
608             " column=\"attr\"\n"+
609             " jdbc-type=\"FLOAT\"\n"+
610             " >\n"+
611             " </field-descriptor>\n"+
612             "</class-descriptor>",
613             runOjbXDoclet(OJB_DEST_FILE));
614         assertEqualsTorqueSchemaFile(
615             "<database name=\"ojbtest\">\n"+
616             " <table name=\"A\">\n"+
617             " <column name=\"attr\"\n"+
618             " javaName=\"attr\"\n"+
619             " type=\"FLOAT\"\n"+
620             " />\n"+
621             " </table>\n"+
622             "</database>",
623             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
624     }
625
626     // Basic test: no attributes, type is String
627
public void testSimple17()
628     {
629         addClass(
630             "test.A",
631             "package test;\n"+
632             "/** @ojb.class */\n"+
633             "public class A {\n"+
634             "/** @ojb.field */\n"+
635             " private String attr;\n"+
636             "}\n");
637
638         assertEqualsOjbDescriptorFile(
639             "<class-descriptor\n"+
640             " class=\"test.A\"\n"+
641             " table=\"A\"\n"+
642             ">\n"+
643             " <field-descriptor\n"+
644             " name=\"attr\"\n"+
645             " column=\"attr\"\n"+
646             " jdbc-type=\"VARCHAR\"\n"+
647             " length=\"254\"\n"+
648             " >\n"+
649             " </field-descriptor>\n"+
650             "</class-descriptor>",
651             runOjbXDoclet(OJB_DEST_FILE));
652         assertEqualsTorqueSchemaFile(
653             "<database name=\"ojbtest\">\n"+
654             " <table name=\"A\">\n"+
655             " <column name=\"attr\"\n"+
656             " javaName=\"attr\"\n"+
657             " type=\"VARCHAR\"\n"+
658             " size=\"254\"\n"+
659             " />\n"+
660             " </table>\n"+
661             "</database>",
662             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
663     }
664
665     // Basic test: no attributes, type is java.util.Date
666
public void testSimple18()
667     {
668         addClass(
669             "test.A",
670             "package test;\n"+
671             "/** @ojb.class */\n"+
672             "public class A {\n"+
673             "/** @ojb.field */\n"+
674             " private java.util.Date attr;\n"+
675             "}\n");
676
677         assertEqualsOjbDescriptorFile(
678             "<class-descriptor\n"+
679             " class=\"test.A\"\n"+
680             " table=\"A\"\n"+
681             ">\n"+
682             " <field-descriptor\n"+
683             " name=\"attr\"\n"+
684             " column=\"attr\"\n"+
685             " jdbc-type=\"DATE\"\n"+
686             " >\n"+
687             " </field-descriptor>\n"+
688             "</class-descriptor>",
689             runOjbXDoclet(OJB_DEST_FILE));
690         assertEqualsTorqueSchemaFile(
691             "<database name=\"ojbtest\">\n"+
692             " <table name=\"A\">\n"+
693             " <column name=\"attr\"\n"+
694             " javaName=\"attr\"\n"+
695             " type=\"DATE\"\n"+
696             " />\n"+
697             " </table>\n"+
698             "</database>",
699             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
700     }
701
702     // Basic test: no attributes, type is java.sql.Date
703
public void testSimple19()
704     {
705         addClass(
706             "test.A",
707             "package test;\n"+
708             "/** @ojb.class */\n"+
709             "public class A {\n"+
710             "/** @ojb.field */\n"+
711             " private java.sql.Date attr;\n"+
712             "}\n");
713
714         assertEqualsOjbDescriptorFile(
715             "<class-descriptor\n"+
716             " class=\"test.A\"\n"+
717             " table=\"A\"\n"+
718             ">\n"+
719             " <field-descriptor\n"+
720             " name=\"attr\"\n"+
721             " column=\"attr\"\n"+
722             " jdbc-type=\"DATE\"\n"+
723             " >\n"+
724             " </field-descriptor>\n"+
725             "</class-descriptor>",
726             runOjbXDoclet(OJB_DEST_FILE));
727         assertEqualsTorqueSchemaFile(
728             "<database name=\"ojbtest\">\n"+
729             " <table name=\"A\">\n"+
730             " <column name=\"attr\"\n"+
731             " javaName=\"attr\"\n"+
732             " type=\"DATE\"\n"+
733             " />\n"+
734             " </table>\n"+
735             "</database>",
736             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
737     }
738
739     // Basic test: no attributes, type is java.sql.Time
740
public void testSimple20()
741     {
742         addClass(
743             "test.A",
744             "package test;\n"+
745             "/** @ojb.class */\n"+
746             "public class A {\n"+
747             "/** @ojb.field */\n"+
748             " private java.sql.Time attr;\n"+
749             "}\n");
750
751         assertEqualsOjbDescriptorFile(
752             "<class-descriptor\n"+
753             " class=\"test.A\"\n"+
754             " table=\"A\"\n"+
755             ">\n"+
756             " <field-descriptor\n"+
757             " name=\"attr\"\n"+
758             " column=\"attr\"\n"+
759             " jdbc-type=\"TIME\"\n"+
760             " >\n"+
761             " </field-descriptor>\n"+
762             "</class-descriptor>",
763             runOjbXDoclet(OJB_DEST_FILE));
764         assertEqualsTorqueSchemaFile(
765             "<database name=\"ojbtest\">\n"+
766             " <table name=\"A\">\n"+
767             " <column name=\"attr\"\n"+
768             " javaName=\"attr\"\n"+
769             " type=\"TIME\"\n"+
770             " />\n"+
771             " </table>\n"+
772             "</database>",
773             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
774     }
775
776     // Basic test: no attributes, type is java.sql.Timestamp
777
public void testSimple21()
778     {
779         addClass(
780             "test.A",
781             "package test;\n"+
782             "/** @ojb.class */\n"+
783             "public class A {\n"+
784             "/** @ojb.field */\n"+
785             " private java.sql.Timestamp attr;\n"+
786             "}\n");
787
788         assertEqualsOjbDescriptorFile(
789             "<class-descriptor\n"+
790             " class=\"test.A\"\n"+
791             " table=\"A\"\n"+
792             ">\n"+
793             " <field-descriptor\n"+
794             " name=\"attr\"\n"+
795             " column=\"attr\"\n"+
796             " jdbc-type=\"TIMESTAMP\"\n"+
797             " >\n"+
798             " </field-descriptor>\n"+
799             "</class-descriptor>",
800             runOjbXDoclet(OJB_DEST_FILE));
801         assertEqualsTorqueSchemaFile(
802             "<database name=\"ojbtest\">\n"+
803             " <table name=\"A\">\n"+
804             " <column name=\"attr\"\n"+
805             " javaName=\"attr\"\n"+
806             " type=\"TIMESTAMP\"\n"+
807             " />\n"+
808             " </table>\n"+
809             "</database>",
810             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
811     }
812
813     // Basic test: no attributes, type is java.sql.Blob
814
public void testSimple22()
815     {
816         addClass(
817             "test.A",
818             "package test;\n"+
819             "/** @ojb.class */\n"+
820             "public class A {\n"+
821             "/** @ojb.field */\n"+
822             " private java.sql.Blob attr;\n"+
823             "}\n");
824
825         assertEqualsOjbDescriptorFile(
826             "<class-descriptor\n"+
827             " class=\"test.A\"\n"+
828             " table=\"A\"\n"+
829             ">\n"+
830             " <field-descriptor\n"+
831             " name=\"attr\"\n"+
832             " column=\"attr\"\n"+
833             " jdbc-type=\"BLOB\"\n"+
834             " >\n"+
835             " </field-descriptor>\n"+
836             "</class-descriptor>",
837             runOjbXDoclet(OJB_DEST_FILE));
838         assertEqualsTorqueSchemaFile(
839             "<database name=\"ojbtest\">\n"+
840             " <table name=\"A\">\n"+
841             " <column name=\"attr\"\n"+
842             " javaName=\"attr\"\n"+
843             " type=\"BLOB\"\n"+
844             " />\n"+
845             " </table>\n"+
846             "</database>",
847             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
848     }
849
850     // Basic test: no attributes, type is java.sql.Clob
851
public void testSimple23()
852     {
853         addClass(
854             "test.A",
855             "package test;\n"+
856             "/** @ojb.class */\n"+
857             "public class A {\n"+
858             "/** @ojb.field */\n"+
859             " private java.sql.Clob attr;\n"+
860             "}\n");
861
862         assertEqualsOjbDescriptorFile(
863             "<class-descriptor\n"+
864             " class=\"test.A\"\n"+
865             " table=\"A\"\n"+
866             ">\n"+
867             " <field-descriptor\n"+
868             " name=\"attr\"\n"+
869             " column=\"attr\"\n"+
870             " jdbc-type=\"CLOB\"\n"+
871             " >\n"+
872             " </field-descriptor>\n"+
873             "</class-descriptor>",
874             runOjbXDoclet(OJB_DEST_FILE));
875         assertEqualsTorqueSchemaFile(
876             "<database name=\"ojbtest\">\n"+
877             " <table name=\"A\">\n"+
878             " <column name=\"attr\"\n"+
879             " javaName=\"attr\"\n"+
880             " type=\"CLOB\"\n"+
881             " />\n"+
882             " </table>\n"+
883             "</database>",
884             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
885     }
886
887     // Basic test: no attributes, type is java.math.BigDecimal
888
public void testSimple24()
889     {
890         addClass(
891             "test.A",
892             "package test;\n"+
893             "/** @ojb.class */\n"+
894             "public class A {\n"+
895             "/** @ojb.field */\n"+
896             " private java.math.BigDecimal attr;\n"+
897             "}\n");
898
899         assertEqualsOjbDescriptorFile(
900             "<class-descriptor\n"+
901             " class=\"test.A\"\n"+
902             " table=\"A\"\n"+
903             ">\n"+
904             " <field-descriptor\n"+
905             " name=\"attr\"\n"+
906             " column=\"attr\"\n"+
907             " jdbc-type=\"DECIMAL\"\n"+
908             " precision=\"20\"\n"+
909             " scale=\"0\"\n"+
910             " >\n"+
911             " </field-descriptor>\n"+
912             "</class-descriptor>",
913             runOjbXDoclet(OJB_DEST_FILE));
914         assertEqualsTorqueSchemaFile(
915             "<database name=\"ojbtest\">\n"+
916             " <table name=\"A\">\n"+
917             " <column name=\"attr\"\n"+
918             " javaName=\"attr\"\n"+
919             " type=\"DECIMAL\"\n"+
920             " size=\"20,0\"\n"+
921             " />\n"+
922             " </table>\n"+
923             "</database>",
924             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
925     }
926
927     // Basic test: no attributes, type is GUID
928
public void testSimple25()
929     {
930         addClass(
931             "test.A",
932             "package test;\n"+
933             "/** @ojb.class */\n"+
934             "public class A {\n"+
935             "/** @ojb.field */\n"+
936             " private org.apache.ojb.broker.util.GUID attr;\n"+
937             "}\n");
938
939         assertEqualsOjbDescriptorFile(
940             "<class-descriptor\n"+
941             " class=\"test.A\"\n"+
942             " table=\"A\"\n"+
943             ">\n"+
944             " <field-descriptor\n"+
945             " name=\"attr\"\n"+
946             " column=\"attr\"\n"+
947             " jdbc-type=\"VARCHAR\"\n"+
948             " conversion=\"org.apache.ojb.broker.accesslayer.conversions.GUID2StringFieldConversion\"\n"+
949             " length=\"254\"\n"+
950             " >\n"+
951             " </field-descriptor>\n"+
952             "</class-descriptor>",
953             runOjbXDoclet(OJB_DEST_FILE));
954         assertEqualsTorqueSchemaFile(
955             "<database name=\"ojbtest\">\n"+
956             " <table name=\"A\">\n"+
957             " <column name=\"attr\"\n"+
958             " javaName=\"attr\"\n"+
959             " type=\"VARCHAR\"\n"+
960             " size=\"254\"\n"+
961             " />\n"+
962             " </table>\n"+
963             "</database>",
964             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
965     }
966
967     // Basic inheritance test: no attributes
968
public void testInheritance()
969     {
970         addClass(
971             "test.A",
972             "package test;\n"+
973             "/** @ojb.class */\n"+
974             "public class A {\n"+
975             "/** @ojb.field */\n"+
976             " private long attr;\n"+
977             "}\n");
978         addClass(
979             "test.B",
980             "package test;\n"+
981             "public class B extends A {}\n");
982         addClass(
983             "test.C",
984             "package test;\n"+
985             "/** @ojb.class */\n"+
986             "public class C extends B {}\n");
987
988         assertEqualsOjbDescriptorFile(
989             "<class-descriptor\n"+
990             " class=\"test.A\"\n"+
991             " table=\"A\"\n"+
992             ">\n"+
993             " <extent-class class-ref=\"test.C\"/>\n"+
994             " <field-descriptor\n"+
995             " name=\"attr\"\n"+
996             " column=\"attr\"\n"+
997             " jdbc-type=\"BIGINT\"\n"+
998             " >\n"+
999             " </field-descriptor>\n"+
1000            "</class-descriptor>\n"+
1001            "<class-descriptor\n"+
1002            " class=\"test.C\"\n"+
1003            " table=\"C\"\n"+
1004            ">\n"+
1005            " <field-descriptor\n"+
1006            " name=\"attr\"\n"+
1007            " column=\"attr\"\n"+
1008            " jdbc-type=\"BIGINT\"\n"+
1009            " >\n"+
1010            " </field-descriptor>\n"+
1011            "</class-descriptor>",
1012            runOjbXDoclet(OJB_DEST_FILE));
1013        assertEqualsTorqueSchemaFile(
1014            "<database name=\"ojbtest\">\n"+
1015            " <table name=\"A\">\n"+
1016            " <column name=\"attr\"\n"+
1017            " javaName=\"attr\"\n"+
1018            " type=\"BIGINT\"\n"+
1019            " />\n"+
1020            " </table>\n"+
1021            " <table name=\"C\">\n"+
1022            " <column name=\"attr\"\n"+
1023            " javaName=\"attr\"\n"+
1024            " type=\"BIGINT\"\n"+
1025            " />\n"+
1026            " </table>\n"+
1027            "</database>",
1028            runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
1029    }
1030
1031    // Basic test: no attributes, redefinition in a sub-type
1032
public void testRedefinition()
1033    {
1034        addClass(
1035            "test.A",
1036            "package test;\n"+
1037            "/** @ojb.class */\n"+
1038            "public class A {\n"+
1039            "/** @ojb.field */\n"+
1040            " private boolean attr;\n"+
1041            "}\n");
1042        addClass(
1043            "test.B",
1044            "package test;\n"+
1045            "/** @ojb.class */\n"+
1046            "public class B extends A {\n"+
1047            "/** @ojb.field */\n"+
1048            " private int attr;\n"+
1049            "}\n");
1050
1051        assertEqualsOjbDescriptorFile(
1052            "<class-descriptor\n"+
1053            " class=\"test.A\"\n"+
1054            " table=\"A\"\n"+
1055            ">\n"+
1056            " <extent-class class-ref=\"test.B\"/>\n"+
1057            " <field-descriptor\n"+
1058            " name=\"attr\"\n"+
1059            " column=\"attr\"\n"+
1060            " jdbc-type=\"BIT\"\n"+
1061            " >\n"+
1062            " </field-descriptor>\n"+
1063            "</class-descriptor>\n"+
1064            "<class-descriptor\n"+
1065            " class=\"test.B\"\n"+
1066            " table=\"B\"\n"+
1067            ">\n"+
1068            " <field-descriptor\n"+
1069            " name=\"attr\"\n"+
1070            " column=\"attr\"\n"+
1071            " jdbc-type=\"INTEGER\"\n"+
1072            " >\n"+
1073            " </field-descriptor>\n"+
1074            "</class-descriptor>",
1075            runOjbXDoclet(OJB_DEST_FILE));
1076        assertEqualsTorqueSchemaFile(
1077            "<database name=\"ojbtest\">\n"+
1078            " <table name=\"A\">\n"+
1079            " <column name=\"attr\"\n"+
1080            " javaName=\"attr\"\n"+
1081            " type=\"BIT\"\n"+
1082            " />\n"+
1083            " </table>\n"+
1084            " <table name=\"B\">\n"+
1085            " <column name=\"attr\"\n"+
1086            " javaName=\"attr\"\n"+
1087            " type=\"INTEGER\"\n"+
1088            " />\n"+
1089            " </table>\n"+
1090            "</database>",
1091            runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
1092    }
1093
1094    // Basic test: final field with type Integer
1095
public void testFinalField()
1096    {
1097        addClass(
1098            "test.A",
1099            "package test;\n"+
1100            "/** @ojb.class */\n"+
1101            "public class A {\n"+
1102            "/** @ojb.field */\n"+
1103            " private final Integer attr;\n"+
1104            "}\n");
1105
1106        // This is a known XDoclet bug: it won't read the final field
1107
assertEqualsOjbDescriptorFile(
1108            "<class-descriptor\n"+
1109            " class=\"test.A\"\n"+
1110            " table=\"A\"\n"+
1111            ">\n"+
1112            "</class-descriptor>",
1113            runOjbXDoclet(OJB_DEST_FILE));
1114        assertEqualsTorqueSchemaFile(
1115            "<database name=\"ojbtest\">\n"+
1116            " <table name=\"A\">\n"+
1117            " </table>\n"+
1118            "</database>",
1119            runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
1120    }
1121
1122    // Basic test: transient field with type Integer
1123
public void testTransientField()
1124    {
1125        addClass(
1126            "test.A",
1127            "package test;\n"+
1128            "/** @ojb.class */\n"+
1129            "public class A {\n"+
1130            "/** @ojb.field */\n"+
1131            " private transient Integer attr;\n"+
1132            "}\n");
1133
1134        // This is a known XDoclet bug: it won't read the transient field
1135
assertEqualsOjbDescriptorFile(
1136            "<class-descriptor\n"+
1137            " class=\"test.A\"\n"+
1138            " table=\"A\"\n"+
1139            ">\n"+
1140            "</class-descriptor>",
1141            runOjbXDoclet(OJB_DEST_FILE));
1142        assertEqualsTorqueSchemaFile(
1143            "<database name=\"ojbtest\">\n"+
1144            " <table name=\"A\">\n"+
1145            " </table>\n"+
1146            "</database>",
1147            runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
1148    }
1149}
1150
Popular Tags