KickJava   Java API By Example, From Geeks To Geeks.

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


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

23 public class ClassTagSimpleTests extends OjbTestBase
24 {
25     public ClassTagSimpleTests(String JavaDoc name)
26     {
27         super(name);
28     }
29
30     // Basic test: no attributes, no sub- or baseclass
31
public void testSimple1()
32     {
33         addClass(
34             "test.A",
35             "package test;\n"+
36             "/** @ojb.class */\n"+
37             "public class A {}\n");
38
39         assertEqualsOjbDescriptorFile(
40             "<class-descriptor\n"+
41             " class=\"test.A\"\n"+
42             " table=\"A\"\n"+
43             ">\n"+
44             "</class-descriptor>",
45             runOjbXDoclet(OJB_DEST_FILE));
46         assertEqualsTorqueSchemaFile(
47             "<database name=\"ojbtest\">\n"+
48             " <table name=\"A\">\n"+
49             " </table>\n"+
50             "</database>",
51             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
52     }
53
54     // Basic test: no attributes, one direct baseclass
55
public void testSimple2()
56     {
57         addClass(
58             "test.A",
59             "package test;\n"+
60             "/** @ojb.class */\n"+
61             "public class A {}\n");
62         addClass(
63             "test.B",
64             "package test;\n"+
65             "/** @ojb.class */\n"+
66             "public class B extends A {}\n");
67
68         assertEqualsOjbDescriptorFile(
69             "<class-descriptor\n"+
70             " class=\"test.A\"\n"+
71             " table=\"A\"\n"+
72             ">\n"+
73             " <extent-class class-ref=\"test.B\"/>\n"+
74             "</class-descriptor>\n"+
75             "<class-descriptor\n"+
76             " class=\"test.B\"\n"+
77             " table=\"B\"\n"+
78             ">\n"+
79             "</class-descriptor>",
80             runOjbXDoclet(OJB_DEST_FILE));
81         assertEqualsTorqueSchemaFile(
82             "<database name=\"ojbtest\">\n"+
83             " <table name=\"A\">\n"+
84             " </table>\n"+
85             " <table name=\"B\">\n"+
86             " </table>\n"+
87             "</database>",
88             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
89     }
90
91     // Basic test: no attributes, two indirect, related baseclasses
92
public void testSimple3()
93     {
94         addClass(
95             "test.A",
96             "package test;\n"+
97             "/** @ojb.class */\n"+
98             "public class A {}\n");
99         addClass(
100             "test.B",
101             "package test;\n"+
102             "public class B extends A {}\n");
103         addClass(
104             "test.C",
105             "package test;\n"+
106             "/** @ojb.class */\n"+
107             "public class C extends B {}\n");
108         addClass(
109             "test.D",
110             "package test;\n"+
111             "public class D extends C {}\n");
112         addClass(
113             "test.E",
114             "package test;\n"+
115             "/** @ojb.class */\n"+
116             "public class E extends D {}\n");
117
118         assertEqualsOjbDescriptorFile(
119             "<class-descriptor\n"+
120             " class=\"test.A\"\n"+
121             " table=\"A\"\n"+
122             ">\n"+
123             " <extent-class class-ref=\"test.C\"/>\n"+
124             "</class-descriptor>\n"+
125             "<class-descriptor\n"+
126             " class=\"test.C\"\n"+
127             " table=\"C\"\n"+
128             ">\n"+
129             " <extent-class class-ref=\"test.E\"/>\n"+
130             "</class-descriptor>\n"+
131             "<class-descriptor\n"+
132             " class=\"test.E\"\n"+
133             " table=\"E\"\n"+
134             ">\n"+
135             "</class-descriptor>",
136             runOjbXDoclet(OJB_DEST_FILE));
137         assertEqualsTorqueSchemaFile(
138             "<database name=\"ojbtest\">\n"+
139             " <table name=\"A\">\n"+
140             " </table>\n"+
141             " <table name=\"C\">\n"+
142             " </table>\n"+
143             " <table name=\"E\">\n"+
144             " </table>\n"+
145             "</database>",
146             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
147     }
148
149     // Basic test: no attributes, three classes with one a nested class
150
public void testSimple4()
151     {
152         addClass(
153             "test.A",
154             "package test;\n"+
155             "/** @ojb.class */\n"+
156             "public class A {}\n");
157         addClass(
158             "test.B",
159             "package test;\n"+
160             "public class B {\n"+
161             " /** @ojb.class */\n"+
162             " public static class Nested extends A {}\n"+
163             "}\n");
164         addClass(
165             "test.C",
166             "package test;\n"+
167             "/** @ojb.class */\n"+
168             "public class C extends test.B.Nested {}\n");
169
170         assertEqualsOjbDescriptorFile(
171             "<class-descriptor\n"+
172             " class=\"test.A\"\n"+
173             " table=\"A\"\n"+
174             ">\n"+
175             " <extent-class class-ref=\"test.B$Nested\"/>\n"+
176             "</class-descriptor>\n"+
177             "<class-descriptor\n"+
178             " class=\"test.B$Nested\"\n"+
179             " table=\"Nested\"\n"+
180             ">\n"+
181             " <extent-class class-ref=\"test.C\"/>\n"+
182             "</class-descriptor>\n"+
183             "<class-descriptor\n"+
184             " class=\"test.C\"\n"+
185             " table=\"C\"\n"+
186             ">\n"+
187             "</class-descriptor>",
188             runOjbXDoclet(OJB_DEST_FILE));
189         assertEqualsTorqueSchemaFile(
190             "<database name=\"ojbtest\">\n"+
191             " <table name=\"A\">\n"+
192             " </table>\n"+
193             " <table name=\"C\">\n"+
194             " </table>\n"+
195             " <table name=\"Nested\">\n"+
196             " </table>\n"+
197             "</database>",
198             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
199     }
200 }
201
Popular Tags