KickJava   Java API By Example, From Geeks To Geeks.

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


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

23 public class ExtentClassTagTests extends OjbTestBase
24 {
25     public ExtentClassTagTests(String JavaDoc name)
26     {
27         super(name);
28     }
29
30     // Test: use without value when determine-extents=true
31
public void testExtentClass1()
32     {
33         addClass(
34             "test.A",
35             "package test;\n"+
36             "/** @ojb.class determine-extents=\"true\"\n"+
37             " * @ojb.extent-class class-ref=\"\"\n"+
38             " */\n"+
39             "public class A {\n"+
40             " /** @ojb.field */\n"+
41             " private int aid;\n"+
42             "}\n");
43         addClass(
44             "test.B",
45             "package test;\n"+
46             "/** @ojb.class */\n"+
47             "public class B extends A {}\n");
48         addClass(
49             "test.C",
50             "package test;\n"+
51             "public class C extends A {}\n");
52         addClass(
53             "test.D",
54             "package test;\n"+
55             "/** @ojb.class */\n"+
56             "public class D extends C {}\n");
57         addClass(
58             "test.E",
59             "package test;\n"+
60             "/** @ojb.class */\n"+
61             "public class E extends D {}\n");
62
63         assertEqualsOjbDescriptorFile(
64             "<class-descriptor\n"+
65             " class=\"test.A\"\n"+
66             " table=\"A\"\n"+
67             ">\n"+
68             " <extent-class class-ref=\"test.B\"/>\n"+
69             " <extent-class class-ref=\"test.D\"/>\n"+
70             " <field-descriptor\n"+
71             " name=\"aid\"\n"+
72             " column=\"aid\"\n"+
73             " jdbc-type=\"INTEGER\"\n"+
74             " >\n"+
75             " </field-descriptor>\n"+
76             "</class-descriptor>\n"+
77             "<class-descriptor\n"+
78             " class=\"test.B\"\n"+
79             " table=\"B\"\n"+
80             ">\n"+
81             " <field-descriptor\n"+
82             " name=\"aid\"\n"+
83             " column=\"aid\"\n"+
84             " jdbc-type=\"INTEGER\"\n"+
85             " >\n"+
86             " </field-descriptor>\n"+
87             "</class-descriptor>\n"+
88             "<class-descriptor\n"+
89             " class=\"test.D\"\n"+
90             " table=\"D\"\n"+
91             ">\n"+
92             " <extent-class class-ref=\"test.E\"/>\n"+
93             " <field-descriptor\n"+
94             " name=\"aid\"\n"+
95             " column=\"aid\"\n"+
96             " jdbc-type=\"INTEGER\"\n"+
97             " >\n"+
98             " </field-descriptor>\n"+
99             "</class-descriptor>\n"+
100             "<class-descriptor\n"+
101             " class=\"test.E\"\n"+
102             " table=\"E\"\n"+
103             ">\n"+
104             " <field-descriptor\n"+
105             " name=\"aid\"\n"+
106             " column=\"aid\"\n"+
107             " jdbc-type=\"INTEGER\"\n"+
108             " >\n"+
109             " </field-descriptor>\n"+
110             "</class-descriptor>",
111             runOjbXDoclet(OJB_DEST_FILE));
112         assertEqualsTorqueSchemaFile(
113             "<database name=\"ojbtest\">\n"+
114             " <table name=\"A\">\n"+
115             " <column name=\"aid\"\n"+
116             " javaName=\"aid\"\n"+
117             " type=\"INTEGER\"\n"+
118             " />\n"+
119             " </table>\n"+
120             " <table name=\"B\">\n"+
121             " <column name=\"aid\"\n"+
122             " javaName=\"aid\"\n"+
123             " type=\"INTEGER\"\n"+
124             " />\n"+
125             " </table>\n"+
126             " <table name=\"D\">\n"+
127             " <column name=\"aid\"\n"+
128             " javaName=\"aid\"\n"+
129             " type=\"INTEGER\"\n"+
130             " />\n"+
131             " </table>\n"+
132             " <table name=\"E\">\n"+
133             " <column name=\"aid\"\n"+
134             " javaName=\"aid\"\n"+
135             " type=\"INTEGER\"\n"+
136             " />\n"+
137             " </table>\n"+
138             "</database>",
139             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
140     }
141
142     // Test: use with remote subclass when determine-extents=true
143
public void testExtentClass2()
144     {
145         addClass(
146             "test.A",
147             "package test;\n"+
148             "/** @ojb.class determine-extents=\"true\"\n"+
149             " * @ojb.extent-class class-ref=\"test.E\"\n"+
150             " */\n"+
151             "public class A {\n"+
152             " /** @ojb.field */\n"+
153             " private int aid;\n"+
154             "}\n");
155         addClass(
156             "test.B",
157             "package test;\n"+
158             "/** @ojb.class */\n"+
159             "public class B extends A {}\n");
160         addClass(
161             "test.C",
162             "package test;\n"+
163             "public class C extends A {}\n");
164         addClass(
165             "test.D",
166             "package test;\n"+
167             "/** @ojb.class */\n"+
168             "public class D extends C {}\n");
169         addClass(
170             "test.E",
171             "package test;\n"+
172             "/** @ojb.class */\n"+
173             "public class E extends D {}\n");
174
175         assertEqualsOjbDescriptorFile(
176             "<class-descriptor\n"+
177             " class=\"test.A\"\n"+
178             " table=\"A\"\n"+
179             ">\n"+
180             " <extent-class class-ref=\"test.B\"/>\n"+
181             " <extent-class class-ref=\"test.D\"/>\n"+
182             " <field-descriptor\n"+
183             " name=\"aid\"\n"+
184             " column=\"aid\"\n"+
185             " jdbc-type=\"INTEGER\"\n"+
186             " >\n"+
187             " </field-descriptor>\n"+
188             "</class-descriptor>\n"+
189             "<class-descriptor\n"+
190             " class=\"test.B\"\n"+
191             " table=\"B\"\n"+
192             ">\n"+
193             " <field-descriptor\n"+
194             " name=\"aid\"\n"+
195             " column=\"aid\"\n"+
196             " jdbc-type=\"INTEGER\"\n"+
197             " >\n"+
198             " </field-descriptor>\n"+
199             "</class-descriptor>\n"+
200             "<class-descriptor\n"+
201             " class=\"test.D\"\n"+
202             " table=\"D\"\n"+
203             ">\n"+
204             " <extent-class class-ref=\"test.E\"/>\n"+
205             " <field-descriptor\n"+
206             " name=\"aid\"\n"+
207             " column=\"aid\"\n"+
208             " jdbc-type=\"INTEGER\"\n"+
209             " >\n"+
210             " </field-descriptor>\n"+
211             "</class-descriptor>\n"+
212             "<class-descriptor\n"+
213             " class=\"test.E\"\n"+
214             " table=\"E\"\n"+
215             ">\n"+
216             " <field-descriptor\n"+
217             " name=\"aid\"\n"+
218             " column=\"aid\"\n"+
219             " jdbc-type=\"INTEGER\"\n"+
220             " >\n"+
221             " </field-descriptor>\n"+
222             "</class-descriptor>",
223             runOjbXDoclet(OJB_DEST_FILE));
224         assertEqualsTorqueSchemaFile(
225             "<database name=\"ojbtest\">\n"+
226             " <table name=\"A\">\n"+
227             " <column name=\"aid\"\n"+
228             " javaName=\"aid\"\n"+
229             " type=\"INTEGER\"\n"+
230             " />\n"+
231             " </table>\n"+
232             " <table name=\"B\">\n"+
233             " <column name=\"aid\"\n"+
234             " javaName=\"aid\"\n"+
235             " type=\"INTEGER\"\n"+
236             " />\n"+
237             " </table>\n"+
238             " <table name=\"D\">\n"+
239             " <column name=\"aid\"\n"+
240             " javaName=\"aid\"\n"+
241             " type=\"INTEGER\"\n"+
242             " />\n"+
243             " </table>\n"+
244             " <table name=\"E\">\n"+
245             " <column name=\"aid\"\n"+
246             " javaName=\"aid\"\n"+
247             " type=\"INTEGER\"\n"+
248             " />\n"+
249             " </table>\n"+
250             "</database>",
251             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
252     }
253
254     // Test: use without value when determine-extents=false
255
public void testExtentClass3()
256     {
257         addClass(
258             "test.A",
259             "package test;\n"+
260             "/** @ojb.class determine-extents=\"false\"\n"+
261             " * @ojb.extent-class class-ref=\"\"\n"+
262             " */\n"+
263             "public class A {\n"+
264             " /** @ojb.field */\n"+
265             " private int aid;\n"+
266             "}\n");
267         addClass(
268             "test.B",
269             "package test;\n"+
270             "/** @ojb.class */\n"+
271             "public class B extends A {}\n");
272         addClass(
273             "test.C",
274             "package test;\n"+
275             "public class C extends A {}\n");
276         addClass(
277             "test.D",
278             "package test;\n"+
279             "/** @ojb.class */\n"+
280             "public class D extends C {}\n");
281         addClass(
282             "test.E",
283             "package test;\n"+
284             "/** @ojb.class */\n"+
285             "public class E extends D {}\n");
286
287         assertNull(runOjbXDoclet(OJB_DEST_FILE));
288         assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
289     }
290
291     // Test: use with direct subclass when determine-extents=false
292
public void testExtentClass4()
293     {
294         addClass(
295             "test.A",
296             "package test;\n"+
297             "/** @ojb.class determine-extents=\"false\"\n"+
298             " * @ojb.extent-class class-ref=\"test.B\"\n"+
299             " */\n"+
300             "public class A {\n"+
301             " /** @ojb.field */\n"+
302             " private int aid;\n"+
303             "}\n");
304         addClass(
305             "test.B",
306             "package test;\n"+
307             "/** @ojb.class */\n"+
308             "public class B extends A {}\n");
309         addClass(
310             "test.C",
311             "package test;\n"+
312             "public class C extends A {}\n");
313         addClass(
314             "test.D",
315             "package test;\n"+
316             "/** @ojb.class */\n"+
317             "public class D extends C {}\n");
318         addClass(
319             "test.E",
320             "package test;\n"+
321             "/** @ojb.class */\n"+
322             "public class E extends D {}\n");
323
324         assertEqualsOjbDescriptorFile(
325             "<class-descriptor\n"+
326             " class=\"test.A\"\n"+
327             " table=\"A\"\n"+
328             ">\n"+
329             " <extent-class class-ref=\"test.B\"/>\n"+
330             " <field-descriptor\n"+
331             " name=\"aid\"\n"+
332             " column=\"aid\"\n"+
333             " jdbc-type=\"INTEGER\"\n"+
334             " >\n"+
335             " </field-descriptor>\n"+
336             "</class-descriptor>\n"+
337             "<class-descriptor\n"+
338             " class=\"test.B\"\n"+
339             " table=\"B\"\n"+
340             ">\n"+
341             " <field-descriptor\n"+
342             " name=\"aid\"\n"+
343             " column=\"aid\"\n"+
344             " jdbc-type=\"INTEGER\"\n"+
345             " >\n"+
346             " </field-descriptor>\n"+
347             "</class-descriptor>\n"+
348             "<class-descriptor\n"+
349             " class=\"test.D\"\n"+
350             " table=\"D\"\n"+
351             ">\n"+
352             " <extent-class class-ref=\"test.E\"/>\n"+
353             " <field-descriptor\n"+
354             " name=\"aid\"\n"+
355             " column=\"aid\"\n"+
356             " jdbc-type=\"INTEGER\"\n"+
357             " >\n"+
358             " </field-descriptor>\n"+
359             "</class-descriptor>\n"+
360             "<class-descriptor\n"+
361             " class=\"test.E\"\n"+
362             " table=\"E\"\n"+
363             ">\n"+
364             " <field-descriptor\n"+
365             " name=\"aid\"\n"+
366             " column=\"aid\"\n"+
367             " jdbc-type=\"INTEGER\"\n"+
368             " >\n"+
369             " </field-descriptor>\n"+
370             "</class-descriptor>",
371             runOjbXDoclet(OJB_DEST_FILE));
372         assertEqualsTorqueSchemaFile(
373             "<database name=\"ojbtest\">\n"+
374             " <table name=\"A\">\n"+
375             " <column name=\"aid\"\n"+
376             " javaName=\"aid\"\n"+
377             " type=\"INTEGER\"\n"+
378             " />\n"+
379             " </table>\n"+
380             " <table name=\"B\">\n"+
381             " <column name=\"aid\"\n"+
382             " javaName=\"aid\"\n"+
383             " type=\"INTEGER\"\n"+
384             " />\n"+
385             " </table>\n"+
386             " <table name=\"D\">\n"+
387             " <column name=\"aid\"\n"+
388             " javaName=\"aid\"\n"+
389             " type=\"INTEGER\"\n"+
390             " />\n"+
391             " </table>\n"+
392             " <table name=\"E\">\n"+
393             " <column name=\"aid\"\n"+
394             " javaName=\"aid\"\n"+
395             " type=\"INTEGER\"\n"+
396             " />\n"+
397             " </table>\n"+
398             "</database>",
399             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
400     }
401
402     // Test: use with remote subclass (no persistent classes in-between) when determine-extents=false
403
public void testExtentClass5()
404     {
405         addClass(
406             "test.A",
407             "package test;\n"+
408             "/** @ojb.class determine-extents=\"false\"\n"+
409             " * @ojb.extent-class class-ref=\"test.D\"\n"+
410             " */\n"+
411             "public class A {\n"+
412             " /** @ojb.field */\n"+
413             " private int aid;\n"+
414             "}\n");
415         addClass(
416             "test.B",
417             "package test;\n"+
418             "/** @ojb.class */\n"+
419             "public class B extends A {}\n");
420         addClass(
421             "test.C",
422             "package test;\n"+
423             "public class C extends A {}\n");
424         addClass(
425             "test.D",
426             "package test;\n"+
427             "/** @ojb.class */\n"+
428             "public class D extends C {}\n");
429         addClass(
430             "test.E",
431             "package test;\n"+
432             "/** @ojb.class */\n"+
433             "public class E extends D {}\n");
434
435         assertEqualsOjbDescriptorFile(
436             "<class-descriptor\n"+
437             " class=\"test.A\"\n"+
438             " table=\"A\"\n"+
439             ">\n"+
440             " <extent-class class-ref=\"test.D\"/>\n"+
441             " <field-descriptor\n"+
442             " name=\"aid\"\n"+
443             " column=\"aid\"\n"+
444             " jdbc-type=\"INTEGER\"\n"+
445             " >\n"+
446             " </field-descriptor>\n"+
447             "</class-descriptor>\n"+
448             "<class-descriptor\n"+
449             " class=\"test.B\"\n"+
450             " table=\"B\"\n"+
451             ">\n"+
452             " <field-descriptor\n"+
453             " name=\"aid\"\n"+
454             " column=\"aid\"\n"+
455             " jdbc-type=\"INTEGER\"\n"+
456             " >\n"+
457             " </field-descriptor>\n"+
458             "</class-descriptor>\n"+
459             "<class-descriptor\n"+
460             " class=\"test.D\"\n"+
461             " table=\"D\"\n"+
462             ">\n"+
463             " <extent-class class-ref=\"test.E\"/>\n"+
464             " <field-descriptor\n"+
465             " name=\"aid\"\n"+
466             " column=\"aid\"\n"+
467             " jdbc-type=\"INTEGER\"\n"+
468             " >\n"+
469             " </field-descriptor>\n"+
470             "</class-descriptor>\n"+
471             "<class-descriptor\n"+
472             " class=\"test.E\"\n"+
473             " table=\"E\"\n"+
474             ">\n"+
475             " <field-descriptor\n"+
476             " name=\"aid\"\n"+
477             " column=\"aid\"\n"+
478             " jdbc-type=\"INTEGER\"\n"+
479             " >\n"+
480             " </field-descriptor>\n"+
481             "</class-descriptor>",
482             runOjbXDoclet(OJB_DEST_FILE));
483         assertEqualsTorqueSchemaFile(
484             "<database name=\"ojbtest\">\n"+
485             " <table name=\"A\">\n"+
486             " <column name=\"aid\"\n"+
487             " javaName=\"aid\"\n"+
488             " type=\"INTEGER\"\n"+
489             " />\n"+
490             " </table>\n"+
491             " <table name=\"B\">\n"+
492             " <column name=\"aid\"\n"+
493             " javaName=\"aid\"\n"+
494             " type=\"INTEGER\"\n"+
495             " />\n"+
496             " </table>\n"+
497             " <table name=\"D\">\n"+
498             " <column name=\"aid\"\n"+
499             " javaName=\"aid\"\n"+
500             " type=\"INTEGER\"\n"+
501             " />\n"+
502             " </table>\n"+
503             " <table name=\"E\">\n"+
504             " <column name=\"aid\"\n"+
505             " javaName=\"aid\"\n"+
506             " type=\"INTEGER\"\n"+
507             " />\n"+
508             " </table>\n"+
509             "</database>",
510             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
511     }
512
513     // Test: use with remote subclass (persistent classes in-between) when determine-extents=false
514
public void testExtentClass6()
515     {
516         addClass(
517             "test.A",
518             "package test;\n"+
519             "/** @ojb.class determine-extents=\"false\"\n"+
520             " * @ojb.extent-class class-ref=\"test.E\"\n"+
521             " */\n"+
522             "public class A {\n"+
523             " /** @ojb.field */\n"+
524             " private int aid;\n"+
525             "}\n");
526         addClass(
527             "test.B",
528             "package test;\n"+
529             "/** @ojb.class */\n"+
530             "public class B extends A {}\n");
531         addClass(
532             "test.C",
533             "package test;\n"+
534             "public class C extends A {}\n");
535         addClass(
536             "test.D",
537             "package test;\n"+
538             "/** @ojb.class */\n"+
539             "public class D extends C {}\n");
540         addClass(
541             "test.E",
542             "package test;\n"+
543             "/** @ojb.class */\n"+
544             "public class E extends D {}\n");
545
546         assertEqualsOjbDescriptorFile(
547             "<class-descriptor\n"+
548             " class=\"test.A\"\n"+
549             " table=\"A\"\n"+
550             ">\n"+
551             " <extent-class class-ref=\"test.E\"/>\n"+
552             " <field-descriptor\n"+
553             " name=\"aid\"\n"+
554             " column=\"aid\"\n"+
555             " jdbc-type=\"INTEGER\"\n"+
556             " >\n"+
557             " </field-descriptor>\n"+
558             "</class-descriptor>\n"+
559             "<class-descriptor\n"+
560             " class=\"test.B\"\n"+
561             " table=\"B\"\n"+
562             ">\n"+
563             " <field-descriptor\n"+
564             " name=\"aid\"\n"+
565             " column=\"aid\"\n"+
566             " jdbc-type=\"INTEGER\"\n"+
567             " >\n"+
568             " </field-descriptor>\n"+
569             "</class-descriptor>\n"+
570             "<class-descriptor\n"+
571             " class=\"test.D\"\n"+
572             " table=\"D\"\n"+
573             ">\n"+
574             " <extent-class class-ref=\"test.E\"/>\n"+
575             " <field-descriptor\n"+
576             " name=\"aid\"\n"+
577             " column=\"aid\"\n"+
578             " jdbc-type=\"INTEGER\"\n"+
579             " >\n"+
580             " </field-descriptor>\n"+
581             "</class-descriptor>\n"+
582             "<class-descriptor\n"+
583             " class=\"test.E\"\n"+
584             " table=\"E\"\n"+
585             ">\n"+
586             " <field-descriptor\n"+
587             " name=\"aid\"\n"+
588             " column=\"aid\"\n"+
589             " jdbc-type=\"INTEGER\"\n"+
590             " >\n"+
591             " </field-descriptor>\n"+
592             "</class-descriptor>",
593             runOjbXDoclet(OJB_DEST_FILE));
594         assertEqualsTorqueSchemaFile(
595             "<database name=\"ojbtest\">\n"+
596             " <table name=\"A\">\n"+
597             " <column name=\"aid\"\n"+
598             " javaName=\"aid\"\n"+
599             " type=\"INTEGER\"\n"+
600             " />\n"+
601             " </table>\n"+
602             " <table name=\"B\">\n"+
603             " <column name=\"aid\"\n"+
604             " javaName=\"aid\"\n"+
605             " type=\"INTEGER\"\n"+
606             " />\n"+
607             " </table>\n"+
608             " <table name=\"D\">\n"+
609             " <column name=\"aid\"\n"+
610             " javaName=\"aid\"\n"+
611             " type=\"INTEGER\"\n"+
612             " />\n"+
613             " </table>\n"+
614             " <table name=\"E\">\n"+
615             " <column name=\"aid\"\n"+
616             " javaName=\"aid\"\n"+
617             " type=\"INTEGER\"\n"+
618             " />\n"+
619             " </table>\n"+
620             "</database>",
621             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
622     }
623
624     // Test: use with multiple subclasses when determine-extents=false
625
public void testExtentClass7()
626     {
627         addClass(
628             "test.A",
629             "package test;\n"+
630             "/** @ojb.class determine-extents=\"false\"\n"+
631             " * @ojb.extent-class class-ref=\"test.B\"\n"+
632             " * @ojb.extent-class class-ref=\"test.E\"\n"+
633             " * @ojb.extent-class class-ref=\"test.D\"\n"+
634             " */\n"+
635             "public class A {\n"+
636             " /** @ojb.field */\n"+
637             " private int aid;\n"+
638             "}\n");
639         addClass(
640             "test.B",
641             "package test;\n"+
642             "/** @ojb.class */\n"+
643             "public class B extends A {}\n");
644         addClass(
645             "test.C",
646             "package test;\n"+
647             "public class C extends A {}\n");
648         addClass(
649             "test.D",
650             "package test;\n"+
651             "/** @ojb.class */\n"+
652             "public class D extends C {}\n");
653         addClass(
654             "test.E",
655             "package test;\n"+
656             "/** @ojb.class */\n"+
657             "public class E extends D {}\n");
658
659         assertEqualsOjbDescriptorFile(
660             "<class-descriptor\n"+
661             " class=\"test.A\"\n"+
662             " table=\"A\"\n"+
663             ">\n"+
664             " <extent-class class-ref=\"test.B\"/>\n"+
665             " <extent-class class-ref=\"test.D\"/>\n"+
666             " <field-descriptor\n"+
667             " name=\"aid\"\n"+
668             " column=\"aid\"\n"+
669             " jdbc-type=\"INTEGER\"\n"+
670             " >\n"+
671             " </field-descriptor>\n"+
672             "</class-descriptor>\n"+
673             "<class-descriptor\n"+
674             " class=\"test.B\"\n"+
675             " table=\"B\"\n"+
676             ">\n"+
677             " <field-descriptor\n"+
678             " name=\"aid\"\n"+
679             " column=\"aid\"\n"+
680             " jdbc-type=\"INTEGER\"\n"+
681             " >\n"+
682             " </field-descriptor>\n"+
683             "</class-descriptor>\n"+
684             "<class-descriptor\n"+
685             " class=\"test.D\"\n"+
686             " table=\"D\"\n"+
687             ">\n"+
688             " <extent-class class-ref=\"test.E\"/>\n"+
689             " <field-descriptor\n"+
690             " name=\"aid\"\n"+
691             " column=\"aid\"\n"+
692             " jdbc-type=\"INTEGER\"\n"+
693             " >\n"+
694             " </field-descriptor>\n"+
695             "</class-descriptor>\n"+
696             "<class-descriptor\n"+
697             " class=\"test.E\"\n"+
698             " table=\"E\"\n"+
699             ">\n"+
700             " <field-descriptor\n"+
701             " name=\"aid\"\n"+
702             " column=\"aid\"\n"+
703             " jdbc-type=\"INTEGER\"\n"+
704             " >\n"+
705             " </field-descriptor>\n"+
706             "</class-descriptor>",
707             runOjbXDoclet(OJB_DEST_FILE));
708         assertEqualsTorqueSchemaFile(
709             "<database name=\"ojbtest\">\n"+
710             " <table name=\"A\">\n"+
711             " <column name=\"aid\"\n"+
712             " javaName=\"aid\"\n"+
713             " type=\"INTEGER\"\n"+
714             " />\n"+
715             " </table>\n"+
716             " <table name=\"B\">\n"+
717             " <column name=\"aid\"\n"+
718             " javaName=\"aid\"\n"+
719             " type=\"INTEGER\"\n"+
720             " />\n"+
721             " </table>\n"+
722             " <table name=\"D\">\n"+
723             " <column name=\"aid\"\n"+
724             " javaName=\"aid\"\n"+
725             " type=\"INTEGER\"\n"+
726             " />\n"+
727             " </table>\n"+
728             " <table name=\"E\">\n"+
729             " <column name=\"aid\"\n"+
730             " javaName=\"aid\"\n"+
731             " type=\"INTEGER\"\n"+
732             " />\n"+
733             " </table>\n"+
734             "</database>",
735             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
736     }
737
738     // Test: use with twice the same subclass when determine-extents=false
739
public void testExtentClass8()
740     {
741         addClass(
742             "test.A",
743             "package test;\n"+
744             "/** @ojb.class determine-extents=\"false\"\n"+
745             " * @ojb.extent-class class-ref=\"test.D\"\n"+
746             " * @ojb.extent-class class-ref=\"test.B\"\n"+
747             " * @ojb.extent-class class-ref=\"test.D\"\n"+
748             " */\n"+
749             "public class A {\n"+
750             " /** @ojb.field */\n"+
751             " private int aid;\n"+
752             "}\n");
753         addClass(
754             "test.B",
755             "package test;\n"+
756             "/** @ojb.class */\n"+
757             "public class B extends A {}\n");
758         addClass(
759             "test.C",
760             "package test;\n"+
761             "public class C extends A {}\n");
762         addClass(
763             "test.D",
764             "package test;\n"+
765             "/** @ojb.class */\n"+
766             "public class D extends C {}\n");
767         addClass(
768             "test.E",
769             "package test;\n"+
770             "/** @ojb.class */\n"+
771             "public class E extends D {}\n");
772
773         assertEqualsOjbDescriptorFile(
774             "<class-descriptor\n"+
775             " class=\"test.A\"\n"+
776             " table=\"A\"\n"+
777             ">\n"+
778             " <extent-class class-ref=\"test.B\"/>\n"+
779             " <extent-class class-ref=\"test.D\"/>\n"+
780             " <field-descriptor\n"+
781             " name=\"aid\"\n"+
782             " column=\"aid\"\n"+
783             " jdbc-type=\"INTEGER\"\n"+
784             " >\n"+
785             " </field-descriptor>\n"+
786             "</class-descriptor>\n"+
787             "<class-descriptor\n"+
788             " class=\"test.B\"\n"+
789             " table=\"B\"\n"+
790             ">\n"+
791             " <field-descriptor\n"+
792             " name=\"aid\"\n"+
793             " column=\"aid\"\n"+
794             " jdbc-type=\"INTEGER\"\n"+
795             " >\n"+
796             " </field-descriptor>\n"+
797             "</class-descriptor>\n"+
798             "<class-descriptor\n"+
799             " class=\"test.D\"\n"+
800             " table=\"D\"\n"+
801             ">\n"+
802             " <extent-class class-ref=\"test.E\"/>\n"+
803             " <field-descriptor\n"+
804             " name=\"aid\"\n"+
805             " column=\"aid\"\n"+
806             " jdbc-type=\"INTEGER\"\n"+
807             " >\n"+
808             " </field-descriptor>\n"+
809             "</class-descriptor>\n"+
810             "<class-descriptor\n"+
811             " class=\"test.E\"\n"+
812             " table=\"E\"\n"+
813             ">\n"+
814             " <field-descriptor\n"+
815             " name=\"aid\"\n"+
816             " column=\"aid\"\n"+
817             " jdbc-type=\"INTEGER\"\n"+
818             " >\n"+
819             " </field-descriptor>\n"+
820             "</class-descriptor>",
821             runOjbXDoclet(OJB_DEST_FILE));
822         assertEqualsTorqueSchemaFile(
823             "<database name=\"ojbtest\">\n"+
824             " <table name=\"A\">\n"+
825             " <column name=\"aid\"\n"+
826             " javaName=\"aid\"\n"+
827             " type=\"INTEGER\"\n"+
828             " />\n"+
829             " </table>\n"+
830             " <table name=\"B\">\n"+
831             " <column name=\"aid\"\n"+
832             " javaName=\"aid\"\n"+
833             " type=\"INTEGER\"\n"+
834             " />\n"+
835             " </table>\n"+
836             " <table name=\"D\">\n"+
837             " <column name=\"aid\"\n"+
838             " javaName=\"aid\"\n"+
839             " type=\"INTEGER\"\n"+
840             " />\n"+
841             " </table>\n"+
842             " <table name=\"E\">\n"+
843             " <column name=\"aid\"\n"+
844             " javaName=\"aid\"\n"+
845             " type=\"INTEGER\"\n"+
846             " />\n"+
847             " </table>\n"+
848             "</database>",
849             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
850     }
851
852     // Test: use with a baseclass when determine-extents=false
853
public void testExtentClass9()
854     {
855         addClass(
856             "test.A",
857             "package test;\n"+
858             "/** @ojb.class determine-extents=\"false\"\n"+
859             " */\n"+
860             "public class A {\n"+
861             " /** @ojb.field */\n"+
862             " private int aid;\n"+
863             "}\n");
864         addClass(
865             "test.B",
866             "package test;\n"+
867             "/** @ojb.class */\n"+
868             "public class B extends A {}\n");
869         addClass(
870             "test.C",
871             "package test;\n"+
872             "public class C extends A {}\n");
873         addClass(
874             "test.D",
875             "package test;\n"+
876             "/** @ojb.class determine-extents=\"false\"\n"+
877             " * @ojb.extent-class class-ref=\"test.A\"\n"+
878             " */\n"+
879             "public class D extends C {}\n");
880         addClass(
881             "test.E",
882             "package test;\n"+
883             "/** @ojb.class */\n"+
884             "public class E extends D {}\n");
885
886         assertNull(runOjbXDoclet(OJB_DEST_FILE));
887         assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
888     }
889
890     // Test: use with an unrelated class when determine-extents=false
891
public void testExtentClass10()
892     {
893         addClass(
894             "test.A",
895             "package test;\n"+
896             "/** @ojb.class determine-extents=\"false\"\n"+
897             " * @ojb.extent-class class-ref=\"test.E\"\n"+
898             " */\n"+
899             "public class A {\n"+
900             " /** @ojb.field */\n"+
901             " private int aid;\n"+
902             "}\n");
903         addClass(
904             "test.B",
905             "package test;\n"+
906             "/** @ojb.class */\n"+
907             "public class B extends A {}\n");
908         addClass(
909             "test.C",
910             "package test;\n"+
911             "public class C {}\n");
912         addClass(
913             "test.D",
914             "package test;\n"+
915             "/** @ojb.class */\n"+
916             "public class D extends C {}\n");
917         addClass(
918             "test.E",
919             "package test;\n"+
920             "/** @ojb.class */\n"+
921             "public class E extends D {}\n");
922
923         assertNull(runOjbXDoclet(OJB_DEST_FILE));
924         assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
925     }
926 }
927
Popular Tags