1 package xdoclet.modules.ojb.tests; 2 3 17 18 23 public class ClassTagGenerateRepositoryInfoAttributeTests extends OjbTestBase 24 { 25 public ClassTagGenerateRepositoryInfoAttributeTests(String name) 26 { 27 super(name); 28 } 29 30 public void testGenerateRepositoryInfo1() 32 { 33 addClass( 34 "test.A", 35 "package test;\n"+ 36 "/** @ojb.class generate-repository-info=\"\" */\n"+ 37 "public class A {}\n"); 38 39 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 40 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 41 } 42 43 public void testGenerateRepositoryInfo2() 45 { 46 addClass( 47 "test.A", 48 "package test;\n"+ 49 "/** @ojb.class generate-repository-info=\"yes\" */\n"+ 50 "public class A {}\n"); 51 52 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 53 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 54 } 55 56 public void testGenerateRepositoryInfo3() 58 { 59 addClass( 60 "test.A", 61 "package test;\n"+ 62 "/** @ojb.class generate-repository-info=\"true\" */\n"+ 63 "public class A {}\n"); 64 65 assertEqualsOjbDescriptorFile( 66 "<class-descriptor\n"+ 67 " class=\"test.A\"\n"+ 68 " table=\"A\"\n"+ 69 ">\n"+ 70 "</class-descriptor>", 71 runOjbXDoclet(OJB_DEST_FILE)); 72 assertEqualsTorqueSchemaFile( 73 "<database name=\"ojbtest\">\n"+ 74 " <table name=\"A\">\n"+ 75 " </table>\n"+ 76 "</database>", 77 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 78 } 79 80 public void testGenerateRepositoryInfo4() 82 { 83 addClass( 84 "test.A", 85 "package test;\n"+ 86 "/** @ojb.class */\n"+ 87 "public class A {\n"+ 88 " /** @ojb.field primarykey=\"true\" */\n"+ 89 " private int id;\n"+ 90 "}\n"); 91 addClass( 92 "test.B", 93 "package test;\n"+ 94 "public class B extends A {}\n"); 95 addClass( 96 "test.C", 97 "package test;\n"+ 98 "/** @ojb.class generate-repository-info=\"false\" */\n"+ 99 "public class C extends B {}\n"); 100 addClass( 101 "test.D", 102 "package test;\n"+ 103 "public class D extends C {}\n"); 104 addClass( 105 "test.E", 106 "package test;\n"+ 107 "/** @ojb.class */\n"+ 108 "public class E extends D {}\n"); 109 110 assertEqualsOjbDescriptorFile( 111 "<class-descriptor\n"+ 112 " class=\"test.A\"\n"+ 113 " table=\"A\"\n"+ 114 ">\n"+ 115 " <extent-class class-ref=\"test.C\"/>\n"+ 116 " <field-descriptor\n"+ 117 " name=\"id\"\n"+ 118 " column=\"id\"\n"+ 119 " jdbc-type=\"INTEGER\"\n"+ 120 " primarykey=\"true\"\n"+ 121 " >\n"+ 122 " </field-descriptor>\n"+ 123 "</class-descriptor>\n"+ 124 "<class-descriptor\n"+ 125 " class=\"test.C\"\n"+ 126 ">\n"+ 127 " <extent-class class-ref=\"test.E\"/>\n"+ 128 "</class-descriptor>\n"+ 129 "<class-descriptor\n"+ 130 " class=\"test.E\"\n"+ 131 " table=\"E\"\n"+ 132 ">\n"+ 133 " <field-descriptor\n"+ 134 " name=\"id\"\n"+ 135 " column=\"id\"\n"+ 136 " jdbc-type=\"INTEGER\"\n"+ 137 " primarykey=\"true\"\n"+ 138 " >\n"+ 139 " </field-descriptor>\n"+ 140 "</class-descriptor>", 141 runOjbXDoclet(OJB_DEST_FILE)); 142 assertEqualsTorqueSchemaFile( 143 "<database name=\"ojbtest\">\n"+ 144 " <table name=\"A\">\n"+ 145 " <column name=\"id\"\n"+ 146 " javaName=\"id\"\n"+ 147 " type=\"INTEGER\"\n"+ 148 " primaryKey=\"true\"\n"+ 149 " required=\"true\"\n"+ 150 " />\n"+ 151 " </table>\n"+ 152 " <table name=\"E\">\n"+ 153 " <column name=\"id\"\n"+ 154 " javaName=\"id\"\n"+ 155 " type=\"INTEGER\"\n"+ 156 " primaryKey=\"true\"\n"+ 157 " required=\"true\"\n"+ 158 " />\n"+ 159 " </table>\n"+ 160 "</database>", 161 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 162 } 163 164 public void testGenerateRepositoryInfo5() 166 { 167 addClass( 168 "test.A", 169 "package test;\n"+ 170 "/** @ojb.class generate-table-info=\"false\" */\n"+ 171 "public interface A {}\n"); 172 addClass( 173 "test.B", 174 "package test;\n"+ 175 "/** @ojb.class */\n"+ 176 "public class B implements A {\n"+ 177 " /** @ojb.field primarykey=\"true\" */\n"+ 178 " private int id;\n"+ 179 "}\n"); 180 addClass( 181 "test.C", 182 "package test;\n"+ 183 "/** @ojb.class */\n"+ 184 "public class C implements A {\n"+ 185 " /** @ojb.field jdbc-type=\"INTEGER\"\n"+ 186 " * primarykey=\"true\"\n"+ 187 " */\n"+ 188 " private short id;\n"+ 189 "}\n"); 190 addClass( 191 "test.D", 192 "package test;\n"+ 193 "/** @ojb.class */\n"+ 194 "public class D {\n"+ 195 " /** @ojb.field */\n"+ 196 " private int attrKey;\n"+ 197 " /** @ojb.reference foreignkey=\"attrKey\" */\n"+ 198 " private A attr;\n"+ 199 "}\n"); 200 201 assertEqualsOjbDescriptorFile( 202 "<class-descriptor\n"+ 203 " class=\"test.A\"\n"+ 204 ">\n"+ 205 " <extent-class class-ref=\"test.B\"/>\n"+ 206 " <extent-class class-ref=\"test.C\"/>\n"+ 207 " <field-descriptor\n"+ 208 " name=\"id\"\n"+ 209 " column=\"id\"\n"+ 210 " jdbc-type=\"INTEGER\"\n"+ 211 " primarykey=\"true\"\n"+ 212 " >\n"+ 213 " </field-descriptor>\n"+ 214 "</class-descriptor>\n"+ 215 "<class-descriptor\n"+ 216 " class=\"test.B\"\n"+ 217 " table=\"B\"\n"+ 218 ">\n"+ 219 " <field-descriptor\n"+ 220 " name=\"id\"\n"+ 221 " column=\"id\"\n"+ 222 " jdbc-type=\"INTEGER\"\n"+ 223 " primarykey=\"true\"\n"+ 224 " >\n"+ 225 " </field-descriptor>\n"+ 226 "</class-descriptor>\n"+ 227 "<class-descriptor\n"+ 228 " class=\"test.C\"\n"+ 229 " table=\"C\"\n"+ 230 ">\n"+ 231 " <field-descriptor\n"+ 232 " name=\"id\"\n"+ 233 " column=\"id\"\n"+ 234 " jdbc-type=\"INTEGER\"\n"+ 235 " primarykey=\"true\"\n"+ 236 " >\n"+ 237 " </field-descriptor>\n"+ 238 "</class-descriptor>\n"+ 239 "<class-descriptor\n"+ 240 " class=\"test.D\"\n"+ 241 " table=\"D\"\n"+ 242 ">\n"+ 243 " <field-descriptor\n"+ 244 " name=\"attrKey\"\n"+ 245 " column=\"attrKey\"\n"+ 246 " jdbc-type=\"INTEGER\"\n"+ 247 " >\n"+ 248 " </field-descriptor>\n"+ 249 " <reference-descriptor\n"+ 250 " name=\"attr\"\n"+ 251 " class-ref=\"test.A\"\n"+ 252 " >\n"+ 253 " <foreignkey field-ref=\"attrKey\"/>\n"+ 254 " </reference-descriptor>\n"+ 255 "</class-descriptor>", 256 runOjbXDoclet(OJB_DEST_FILE)); 257 assertEqualsTorqueSchemaFile( 258 "<database name=\"ojbtest\">\n"+ 259 " <table name=\"B\">\n"+ 260 " <column name=\"id\"\n"+ 261 " javaName=\"id\"\n"+ 262 " type=\"INTEGER\"\n"+ 263 " primaryKey=\"true\"\n"+ 264 " required=\"true\"\n"+ 265 " />\n"+ 266 " </table>\n"+ 267 " <table name=\"C\">\n"+ 268 " <column name=\"id\"\n"+ 269 " javaName=\"id\"\n"+ 270 " type=\"INTEGER\"\n"+ 271 " primaryKey=\"true\"\n"+ 272 " required=\"true\"\n"+ 273 " />\n"+ 274 " </table>\n"+ 275 " <table name=\"D\">\n"+ 276 " <column name=\"attrKey\"\n"+ 277 " javaName=\"attrKey\"\n"+ 278 " type=\"INTEGER\"\n"+ 279 " />\n"+ 280 " </table>\n"+ 281 "</database>", 282 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 283 } 284 285 public void testGenerateRepositoryInfo6() 287 { 288 addClass( 289 "test.A", 290 "package test;\n"+ 291 "/** @ojb.class generate-repository-info=\"false\" */\n"+ 292 "public abstract class A {}\n"); 293 addClass( 294 "test.B", 295 "package test;\n"+ 296 "/** @ojb.class */\n"+ 297 "public class B extends A {\n"+ 298 " /** @ojb.field primarykey=\"true\" */\n"+ 299 " private int id;\n"+ 300 " /** @ojb.field */\n"+ 301 " private int eid;\n"+ 302 "}\n"); 303 addClass( 304 "test.C", 305 "package test;\n"+ 306 "public class C extends A {\n"+ 307 " /** @ojb.field */\n"+ 308 " private int eid;\n"+ 309 "}\n"); 310 addClass( 311 "test.D", 312 "package test;\n"+ 313 "/** @ojb.class */\n"+ 314 "public class D extends C {\n" + 315 " /** @ojb.field primarykey=\"true\"\n"+ 316 " * length=\"50\"\n"+ 317 " * id=\"0\"\n"+ 318 " */\n"+ 319 " private String id;\n"+ 320 "}\n"); 321 addClass( 322 "test.E", 323 "package test;\n"+ 324 "/** @ojb.class */\n"+ 325 "public class E {\n"+ 326 " /** @ojb.field primarykey=\"true\" */\n"+ 327 " private int id;\n"+ 328 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 329 " * foreignkey=\"eid\"\n"+ 330 " */\n"+ 331 " private java.util.List as;\n"+ 332 "}\n"); 333 334 assertEqualsOjbDescriptorFile( 335 "<class-descriptor\n"+ 336 " class=\"test.A\"\n"+ 337 ">\n"+ 338 " <extent-class class-ref=\"test.B\"/>\n"+ 339 " <extent-class class-ref=\"test.D\"/>\n"+ 340 " <field-descriptor\n"+ 341 " name=\"eid\"\n"+ 342 " column=\"eid\"\n"+ 343 " jdbc-type=\"INTEGER\"\n"+ 344 " >\n"+ 345 " </field-descriptor>\n"+ 346 "</class-descriptor>\n"+ 347 "<class-descriptor\n"+ 348 " class=\"test.B\"\n"+ 349 " table=\"B\"\n"+ 350 ">\n"+ 351 " <field-descriptor\n"+ 352 " name=\"id\"\n"+ 353 " column=\"id\"\n"+ 354 " jdbc-type=\"INTEGER\"\n"+ 355 " primarykey=\"true\"\n"+ 356 " >\n"+ 357 " </field-descriptor>\n"+ 358 " <field-descriptor\n"+ 359 " name=\"eid\"\n"+ 360 " column=\"eid\"\n"+ 361 " jdbc-type=\"INTEGER\"\n"+ 362 " >\n"+ 363 " </field-descriptor>\n"+ 364 "</class-descriptor>\n"+ 365 "<class-descriptor\n"+ 366 " class=\"test.D\"\n"+ 367 " table=\"D\"\n"+ 368 ">\n"+ 369 " <field-descriptor\n"+ 370 " name=\"id\"\n"+ 371 " column=\"id\"\n"+ 372 " jdbc-type=\"VARCHAR\"\n"+ 373 " primarykey=\"true\"\n"+ 374 " length=\"50\"\n"+ 375 " >\n"+ 376 " </field-descriptor>\n"+ 377 " <field-descriptor\n"+ 378 " name=\"eid\"\n"+ 379 " column=\"eid\"\n"+ 380 " jdbc-type=\"INTEGER\"\n"+ 381 " >\n"+ 382 " </field-descriptor>\n"+ 383 "</class-descriptor>\n"+ 384 "<class-descriptor\n"+ 385 " class=\"test.E\"\n"+ 386 " table=\"E\"\n"+ 387 ">\n"+ 388 " <field-descriptor\n"+ 389 " name=\"id\"\n"+ 390 " column=\"id\"\n"+ 391 " jdbc-type=\"INTEGER\"\n"+ 392 " primarykey=\"true\"\n"+ 393 " >\n"+ 394 " </field-descriptor>\n"+ 395 " <collection-descriptor\n"+ 396 " name=\"as\"\n"+ 397 " element-class-ref=\"test.A\"\n"+ 398 " >\n"+ 399 " <inverse-foreignkey field-ref=\"eid\"/>\n"+ 400 " </collection-descriptor>\n"+ 401 "</class-descriptor>", 402 runOjbXDoclet(OJB_DEST_FILE)); 403 assertEqualsTorqueSchemaFile( 404 "<database name=\"ojbtest\">\n"+ 405 " <table name=\"B\">\n"+ 406 " <column name=\"id\"\n"+ 407 " javaName=\"id\"\n"+ 408 " type=\"INTEGER\"\n"+ 409 " primaryKey=\"true\"\n"+ 410 " required=\"true\"\n"+ 411 " />\n"+ 412 " <column name=\"eid\"\n"+ 413 " javaName=\"eid\"\n"+ 414 " type=\"INTEGER\"\n"+ 415 " />\n"+ 416 " <foreign-key foreignTable=\"E\">\n"+ 417 " <reference local=\"eid\" foreign=\"id\"/>\n"+ 418 " </foreign-key>\n"+ 419 " </table>\n"+ 420 " <table name=\"D\">\n"+ 421 " <column name=\"id\"\n"+ 422 " javaName=\"id\"\n"+ 423 " type=\"VARCHAR\"\n"+ 424 " primaryKey=\"true\"\n"+ 425 " required=\"true\"\n"+ 426 " size=\"50\"\n"+ 427 " />\n"+ 428 " <column name=\"eid\"\n"+ 429 " javaName=\"eid\"\n"+ 430 " type=\"INTEGER\"\n"+ 431 " />\n"+ 432 " <foreign-key foreignTable=\"E\">\n"+ 433 " <reference local=\"eid\" foreign=\"id\"/>\n"+ 434 " </foreign-key>\n"+ 435 " </table>\n"+ 436 " <table name=\"E\">\n"+ 437 " <column name=\"id\"\n"+ 438 " javaName=\"id\"\n"+ 439 " type=\"INTEGER\"\n"+ 440 " primaryKey=\"true\"\n"+ 441 " required=\"true\"\n"+ 442 " />\n"+ 443 " </table>\n"+ 444 "</database>", 445 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 446 } 447 448 public void testGenerateRepositoryInfo8() 450 { 451 addClass( 452 "test.A", 453 "package test;\n"+ 454 "/** @ojb.class generate-repository-info=\"false\" */\n"+ 455 "public interface A {}\n"); 456 addClass( 457 "test.B", 458 "package test;\n"+ 459 "/** @ojb.class */\n"+ 460 "public class B implements A {\n"+ 461 " /** @ojb.field primarykey=\"true\" */\n"+ 462 " private int id;\n"+ 463 " /** @ojb.collection element-class-ref=\"test.D\"\n"+ 464 " * indirection-table=\"A_D\"\n"+ 465 " * foreignkey=\"AID\"\n"+ 466 " */\n"+ 467 " private java.util.List ds;\n"+ 468 "}\n"); 469 addClass( 470 "test.C", 471 "package test;\n"+ 472 "/** @ojb.class */\n"+ 473 "public class C implements A {\n"+ 474 " /** @ojb.field primarykey=\"true\" */\n"+ 475 " private int id;\n"+ 476 " /** @ojb.collection element-class-ref=\"test.D\"\n"+ 477 " * indirection-table=\"A_D\"\n"+ 478 " * foreignkey=\"AID\"\n"+ 479 " */\n"+ 480 " private java.util.List ds;\n"+ 481 "}\n"); 482 addClass( 483 "test.D", 484 "package test;\n"+ 485 "/** @ojb.class */\n"+ 486 "public class D {\n"+ 487 " /** @ojb.field primarykey=\"true\" */\n"+ 488 " private int id;\n"+ 489 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 490 " * indirection-table=\"A_D\"\n"+ 491 " * foreignkey=\"DID\"\n"+ 492 " */\n"+ 493 " private java.util.List as;\n"+ 494 "}\n"); 495 496 assertEqualsOjbDescriptorFile( 497 "<class-descriptor\n"+ 498 " class=\"test.A\"\n"+ 499 ">\n"+ 500 " <extent-class class-ref=\"test.B\"/>\n"+ 501 " <extent-class class-ref=\"test.C\"/>\n"+ 502 " <field-descriptor\n"+ 503 " name=\"id\"\n"+ 504 " column=\"id\"\n"+ 505 " jdbc-type=\"INTEGER\"\n"+ 506 " primarykey=\"true\"\n"+ 507 " >\n"+ 508 " </field-descriptor>\n"+ 509 "</class-descriptor>\n"+ 510 "<class-descriptor\n"+ 511 " class=\"test.B\"\n"+ 512 " table=\"B\"\n"+ 513 ">\n"+ 514 " <field-descriptor\n"+ 515 " name=\"id\"\n"+ 516 " column=\"id\"\n"+ 517 " jdbc-type=\"INTEGER\"\n"+ 518 " primarykey=\"true\"\n"+ 519 " >\n"+ 520 " </field-descriptor>\n"+ 521 " <collection-descriptor\n"+ 522 " name=\"ds\"\n"+ 523 " element-class-ref=\"test.D\"\n"+ 524 " indirection-table=\"A_D\"\n"+ 525 " >\n"+ 526 " <fk-pointing-to-this-class column=\"AID\"/>\n"+ 527 " <fk-pointing-to-element-class column=\"DID\"/>\n"+ 528 " </collection-descriptor>\n"+ 529 "</class-descriptor>\n"+ 530 "<class-descriptor\n"+ 531 " class=\"test.C\"\n"+ 532 " table=\"C\"\n"+ 533 ">\n"+ 534 " <field-descriptor\n"+ 535 " name=\"id\"\n"+ 536 " column=\"id\"\n"+ 537 " jdbc-type=\"INTEGER\"\n"+ 538 " primarykey=\"true\"\n"+ 539 " >\n"+ 540 " </field-descriptor>\n"+ 541 " <collection-descriptor\n"+ 542 " name=\"ds\"\n"+ 543 " element-class-ref=\"test.D\"\n"+ 544 " indirection-table=\"A_D\"\n"+ 545 " >\n"+ 546 " <fk-pointing-to-this-class column=\"AID\"/>\n"+ 547 " <fk-pointing-to-element-class column=\"DID\"/>\n"+ 548 " </collection-descriptor>\n"+ 549 "</class-descriptor>\n"+ 550 "<class-descriptor\n"+ 551 " class=\"test.D\"\n"+ 552 " table=\"D\"\n"+ 553 ">\n"+ 554 " <field-descriptor\n"+ 555 " name=\"id\"\n"+ 556 " column=\"id\"\n"+ 557 " jdbc-type=\"INTEGER\"\n"+ 558 " primarykey=\"true\"\n"+ 559 " >\n"+ 560 " </field-descriptor>\n"+ 561 " <collection-descriptor\n"+ 562 " name=\"as\"\n"+ 563 " element-class-ref=\"test.A\"\n"+ 564 " indirection-table=\"A_D\"\n"+ 565 " >\n"+ 566 " <fk-pointing-to-this-class column=\"DID\"/>\n"+ 567 " <fk-pointing-to-element-class column=\"AID\"/>\n"+ 568 " </collection-descriptor>\n"+ 569 "</class-descriptor>", 570 runOjbXDoclet(OJB_DEST_FILE)); 571 assertEqualsTorqueSchemaFile( 572 "<database name=\"ojbtest\">\n"+ 573 " <table name=\"A_D\">\n"+ 574 " <column name=\"AID\"\n"+ 575 " type=\"INTEGER\"\n"+ 576 " />\n"+ 577 " <column name=\"DID\"\n"+ 578 " type=\"INTEGER\"\n"+ 579 " />\n"+ 580 " <foreign-key foreignTable=\"D\">\n"+ 581 " <reference local=\"DID\" foreign=\"id\"/>\n"+ 582 " </foreign-key>\n"+ 583 " </table>\n"+ 584 " <table name=\"B\">\n"+ 585 " <column name=\"id\"\n"+ 586 " javaName=\"id\"\n"+ 587 " type=\"INTEGER\"\n"+ 588 " primaryKey=\"true\"\n"+ 589 " required=\"true\"\n"+ 590 " />\n"+ 591 " </table>\n"+ 592 " <table name=\"C\">\n"+ 593 " <column name=\"id\"\n"+ 594 " javaName=\"id\"\n"+ 595 " type=\"INTEGER\"\n"+ 596 " primaryKey=\"true\"\n"+ 597 " required=\"true\"\n"+ 598 " />\n"+ 599 " </table>\n"+ 600 " <table name=\"D\">\n"+ 601 " <column name=\"id\"\n"+ 602 " javaName=\"id\"\n"+ 603 " type=\"INTEGER\"\n"+ 604 " primaryKey=\"true\"\n"+ 605 " required=\"true\"\n"+ 606 " />\n"+ 607 " </table>\n"+ 608 "</database>", 609 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 610 } 611 612 public void testGenerateRepositoryInfo9() 614 { 615 addClass( 616 "test.A", 617 "package test;\n"+ 618 "/** @ojb.class generate-repository-info=\"false\" */\n"+ 619 "public class A {\n"+ 620 " /** @ojb.field primarykey=\"true\"\n"+ 621 " * length=\"50\"\n"+ 622 " */\n"+ 623 " private String id1;\n"+ 624 "}\n"); 625 addClass( 626 "test.B", 627 "package test;\n"+ 628 "/** @ojb.class */\n"+ 629 "public class B extends A {\n"+ 630 " /** @ojb.field primarykey=\"true\" */\n"+ 631 " private int id2;\n"+ 632 "}\n"); 633 addClass( 634 "test.C", 635 "package test;\n"+ 636 "/** @ojb.class */\n"+ 637 "public class C extends A {\n"+ 638 " /** @ojb.field primarykey=\"true\" */\n"+ 639 " private int id2;\n"+ 640 "}\n"); 641 addClass( 642 "test.D", 643 "package test;\n"+ 644 "/** @ojb.class */\n"+ 645 "public class D {\n"+ 646 " /** @ojb.field primarykey=\"true\" */\n"+ 647 " private int id;\n"+ 648 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 649 " * indirection-table=\"A_D\"\n"+ 650 " * foreignkey=\"DID\"\n"+ 651 " * remote-foreignkey=\"AID1,AID2\"\n"+ 652 " */\n"+ 653 " private java.util.List as;\n"+ 654 "}\n"); 655 656 assertEqualsOjbDescriptorFile( 657 "<class-descriptor\n"+ 658 " class=\"test.A\"\n"+ 659 ">\n"+ 660 " <extent-class class-ref=\"test.B\"/>\n"+ 661 " <extent-class class-ref=\"test.C\"/>\n"+ 662 " <field-descriptor\n"+ 663 " name=\"id1\"\n"+ 664 " column=\"id1\"\n"+ 665 " jdbc-type=\"VARCHAR\"\n"+ 666 " primarykey=\"true\"\n"+ 667 " length=\"50\"\n"+ 668 " >\n"+ 669 " </field-descriptor>\n"+ 670 " <field-descriptor\n"+ 671 " name=\"id2\"\n"+ 672 " column=\"id2\"\n"+ 673 " jdbc-type=\"INTEGER\"\n"+ 674 " primarykey=\"true\"\n"+ 675 " >\n"+ 676 " </field-descriptor>\n"+ 677 "</class-descriptor>\n"+ 678 "<class-descriptor\n"+ 679 " class=\"test.B\"\n"+ 680 " table=\"B\"\n"+ 681 ">\n"+ 682 " <field-descriptor\n"+ 683 " name=\"id1\"\n"+ 684 " column=\"id1\"\n"+ 685 " jdbc-type=\"VARCHAR\"\n"+ 686 " primarykey=\"true\"\n"+ 687 " length=\"50\"\n"+ 688 " >\n"+ 689 " </field-descriptor>\n"+ 690 " <field-descriptor\n"+ 691 " name=\"id2\"\n"+ 692 " column=\"id2\"\n"+ 693 " jdbc-type=\"INTEGER\"\n"+ 694 " primarykey=\"true\"\n"+ 695 " >\n"+ 696 " </field-descriptor>\n"+ 697 "</class-descriptor>\n"+ 698 "<class-descriptor\n"+ 699 " class=\"test.C\"\n"+ 700 " table=\"C\"\n"+ 701 ">\n"+ 702 " <field-descriptor\n"+ 703 " name=\"id1\"\n"+ 704 " column=\"id1\"\n"+ 705 " jdbc-type=\"VARCHAR\"\n"+ 706 " primarykey=\"true\"\n"+ 707 " length=\"50\"\n"+ 708 " >\n"+ 709 " </field-descriptor>\n"+ 710 " <field-descriptor\n"+ 711 " name=\"id2\"\n"+ 712 " column=\"id2\"\n"+ 713 " jdbc-type=\"INTEGER\"\n"+ 714 " primarykey=\"true\"\n"+ 715 " >\n"+ 716 " </field-descriptor>\n"+ 717 "</class-descriptor>\n"+ 718 "<class-descriptor\n"+ 719 " class=\"test.D\"\n"+ 720 " table=\"D\"\n"+ 721 ">\n"+ 722 " <field-descriptor\n"+ 723 " name=\"id\"\n"+ 724 " column=\"id\"\n"+ 725 " jdbc-type=\"INTEGER\"\n"+ 726 " primarykey=\"true\"\n"+ 727 " >\n"+ 728 " </field-descriptor>\n"+ 729 " <collection-descriptor\n"+ 730 " name=\"as\"\n"+ 731 " element-class-ref=\"test.A\"\n"+ 732 " indirection-table=\"A_D\"\n"+ 733 " >\n"+ 734 " <fk-pointing-to-this-class column=\"DID\"/>\n"+ 735 " <fk-pointing-to-element-class column=\"AID1\"/>\n"+ 736 " <fk-pointing-to-element-class column=\"AID2\"/>\n"+ 737 " </collection-descriptor>\n"+ 738 "</class-descriptor>", 739 runOjbXDoclet(OJB_DEST_FILE)); 740 assertEqualsTorqueSchemaFile( 741 "<database name=\"ojbtest\">\n"+ 742 " <table name=\"A_D\">\n"+ 743 " <column name=\"DID\"\n"+ 744 " type=\"INTEGER\"\n"+ 745 " />\n"+ 746 " <column name=\"AID1\"\n"+ 747 " type=\"VARCHAR\"\n"+ 748 " size=\"50\"\n"+ 749 " />\n"+ 750 " <column name=\"AID2\"\n"+ 751 " type=\"INTEGER\"\n"+ 752 " />\n"+ 753 " <foreign-key foreignTable=\"D\">\n"+ 754 " <reference local=\"DID\" foreign=\"id\"/>\n"+ 755 " </foreign-key>\n"+ 756 " </table>\n"+ 757 " <table name=\"B\">\n"+ 758 " <column name=\"id1\"\n"+ 759 " javaName=\"id1\"\n"+ 760 " type=\"VARCHAR\"\n"+ 761 " primaryKey=\"true\"\n"+ 762 " required=\"true\"\n"+ 763 " size=\"50\"\n"+ 764 " />\n"+ 765 " <column name=\"id2\"\n"+ 766 " javaName=\"id2\"\n"+ 767 " type=\"INTEGER\"\n"+ 768 " primaryKey=\"true\"\n"+ 769 " required=\"true\"\n"+ 770 " />\n"+ 771 " </table>\n"+ 772 " <table name=\"C\">\n"+ 773 " <column name=\"id1\"\n"+ 774 " javaName=\"id1\"\n"+ 775 " type=\"VARCHAR\"\n"+ 776 " primaryKey=\"true\"\n"+ 777 " required=\"true\"\n"+ 778 " size=\"50\"\n"+ 779 " />\n"+ 780 " <column name=\"id2\"\n"+ 781 " javaName=\"id2\"\n"+ 782 " type=\"INTEGER\"\n"+ 783 " primaryKey=\"true\"\n"+ 784 " required=\"true\"\n"+ 785 " />\n"+ 786 " </table>\n"+ 787 " <table name=\"D\">\n"+ 788 " <column name=\"id\"\n"+ 789 " javaName=\"id\"\n"+ 790 " type=\"INTEGER\"\n"+ 791 " primaryKey=\"true\"\n"+ 792 " required=\"true\"\n"+ 793 " />\n"+ 794 " </table>\n"+ 795 "</database>", 796 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 797 } 798 799 public void testGenerateRepositoryInfo7() 802 { 803 addClass( 804 "test.A", 805 "package test;\n"+ 806 "/** @ojb.class generate-repository-info=\"false\" */\n"+ 807 "public abstract class A {\n"+ 808 " /** @ojb.field length=\"50\" */\n"+ 809 " private String did1;\n"+ 810 "}\n"); 811 addClass( 812 "test.B", 813 "package test;\n"+ 814 "/** @ojb.class */\n"+ 815 "public class B extends A {\n"+ 816 " /** @ojb.field */\n"+ 817 " private int did2;\n"+ 818 "}\n"); 819 addClass( 820 "test.C", 821 "package test;\n"+ 822 "/** @ojb.class */\n"+ 823 "public class C extends A {\n"+ 824 " /** @ojb.field */\n"+ 825 " private float did2;\n"+ 826 "}\n"); 827 addClass( 828 "test.D", 829 "package test;\n"+ 830 "/** @ojb.class */\n"+ 831 "public class D {\n"+ 832 " /** @ojb.field primarykey=\"true\"\n"+ 833 " * length=\"50\"\n"+ 834 " */\n"+ 835 " private String id1;\n"+ 836 " /** @ojb.field primarykey=\"true\" */\n"+ 837 " private int id2;\n"+ 838 " /** @ojb.collection element-class-ref=\"test.A\"\n"+ 839 " * foreignkey=\"did1,did2\"\n"+ 840 " */\n"+ 841 " private java.util.List as;\n"+ 842 "}\n"); 843 844 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 845 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 846 } 847 848 public void testGenerateRepositoryInfo10() 850 { 851 addClass( 852 "test.A", 853 "package test;\n"+ 854 "/** @ojb.class generate-table-info=\"false\" */\n"+ 855 "public interface A {}\n"); 856 addClass( 857 "test.B", 858 "package test;\n"+ 859 "/** @ojb.class */\n"+ 860 "public class B implements A {\n"+ 861 " /** @ojb.field */\n"+ 862 " private int id;\n"+ 863 "}\n"); 864 addClass( 865 "test.C", 866 "package test;\n"+ 867 "/** @ojb.class */\n"+ 868 "public class C implements A {\n"+ 869 " /** @ojb.field */\n"+ 870 " private float id;\n"+ 871 "}\n"); 872 addClass( 873 "test.D", 874 "package test;\n"+ 875 "/** @ojb.class */\n"+ 876 "public class D {\n"+ 877 " /** @ojb.field */\n"+ 878 " private int aid;\n"+ 879 " /** @ojb.reference foreignkey=\"aid\"\n"+ 880 " */\n"+ 881 " private A a;\n"+ 882 "}\n"); 883 884 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 885 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 886 } 887 } 888 | Popular Tags |