KickJava   Java API By Example, From Geeks To Geeks.

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


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

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