KickJava   Java API By Example, From Geeks To Geeks.

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


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

23 public class FieldTagDocumentationAttributeTests extends OjbTestBase
24 {
25     public FieldTagDocumentationAttributeTests(String JavaDoc name)
26     {
27         super(name);
28     }
29
30     // Test: documentation attribute with no value
31
public void testDocumentation1()
32     {
33         addClass(
34             "test.A",
35             "package test;\n"+
36             "/** @ojb.class */\n"+
37             "public class A {\n"+
38             "/** @ojb.field documentation=\"\" */\n"+
39             " private int attr;\n"+
40             "}\n");
41
42         assertEqualsOjbDescriptorFile(
43             "<class-descriptor\n"+
44             " class=\"test.A\"\n"+
45             " table=\"A\"\n"+
46             ">\n"+
47             " <field-descriptor\n"+
48             " name=\"attr\"\n"+
49             " column=\"attr\"\n"+
50             " jdbc-type=\"INTEGER\"\n"+
51             " >\n"+
52             " </field-descriptor>\n"+
53             "</class-descriptor>",
54             runOjbXDoclet(OJB_DEST_FILE));
55         assertEqualsTorqueSchemaFile(
56             "<database name=\"ojbtest\">\n"+
57             " <table name=\"A\">\n"+
58             " <column name=\"attr\"\n"+
59             " javaName=\"attr\"\n"+
60             " type=\"INTEGER\"\n"+
61             " />\n"+
62             " </table>\n"+
63             "</database>",
64             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
65     }
66
67     // Test: documentation attribute with value
68
public void testDocumentation2()
69     {
70         addClass(
71             "test.A",
72             "package test;\n"+
73             "/** @ojb.class */\n"+
74             "public class A {\n"+
75             "/** @ojb.field documentation=\"Some documentation\" */\n"+
76             " private int attr;\n"+
77             "}\n");
78
79         assertEqualsOjbDescriptorFile(
80             "<class-descriptor\n"+
81             " class=\"test.A\"\n"+
82             " table=\"A\"\n"+
83             ">\n"+
84             " <field-descriptor\n"+
85             " name=\"attr\"\n"+
86             " column=\"attr\"\n"+
87             " jdbc-type=\"INTEGER\"\n"+
88             " >\n"+
89             " <documentation>Some documentation</documentation>\n"+
90             " </field-descriptor>\n"+
91             "</class-descriptor>",
92             runOjbXDoclet(OJB_DEST_FILE));
93         assertEqualsTorqueSchemaFile(
94             "<database name=\"ojbtest\">\n"+
95             " <table name=\"A\">\n"+
96             " <column name=\"attr\"\n"+
97             " javaName=\"attr\"\n"+
98             " type=\"INTEGER\"\n"+
99             " description=\"Some documentation\""+
100             " />\n"+
101             " </table>\n"+
102             "</database>",
103             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
104     }
105
106     // Test: inherited documentation attribute with value
107
public void testDocumentation3()
108     {
109         addClass(
110             "test.A",
111             "package test;\n"+
112             "/** @ojb.class */\n"+
113             "public class A {\n"+
114             "/** @ojb.field documentation=\"Some documentation\" */\n"+
115             " private int attr;\n"+
116             "}\n");
117         addClass(
118             "test.B",
119             "package test;\n"+
120             "/** @ojb.class */\n"+
121             "public class B extends A {}\n");
122
123         assertEqualsOjbDescriptorFile(
124             "<class-descriptor\n"+
125             " class=\"test.A\"\n"+
126             " table=\"A\"\n"+
127             ">\n"+
128             " <extent-class class-ref=\"test.B\"/>\n"+
129             " <field-descriptor\n"+
130             " name=\"attr\"\n"+
131             " column=\"attr\"\n"+
132             " jdbc-type=\"INTEGER\"\n"+
133             " >\n"+
134             " <documentation>Some documentation</documentation>\n"+
135             " </field-descriptor>\n"+
136             "</class-descriptor>\n"+
137             "<class-descriptor\n"+
138             " class=\"test.B\"\n"+
139             " table=\"B\"\n"+
140             ">\n"+
141             " <field-descriptor\n"+
142             " name=\"attr\"\n"+
143             " column=\"attr\"\n"+
144             " jdbc-type=\"INTEGER\"\n"+
145             " >\n"+
146             " <documentation>Some documentation</documentation>\n"+
147             " </field-descriptor>\n"+
148             "</class-descriptor>",
149             runOjbXDoclet(OJB_DEST_FILE));
150         assertEqualsTorqueSchemaFile(
151             "<database name=\"ojbtest\">\n"+
152             " <table name=\"A\">\n"+
153             " <column name=\"attr\"\n"+
154             " javaName=\"attr\"\n"+
155             " type=\"INTEGER\"\n"+
156             " description=\"Some documentation\""+
157             " />\n"+
158             " </table>\n"+
159             " <table name=\"B\">\n"+
160             " <column name=\"attr\"\n"+
161             " javaName=\"attr\"\n"+
162             " type=\"INTEGER\"\n"+
163             " description=\"Some documentation\""+
164             " />\n"+
165             " </table>\n"+
166             "</database>",
167             runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest"));
168     }
169 }
170
Popular Tags