KickJava   Java API By Example, From Geeks To Geeks.

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


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

23 public class ModifyInheritedTagOrderbyAttributeTests extends OjbTestBase
24 {
25     public ModifyInheritedTagOrderbyAttributeTests(String JavaDoc name)
26     {
27         super(name);
28     }
29
30     // Test: removing orderby attribute (single value) of inherited collection
31
public void testOrderby1()
32     {
33         addClass(
34             "test.A",
35             "package test;\n"+
36             "/** @ojb.class */\n"+
37             "public class A {\n"+
38             " /** @ojb.field primarykey=\"true\" */\n"+
39             " private int id;\n"+
40             " /** @ojb.collection element-class-ref=\"test.B\"\n"+
41             " * foreignkey=\"aid\"\n"+
42             " * orderby=\"id\"\n"+
43             " * database-foreignkey=\"false\"\n"+
44             " */\n"+
45             " private java.util.List objs;\n"+
46             "}\n");
47         addClass(
48             "test.B",
49             "package test;\n"+
50             "/** @ojb.class */\n"+
51             "public class B {\n"+
52             " /** @ojb.field primarykey=\"true\" */\n"+
53             " private int id;\n"+
54             " /** @ojb.field */\n"+
55             " private int aid;\n"+
56             "}\n");
57         addClass(
58             "test.C",
59             "package test;\n"+
60             "/** @ojb.class\n"+
61             " * @ojb.modify-inherited name=\"objs\"\n"+
62             " * orderby=\"\"\n"+
63             " */\n"+
64             "public class C extends A {}\n");
65
66         assertEqualsOjbDescriptorFile(
67             "<class-descriptor\n"+
68             " class=\"test.A\"\n"+
69             " table=\"A\"\n"+
70             ">\n"+
71             " <extent-class class-ref=\"test.C\"/>\n"+
72             " <field-descriptor\n"+
73             " name=\"id\"\n"+
74             " column=\"id\"\n"+
75             " jdbc-type=\"INTEGER\"\n"+
76             " primarykey=\"true\"\n"+
77             " >\n"+
78             " </field-descriptor>\n"+
79             " <collection-descriptor\n"+
80             " name=\"objs\"\n"+
81             " element-class-ref=\"test.B\"\n"+
82             " >\n"+
83             " <orderby name=\"id\" sort=\"ASC\"/>\n"+
84             " <inverse-foreignkey field-ref=\"aid\"/>\n"+
85             " </collection-descriptor>\n"+
86             "</class-descriptor>\n"+
87             "<class-descriptor\n"+
88             " class=\"test.B\"\n"+
89             " table=\"B\"\n"+
90             ">\n"+
91             " <field-descriptor\n"+
92             " name=\"id\"\n"+
93             " column=\"id\"\n"+
94             " jdbc-type=\"INTEGER\"\n"+
95             " primarykey=\"true\"\n"+
96             " >\n"+
97             " </field-descriptor>\n"+
98             " <field-descriptor\n"+
99             " name=\"aid\"\n"+
100             " column=\"aid\"\n"+
101             " jdbc-type=\"INTEGER\"\n"+
102             " >\n"+
103             " </field-descriptor>\n"+
104             "</class-descriptor>\n"+
105             "<class-descriptor\n"+
106             " class=\"test.C\"\n"+
107             " table=\"C\"\n"+
108             ">\n"+
109             " <field-descriptor\n"+
110             " name=\"id\"\n"+
111             " column=\"id\"\n"+
112             " jdbc-type=\"INTEGER\"\n"+
113             " primarykey=\"true\"\n"+
114             " >\n"+
115             " </field-descriptor>\n"+
116             " <collection-descriptor\n"+
117             " name=\"objs\"\n"+
118             " element-class-ref=\"test.B\"\n"+
119             " >\n"+
120             " <inverse-foreignkey field-ref=\"aid\"/>\n"+
121             " </collection-descriptor>\n"+
122             "</class-descriptor>",
123             runOjbXDoclet(OJB_DEST_FILE));
124         assertEqualsTorqueSchemaFile(
125             "<database name=\"ojbtest\">\n"+
126             " <table name=\"A\">\n"+
127             " <column name=\"id\"\n"+
128             " javaName=\"id\"\n"+
129             " type=\"INTEGER\"\n"+
130             " primaryKey=\"true\"\n"+
131             " required=\"true\"\n"+
132             " />\n"+
133             " </table>\n"+
134             " <table name=\"B\">\n"+
135             " <column name=\"id\"\n"+
136             " javaName=\"id\"\n"+
137             " type=\"INTEGER\"\n"+
138             " primaryKey=\"true\"\n"+
139             " required=\"true\"\n"+
140             " />\n"+
141             " <column name=\"aid\"\n"+
142             " javaName=\"aid\"\n"+
143             " type=\"INTEGER\"\n"+
144             " />\n"+
145             " </table>\n"+
146             " <table name=\"C\">\n"+
147             " <column name=\"id\"\n"+
148             " javaName=\"id\"\n"+
149             " type=\"INTEGER\"\n"+
150             " primaryKey=\"true\"\n"+
151             " required=\"true\"\n"+
152             " />\n"+
153             " </table>\n"+
154             "</database>",
155             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
156     }
157
158     // Test: removing orderby attribute (multiple values) of inherited collection
159
public void testOrderby2()
160     {
161         addClass(
162             "test.A",
163             "package test;\n"+
164             "/** @ojb.class */\n"+
165             "public class A {\n"+
166             " /** @ojb.field primarykey=\"true\" */\n"+
167             " private int id;\n"+
168             " /** @ojb.collection element-class-ref=\"test.B\"\n"+
169             " * foreignkey=\"aid\"\n"+
170             " * orderby=\"val2,val1=ASC,id=DESC\"\n"+
171             " * database-foreignkey=\"false\"\n"+
172             " */\n"+
173             " private java.util.List objs;\n"+
174             "}\n");
175         addClass(
176             "test.B",
177             "package test;\n"+
178             "/** @ojb.class */\n"+
179             "public class B {\n"+
180             " /** @ojb.field primarykey=\"true\" */\n"+
181             " private int id;\n"+
182             " /** @ojb.field */\n"+
183             " private String val1;\n"+
184             " /** @ojb.field */\n"+
185             " private java.util.Date val2;\n"+
186             " /** @ojb.field */\n"+
187             " private int aid;\n"+
188             "}\n");
189         addClass(
190             "test.C",
191             "package test;\n"+
192             "/** @ojb.class\n"+
193             " * @ojb.modify-inherited name=\"objs\"\n"+
194             " * orderby=\"\"\n"+
195             " */\n"+
196             "public class C extends A {}\n");
197
198         assertEqualsOjbDescriptorFile(
199             "<class-descriptor\n"+
200             " class=\"test.A\"\n"+
201             " table=\"A\"\n"+
202             ">\n"+
203             " <extent-class class-ref=\"test.C\"/>\n"+
204             " <field-descriptor\n"+
205             " name=\"id\"\n"+
206             " column=\"id\"\n"+
207             " jdbc-type=\"INTEGER\"\n"+
208             " primarykey=\"true\"\n"+
209             " >\n"+
210             " </field-descriptor>\n"+
211             " <collection-descriptor\n"+
212             " name=\"objs\"\n"+
213             " element-class-ref=\"test.B\"\n"+
214             " >\n"+
215             " <orderby name=\"val2\" sort=\"ASC\"/>\n"+
216             " <orderby name=\"val1\" sort=\"ASC\"/>\n"+
217             " <orderby name=\"id\" sort=\"DESC\"/>\n"+
218             " <inverse-foreignkey field-ref=\"aid\"/>\n"+
219             " </collection-descriptor>\n"+
220             "</class-descriptor>\n"+
221             "<class-descriptor\n"+
222             " class=\"test.B\"\n"+
223             " table=\"B\"\n"+
224             ">\n"+
225             " <field-descriptor\n"+
226             " name=\"id\"\n"+
227             " column=\"id\"\n"+
228             " jdbc-type=\"INTEGER\"\n"+
229             " primarykey=\"true\"\n"+
230             " >\n"+
231             " </field-descriptor>\n"+
232             " <field-descriptor\n"+
233             " name=\"val1\"\n"+
234             " column=\"val1\"\n"+
235             " jdbc-type=\"VARCHAR\"\n"+
236             " length=\"254\"\n"+
237             " >\n"+
238             " </field-descriptor>\n"+
239             " <field-descriptor\n"+
240             " name=\"val2\"\n"+
241             " column=\"val2\"\n"+
242             " jdbc-type=\"DATE\"\n"+
243             " >\n"+
244             " </field-descriptor>\n"+
245             " <field-descriptor\n"+
246             " name=\"aid\"\n"+
247             " column=\"aid\"\n"+
248             " jdbc-type=\"INTEGER\"\n"+
249             " >\n"+
250             " </field-descriptor>\n"+
251             "</class-descriptor>\n"+
252             "<class-descriptor\n"+
253             " class=\"test.C\"\n"+
254             " table=\"C\"\n"+
255             ">\n"+
256             " <field-descriptor\n"+
257             " name=\"id\"\n"+
258             " column=\"id\"\n"+
259             " jdbc-type=\"INTEGER\"\n"+
260             " primarykey=\"true\"\n"+
261             " >\n"+
262             " </field-descriptor>\n"+
263             " <collection-descriptor\n"+
264             " name=\"objs\"\n"+
265             " element-class-ref=\"test.B\"\n"+
266             " >\n"+
267             " <inverse-foreignkey field-ref=\"aid\"/>\n"+
268             " </collection-descriptor>\n"+
269             "</class-descriptor>",
270             runOjbXDoclet(OJB_DEST_FILE));
271         assertEqualsTorqueSchemaFile(
272             "<database name=\"ojbtest\">\n"+
273             " <table name=\"A\">\n"+
274             " <column name=\"id\"\n"+
275             " javaName=\"id\"\n"+
276             " type=\"INTEGER\"\n"+
277             " primaryKey=\"true\"\n"+
278             " required=\"true\"\n"+
279             " />\n"+
280             " </table>\n"+
281             " <table name=\"B\">\n"+
282             " <column name=\"id\"\n"+
283             " javaName=\"id\"\n"+
284             " type=\"INTEGER\"\n"+
285             " primaryKey=\"true\"\n"+
286             " required=\"true\"\n"+
287             " />\n"+
288             " <column name=\"val1\"\n"+
289             " javaName=\"val1\"\n"+
290             " type=\"VARCHAR\"\n"+
291             " size=\"254\"\n"+
292             " />\n"+
293             " <column name=\"val2\"\n"+
294             " javaName=\"val2\"\n"+
295             " type=\"DATE\"\n"+
296             " />\n"+
297             " <column name=\"aid\"\n"+
298             " javaName=\"aid\"\n"+
299             " type=\"INTEGER\"\n"+
300             " />\n"+
301             " </table>\n"+
302             " <table name=\"C\">\n"+
303             " <column name=\"id\"\n"+
304             " javaName=\"id\"\n"+
305             " type=\"INTEGER\"\n"+
306             " primaryKey=\"true\"\n"+
307             " required=\"true\"\n"+
308             " />\n"+
309             " </table>\n"+
310             "</database>",
311             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
312     }
313
314     // Test: setting orderby attribute (single value) of remotely inherited collection
315
public void testOrderby3()
316     {
317         addClass(
318             "test.A",
319             "package test;\n"+
320             "/** @ojb.class */\n"+
321             "public class A {\n"+
322             " /** @ojb.field primarykey=\"true\" */\n"+
323             " private int id;\n"+
324             " /** @ojb.collection element-class-ref=\"test.B\"\n"+
325             " * foreignkey=\"aid\"\n"+
326             " * database-foreignkey=\"false\"\n"+
327             " */\n"+
328             " private java.util.List objs;\n"+
329             "}\n");
330         addClass(
331             "test.B",
332             "package test;\n"+
333             "/** @ojb.class */\n"+
334             "public class B {\n"+
335             " /** @ojb.field primarykey=\"true\" */\n"+
336             " private int id;\n"+
337             " /** @ojb.field */\n"+
338             " private int aid;\n"+
339             "}\n");
340         addClass(
341             "test.C",
342             "package test;\n"+
343             "public class C extends A {}\n");
344         addClass(
345             "test.D",
346             "package test;\n"+
347             "/** @ojb.class\n"+
348             " * @ojb.modify-inherited name=\"objs\"\n"+
349             " * orderby=\"id=DESC\"\n"+
350             " */\n"+
351             "public class D extends C {}\n");
352
353         assertEqualsOjbDescriptorFile(
354             "<class-descriptor\n"+
355             " class=\"test.A\"\n"+
356             " table=\"A\"\n"+
357             ">\n"+
358             " <extent-class class-ref=\"test.D\"/>\n"+
359             " <field-descriptor\n"+
360             " name=\"id\"\n"+
361             " column=\"id\"\n"+
362             " jdbc-type=\"INTEGER\"\n"+
363             " primarykey=\"true\"\n"+
364             " >\n"+
365             " </field-descriptor>\n"+
366             " <collection-descriptor\n"+
367             " name=\"objs\"\n"+
368             " element-class-ref=\"test.B\"\n"+
369             " >\n"+
370             " <inverse-foreignkey field-ref=\"aid\"/>\n"+
371             " </collection-descriptor>\n"+
372             "</class-descriptor>\n"+
373             "<class-descriptor\n"+
374             " class=\"test.B\"\n"+
375             " table=\"B\"\n"+
376             ">\n"+
377             " <field-descriptor\n"+
378             " name=\"id\"\n"+
379             " column=\"id\"\n"+
380             " jdbc-type=\"INTEGER\"\n"+
381             " primarykey=\"true\"\n"+
382             " >\n"+
383             " </field-descriptor>\n"+
384             " <field-descriptor\n"+
385             " name=\"aid\"\n"+
386             " column=\"aid\"\n"+
387             " jdbc-type=\"INTEGER\"\n"+
388             " >\n"+
389             " </field-descriptor>\n"+
390             "</class-descriptor>\n"+
391             "<class-descriptor\n"+
392             " class=\"test.D\"\n"+
393             " table=\"D\"\n"+
394             ">\n"+
395             " <field-descriptor\n"+
396             " name=\"id\"\n"+
397             " column=\"id\"\n"+
398             " jdbc-type=\"INTEGER\"\n"+
399             " primarykey=\"true\"\n"+
400             " >\n"+
401             " </field-descriptor>\n"+
402             " <collection-descriptor\n"+
403             " name=\"objs\"\n"+
404             " element-class-ref=\"test.B\"\n"+
405             " >\n"+
406             " <orderby name=\"id\" sort=\"DESC\"/>\n"+
407             " <inverse-foreignkey field-ref=\"aid\"/>\n"+
408             " </collection-descriptor>\n"+
409             "</class-descriptor>",
410             runOjbXDoclet(OJB_DEST_FILE));
411         assertEqualsTorqueSchemaFile(
412             "<database name=\"ojbtest\">\n"+
413             " <table name=\"A\">\n"+
414             " <column name=\"id\"\n"+
415             " javaName=\"id\"\n"+
416             " type=\"INTEGER\"\n"+
417             " primaryKey=\"true\"\n"+
418             " required=\"true\"\n"+
419             " />\n"+
420             " </table>\n"+
421             " <table name=\"B\">\n"+
422             " <column name=\"id\"\n"+
423             " javaName=\"id\"\n"+
424             " type=\"INTEGER\"\n"+
425             " primaryKey=\"true\"\n"+
426             " required=\"true\"\n"+
427             " />\n"+
428             " <column name=\"aid\"\n"+
429             " javaName=\"aid\"\n"+
430             " type=\"INTEGER\"\n"+
431             " />\n"+
432             " </table>\n"+
433             " <table name=\"D\">\n"+
434             " <column name=\"id\"\n"+
435             " javaName=\"id\"\n"+
436             " type=\"INTEGER\"\n"+
437             " primaryKey=\"true\"\n"+
438             " required=\"true\"\n"+
439             " />\n"+
440             " </table>\n"+
441             "</database>",
442             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
443     }
444
445     // Test: setting orderby attribute of inherited collection to unknown field
446
public void testOrderby4()
447     {
448         addClass(
449             "test.A",
450             "package test;\n"+
451             "/** @ojb.class */\n"+
452             "public class A {\n"+
453             " /** @ojb.field primarykey=\"true\" */\n"+
454             " private int id;\n"+
455             " /** @ojb.collection element-class-ref=\"test.B\"\n"+
456             " * foreignkey=\"aid\"\n"+
457             " */\n"+
458             " private java.util.List objs;\n"+
459             "}\n");
460         addClass(
461             "test.B",
462             "package test;\n"+
463             "/** @ojb.class */\n"+
464             "public class B {\n"+
465             " /** @ojb.field */\n"+
466             " private int aid;\n"+
467             "}\n");
468         addClass(
469             "test.C",
470             "package test;\n"+
471             "/** @ojb.class\n"+
472             " * @ojb.modify-inherited name=\"objs\"\n"+
473             " * orderby=\"id=DESC\"\n"+
474             " */\n"+
475             "public class C extends A {}\n");
476
477         assertNull(runOjbXDoclet(OJB_DEST_FILE));
478         assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
479     }
480
481     // Test: setting orderby attribute of inherited collection to invalid sorting order
482
public void testOrderby5()
483     {
484         addClass(
485             "test.A",
486             "package test;\n"+
487             "/** @ojb.class */\n"+
488             "public class A {\n"+
489             " /** @ojb.field primarykey=\"true\" */\n"+
490             " private int id;\n"+
491             " /** @ojb.collection element-class-ref=\"test.B\"\n"+
492             " * foreignkey=\"aid\"\n"+
493             " */\n"+
494             " private java.util.List objs;\n"+
495             "}\n");
496         addClass(
497             "test.B",
498             "package test;\n"+
499             "/** @ojb.class */\n"+
500             "public class B {\n"+
501             " /** @ojb.field primarykey=\"true\" */\n"+
502             " private int id;\n"+
503             " /** @ojb.field */\n"+
504             " private int aid;\n"+
505             "}\n");
506         addClass(
507             "test.C",
508             "package test;\n"+
509             "/** @ojb.class\n"+
510             " * @ojb.modify-inherited name=\"objs\"\n"+
511             " * orderby=\"id=UNORDERED\"\n"+
512             " */\n"+
513             "public class C extends A {}\n");
514
515         assertNull(runOjbXDoclet(OJB_DEST_FILE));
516         assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
517     }
518
519     // Test: setting orderby attribute (multiple values) of inherited collection
520
public void testOrderby6()
521     {
522         addClass(
523             "test.A",
524             "package test;\n"+
525             "/** @ojb.class */\n"+
526             "public class A {\n"+
527             " /** @ojb.field primarykey=\"true\" */\n"+
528             " private int id;\n"+
529             " /** @ojb.collection element-class-ref=\"test.B\"\n"+
530             " * foreignkey=\"aid\"\n"+
531             " * database-foreignkey=\"false\"\n"+
532             " */\n"+
533             " private java.util.List objs;\n"+
534             "}\n");
535         addClass(
536             "test.B",
537             "package test;\n"+
538             "/** @ojb.class */\n"+
539             "public class B {\n"+
540             " /** @ojb.field primarykey=\"true\" */\n"+
541             " private int id;\n"+
542             " /** @ojb.field */\n"+
543             " private String val1;\n"+
544             " /** @ojb.field */\n"+
545             " private java.util.Date val2;\n"+
546             " /** @ojb.field */\n"+
547             " private int aid;\n"+
548             "}\n");
549         addClass(
550             "test.C",
551             "package test;\n"+
552             "/** @ojb.class\n"+
553             " * @ojb.modify-inherited name=\"objs\"\n"+
554             " * orderby=\"val1=DESC,val2=,id=ASC\"\n"+
555             " */\n"+
556             "public class C extends A {}\n");
557         addClass(
558             "test.D",
559             "package test;\n"+
560             "/** @ojb.class */\n"+
561             "public class D extends C {}\n");
562
563         assertEqualsOjbDescriptorFile(
564             "<class-descriptor\n"+
565             " class=\"test.A\"\n"+
566             " table=\"A\"\n"+
567             ">\n"+
568             " <extent-class class-ref=\"test.C\"/>\n"+
569             " <field-descriptor\n"+
570             " name=\"id\"\n"+
571             " column=\"id\"\n"+
572             " jdbc-type=\"INTEGER\"\n"+
573             " primarykey=\"true\"\n"+
574             " >\n"+
575             " </field-descriptor>\n"+
576             " <collection-descriptor\n"+
577             " name=\"objs\"\n"+
578             " element-class-ref=\"test.B\"\n"+
579             " >\n"+
580             " <inverse-foreignkey field-ref=\"aid\"/>\n"+
581             " </collection-descriptor>\n"+
582             "</class-descriptor>\n"+
583             "<class-descriptor\n"+
584             " class=\"test.B\"\n"+
585             " table=\"B\"\n"+
586             ">\n"+
587             " <field-descriptor\n"+
588             " name=\"id\"\n"+
589             " column=\"id\"\n"+
590             " jdbc-type=\"INTEGER\"\n"+
591             " primarykey=\"true\"\n"+
592             " >\n"+
593             " </field-descriptor>\n"+
594             " <field-descriptor\n"+
595             " name=\"val1\"\n"+
596             " column=\"val1\"\n"+
597             " jdbc-type=\"VARCHAR\"\n"+
598             " length=\"254\"\n"+
599             " >\n"+
600             " </field-descriptor>\n"+
601             " <field-descriptor\n"+
602             " name=\"val2\"\n"+
603             " column=\"val2\"\n"+
604             " jdbc-type=\"DATE\"\n"+
605             " >\n"+
606             " </field-descriptor>\n"+
607             " <field-descriptor\n"+
608             " name=\"aid\"\n"+
609             " column=\"aid\"\n"+
610             " jdbc-type=\"INTEGER\"\n"+
611             " >\n"+
612             " </field-descriptor>\n"+
613             "</class-descriptor>\n"+
614             "<class-descriptor\n"+
615             " class=\"test.C\"\n"+
616             " table=\"C\"\n"+
617             ">\n"+
618             " <extent-class class-ref=\"test.D\"/>\n"+
619             " <field-descriptor\n"+
620             " name=\"id\"\n"+
621             " column=\"id\"\n"+
622             " jdbc-type=\"INTEGER\"\n"+
623             " primarykey=\"true\"\n"+
624             " >\n"+
625             " </field-descriptor>\n"+
626             " <collection-descriptor\n"+
627             " name=\"objs\"\n"+
628             " element-class-ref=\"test.B\"\n"+
629             " >\n"+
630             " <orderby name=\"val1\" sort=\"DESC\"/>\n"+
631             " <orderby name=\"val2\" sort=\"ASC\"/>\n"+
632             " <orderby name=\"id\" sort=\"ASC\"/>\n"+
633             " <inverse-foreignkey field-ref=\"aid\"/>\n"+
634             " </collection-descriptor>\n"+
635             "</class-descriptor>\n"+
636             "<class-descriptor\n"+
637             " class=\"test.D\"\n"+
638             " table=\"D\"\n"+
639             ">\n"+
640             " <field-descriptor\n"+
641             " name=\"id\"\n"+
642             " column=\"id\"\n"+
643             " jdbc-type=\"INTEGER\"\n"+
644             " primarykey=\"true\"\n"+
645             " >\n"+
646             " </field-descriptor>\n"+
647             " <collection-descriptor\n"+
648             " name=\"objs\"\n"+
649             " element-class-ref=\"test.B\"\n"+
650             " >\n"+
651             " <orderby name=\"val1\" sort=\"DESC\"/>\n"+
652             " <orderby name=\"val2\" sort=\"ASC\"/>\n"+
653             " <orderby name=\"id\" sort=\"ASC\"/>\n"+
654             " <inverse-foreignkey field-ref=\"aid\"/>\n"+
655             " </collection-descriptor>\n"+
656             "</class-descriptor>",
657             runOjbXDoclet(OJB_DEST_FILE));
658         assertEqualsTorqueSchemaFile(
659             "<database name=\"ojbtest\">\n"+
660             " <table name=\"A\">\n"+
661             " <column name=\"id\"\n"+
662             " javaName=\"id\"\n"+
663             " type=\"INTEGER\"\n"+
664             " primaryKey=\"true\"\n"+
665             " required=\"true\"\n"+
666             " />\n"+
667             " </table>\n"+
668             " <table name=\"B\">\n"+
669             " <column name=\"id\"\n"+
670             " javaName=\"id\"\n"+
671             " type=\"INTEGER\"\n"+
672             " primaryKey=\"true\"\n"+
673             " required=\"true\"\n"+
674             " />\n"+
675             " <column name=\"val1\"\n"+
676             " javaName=\"val1\"\n"+
677             " type=\"VARCHAR\"\n"+
678             " size=\"254\"\n"+
679             " />\n"+
680             " <column name=\"val2\"\n"+
681             " javaName=\"val2\"\n"+
682             " type=\"DATE\"\n"+
683             " />\n"+
684             " <column name=\"aid\"\n"+
685             " javaName=\"aid\"\n"+
686             " type=\"INTEGER\"\n"+
687             " />\n"+
688             " </table>\n"+
689             " <table name=\"C\">\n"+
690             " <column name=\"id\"\n"+
691             " javaName=\"id\"\n"+
692             " type=\"INTEGER\"\n"+
693             " primaryKey=\"true\"\n"+
694             " required=\"true\"\n"+
695             " />\n"+
696             " </table>\n"+
697             " <table name=\"D\">\n"+
698             " <column name=\"id\"\n"+
699             " javaName=\"id\"\n"+
700             " type=\"INTEGER\"\n"+
701             " primaryKey=\"true\"\n"+
702             " required=\"true\"\n"+
703             " />\n"+
704             " </table>\n"+
705             "</database>",
706             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
707     }
708
709     // Test: setting orderby attribute of inherited collection to multiple values, one refering to non-persistent field
710
public void testOrderby7()
711     {
712         addClass(
713             "test.A",
714             "package test;\n"+
715             "/** @ojb.class */\n"+
716             "public class A {\n"+
717             " /** @ojb.field primarykey=\"true\" */\n"+
718             " private int id;\n"+
719             " /** @ojb.collection element-class-ref=\"test.B\"\n"+
720             " * foreignkey=\"aid\"\n"+
721             " */\n"+
722             " private java.util.List objs;\n"+
723             "}\n");
724         addClass(
725             "test.B",
726             "package test;\n"+
727             "/** @ojb.class */\n"+
728             "public class B {\n"+
729             " /** @ojb.field primarykey=\"true\" */\n"+
730             " private int id;\n"+
731             " private String val1;\n"+
732             " /** @ojb.field */\n"+
733             " private java.util.Date val2;\n"+
734             " /** @ojb.field */\n"+
735             " private int aid;\n"+
736             "}\n");
737         addClass(
738             "test.C",
739             "package test;\n"+
740             "/** @ojb.class\n"+
741             " * @ojb.modify-inherited name=\"objs\"\n"+
742             " * orderby=\"val1=DESC,val2=,id=ASC\"\n"+
743             " */\n"+
744             "public class C extends A {}\n");
745
746         assertNull(runOjbXDoclet(OJB_DEST_FILE));
747         assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
748     }
749
750     // Test: setting orderby attribute of inherited collection to multiple values, one with invalid sorting order
751
public void testOrderby8()
752     {
753         addClass(
754             "test.A",
755             "package test;\n"+
756             "/** @ojb.class */\n"+
757             "public class A {\n"+
758             " /** @ojb.field primarykey=\"true\" */\n"+
759             " private int id;\n"+
760             " /** @ojb.collection element-class-ref=\"test.B\"\n"+
761             " * foreignkey=\"aid\"\n"+
762             " */\n"+
763             " private java.util.List objs;\n"+
764             "}\n");
765         addClass(
766             "test.B",
767             "package test;\n"+
768             "/** @ojb.class */\n"+
769             "public class B {\n"+
770             " /** @ojb.field primarykey=\"true\" */\n"+
771             " private int id;\n"+
772             " /** @ojb.field */\n"+
773             " private String val1;\n"+
774             " /** @ojb.field */\n"+
775             " private java.util.Date val2;\n"+
776             " /** @ojb.field */\n"+
777             " private int aid;\n"+
778             "}\n");
779         addClass(
780             "test.C",
781             "package test;\n"+
782             "/** @ojb.class\n"+
783             " * @ojb.modify-inherited name=\"objs\"\n"+
784             " * orderby=\"val1=DESC,val2=UNSORTED,id=ASC\"\n"+
785             " */\n"+
786             "public class C extends A {}\n");
787
788         assertNull(runOjbXDoclet(OJB_DEST_FILE));
789         assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
790     }
791
792     // Test: changing orderby attribute (single value) of inherited collection
793
public void testOrderby9()
794     {
795         addClass(
796             "test.A",
797             "package test;\n"+
798             "/** @ojb.class */\n"+
799             "public class A {\n"+
800             " /** @ojb.field primarykey=\"true\" */\n"+
801             " private int id;\n"+
802             " /** @ojb.collection element-class-ref=\"test.B\"\n"+
803             " * foreignkey=\"aid\"\n"+
804             " * orderby=\"id=DESC\"\n"+
805             " * database-foreignkey=\"false\"\n"+
806             " */\n"+
807             " private java.util.List objs;\n"+
808             "}\n");
809         addClass(
810             "test.B",
811             "package test;\n"+
812             "/** @ojb.class */\n"+
813             "public class B {\n"+
814             " /** @ojb.field primarykey=\"true\" */\n"+
815             " private int id;\n"+
816             " /** @ojb.field */\n"+
817             " private String val1;\n"+
818             " /** @ojb.field */\n"+
819             " private int aid;\n"+
820             "}\n");
821         addClass(
822             "test.C",
823             "package test;\n"+
824             "/** @ojb.class\n"+
825             " * @ojb.modify-inherited name=\"objs\"\n"+
826             " * orderby=\"val1\"\n"+
827             " */\n"+
828             "public class C extends A {}\n");
829
830         assertEqualsOjbDescriptorFile(
831             "<class-descriptor\n"+
832             " class=\"test.A\"\n"+
833             " table=\"A\"\n"+
834             ">\n"+
835             " <extent-class class-ref=\"test.C\"/>\n"+
836             " <field-descriptor\n"+
837             " name=\"id\"\n"+
838             " column=\"id\"\n"+
839             " jdbc-type=\"INTEGER\"\n"+
840             " primarykey=\"true\"\n"+
841             " >\n"+
842             " </field-descriptor>\n"+
843             " <collection-descriptor\n"+
844             " name=\"objs\"\n"+
845             " element-class-ref=\"test.B\"\n"+
846             " >\n"+
847             " <orderby name=\"id\" sort=\"DESC\"/>\n"+
848             " <inverse-foreignkey field-ref=\"aid\"/>\n"+
849             " </collection-descriptor>\n"+
850             "</class-descriptor>\n"+
851             "<class-descriptor\n"+
852             " class=\"test.B\"\n"+
853             " table=\"B\"\n"+
854             ">\n"+
855             " <field-descriptor\n"+
856             " name=\"id\"\n"+
857             " column=\"id\"\n"+
858             " jdbc-type=\"INTEGER\"\n"+
859             " primarykey=\"true\"\n"+
860             " >\n"+
861             " </field-descriptor>\n"+
862             " <field-descriptor\n"+
863             " name=\"val1\"\n"+
864             " column=\"val1\"\n"+
865             " jdbc-type=\"VARCHAR\"\n"+
866             " length=\"254\"\n"+
867             " >\n"+
868             " </field-descriptor>\n"+
869             " <field-descriptor\n"+
870             " name=\"aid\"\n"+
871             " column=\"aid\"\n"+
872             " jdbc-type=\"INTEGER\"\n"+
873             " >\n"+
874             " </field-descriptor>\n"+
875             "</class-descriptor>\n"+
876             "<class-descriptor\n"+
877             " class=\"test.C\"\n"+
878             " table=\"C\"\n"+
879             ">\n"+
880             " <field-descriptor\n"+
881             " name=\"id\"\n"+
882             " column=\"id\"\n"+
883             " jdbc-type=\"INTEGER\"\n"+
884             " primarykey=\"true\"\n"+
885             " >\n"+
886             " </field-descriptor>\n"+
887             " <collection-descriptor\n"+
888             " name=\"objs\"\n"+
889             " element-class-ref=\"test.B\"\n"+
890             " >\n"+
891             " <orderby name=\"val1\" sort=\"ASC\"/>\n"+
892             " <inverse-foreignkey field-ref=\"aid\"/>\n"+
893             " </collection-descriptor>\n"+
894             "</class-descriptor>",
895             runOjbXDoclet(OJB_DEST_FILE));
896         assertEqualsTorqueSchemaFile(
897             "<database name=\"ojbtest\">\n"+
898             " <table name=\"A\">\n"+
899             " <column name=\"id\"\n"+
900             " javaName=\"id\"\n"+
901             " type=\"INTEGER\"\n"+
902             " primaryKey=\"true\"\n"+
903             " required=\"true\"\n"+
904             " />\n"+
905             " </table>\n"+
906             " <table name=\"B\">\n"+
907             " <column name=\"id\"\n"+
908             " javaName=\"id\"\n"+
909             " type=\"INTEGER\"\n"+
910             " primaryKey=\"true\"\n"+
911             " required=\"true\"\n"+
912             " />\n"+
913             " <column name=\"val1\"\n"+
914             " javaName=\"val1\"\n"+
915             " type=\"VARCHAR\"\n"+
916             " size=\"254\"\n"+
917             " />\n"+
918             " <column name=\"aid\"\n"+
919             " javaName=\"aid\"\n"+
920             " type=\"INTEGER\"\n"+
921             " />\n"+
922             " </table>\n"+
923             " <table name=\"C\">\n"+
924             " <column name=\"id\"\n"+
925             " javaName=\"id\"\n"+
926             " type=\"INTEGER\"\n"+
927             " primaryKey=\"true\"\n"+
928             " required=\"true\"\n"+
929             " />\n"+
930             " </table>\n"+
931             "</database>",
932             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
933     }
934
935     // Test: changing orderby attribute (single value) of inherited collection to non-persistent field
936
public void testOrderby10()
937     {
938         addClass(
939             "test.A",
940             "package test;\n"+
941             "/** @ojb.class */\n"+
942             "public class A {\n"+
943             " /** @ojb.field primarykey=\"true\" */\n"+
944             " private int id;\n"+
945             " /** @ojb.collection element-class-ref=\"test.B\"\n"+
946             " * foreignkey=\"aid\"\n"+
947             " * orderby=\"id\"\n"+
948             " */\n"+
949             " private java.util.List objs;\n"+
950             "}\n");
951         addClass(
952             "test.B",
953             "package test;\n"+
954             "/** @ojb.class */\n"+
955             "public class B {\n"+
956             " /** @ojb.field primarykey=\"true\" */\n"+
957             " private int id;\n"+
958             " private String val1;\n"+
959             " /** @ojb.field */\n"+
960             " private int aid;\n"+
961             "}\n");
962         addClass(
963             "test.C",
964             "package test;\n"+
965             "/** @ojb.class\n"+
966             " * @ojb.modify-inherited name=\"objs\"\n"+
967             " * orderby=\"val1=DESC\"\n"+
968             " */\n"+
969             "public class C extends A {}\n");
970
971         assertNull(runOjbXDoclet(OJB_DEST_FILE));
972         assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
973     }
974
975     // Test: changing orderby attribute (single value) of inherited collection to multiple values
976
public void testOrderby11()
977     {
978         addClass(
979             "test.A",
980             "package test;\n"+
981             "/** @ojb.class */\n"+
982             "public class A {\n"+
983             " /** @ojb.field primarykey=\"true\" */\n"+
984             " private int id;\n"+
985             " /** @ojb.collection element-class-ref=\"test.B\"\n"+
986             " * foreignkey=\"aid\"\n"+
987             " * orderby=\"id=DESC\"\n"+
988             " * database-foreignkey=\"false\"\n"+
989             " */\n"+
990             " private java.util.List objs;\n"+
991             "}\n");
992         addClass(
993             "test.B",
994             "package test;\n"+
995             "/** @ojb.class */\n"+
996             "public class B {\n"+
997             " /** @ojb.field primarykey=\"true\" */\n"+
998             " private int id;\n"+
999             " /** @ojb.field */\n"+
1000            " private String val1;\n"+
1001            " /** @ojb.field */\n"+
1002            " private int aid;\n"+
1003            "}\n");
1004        addClass(
1005            "test.C",
1006            "package test;\n"+
1007            "/** @ojb.class\n"+
1008            " * @ojb.modify-inherited name=\"objs\"\n"+
1009            " * orderby=\"val1,id\"\n"+
1010            " */\n"+
1011            "public class C extends A {}\n");
1012
1013        assertEqualsOjbDescriptorFile(
1014            "<class-descriptor\n"+
1015            " class=\"test.A\"\n"+
1016            " table=\"A\"\n"+
1017            ">\n"+
1018            " <extent-class class-ref=\"test.C\"/>\n"+
1019            " <field-descriptor\n"+
1020            " name=\"id\"\n"+
1021            " column=\"id\"\n"+
1022            " jdbc-type=\"INTEGER\"\n"+
1023            " primarykey=\"true\"\n"+
1024            " >\n"+
1025            " </field-descriptor>\n"+
1026            " <collection-descriptor\n"+
1027            " name=\"objs\"\n"+
1028            " element-class-ref=\"test.B\"\n"+
1029            " >\n"+
1030            " <orderby name=\"id\" sort=\"DESC\"/>\n"+
1031            " <inverse-foreignkey field-ref=\"aid\"/>\n"+
1032            " </collection-descriptor>\n"+
1033            "</class-descriptor>\n"+
1034            "<class-descriptor\n"+
1035            " class=\"test.B\"\n"+
1036            " table=\"B\"\n"+
1037            ">\n"+
1038            " <field-descriptor\n"+
1039            " name=\"id\"\n"+
1040            " column=\"id\"\n"+
1041            " jdbc-type=\"INTEGER\"\n"+
1042            " primarykey=\"true\"\n"+
1043            " >\n"+
1044            " </field-descriptor>\n"+
1045            " <field-descriptor\n"+
1046            " name=\"val1\"\n"+
1047            " column=\"val1\"\n"+
1048            " jdbc-type=\"VARCHAR\"\n"+
1049            " length=\"254\"\n"+
1050            " >\n"+
1051            " </field-descriptor>\n"+
1052            " <field-descriptor\n"+
1053            " name=\"aid\"\n"+
1054            " column=\"aid\"\n"+
1055            " jdbc-type=\"INTEGER\"\n"+
1056            " >\n"+
1057            " </field-descriptor>\n"+
1058            "</class-descriptor>\n"+
1059            "<class-descriptor\n"+
1060            " class=\"test.C\"\n"+
1061            " table=\"C\"\n"+
1062            ">\n"+
1063            " <field-descriptor\n"+
1064            " name=\"id\"\n"+
1065            " column=\"id\"\n"+
1066            " jdbc-type=\"INTEGER\"\n"+
1067            " primarykey=\"true\"\n"+
1068            " >\n"+
1069            " </field-descriptor>\n"+
1070            " <collection-descriptor\n"+
1071            " name=\"objs\"\n"+
1072            " element-class-ref=\"test.B\"\n"+
1073            " >\n"+
1074            " <orderby name=\"val1\" sort=\"ASC\"/>\n"+
1075            " <orderby name=\"id\" sort=\"ASC\"/>\n"+
1076            " <inverse-foreignkey field-ref=\"aid\"/>\n"+
1077            " </collection-descriptor>\n"+
1078            "</class-descriptor>",
1079            runOjbXDoclet(OJB_DEST_FILE));
1080        assertEqualsTorqueSchemaFile(
1081            "<database name=\"ojbtest\">\n"+
1082            " <table name=\"A\">\n"+
1083            " <column name=\"id\"\n"+
1084            " javaName=\"id\"\n"+
1085            " type=\"INTEGER\"\n"+
1086            " primaryKey=\"true\"\n"+
1087            " required=\"true\"\n"+
1088            " />\n"+
1089            " </table>\n"+
1090            " <table name=\"B\">\n"+
1091            " <column name=\"id\"\n"+
1092            " javaName=\"id\"\n"+
1093            " type=\"INTEGER\"\n"+
1094            " primaryKey=\"true\"\n"+
1095            " required=\"true\"\n"+
1096            " />\n"+
1097            " <column name=\"val1\"\n"+
1098            " javaName=\"val1\"\n"+
1099            " type=\"VARCHAR\"\n"+
1100            " size=\"254\"\n"+
1101            " />\n"+
1102            " <column name=\"aid\"\n"+
1103            " javaName=\"aid\"\n"+
1104            " type=\"INTEGER\"\n"+
1105            " />\n"+
1106            " </table>\n"+
1107            " <table name=\"C\">\n"+
1108            " <column name=\"id\"\n"+
1109            " javaName=\"id\"\n"+
1110            " type=\"INTEGER\"\n"+
1111            " primaryKey=\"true\"\n"+
1112            " required=\"true\"\n"+
1113            " />\n"+
1114            " </table>\n"+
1115            "</database>",
1116            runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
1117    }
1118
1119    // Test: changing orderby attribute (multiple values) of inherited collection to single values
1120
public void testOrderby12()
1121    {
1122        addClass(
1123            "test.A",
1124            "package test;\n"+
1125            "/** @ojb.class */\n"+
1126            "public class A {\n"+
1127            " /** @ojb.field primarykey=\"true\" */\n"+
1128            " private int id;\n"+
1129            " /** @ojb.collection element-class-ref=\"test.B\"\n"+
1130            " * foreignkey=\"aid\"\n"+
1131            " * orderby=\"val1,id=DESC\"\n"+
1132            " * database-foreignkey=\"false\"\n"+
1133            " */\n"+
1134            " private java.util.List objs;\n"+
1135            "}\n");
1136        addClass(
1137            "test.B",
1138            "package test;\n"+
1139            "/** @ojb.class */\n"+
1140            "public class B {\n"+
1141            " /** @ojb.field primarykey=\"true\" */\n"+
1142            " private int id;\n"+
1143            " /** @ojb.field */\n"+
1144            " private String val1;\n"+
1145            " /** @ojb.field */\n"+
1146            " private int aid;\n"+
1147            "}\n");
1148        addClass(
1149            "test.C",
1150            "package test;\n"+
1151            "/** @ojb.class\n"+
1152            " * @ojb.modify-inherited name=\"objs\"\n"+
1153            " * orderby=\"val1=DESC\"\n"+
1154            " */\n"+
1155            "public class C extends A {}\n");
1156
1157        assertEqualsOjbDescriptorFile(
1158            "<class-descriptor\n"+
1159            " class=\"test.A\"\n"+
1160            " table=\"A\"\n"+
1161            ">\n"+
1162            " <extent-class class-ref=\"test.C\"/>\n"+
1163            " <field-descriptor\n"+
1164            " name=\"id\"\n"+
1165            " column=\"id\"\n"+
1166            " jdbc-type=\"INTEGER\"\n"+
1167            " primarykey=\"true\"\n"+
1168            " >\n"+
1169            " </field-descriptor>\n"+
1170            " <collection-descriptor\n"+
1171            " name=\"objs\"\n"+
1172            " element-class-ref=\"test.B\"\n"+
1173            " >\n"+
1174            " <orderby name=\"val1\" sort=\"ASC\"/>\n"+
1175            " <orderby name=\"id\" sort=\"DESC\"/>\n"+
1176            " <inverse-foreignkey field-ref=\"aid\"/>\n"+
1177            " </collection-descriptor>\n"+
1178            "</class-descriptor>\n"+
1179            "<class-descriptor\n"+
1180            " class=\"test.B\"\n"+
1181            " table=\"B\"\n"+
1182            ">\n"+
1183            " <field-descriptor\n"+
1184            " name=\"id\"\n"+
1185            " column=\"id\"\n"+
1186            " jdbc-type=\"INTEGER\"\n"+
1187            " primarykey=\"true\"\n"+
1188            " >\n"+
1189            " </field-descriptor>\n"+
1190            " <field-descriptor\n"+
1191            " name=\"val1\"\n"+
1192            " column=\"val1\"\n"+
1193            " jdbc-type=\"VARCHAR\"\n"+
1194            " length=\"254\"\n"+
1195            " >\n"+
1196            " </field-descriptor>\n"+
1197            " <field-descriptor\n"+
1198            " name=\"aid\"\n"+
1199            " column=\"aid\"\n"+
1200            " jdbc-type=\"INTEGER\"\n"+
1201            " >\n"+
1202            " </field-descriptor>\n"+
1203            "</class-descriptor>\n"+
1204            "<class-descriptor\n"+
1205            " class=\"test.C\"\n"+
1206            " table=\"C\"\n"+
1207            ">\n"+
1208            " <field-descriptor\n"+
1209            " name=\"id\"\n"+
1210            " column=\"id\"\n"+
1211            " jdbc-type=\"INTEGER\"\n"+
1212            " primarykey=\"true\"\n"+
1213            " >\n"+
1214            " </field-descriptor>\n"+
1215            " <collection-descriptor\n"+
1216            " name=\"objs\"\n"+
1217            " element-class-ref=\"test.B\"\n"+
1218            " >\n"+
1219            " <orderby name=\"val1\" sort=\"DESC\"/>\n"+
1220            " <inverse-foreignkey field-ref=\"aid\"/>\n"+
1221            " </collection-descriptor>\n"+
1222            "</class-descriptor>",
1223            runOjbXDoclet(OJB_DEST_FILE));
1224        assertEqualsTorqueSchemaFile(
1225            "<database name=\"ojbtest\">\n"+
1226            " <table name=\"A\">\n"+
1227            " <column name=\"id\"\n"+
1228            " javaName=\"id\"\n"+
1229            " type=\"INTEGER\"\n"+
1230            " primaryKey=\"true\"\n"+
1231            " required=\"true\"\n"+
1232            " />\n"+
1233            " </table>\n"+
1234            " <table name=\"B\">\n"+
1235            " <column name=\"id\"\n"+
1236            " javaName=\"id\"\n"+
1237            " type=\"INTEGER\"\n"+
1238            " primaryKey=\"true\"\n"+
1239            " required=\"true\"\n"+
1240            " />\n"+
1241            " <column name=\"val1\"\n"+
1242            " javaName=\"val1\"\n"+
1243            " type=\"VARCHAR\"\n"+
1244            " size=\"254\"\n"+
1245            " />\n"+
1246            " <column name=\"aid\"\n"+
1247            " javaName=\"aid\"\n"+
1248            " type=\"INTEGER\"\n"+
1249            " />\n"+
1250            " </table>\n"+
1251            " <table name=\"C\">\n"+
1252            " <column name=\"id\"\n"+
1253            " javaName=\"id\"\n"+
1254            " type=\"INTEGER\"\n"+
1255            " primaryKey=\"true\"\n"+
1256            " required=\"true\"\n"+
1257            " />\n"+
1258            " </table>\n"+
1259            "</database>",
1260            runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
1261    }
1262
1263    // Test: changing orderby attribute (multiple values) of inherited collection
1264
public void testOrderby13()
1265    {
1266        addClass(
1267            "test.A",
1268            "package test;\n"+
1269            "/** @ojb.class */\n"+
1270            "public class A {\n"+
1271            " /** @ojb.field primarykey=\"true\" */\n"+
1272            " private int id;\n"+
1273            " /** @ojb.collection element-class-ref=\"test.B\"\n"+
1274            " * foreignkey=\"aid\"\n"+
1275            " * orderby=\"val1,id=DESC\"\n"+
1276            " * database-foreignkey=\"false\"\n"+
1277            " */\n"+
1278            " private java.util.List objs;\n"+
1279            "}\n");
1280        addClass(
1281            "test.B",
1282            "package test;\n"+
1283            "/** @ojb.class */\n"+
1284            "public class B {\n"+
1285            " /** @ojb.field primarykey=\"true\" */\n"+
1286            " private int id;\n"+
1287            " /** @ojb.field */\n"+
1288            " private String val1;\n"+
1289            " /** @ojb.field */\n"+
1290            " private int aid;\n"+
1291            "}\n");
1292        addClass(
1293            "test.C",
1294            "package test;\n"+
1295            "/** @ojb.class\n"+
1296            " * @ojb.modify-inherited name=\"objs\"\n"+
1297            " * orderby=\"id,val1=DESC\"\n"+
1298            " */\n"+
1299            "public class C extends A {}\n");
1300
1301        assertEqualsOjbDescriptorFile(
1302            "<class-descriptor\n"+
1303            " class=\"test.A\"\n"+
1304            " table=\"A\"\n"+
1305            ">\n"+
1306            " <extent-class class-ref=\"test.C\"/>\n"+
1307            " <field-descriptor\n"+
1308            " name=\"id\"\n"+
1309            " column=\"id\"\n"+
1310            " jdbc-type=\"INTEGER\"\n"+
1311            " primarykey=\"true\"\n"+
1312            " >\n"+
1313            " </field-descriptor>\n"+
1314            " <collection-descriptor\n"+
1315            " name=\"objs\"\n"+
1316            " element-class-ref=\"test.B\"\n"+
1317            " >\n"+
1318            " <orderby name=\"val1\" sort=\"ASC\"/>\n"+
1319            " <orderby name=\"id\" sort=\"DESC\"/>\n"+
1320            " <inverse-foreignkey field-ref=\"aid\"/>\n"+
1321            " </collection-descriptor>\n"+
1322            "</class-descriptor>\n"+
1323            "<class-descriptor\n"+
1324            " class=\"test.B\"\n"+
1325            " table=\"B\"\n"+
1326            ">\n"+
1327            " <field-descriptor\n"+
1328            " name=\"id\"\n"+
1329            " column=\"id\"\n"+
1330            " jdbc-type=\"INTEGER\"\n"+
1331            " primarykey=\"true\"\n"+
1332            " >\n"+
1333            " </field-descriptor>\n"+
1334            " <field-descriptor\n"+
1335            " name=\"val1\"\n"+
1336            " column=\"val1\"\n"+
1337            " jdbc-type=\"VARCHAR\"\n"+
1338            " length=\"254\"\n"+
1339            " >\n"+
1340            " </field-descriptor>\n"+
1341            " <field-descriptor\n"+
1342            " name=\"aid\"\n"+
1343            " column=\"aid\"\n"+
1344            " jdbc-type=\"INTEGER\"\n"+
1345            " >\n"+
1346            " </field-descriptor>\n"+
1347            "</class-descriptor>\n"+
1348            "<class-descriptor\n"+
1349            " class=\"test.C\"\n"+
1350            " table=\"C\"\n"+
1351            ">\n"+
1352            " <field-descriptor\n"+
1353            " name=\"id\"\n"+
1354            " column=\"id\"\n"+
1355            " jdbc-type=\"INTEGER\"\n"+
1356            " primarykey=\"true\"\n"+
1357            " >\n"+
1358            " </field-descriptor>\n"+
1359            " <collection-descriptor\n"+
1360            " name=\"objs\"\n"+
1361            " element-class-ref=\"test.B\"\n"+
1362            " >\n"+
1363            " <orderby name=\"id\" sort=\"ASC\"/>\n"+
1364            " <orderby name=\"val1\" sort=\"DESC\"/>\n"+
1365            " <inverse-foreignkey field-ref=\"aid\"/>\n"+
1366            " </collection-descriptor>\n"+
1367            "</class-descriptor>",
1368            runOjbXDoclet(OJB_DEST_FILE));
1369        assertEqualsTorqueSchemaFile(
1370            "<database name=\"ojbtest\">\n"+
1371            " <table name=\"A\">\n"+
1372            " <column name=\"id\"\n"+
1373            " javaName=\"id\"\n"+
1374            " type=\"INTEGER\"\n"+
1375            " primaryKey=\"true\"\n"+
1376            " required=\"true\"\n"+
1377            " />\n"+
1378            " </table>\n"+
1379            " <table name=\"B\">\n"+
1380            " <column name=\"id\"\n"+
1381            " javaName=\"id\"\n"+
1382            " type=\"INTEGER\"\n"+
1383            " primaryKey=\"true\"\n"+
1384            " required=\"true\"\n"+
1385            " />\n"+
1386            " <column name=\"val1\"\n"+
1387            " javaName=\"val1\"\n"+
1388            " type=\"VARCHAR\"\n"+
1389            " size=\"254\"\n"+
1390            " />\n"+
1391            " <column name=\"aid\"\n"+
1392            " javaName=\"aid\"\n"+
1393            " type=\"INTEGER\"\n"+
1394            " />\n"+
1395            " </table>\n"+
1396            " <table name=\"C\">\n"+
1397            " <column name=\"id\"\n"+
1398            " javaName=\"id\"\n"+
1399            " type=\"INTEGER\"\n"+
1400            " primaryKey=\"true\"\n"+
1401            " required=\"true\"\n"+
1402            " />\n"+
1403            " </table>\n"+
1404            "</database>",
1405            runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
1406    }
1407
1408    // Test: changing orderby attribute (multiple values) of inherited collection where one value refers to unknown field
1409
public void testOrderby14()
1410    {
1411        addClass(
1412            "test.A",
1413            "package test;\n"+
1414            "/** @ojb.class */\n"+
1415            "public class A {\n"+
1416            " /** @ojb.field primarykey=\"true\" */\n"+
1417            " private int id;\n"+
1418            " /** @ojb.collection element-class-ref=\"test.B\"\n"+
1419            " * foreignkey=\"aid\"\n"+
1420            " * orderby=\"val1,id=DESC\"\n"+
1421            " */\n"+
1422            " private java.util.List objs;\n"+
1423            "}\n");
1424        addClass(
1425            "test.B",
1426            "package test;\n"+
1427            "/** @ojb.class */\n"+
1428            "public class B {\n"+
1429            " /** @ojb.field primarykey=\"true\" */\n"+
1430            " private int id;\n"+
1431            " /** @ojb.field */\n"+
1432            " private String val1;\n"+
1433            " /** @ojb.field */\n"+
1434            " private int aid;\n"+
1435            "}\n");
1436        addClass(
1437            "test.C",
1438            "package test;\n"+
1439            "/** @ojb.class\n"+
1440            " * @ojb.modify-inherited name=\"objs\"\n"+
1441            " * orderby=\"id,val2=DESC\"\n"+
1442            " */\n"+
1443            "public class C extends A {}\n");
1444
1445        assertNull(runOjbXDoclet(OJB_DEST_FILE));
1446        assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
1447    }
1448}
1449
Popular Tags