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