KickJava   Java API By Example, From Geeks To Geeks.

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


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

17
18 /**
19  * Tests for the ojb.modify-inherited tag with the jdbc-type attribute
20  * Note that the xdoclet ojb module does not check whether the JDBC type required a conversion when used
21  * for the field's java type, so most of the tests here would not make sense in a real application.
22  *
23  * @author <a HREF="mailto:tomdz@users.sourceforge.net">Thomas Dudziak (tomdz@users.sourceforge.net)</a>
24  */

25 public class ModifyInheritedTagJdbcTypeAttributeTests extends OjbTestBase
26 {
27     public ModifyInheritedTagJdbcTypeAttributeTests(String JavaDoc name)
28     {
29         super(name);
30     }
31
32     // Test: removing jdbc-type of inherited field
33
public void testJdbcType1()
34     {
35         addClass(
36             "test.A",
37             "package test;\n"+
38             "/** @ojb.class */\n"+
39             "public class A {\n"+
40             "/** @ojb.field jdbc-type=\"BIT\" */\n"+
41             " private int attr;\n"+
42             "}\n");
43         addClass(
44             "test.B",
45             "package test;\n"+
46             "/** @ojb.class\n"+
47             " * @ojb.modify-inherited name=\"attr\"\n"+
48             " * jdbc-type=\"\"\n"+
49             " */\n"+
50             "public class B extends A {}\n");
51
52         assertEqualsOjbDescriptorFile(
53             "<class-descriptor\n"+
54             " class=\"test.A\"\n"+
55             " table=\"A\"\n"+
56             ">\n"+
57             " <extent-class class-ref=\"test.B\"/>\n"+
58             " <field-descriptor\n"+
59             " name=\"attr\"\n"+
60             " column=\"attr\"\n"+
61             " jdbc-type=\"BIT\"\n"+
62             " >\n"+
63             " </field-descriptor>\n"+
64             "</class-descriptor>\n"+
65             "<class-descriptor\n"+
66             " class=\"test.B\"\n"+
67             " table=\"B\"\n"+
68             ">\n"+
69             " <field-descriptor\n"+
70             " name=\"attr\"\n"+
71             " column=\"attr\"\n"+
72             " jdbc-type=\"INTEGER\"\n"+
73             " >\n"+
74             " </field-descriptor>\n"+
75             "</class-descriptor>",
76             runOjbXDoclet(OJB_DEST_FILE));
77         assertEqualsTorqueSchemaFile(
78             "<database name=\"ojbtest\">\n"+
79             " <table name=\"A\">\n"+
80             " <column name=\"attr\"\n"+
81             " javaName=\"attr\"\n"+
82             " type=\"BIT\"\n"+
83             " />\n"+
84             " </table>\n"+
85             " <table name=\"B\">\n"+
86             " <column name=\"attr\"\n"+
87             " javaName=\"attr\"\n"+
88             " type=\"INTEGER\"\n"+
89             " />\n"+
90             " </table>\n"+
91             "</database>",
92             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
93     }
94
95     // Test: setting jdbc-type of remotely inherited field
96
public void testJdbcType2()
97     {
98         addClass(
99             "test.A",
100             "package test;\n"+
101             "/** @ojb.class */\n"+
102             "public class A {\n"+
103             "/** @ojb.field */\n"+
104             " private int attr;\n"+
105             "}\n");
106         addClass(
107             "test.B",
108             "package test;\n"+
109             "/** @ojb.class */\n"+
110             "public class B extends A {}\n");
111         addClass(
112             "test.C",
113             "package test;\n"+
114             "/** @ojb.class\n"+
115             " * @ojb.modify-inherited name=\"attr\"\n"+
116             " * jdbc-type=\"BIGINT\"\n"+
117             " */\n"+
118             "public class C extends B {}\n");
119
120         assertEqualsOjbDescriptorFile(
121             "<class-descriptor\n"+
122             " class=\"test.A\"\n"+
123             " table=\"A\"\n"+
124             ">\n"+
125             " <extent-class class-ref=\"test.B\"/>\n"+
126             " <field-descriptor\n"+
127             " name=\"attr\"\n"+
128             " column=\"attr\"\n"+
129             " jdbc-type=\"INTEGER\"\n"+
130             " >\n"+
131             " </field-descriptor>\n"+
132             "</class-descriptor>\n"+
133             "<class-descriptor\n"+
134             " class=\"test.B\"\n"+
135             " table=\"B\"\n"+
136             ">\n"+
137             " <extent-class class-ref=\"test.C\"/>\n"+
138             " <field-descriptor\n"+
139             " name=\"attr\"\n"+
140             " column=\"attr\"\n"+
141             " jdbc-type=\"INTEGER\"\n"+
142             " >\n"+
143             " </field-descriptor>\n"+
144             "</class-descriptor>\n"+
145             "<class-descriptor\n"+
146             " class=\"test.C\"\n"+
147             " table=\"C\"\n"+
148             ">\n"+
149             " <field-descriptor\n"+
150             " name=\"attr\"\n"+
151             " column=\"attr\"\n"+
152             " jdbc-type=\"BIGINT\"\n"+
153             " >\n"+
154             " </field-descriptor>\n"+
155             "</class-descriptor>",
156             runOjbXDoclet(OJB_DEST_FILE));
157         assertEqualsTorqueSchemaFile(
158             "<database name=\"ojbtest\">\n"+
159             " <table name=\"A\">\n"+
160             " <column name=\"attr\"\n"+
161             " javaName=\"attr\"\n"+
162             " type=\"INTEGER\"\n"+
163             " />\n"+
164             " </table>\n"+
165             " <table name=\"B\">\n"+
166             " <column name=\"attr\"\n"+
167             " javaName=\"attr\"\n"+
168             " type=\"INTEGER\"\n"+
169             " />\n"+
170             " </table>\n"+
171             " <table name=\"C\">\n"+
172             " <column name=\"attr\"\n"+
173             " javaName=\"attr\"\n"+
174             " type=\"BIGINT\"\n"+
175             " />\n"+
176             " </table>\n"+
177             "</database>",
178             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
179     }
180
181     // Test: invalid value for jdbc-type
182
public void testJdbcType3()
183     {
184         addClass(
185             "test.A",
186             "package test;\n"+
187             "/** @ojb.class */\n"+
188             "public class A {\n"+
189             "/** @ojb.field */\n"+
190             " private int attr;\n"+
191             "}\n");
192         addClass(
193             "test.B",
194             "package test;\n"+
195             "/** @ojb.class\n"+
196             " * @ojb.modify-inherited name=\"attr\"\n"+
197             " * jdbc-type=\"UNKNOWN\"\n"+
198             " */\n"+
199             "public class B extends A {}\n");
200
201         assertNull(runOjbXDoclet(OJB_DEST_FILE));
202         assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
203     }
204
205     // Test: changing jdbc-type of inherited field
206
public void testJdbcType4()
207     {
208         addClass(
209             "test.A",
210             "package test;\n"+
211             "/** @ojb.class */\n"+
212             "public class A {\n"+
213             "/** @ojb.field jdbc-type=\"SMALLINT\" */\n"+
214             " private int attr;\n"+
215             "}\n");
216         addClass(
217             "test.B",
218             "package test;\n"+
219             "/** @ojb.class\n"+
220             " * @ojb.modify-inherited name=\"attr\"\n"+
221             " * jdbc-type=\"BIGINT\"\n"+
222             " */\n"+
223             "public class B extends A {}\n");
224         addClass(
225             "test.C",
226             "package test;\n"+
227             "/** @ojb.class */\n"+
228             "public class C extends B {}\n");
229
230         assertEqualsOjbDescriptorFile(
231             "<class-descriptor\n"+
232             " class=\"test.A\"\n"+
233             " table=\"A\"\n"+
234             ">\n"+
235             " <extent-class class-ref=\"test.B\"/>\n"+
236             " <field-descriptor\n"+
237             " name=\"attr\"\n"+
238             " column=\"attr\"\n"+
239             " jdbc-type=\"SMALLINT\"\n"+
240             " >\n"+
241             " </field-descriptor>\n"+
242             "</class-descriptor>\n"+
243             "<class-descriptor\n"+
244             " class=\"test.B\"\n"+
245             " table=\"B\"\n"+
246             ">\n"+
247             " <extent-class class-ref=\"test.C\"/>\n"+
248             " <field-descriptor\n"+
249             " name=\"attr\"\n"+
250             " column=\"attr\"\n"+
251             " jdbc-type=\"BIGINT\"\n"+
252             " >\n"+
253             " </field-descriptor>\n"+
254             "</class-descriptor>\n"+
255             "<class-descriptor\n"+
256             " class=\"test.C\"\n"+
257             " table=\"C\"\n"+
258             ">\n"+
259             " <field-descriptor\n"+
260             " name=\"attr\"\n"+
261             " column=\"attr\"\n"+
262             " jdbc-type=\"BIGINT\"\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=\"attr\"\n"+
271             " javaName=\"attr\"\n"+
272             " type=\"SMALLINT\"\n"+
273             " />\n"+
274             " </table>\n"+
275             " <table name=\"B\">\n"+
276             " <column name=\"attr\"\n"+
277             " javaName=\"attr\"\n"+
278             " type=\"BIGINT\"\n"+
279             " />\n"+
280             " </table>\n"+
281             " <table name=\"C\">\n"+
282             " <column name=\"attr\"\n"+
283             " javaName=\"attr\"\n"+
284             " type=\"BIGINT\"\n"+
285             " />\n"+
286             " </table>\n"+
287             "</database>",
288             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
289     }
290
291     // Test: changing jdbc-type of inherited field to a type with default length
292
public void testJdbcType5()
293     {
294         addClass(
295             "test.A",
296             "package test;\n"+
297             "/** @ojb.class */\n"+
298             "public class A {\n"+
299             "/** @ojb.field jdbc-type=\"BIGINT\" */\n"+
300             " private int attr;\n"+
301             "}\n");
302         addClass(
303             "test.B",
304             "package test;\n"+
305             "/** @ojb.class\n"+
306             " * @ojb.modify-inherited name=\"attr\"\n"+
307             " * jdbc-type=\"VARCHAR\"\n"+
308             " */\n"+
309             "public class B extends A {}\n");
310
311         assertEqualsOjbDescriptorFile(
312             "<class-descriptor\n"+
313             " class=\"test.A\"\n"+
314             " table=\"A\"\n"+
315             ">\n"+
316             " <extent-class class-ref=\"test.B\"/>\n"+
317             " <field-descriptor\n"+
318             " name=\"attr\"\n"+
319             " column=\"attr\"\n"+
320             " jdbc-type=\"BIGINT\"\n"+
321             " >\n"+
322             " </field-descriptor>\n"+
323             "</class-descriptor>\n"+
324             "<class-descriptor\n"+
325             " class=\"test.B\"\n"+
326             " table=\"B\"\n"+
327             ">\n"+
328             " <field-descriptor\n"+
329             " name=\"attr\"\n"+
330             " column=\"attr\"\n"+
331             " jdbc-type=\"VARCHAR\"\n"+
332             " length=\"254\"\n"+
333             " >\n"+
334             " </field-descriptor>\n"+
335             "</class-descriptor>",
336             runOjbXDoclet(OJB_DEST_FILE));
337         assertEqualsTorqueSchemaFile(
338             "<database name=\"ojbtest\">\n"+
339             " <table name=\"A\">\n"+
340             " <column name=\"attr\"\n"+
341             " javaName=\"attr\"\n"+
342             " type=\"BIGINT\"\n"+
343             " />\n"+
344             " </table>\n"+
345             " <table name=\"B\">\n"+
346             " <column name=\"attr\"\n"+
347             " javaName=\"attr\"\n"+
348             " type=\"VARCHAR\"\n"+
349             " size=\"254\"\n"+
350             " />\n"+
351             " </table>\n"+
352             "</database>",
353             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
354     }
355
356     // Test: changing jdbc-type of inherited field to a type with default precision/scale
357
public void testJdbcType6()
358     {
359         addClass(
360             "test.A",
361             "package test;\n"+
362             "/** @ojb.class */\n"+
363             "public class A {\n"+
364             "/** @ojb.field jdbc-type=\"BIGINT\" */\n"+
365             " private int attr;\n"+
366             "}\n");
367         addClass(
368             "test.B",
369             "package test;\n"+
370             "/** @ojb.class\n"+
371             " * @ojb.modify-inherited name=\"attr\"\n"+
372             " * jdbc-type=\"DECIMAL\"\n"+
373             " */\n"+
374             "public class B extends A {}\n");
375
376         assertEqualsOjbDescriptorFile(
377             "<class-descriptor\n"+
378             " class=\"test.A\"\n"+
379             " table=\"A\"\n"+
380             ">\n"+
381             " <extent-class class-ref=\"test.B\"/>\n"+
382             " <field-descriptor\n"+
383             " name=\"attr\"\n"+
384             " column=\"attr\"\n"+
385             " jdbc-type=\"BIGINT\"\n"+
386             " >\n"+
387             " </field-descriptor>\n"+
388             "</class-descriptor>\n"+
389             "<class-descriptor\n"+
390             " class=\"test.B\"\n"+
391             " table=\"B\"\n"+
392             ">\n"+
393             " <field-descriptor\n"+
394             " name=\"attr\"\n"+
395             " column=\"attr\"\n"+
396             " jdbc-type=\"DECIMAL\"\n"+
397             " precision=\"20\"\n"+
398             " scale=\"0\"\n"+
399             " >\n"+
400             " </field-descriptor>\n"+
401             "</class-descriptor>",
402             runOjbXDoclet(OJB_DEST_FILE));
403         assertEqualsTorqueSchemaFile(
404             "<database name=\"ojbtest\">\n"+
405             " <table name=\"A\">\n"+
406             " <column name=\"attr\"\n"+
407             " javaName=\"attr\"\n"+
408             " type=\"BIGINT\"\n"+
409             " />\n"+
410             " </table>\n"+
411             " <table name=\"B\">\n"+
412             " <column name=\"attr\"\n"+
413             " javaName=\"attr\"\n"+
414             " type=\"DECIMAL\"\n"+
415             " size=\"20,0\"\n"+
416             " />\n"+
417             " </table>\n"+
418             "</database>",
419             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
420     }
421
422     // Test: changing jdbc-type of inherited field from a type with default length
423
public void testJdbcType7()
424     {
425         addClass(
426             "test.A",
427             "package test;\n"+
428             "/** @ojb.class */\n"+
429             "public class A {\n"+
430             "/** @ojb.field jdbc-type=\"VARCHAR\" */\n"+
431             " private String attr;\n"+
432             "}\n");
433         addClass(
434             "test.B",
435             "package test;\n"+
436             "/** @ojb.class\n"+
437             " * @ojb.modify-inherited name=\"attr\"\n"+
438             " * jdbc-type=\"CLOB\"\n"+
439             " */\n"+
440             "public class B extends A {}\n");
441
442         assertEqualsOjbDescriptorFile(
443             "<class-descriptor\n"+
444             " class=\"test.A\"\n"+
445             " table=\"A\"\n"+
446             ">\n"+
447             " <extent-class class-ref=\"test.B\"/>\n"+
448             " <field-descriptor\n"+
449             " name=\"attr\"\n"+
450             " column=\"attr\"\n"+
451             " jdbc-type=\"VARCHAR\"\n"+
452             " length=\"254\"\n"+
453             " >\n"+
454             " </field-descriptor>\n"+
455             "</class-descriptor>\n"+
456             "<class-descriptor\n"+
457             " class=\"test.B\"\n"+
458             " table=\"B\"\n"+
459             ">\n"+
460             " <field-descriptor\n"+
461             " name=\"attr\"\n"+
462             " column=\"attr\"\n"+
463             " jdbc-type=\"CLOB\"\n"+
464             " >\n"+
465             " </field-descriptor>\n"+
466             "</class-descriptor>",
467             runOjbXDoclet(OJB_DEST_FILE));
468         assertEqualsTorqueSchemaFile(
469             "<database name=\"ojbtest\">\n"+
470             " <table name=\"A\">\n"+
471             " <column name=\"attr\"\n"+
472             " javaName=\"attr\"\n"+
473             " type=\"VARCHAR\"\n"+
474             " size=\"254\"\n"+
475             " />\n"+
476             " </table>\n"+
477             " <table name=\"B\">\n"+
478             " <column name=\"attr\"\n"+
479             " javaName=\"attr\"\n"+
480             " type=\"CLOB\"\n"+
481             " />\n"+
482             " </table>\n"+
483             "</database>",
484             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
485     }
486
487     // Test: changing jdbc-type of inherited field from a type with default conversion
488
public void testJdbcType8()
489     {
490         addClass(
491             "test.A",
492             "package test;\n"+
493             "/** @ojb.class */\n"+
494             "public class A {\n"+
495             "/** @ojb.field jdbc-type=\"VARCHAR\" */\n"+
496             " private org.apache.ojb.broker.util.GUID attr;\n"+
497             "}\n");
498         addClass(
499             "test.B",
500             "package test;\n"+
501             "/** @ojb.class\n"+
502             " * @ojb.modify-inherited name=\"attr\"\n"+
503             " * jdbc-type=\"CLOB\"\n"+
504             " */\n"+
505             "public class B extends A {}\n");
506
507         assertEqualsOjbDescriptorFile(
508             "<class-descriptor\n"+
509             " class=\"test.A\"\n"+
510             " table=\"A\"\n"+
511             ">\n"+
512             " <extent-class class-ref=\"test.B\"/>\n"+
513             " <field-descriptor\n"+
514             " name=\"attr\"\n"+
515             " column=\"attr\"\n"+
516             " jdbc-type=\"VARCHAR\"\n"+
517             " conversion=\"org.apache.ojb.broker.accesslayer.conversions.GUID2StringFieldConversion\"\n"+
518             " length=\"254\"\n"+
519             " >\n"+
520             " </field-descriptor>\n"+
521             "</class-descriptor>\n"+
522             "<class-descriptor\n"+
523             " class=\"test.B\"\n"+
524             " table=\"B\"\n"+
525             ">\n"+
526             " <field-descriptor\n"+
527             " name=\"attr\"\n"+
528             " column=\"attr\"\n"+
529             " jdbc-type=\"CLOB\"\n"+
530             " >\n"+
531             " </field-descriptor>\n"+
532             "</class-descriptor>",
533             runOjbXDoclet(OJB_DEST_FILE));
534         assertEqualsTorqueSchemaFile(
535             "<database name=\"ojbtest\">\n"+
536             " <table name=\"A\">\n"+
537             " <column name=\"attr\"\n"+
538             " javaName=\"attr\"\n"+
539             " type=\"VARCHAR\"\n"+
540             " size=\"254\"\n"+
541             " />\n"+
542             " </table>\n"+
543             " <table name=\"B\">\n"+
544             " <column name=\"attr\"\n"+
545             " javaName=\"attr\"\n"+
546             " type=\"CLOB\"\n"+
547             " />\n"+
548             " </table>\n"+
549             "</database>",
550             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
551     }
552
553     // Test: changing jdbc-type of inherited field from a type with default precision/scale
554
public void testJdbcType9()
555     {
556         addClass(
557             "test.A",
558             "package test;\n"+
559             "/** @ojb.class */\n"+
560             "public class A {\n"+
561             "/** @ojb.field jdbc-type=\"NUMERIC\" */\n"+
562             " private int attr;\n"+
563             "}\n");
564         addClass(
565             "test.B",
566             "package test;\n"+
567             "/** @ojb.class\n"+
568             " * @ojb.modify-inherited name=\"attr\"\n"+
569             " * jdbc-type=\"INTEGER\"\n"+
570             " */\n"+
571             "public class B extends A {}\n");
572
573         assertEqualsOjbDescriptorFile(
574             "<class-descriptor\n"+
575             " class=\"test.A\"\n"+
576             " table=\"A\"\n"+
577             ">\n"+
578             " <extent-class class-ref=\"test.B\"/>\n"+
579             " <field-descriptor\n"+
580             " name=\"attr\"\n"+
581             " column=\"attr\"\n"+
582             " jdbc-type=\"NUMERIC\"\n"+
583             " precision=\"20\"\n"+
584             " scale=\"0\"\n"+
585             " >\n"+
586             " </field-descriptor>\n"+
587             "</class-descriptor>\n"+
588             "<class-descriptor\n"+
589             " class=\"test.B\"\n"+
590             " table=\"B\"\n"+
591             ">\n"+
592             " <field-descriptor\n"+
593             " name=\"attr\"\n"+
594             " column=\"attr\"\n"+
595             " jdbc-type=\"INTEGER\"\n"+
596             " >\n"+
597             " </field-descriptor>\n"+
598             "</class-descriptor>",
599             runOjbXDoclet(OJB_DEST_FILE));
600         assertEqualsTorqueSchemaFile(
601             "<database name=\"ojbtest\">\n"+
602             " <table name=\"A\">\n"+
603             " <column name=\"attr\"\n"+
604             " javaName=\"attr\"\n"+
605             " type=\"NUMERIC\"\n"+
606             " size=\"20,0\"\n"+
607             " />\n"+
608             " </table>\n"+
609             " <table name=\"B\">\n"+
610             " <column name=\"attr\"\n"+
611             " javaName=\"attr\"\n"+
612             " type=\"INTEGER\"\n"+
613             " />\n"+
614             " </table>\n"+
615             "</database>",
616             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
617     }
618
619     // Test: changing jdbc-type of reference foreignkey
620
public void testJdbcType10()
621     {
622         addClass(
623             "test.A",
624             "package test;\n"+
625             "/** @ojb.class */\n"+
626             "public class A {\n"+
627             " /** @ojb.field */\n"+
628             " private int attrKey;\n"+
629             " /** @ojb.reference foreignkey=\"attrKey\" */\n"+
630             " private test.C attr;\n"+
631             "}\n");
632         addClass(
633             "test.B",
634             "package test;\n"+
635             "/** @ojb.class\n"+
636             " * @ojb.modify-inherited name=\"attrKey\"\n"+
637             " * jdbc-type=\"FLOAT\"\n"+
638             " */\n"+
639             "public class B extends A {}\n");
640         addClass(
641             "test.C",
642             "package test;\n"+
643             "/** @ojb.class */\n"+
644             "public class C {\n"+
645             " /** @ojb.field primarykey=\"true\" */\n"+
646             " private int id;\n"+
647             "}\n");
648
649         assertNull(runOjbXDoclet(OJB_DEST_FILE));
650         assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
651     }
652
653     // Test: changing jdbc-type of primarykey in type referenced by a reference
654
public void testJdbcType11()
655     {
656         addClass(
657             "test.A",
658             "package test;\n"+
659             "/** @ojb.class */\n"+
660             "public class A {\n"+
661             " /** @ojb.field */\n"+
662             " private int attrKey;\n"+
663             " /** @ojb.reference foreignkey=\"attrKey\" */\n"+
664             " private test.B attr;\n"+
665             "}\n");
666         addClass(
667             "test.B",
668             "package test;\n"+
669             "/** @ojb.class */\n"+
670             "public class B {\n"+
671             " /** @ojb.field primarykey=\"true\" */\n"+
672             " private int id;\n"+
673             "}\n");
674         addClass(
675             "test.C",
676             "package test;\n"+
677             "/** @ojb.class\n"+
678             " * @ojb.modify-inherited name=\"id\"\n"+
679             " * jdbc-type=\"BIGINT\"\n"+
680             " */\n"+
681             "public class C extends B {}\n");
682         
683         assertNull(runOjbXDoclet(OJB_DEST_FILE));
684         assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
685     }
686
687     // Test: changing jdbc-type of a collection foreignkey
688
public void testJdbcType12()
689     {
690         addClass(
691             "test.A",
692             "package test;\n"+
693             "/** @ojb.class */\n" +
694             "public class A {\n"+
695             " /** @ojb.field primarykey=\"true\" */\n"+
696             " private int id;\n"+
697             " /** @ojb.collection element-class-ref=\"test.B\"\n"+
698             " * foreignkey=\"aid\"\n"+
699             " */\n"+
700             " private java.util.List attr;\n"+
701             "}");
702         addClass(
703             "test.B",
704             "package test;\n"+
705             "/** @ojb.class */\n"+
706             "public class B {\n"+
707             " /** @ojb.field */\n"+
708             " private int aid;\n"+
709             "}\n");
710         addClass(
711             "test.C",
712             "package test;\n"+
713             "/** @ojb.class\n"+
714             " * @ojb.modify-inherited name=\"aid\"\n"+
715             " * jdbc-type=\"BIGINT\"\n"+
716             " */\n" +
717             "public class C extends B {}");
718
719         assertNull(runOjbXDoclet(OJB_DEST_FILE));
720         assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
721     }
722
723     // Test: changing jdbc-type of primarykey of class with a collection
724
public void testJdbcType13()
725     {
726         addClass(
727             "test.A",
728             "package test;\n"+
729             "/** @ojb.class */\n" +
730             "public class A {\n"+
731             " /** @ojb.field primarykey=\"true\" */\n"+
732             " private int id;\n"+
733             " /** @ojb.collection element-class-ref=\"test.B\"\n"+
734             " * foreignkey=\"aid\"\n"+
735             " */\n"+
736             " private java.util.List attr;\n"+
737             "}");
738         addClass(
739             "test.B",
740             "package test;\n"+
741             "/** @ojb.class */\n"+
742             "public class B {\n"+
743             " /** @ojb.field */\n"+
744             " private int aid;\n"+
745             "}\n");
746         addClass(
747             "test.C",
748             "package test;\n"+
749             "/** @ojb.class\n"+
750             " * @ojb.modify-inherited name=\"id\"\n"+
751             " * jdbc-type=\"BIGINT\"\n"+
752             " */\n" +
753             "public class C extends A {}");
754
755         assertNull(runOjbXDoclet(OJB_DEST_FILE));
756         assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
757     }
758 }
759
Popular Tags