1 package xdoclet.modules.ojb.tests; 2 3 17 18 23 public class ClassTagTableDocumentationAttributeTests extends OjbTestBase 24 { 25 public ClassTagTableDocumentationAttributeTests(String name) 26 { 27 super(name); 28 } 29 30 public void testDocumentation1() 32 { 33 addClass( 34 "test.A", 35 "package test;\n"+ 36 "/** @ojb.class table-documentation=\"\" */\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 public void testDocumentation2() 56 { 57 addClass( 58 "test.A", 59 "package test;\n"+ 60 "/** @ojb.class table-documentation=\"some documentation\" */\n"+ 61 "public class A {}\n"); 62 63 assertEqualsOjbDescriptorFile( 64 "<class-descriptor\n"+ 65 " class=\"test.A\"\n"+ 66 " table=\"A\"\n"+ 67 ">\n"+ 68 "</class-descriptor>", 69 runOjbXDoclet(OJB_DEST_FILE)); 70 assertEqualsTorqueSchemaFile( 71 "<database name=\"ojbtest\">\n"+ 72 " <table name=\"A\"\n"+ 73 " description=\"some documentation\"\n"+ 74 " >\n"+ 75 " </table>\n"+ 76 "</database>", 77 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 78 } 79 80 public void testDocumentation3() 82 { 83 addClass( 84 "test.A", 85 "package test;\n"+ 86 "/** @ojb.class table-documentation=\"some documentation\" */\n"+ 87 "public class A {}\n"); 88 addClass( 89 "test.B", 90 "package test;\n"+ 91 "/** @ojb.class */\n"+ 92 "public class B extends A {}\n"); 93 94 assertEqualsOjbDescriptorFile( 95 "<class-descriptor\n"+ 96 " class=\"test.A\"\n"+ 97 " table=\"A\"\n"+ 98 ">\n"+ 99 " <extent-class class-ref=\"test.B\"/>\n"+ 100 "</class-descriptor>\n"+ 101 "<class-descriptor\n"+ 102 " class=\"test.B\"\n"+ 103 " table=\"B\"\n"+ 104 ">\n"+ 105 "</class-descriptor>", 106 runOjbXDoclet(OJB_DEST_FILE)); 107 assertEqualsTorqueSchemaFile( 108 "<database name=\"ojbtest\">\n"+ 109 " <table name=\"A\"\n"+ 110 " description=\"some documentation\"\n"+ 111 " >\n"+ 112 " </table>\n"+ 113 " <table name=\"B\">\n"+ 114 " </table>\n"+ 115 "</database>", 116 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 117 } 118 119 public void testDocumentation4() 121 { 122 addClass( 123 "test.A", 124 "package test;\n"+ 125 "/** @ojb.class table-documentation=\"Table A\" */\n"+ 126 "public class A {\n"+ 127 " /** @ojb.field primarykey=\"true\" */\n"+ 128 " private Integer id;\n"+ 129 " /** @ojb.collection element-class-ref=\"test.B\"\n"+ 130 " * foreignkey=\"aid\"\n"+ 131 " */\n"+ 132 " private java.util.List bs;\n"+ 133 "}\n"); 134 addClass( 135 "test.B", 136 "package test;\n"+ 137 "/** @ojb.class table-documentation=\"Table B\" */\n"+ 138 "public class B {\n"+ 139 " /** @ojb.field primarykey=\"true\" */\n"+ 140 " private Integer aid;\n"+ 141 " /** @ojb.field primarykey=\"true\" */\n"+ 142 " private Integer cid;\n"+ 143 " /** @ojb.reference foreignkey=\"cid\" */\n"+ 144 " private C c;\n"+ 145 "}\n"); 146 addClass( 147 "test.C", 148 "package test;\n"+ 149 "/** @ojb.class table-documentation=\"Table C\" */\n"+ 150 "public class C {\n"+ 151 " /** @ojb.field primarykey=\"true\" */\n"+ 152 " private Integer id;\n"+ 153 "}\n"); 154 155 assertEqualsOjbDescriptorFile( 156 "<class-descriptor\n"+ 157 " class=\"test.A\"\n"+ 158 " table=\"A\"\n"+ 159 ">\n"+ 160 " <field-descriptor\n"+ 161 " name=\"id\"\n"+ 162 " column=\"id\"\n"+ 163 " jdbc-type=\"INTEGER\"\n"+ 164 " primarykey=\"true\"\n"+ 165 " >\n"+ 166 " </field-descriptor>\n"+ 167 " <collection-descriptor\n"+ 168 " name=\"bs\"\n"+ 169 " element-class-ref=\"test.B\"\n"+ 170 " >\n"+ 171 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 172 " </collection-descriptor>\n"+ 173 "</class-descriptor>\n"+ 174 "<class-descriptor\n"+ 175 " class=\"test.B\"\n"+ 176 " table=\"B\"\n"+ 177 ">\n"+ 178 " <field-descriptor\n"+ 179 " name=\"aid\"\n"+ 180 " column=\"aid\"\n"+ 181 " jdbc-type=\"INTEGER\"\n"+ 182 " primarykey=\"true\"\n"+ 183 " >\n"+ 184 " </field-descriptor>\n"+ 185 " <field-descriptor\n"+ 186 " name=\"cid\"\n"+ 187 " column=\"cid\"\n"+ 188 " jdbc-type=\"INTEGER\"\n"+ 189 " primarykey=\"true\"\n"+ 190 " >\n"+ 191 " </field-descriptor>\n"+ 192 " <reference-descriptor\n"+ 193 " name=\"c\"\n"+ 194 " class-ref=\"test.C\"\n"+ 195 " >\n"+ 196 " <foreignkey field-ref=\"cid\"/>\n"+ 197 " </reference-descriptor>\n"+ 198 "</class-descriptor>\n"+ 199 "<class-descriptor\n"+ 200 " class=\"test.C\"\n"+ 201 " table=\"C\"\n"+ 202 ">\n"+ 203 " <field-descriptor\n"+ 204 " name=\"id\"\n"+ 205 " column=\"id\"\n"+ 206 " jdbc-type=\"INTEGER\"\n"+ 207 " primarykey=\"true\"\n"+ 208 " >\n"+ 209 " </field-descriptor>\n"+ 210 "</class-descriptor>", 211 runOjbXDoclet(OJB_DEST_FILE)); 212 assertEqualsTorqueSchemaFile( 213 "<database name=\"ojbtest\">\n"+ 214 " <table name=\"A\"\n"+ 215 " description=\"Table A\"\n"+ 216 " >\n"+ 217 " <column name=\"id\"\n"+ 218 " javaName=\"id\"\n"+ 219 " type=\"INTEGER\"\n"+ 220 " primaryKey=\"true\"\n"+ 221 " required=\"true\"\n"+ 222 " />\n"+ 223 " </table>\n"+ 224 " <table name=\"B\"\n"+ 225 " description=\"Table B\"\n"+ 226 " >\n"+ 227 " <column name=\"aid\"\n"+ 228 " javaName=\"aid\"\n"+ 229 " type=\"INTEGER\"\n"+ 230 " primaryKey=\"true\"\n"+ 231 " required=\"true\"\n"+ 232 " />\n"+ 233 " <column name=\"cid\"\n"+ 234 " javaName=\"cid\"\n"+ 235 " type=\"INTEGER\"\n"+ 236 " primaryKey=\"true\"\n"+ 237 " required=\"true\"\n"+ 238 " />\n"+ 239 " <foreign-key foreignTable=\"A\">\n"+ 240 " <reference local=\"aid\" foreign=\"id\"/>\n"+ 241 " </foreign-key>\n"+ 242 " <foreign-key foreignTable=\"C\">\n"+ 243 " <reference local=\"cid\" foreign=\"id\"/>\n"+ 244 " </foreign-key>\n"+ 245 " </table>\n"+ 246 " <table name=\"C\"\n"+ 247 " description=\"Table C\"\n"+ 248 " >\n"+ 249 " <column name=\"id\"\n"+ 250 " javaName=\"id\"\n"+ 251 " type=\"INTEGER\"\n"+ 252 " primaryKey=\"true\"\n"+ 253 " required=\"true\"\n"+ 254 " />\n"+ 255 " </table>\n"+ 256 "</database>", 257 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 258 } 259 260 public void testDocumentation5() 262 { 263 addClass( 264 "test.A", 265 "package test;\n"+ 266 "/** @ojb.class documentation=\"some other documentation\"\n"+ 267 " * table-documentation=\"some documentation\"\n"+ 268 " */\n"+ 269 "public class A {}\n"); 270 271 assertEqualsOjbDescriptorFile( 272 "<class-descriptor\n"+ 273 " class=\"test.A\"\n"+ 274 " table=\"A\"\n"+ 275 ">\n"+ 276 " <documentation>some other documentation</documentation>\n"+ 277 "</class-descriptor>", 278 runOjbXDoclet(OJB_DEST_FILE)); 279 assertEqualsTorqueSchemaFile( 280 "<database name=\"ojbtest\">\n"+ 281 " <table name=\"A\"\n"+ 282 " description=\"some documentation\"\n"+ 283 " >\n"+ 284 " </table>\n"+ 285 "</database>", 286 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 287 } 288 289 public void testDocumentation6() 291 { 292 addClass( 293 "test.A", 294 "package test;\n"+ 295 "/** @ojb.class table-documentation=\"some documentation\" */\n"+ 296 "public class A {}\n"); 297 addClass( 298 "test.B", 299 "package test;\n"+ 300 "/** @ojb.class table=\"A\"\n"+ 301 " * documentation=\"some other documentation\"\n"+ 302 " */\n"+ 303 "public class B extends A {}\n"); 304 305 assertEqualsOjbDescriptorFile( 306 "<class-descriptor\n"+ 307 " class=\"test.A\"\n"+ 308 " table=\"A\"\n"+ 309 ">\n"+ 310 " <extent-class class-ref=\"test.B\"/>\n"+ 311 "</class-descriptor>\n"+ 312 "<class-descriptor\n"+ 313 " class=\"test.B\"\n"+ 314 " table=\"A\"\n"+ 315 ">\n"+ 316 " <documentation>some other documentation</documentation>\n"+ 317 "</class-descriptor>", 318 runOjbXDoclet(OJB_DEST_FILE)); 319 assertEqualsTorqueSchemaFile( 320 "<database name=\"ojbtest\">\n"+ 321 " <table name=\"A\"\n"+ 322 " description=\"some documentation\"\n"+ 323 " >\n"+ 324 " </table>\n"+ 325 "</database>", 326 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 327 } 328 } 329 | Popular Tags |