KickJava   Java API By Example, From Geeks To Geeks.

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


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

23 public class AnonymousReferenceTagTests extends OjbTestBase
24 {
25     public AnonymousReferenceTagTests(String JavaDoc name)
26     {
27         super(name);
28     }
29
30     /**
31      * Test: one baseclass, one subclass, super-reference with anonymous field for the foreignkey
32      */

33     public void testSimple()
34     {
35         addClass(
36             "test.A",
37             "package test;\n"+
38             "/** @ojb.class */\n" +
39             "public class A {\n"+
40             " /** @ojb.field primarykey=\"true\" */\n"+
41             " private int id;\n"+
42             "}\n");
43         addClass(
44             "test.B",
45             "package test;\n"+
46             "/** @ojb.class\n" +
47             " * @ojb.field name=\"aid\"\n"+
48             " * jdbc-type=\"INTEGER\"\n"+
49             " * @ojb.reference class-ref=\"test.A\"\n"+
50             " * auto-retrieve=\"true\"\n"+
51             " * auto-update=\"true\"\n"+
52             " * auto-delete=\"true\"\n"+
53             " * foreignkey=\"aid\"\n"+
54             " */\n"+
55             "public class B extends A {}\n");
56         addClass(
57             "test.C",
58             "package test;\n"+
59             "/** @ojb.class */\n"+
60             "public class C extends B {}\n");
61
62         assertEqualsOjbDescriptorFile(
63             "<class-descriptor\n"+
64             " class=\"test.A\"\n"+
65             " table=\"A\"\n"+
66             ">\n"+
67             " <extent-class class-ref=\"test.B\"/>\n"+
68             " <field-descriptor\n"+
69             " name=\"id\"\n"+
70             " column=\"id\"\n"+
71             " jdbc-type=\"INTEGER\"\n"+
72             " primarykey=\"true\"\n"+
73             " >\n"+
74             " </field-descriptor>\n"+
75             "</class-descriptor>\n"+
76             "<class-descriptor\n"+
77             " class=\"test.B\"\n"+
78             " table=\"B\"\n"+
79             ">\n"+
80             " <extent-class class-ref=\"test.C\"/>\n"+
81             " <field-descriptor\n"+
82             " name=\"id\"\n"+
83             " column=\"id\"\n"+
84             " jdbc-type=\"INTEGER\"\n"+
85             " primarykey=\"true\"\n"+
86             " >\n"+
87             " </field-descriptor>\n"+
88             " <field-descriptor\n"+
89             " name=\"aid\"\n"+
90             " column=\"aid\"\n"+
91             " jdbc-type=\"INTEGER\"\n"+
92             " access=\"anonymous\"\n"+
93             " >\n"+
94             " </field-descriptor>\n"+
95             " <reference-descriptor\n"+
96             " name=\"super\"\n"+
97             " class-ref=\"test.A\"\n"+
98             " auto-retrieve=\"true\"\n"+
99             " auto-update=\"true\"\n"+
100             " auto-delete=\"true\"\n"+
101             " >\n"+
102             " <foreignkey field-ref=\"aid\"/>\n"+
103             " </reference-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             " <field-descriptor\n"+
117             " name=\"aid\"\n"+
118             " column=\"aid\"\n"+
119             " jdbc-type=\"INTEGER\"\n"+
120             " access=\"anonymous\"\n"+
121             " >\n"+
122             " </field-descriptor>\n"+
123             "</class-descriptor>",
124             runOjbXDoclet(OJB_DEST_FILE));
125         assertEqualsTorqueSchemaFile(
126             "<database name=\"ojbtest\">\n"+
127             " <table name=\"A\">\n"+
128             " <column name=\"id\"\n"+
129             " javaName=\"id\"\n"+
130             " type=\"INTEGER\"\n"+
131             " primaryKey=\"true\"\n"+
132             " required=\"true\"\n"+
133             " />\n"+
134             " </table>\n"+
135             " <table name=\"B\">\n"+
136             " <column name=\"id\"\n"+
137             " javaName=\"id\"\n"+
138             " type=\"INTEGER\"\n"+
139             " primaryKey=\"true\"\n"+
140             " required=\"true\"\n"+
141             " />\n"+
142             " <column name=\"aid\"\n"+
143             " javaName=\"aid\"\n"+
144             " type=\"INTEGER\"\n"+
145             " />\n"+
146             " <foreign-key foreignTable=\"A\">\n"+
147             " <reference local=\"aid\" foreign=\"id\"/>\n"+
148             " </foreign-key>\n"+
149             " </table>\n"+
150             " <table name=\"C\">\n"+
151             " <column name=\"id\"\n"+
152             " javaName=\"id\"\n"+
153             " type=\"INTEGER\"\n"+
154             " primaryKey=\"true\"\n"+
155             " required=\"true\"\n"+
156             " />\n"+
157             " <column name=\"aid\"\n"+
158             " javaName=\"aid\"\n"+
159             " type=\"INTEGER\"\n"+
160             " />\n"+
161             " </table>\n"+
162             "</database>",
163             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
164     }
165 }
166
Popular Tags