KickJava   Java API By Example, From Geeks To Geeks.

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


1 package xdoclet.modules.ojb.tests;
2
3 /* Copyright 2002-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.reference tag with the proxy and proxy-prefetching-limit attributes.
20  *
21  * @author <a HREF="mailto:tomdz@users.sourceforge.net">Thomas Dudziak (tomdz@users.sourceforge.net)</a>
22  */

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