1 package xdoclet.modules.ojb.tests; 2 3 17 18 23 public class ModifyInheritedTagDocumentationAttributeTests extends OjbTestBase 24 { 25 public ModifyInheritedTagDocumentationAttributeTests(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 */\n" + 37 "public class A {\n"+ 38 " /** @ojb.field */\n"+ 39 " private int attr;\n"+ 40 "}"); 41 addClass( 42 "test.B", 43 "package test;\n"+ 44 "/** @ojb.class\n" + 45 " * @ojb.modify-inherited name=\"attr\"\n"+ 46 " * documentation=\"Some documentation\"\n"+ 47 " */\n"+ 48 "public class B extends A {}\n"); 49 50 assertEqualsOjbDescriptorFile( 51 "<class-descriptor\n"+ 52 " class=\"test.A\"\n"+ 53 " table=\"A\"\n"+ 54 ">\n"+ 55 " <extent-class class-ref=\"test.B\"/>\n"+ 56 " <field-descriptor\n"+ 57 " name=\"attr\"\n"+ 58 " column=\"attr\"\n"+ 59 " jdbc-type=\"INTEGER\"\n"+ 60 " >\n"+ 61 " </field-descriptor>\n"+ 62 "</class-descriptor>\n"+ 63 "<class-descriptor\n"+ 64 " class=\"test.B\"\n"+ 65 " table=\"B\"\n"+ 66 ">\n"+ 67 " <field-descriptor\n"+ 68 " name=\"attr\"\n"+ 69 " column=\"attr\"\n"+ 70 " jdbc-type=\"INTEGER\"\n"+ 71 " >\n"+ 72 " <documentation>Some documentation</documentation>\n"+ 73 " </field-descriptor>\n"+ 74 "</class-descriptor>", 75 runOjbXDoclet(OJB_DEST_FILE)); 76 assertEqualsTorqueSchemaFile( 77 "<database name=\"ojbtest\">\n"+ 78 " <table name=\"A\">\n"+ 79 " <column name=\"attr\"\n"+ 80 " javaName=\"attr\"\n"+ 81 " type=\"INTEGER\"\n"+ 82 " />\n"+ 83 " </table>\n"+ 84 " <table name=\"B\">\n"+ 85 " <column name=\"attr\"\n"+ 86 " javaName=\"attr\"\n"+ 87 " type=\"INTEGER\"\n"+ 88 " description=\"Some documentation\"\n"+ 89 " />\n"+ 90 " </table>\n"+ 91 "</database>", 92 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 93 } 94 95 public void testDocumentation2() 97 { 98 addClass( 99 "test.A", 100 "package test;\n"+ 101 "/** @ojb.class */\n" + 102 "public class A {\n"+ 103 " /** @ojb.field */\n"+ 104 " private int bid;\n"+ 105 " /** @ojb.reference foreignkey=\"bid\"\n"+ 106 " * documentation=\"Some documentation\"\n"+ 107 " */\n"+ 108 " private B b;\n"+ 109 "}"); 110 addClass( 111 "test.B", 112 "package test;\n"+ 113 "/** @ojb.class */\n" + 114 "public class B {\n"+ 115 " /** @ojb.field primarykey=\"true\" */\n"+ 116 " private int id;\n"+ 117 "}"); 118 addClass( 119 "test.C", 120 "package test;\n"+ 121 "public class C extends A {}"); 122 addClass( 123 "test.D", 124 "package test;\n"+ 125 "/** @ojb.class */\n" + 126 "public class D extends C {}"); 127 addClass( 128 "test.E", 129 "package test;\n"+ 130 "/** @ojb.class\n" + 131 " * @ojb.modify-inherited name=\"b\"\n"+ 132 " * documentation=\"Some other documentation\"\n"+ 133 " */\n"+ 134 "public class E extends D {}\n"); 135 136 assertEqualsOjbDescriptorFile( 137 "<class-descriptor\n"+ 138 " class=\"test.A\"\n"+ 139 " table=\"A\"\n"+ 140 ">\n"+ 141 " <extent-class class-ref=\"test.D\"/>\n"+ 142 " <field-descriptor\n"+ 143 " name=\"bid\"\n"+ 144 " column=\"bid\"\n"+ 145 " jdbc-type=\"INTEGER\"\n"+ 146 " >\n"+ 147 " </field-descriptor>\n"+ 148 " <reference-descriptor\n"+ 149 " name=\"b\"\n"+ 150 " class-ref=\"test.B\"\n"+ 151 " >\n"+ 152 " <documentation>Some documentation</documentation>\n"+ 153 " <foreignkey field-ref=\"bid\"/>\n"+ 154 " </reference-descriptor>\n"+ 155 "</class-descriptor>\n"+ 156 "<class-descriptor\n"+ 157 " class=\"test.B\"\n"+ 158 " table=\"B\"\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 "</class-descriptor>\n"+ 168 "<class-descriptor\n"+ 169 " class=\"test.D\"\n"+ 170 " table=\"D\"\n"+ 171 ">\n"+ 172 " <extent-class class-ref=\"test.E\"/>\n"+ 173 " <field-descriptor\n"+ 174 " name=\"bid\"\n"+ 175 " column=\"bid\"\n"+ 176 " jdbc-type=\"INTEGER\"\n"+ 177 " >\n"+ 178 " </field-descriptor>\n"+ 179 " <reference-descriptor\n"+ 180 " name=\"b\"\n"+ 181 " class-ref=\"test.B\"\n"+ 182 " >\n"+ 183 " <documentation>Some documentation</documentation>\n"+ 184 " <foreignkey field-ref=\"bid\"/>\n"+ 185 " </reference-descriptor>\n"+ 186 "</class-descriptor>\n"+ 187 "<class-descriptor\n"+ 188 " class=\"test.E\"\n"+ 189 " table=\"E\"\n"+ 190 ">\n"+ 191 " <field-descriptor\n"+ 192 " name=\"bid\"\n"+ 193 " column=\"bid\"\n"+ 194 " jdbc-type=\"INTEGER\"\n"+ 195 " >\n"+ 196 " </field-descriptor>\n"+ 197 " <reference-descriptor\n"+ 198 " name=\"b\"\n"+ 199 " class-ref=\"test.B\"\n"+ 200 " >\n"+ 201 " <documentation>Some other documentation</documentation>\n"+ 202 " <foreignkey field-ref=\"bid\"/>\n"+ 203 " </reference-descriptor>\n"+ 204 "</class-descriptor>", 205 runOjbXDoclet(OJB_DEST_FILE)); 206 assertEqualsTorqueSchemaFile( 207 "<database name=\"ojbtest\">\n"+ 208 " <table name=\"A\">\n"+ 209 " <column name=\"bid\"\n"+ 210 " javaName=\"bid\"\n"+ 211 " type=\"INTEGER\"\n"+ 212 " />\n"+ 213 " <foreign-key foreignTable=\"B\">\n"+ 214 " <reference local=\"bid\" foreign=\"id\"/>\n"+ 215 " </foreign-key>\n"+ 216 " </table>\n"+ 217 " <table name=\"B\">\n"+ 218 " <column name=\"id\"\n"+ 219 " javaName=\"id\"\n"+ 220 " type=\"INTEGER\"\n"+ 221 " primaryKey=\"true\"\n"+ 222 " required=\"true\"\n"+ 223 " />\n"+ 224 " </table>\n"+ 225 " <table name=\"D\">\n"+ 226 " <column name=\"bid\"\n"+ 227 " javaName=\"bid\"\n"+ 228 " type=\"INTEGER\"\n"+ 229 " />\n"+ 230 " <foreign-key foreignTable=\"B\">\n"+ 231 " <reference local=\"bid\" foreign=\"id\"/>\n"+ 232 " </foreign-key>\n"+ 233 " </table>\n"+ 234 " <table name=\"E\">\n"+ 235 " <column name=\"bid\"\n"+ 236 " javaName=\"bid\"\n"+ 237 " type=\"INTEGER\"\n"+ 238 " />\n"+ 239 " <foreign-key foreignTable=\"B\">\n"+ 240 " <reference local=\"bid\" foreign=\"id\"/>\n"+ 241 " </foreign-key>\n"+ 242 " </table>\n"+ 243 "</database>", 244 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 245 } 246 247 public void testDocumentation3() 249 { 250 addClass( 251 "test.A", 252 "package test;\n"+ 253 "/** @ojb.class */\n" + 254 "public class A {\n"+ 255 " /** @ojb.field primarykey=\"true\" */\n"+ 256 " private int id;\n"+ 257 " /** @ojb.collection element-class-ref=\"test.B\"\n"+ 258 " * foreignkey=\"aid\"\n"+ 259 " * documentation=\"Some documentation\"\n"+ 260 " * database-foreignkey=\"false\"\n"+ 261 " */\n"+ 262 " private java.util.Collection bs;\n"+ 263 "}"); 264 addClass( 265 "test.B", 266 "package test;\n"+ 267 "/** @ojb.class */\n" + 268 "public class B {\n"+ 269 " /** @ojb.field */\n"+ 270 " private int aid;\n"+ 271 "}"); 272 addClass( 273 "test.C", 274 "package test;\n"+ 275 "/** @ojb.class\n" + 276 " * @ojb.modify-inherited name=\"bs\"\n"+ 277 " * documentation=\"Some other documentation\"\n"+ 278 " */\n"+ 279 "public class C extends A {}\n"); 280 addClass( 281 "test.D", 282 "package test;\n"+ 283 "/** @ojb.class */\n"+ 284 "public class D extends C {}\n"); 285 286 assertEqualsOjbDescriptorFile( 287 "<class-descriptor\n"+ 288 " class=\"test.A\"\n"+ 289 " table=\"A\"\n"+ 290 ">\n"+ 291 " <extent-class class-ref=\"test.C\"/>\n"+ 292 " <field-descriptor\n"+ 293 " name=\"id\"\n"+ 294 " column=\"id\"\n"+ 295 " jdbc-type=\"INTEGER\"\n"+ 296 " primarykey=\"true\"\n"+ 297 " >\n"+ 298 " </field-descriptor>\n"+ 299 " <collection-descriptor\n"+ 300 " name=\"bs\"\n"+ 301 " element-class-ref=\"test.B\"\n"+ 302 " >\n"+ 303 " <documentation>Some documentation</documentation>\n"+ 304 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 305 " </collection-descriptor>\n"+ 306 "</class-descriptor>\n"+ 307 "<class-descriptor\n"+ 308 " class=\"test.B\"\n"+ 309 " table=\"B\"\n"+ 310 ">\n"+ 311 " <field-descriptor\n"+ 312 " name=\"aid\"\n"+ 313 " column=\"aid\"\n"+ 314 " jdbc-type=\"INTEGER\"\n"+ 315 " >\n"+ 316 " </field-descriptor>\n"+ 317 "</class-descriptor>\n"+ 318 "<class-descriptor\n"+ 319 " class=\"test.C\"\n"+ 320 " table=\"C\"\n"+ 321 ">\n"+ 322 " <extent-class class-ref=\"test.D\"/>\n"+ 323 " <field-descriptor\n"+ 324 " name=\"id\"\n"+ 325 " column=\"id\"\n"+ 326 " jdbc-type=\"INTEGER\"\n"+ 327 " primarykey=\"true\"\n"+ 328 " >\n"+ 329 " </field-descriptor>\n"+ 330 " <collection-descriptor\n"+ 331 " name=\"bs\"\n"+ 332 " element-class-ref=\"test.B\"\n"+ 333 " >\n"+ 334 " <documentation>Some other documentation</documentation>\n"+ 335 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 336 " </collection-descriptor>\n"+ 337 "</class-descriptor>\n"+ 338 "<class-descriptor\n"+ 339 " class=\"test.D\"\n"+ 340 " table=\"D\"\n"+ 341 ">\n"+ 342 " <field-descriptor\n"+ 343 " name=\"id\"\n"+ 344 " column=\"id\"\n"+ 345 " jdbc-type=\"INTEGER\"\n"+ 346 " primarykey=\"true\"\n"+ 347 " >\n"+ 348 " </field-descriptor>\n"+ 349 " <collection-descriptor\n"+ 350 " name=\"bs\"\n"+ 351 " element-class-ref=\"test.B\"\n"+ 352 " >\n"+ 353 " <documentation>Some other documentation</documentation>\n"+ 354 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 355 " </collection-descriptor>\n"+ 356 "</class-descriptor>", 357 runOjbXDoclet(OJB_DEST_FILE)); 358 assertEqualsTorqueSchemaFile( 359 "<database name=\"ojbtest\">\n"+ 360 " <table name=\"A\">\n"+ 361 " <column name=\"id\"\n"+ 362 " javaName=\"id\"\n"+ 363 " type=\"INTEGER\"\n"+ 364 " primaryKey=\"true\"\n"+ 365 " required=\"true\"\n"+ 366 " />\n"+ 367 " </table>\n"+ 368 " <table name=\"B\">\n"+ 369 " <column name=\"aid\"\n"+ 370 " javaName=\"aid\"\n"+ 371 " type=\"INTEGER\"\n"+ 372 " />\n"+ 373 " </table>\n"+ 374 " <table name=\"C\">\n"+ 375 " <column name=\"id\"\n"+ 376 " javaName=\"id\"\n"+ 377 " type=\"INTEGER\"\n"+ 378 " primaryKey=\"true\"\n"+ 379 " required=\"true\"\n"+ 380 " />\n"+ 381 " </table>\n"+ 382 " <table name=\"D\">\n"+ 383 " <column name=\"id\"\n"+ 384 " javaName=\"id\"\n"+ 385 " type=\"INTEGER\"\n"+ 386 " primaryKey=\"true\"\n"+ 387 " required=\"true\"\n"+ 388 " />\n"+ 389 " </table>\n"+ 390 "</database>", 391 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 392 } 393 394 public void testDocumentation4() 396 { 397 addClass( 398 "test.A", 399 "package test;\n"+ 400 "/** @ojb.class\n"+ 401 " * @ojb.field name=\"attr\"\n"+ 402 " * jdbc-type=\"INTEGER\"\n"+ 403 " */\n" + 404 "public class A {}"); 405 addClass( 406 "test.B", 407 "package test;\n"+ 408 "/** @ojb.class\n" + 409 " * @ojb.modify-inherited name=\"attr\"\n"+ 410 " * documentation=\"Some documentation\"\n"+ 411 " */\n"+ 412 "public class B extends A {}\n"); 413 414 assertEqualsOjbDescriptorFile( 415 "<class-descriptor\n"+ 416 " class=\"test.A\"\n"+ 417 " table=\"A\"\n"+ 418 ">\n"+ 419 " <extent-class class-ref=\"test.B\"/>\n"+ 420 " <field-descriptor\n"+ 421 " name=\"attr\"\n"+ 422 " column=\"attr\"\n"+ 423 " jdbc-type=\"INTEGER\"\n"+ 424 " access=\"anonymous\"\n"+ 425 " >\n"+ 426 " </field-descriptor>\n"+ 427 "</class-descriptor>\n"+ 428 "<class-descriptor\n"+ 429 " class=\"test.B\"\n"+ 430 " table=\"B\"\n"+ 431 ">\n"+ 432 " <field-descriptor\n"+ 433 " name=\"attr\"\n"+ 434 " column=\"attr\"\n"+ 435 " jdbc-type=\"INTEGER\"\n"+ 436 " access=\"anonymous\"\n"+ 437 " >\n"+ 438 " <documentation>Some documentation</documentation>\n"+ 439 " </field-descriptor>\n"+ 440 "</class-descriptor>", 441 runOjbXDoclet(OJB_DEST_FILE)); 442 assertEqualsTorqueSchemaFile( 443 "<database name=\"ojbtest\">\n"+ 444 " <table name=\"A\">\n"+ 445 " <column name=\"attr\"\n"+ 446 " javaName=\"attr\"\n"+ 447 " type=\"INTEGER\"\n"+ 448 " />\n"+ 449 " </table>\n"+ 450 " <table name=\"B\">\n"+ 451 " <column name=\"attr\"\n"+ 452 " javaName=\"attr\"\n"+ 453 " type=\"INTEGER\"\n"+ 454 " description=\"Some documentation\"\n"+ 455 " />\n"+ 456 " </table>\n"+ 457 "</database>", 458 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 459 } 460 461 public void testDocumentation5() 463 { 464 addClass( 465 "test.A", 466 "package test;\n"+ 467 "/** @ojb.class */\n" + 468 "public class A {\n"+ 469 " /** @ojb.field documentation=\"Some documentation\" */\n"+ 470 " private int attr;\n"+ 471 "}"); 472 addClass( 473 "test.B", 474 "package test;\n"+ 475 "/** @ojb.class\n" + 476 " * @ojb.modify-inherited name=\"attr\"\n"+ 477 " * documentation=\"\"\n"+ 478 " */\n"+ 479 "public class B extends A {}\n"); 480 481 assertEqualsOjbDescriptorFile( 482 "<class-descriptor\n"+ 483 " class=\"test.A\"\n"+ 484 " table=\"A\"\n"+ 485 ">\n"+ 486 " <extent-class class-ref=\"test.B\"/>\n"+ 487 " <field-descriptor\n"+ 488 " name=\"attr\"\n"+ 489 " column=\"attr\"\n"+ 490 " jdbc-type=\"INTEGER\"\n"+ 491 " >\n"+ 492 " <documentation>Some documentation</documentation>\n"+ 493 " </field-descriptor>\n"+ 494 "</class-descriptor>\n"+ 495 "<class-descriptor\n"+ 496 " class=\"test.B\"\n"+ 497 " table=\"B\"\n"+ 498 ">\n"+ 499 " <field-descriptor\n"+ 500 " name=\"attr\"\n"+ 501 " column=\"attr\"\n"+ 502 " jdbc-type=\"INTEGER\"\n"+ 503 " >\n"+ 504 " </field-descriptor>\n"+ 505 "</class-descriptor>", 506 runOjbXDoclet(OJB_DEST_FILE)); 507 assertEqualsTorqueSchemaFile( 508 "<database name=\"ojbtest\">\n"+ 509 " <table name=\"A\">\n"+ 510 " <column name=\"attr\"\n"+ 511 " javaName=\"attr\"\n"+ 512 " type=\"INTEGER\"\n"+ 513 " description=\"Some documentation\"\n"+ 514 " />\n"+ 515 " </table>\n"+ 516 " <table name=\"B\">\n"+ 517 " <column name=\"attr\"\n"+ 518 " javaName=\"attr\"\n"+ 519 " type=\"INTEGER\"\n"+ 520 " />\n"+ 521 " </table>\n"+ 522 "</database>", 523 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 524 } 525 } 526 | Popular Tags |