1 package xdoclet.modules.ojb.tests; 2 3 17 18 23 public class ModifyInheritedTagProxyAttributeTests extends OjbTestBase 24 { 25 public ModifyInheritedTagProxyAttributeTests(String name) 26 { 27 super(name); 28 } 29 30 public void testProxy1() 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 " * proxy=\"true\"\n"+ 47 " */\n"+ 48 "public class B extends A {}\n"); 49 50 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 51 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 52 } 53 54 public void testProxy2() 56 { 57 addClass( 58 "test.A", 59 "package test;\n"+ 60 "/** @ojb.class */\n"+ 61 "public class A {\n"+ 62 "/** @ojb.field */\n"+ 63 " private int attrKey;\n"+ 64 "/** @ojb.reference foreignkey=\"attrKey\"\n"+ 65 " * proxy=\"true\"\n"+ 66 " */\n"+ 67 " private test.B attr;\n"+ 68 "}\n"); 69 addClass( 70 "test.B", 71 "package test;\n"+ 72 "/** @ojb.class */\n"+ 73 "public class B {\n"+ 74 "/** @ojb.field primarykey=\"true\" */\n"+ 75 " private int id;\n"+ 76 "}\n"); 77 addClass( 78 "test.C", 79 "package test;\n"+ 80 "/** @ojb.class\n" + 81 " * @ojb.modify-inherited name=\"attr\"\n"+ 82 " * proxy=\"false\"\n"+ 83 " */\n"+ 84 "public class C extends A {}\n"); 85 86 assertEqualsOjbDescriptorFile( 87 "<class-descriptor\n"+ 88 " class=\"test.A\"\n"+ 89 " table=\"A\"\n"+ 90 ">\n"+ 91 " <extent-class class-ref=\"test.C\"/>\n"+ 92 " <field-descriptor\n"+ 93 " name=\"attrKey\"\n"+ 94 " column=\"attrKey\"\n"+ 95 " jdbc-type=\"INTEGER\"\n"+ 96 " >\n"+ 97 " </field-descriptor>\n"+ 98 " <reference-descriptor\n"+ 99 " name=\"attr\"\n"+ 100 " class-ref=\"test.B\"\n"+ 101 " proxy=\"true\"\n"+ 102 " >\n"+ 103 " <foreignkey field-ref=\"attrKey\"/>\n"+ 104 " </reference-descriptor>\n"+ 105 "</class-descriptor>\n"+ 106 "<class-descriptor\n"+ 107 " class=\"test.B\"\n"+ 108 " table=\"B\"\n"+ 109 ">\n"+ 110 " <field-descriptor\n"+ 111 " name=\"id\"\n"+ 112 " column=\"id\"\n"+ 113 " jdbc-type=\"INTEGER\"\n"+ 114 " primarykey=\"true\"\n"+ 115 " >\n"+ 116 " </field-descriptor>\n"+ 117 "</class-descriptor>\n"+ 118 "<class-descriptor\n"+ 119 " class=\"test.C\"\n"+ 120 " table=\"C\"\n"+ 121 ">\n"+ 122 " <field-descriptor\n"+ 123 " name=\"attrKey\"\n"+ 124 " column=\"attrKey\"\n"+ 125 " jdbc-type=\"INTEGER\"\n"+ 126 " >\n"+ 127 " </field-descriptor>\n"+ 128 " <reference-descriptor\n"+ 129 " name=\"attr\"\n"+ 130 " class-ref=\"test.B\"\n"+ 131 " proxy=\"false\"\n"+ 132 " >\n"+ 133 " <foreignkey field-ref=\"attrKey\"/>\n"+ 134 " </reference-descriptor>\n"+ 135 "</class-descriptor>", 136 runOjbXDoclet(OJB_DEST_FILE)); 137 assertEqualsTorqueSchemaFile( 138 "<database name=\"ojbtest\">\n"+ 139 " <table name=\"A\">\n"+ 140 " <column name=\"attrKey\"\n"+ 141 " javaName=\"attrKey\"\n"+ 142 " type=\"INTEGER\"\n"+ 143 " />\n"+ 144 " <foreign-key foreignTable=\"B\">\n"+ 145 " <reference local=\"attrKey\" foreign=\"id\"/>\n"+ 146 " </foreign-key>\n"+ 147 " </table>\n"+ 148 " <table name=\"B\">\n"+ 149 " <column name=\"id\"\n"+ 150 " javaName=\"id\"\n"+ 151 " type=\"INTEGER\"\n"+ 152 " primaryKey=\"true\"\n"+ 153 " required=\"true\"\n"+ 154 " />\n"+ 155 " </table>\n"+ 156 " <table name=\"C\">\n"+ 157 " <column name=\"attrKey\"\n"+ 158 " javaName=\"attrKey\"\n"+ 159 " type=\"INTEGER\"\n"+ 160 " />\n"+ 161 " <foreign-key foreignTable=\"B\">\n"+ 162 " <reference local=\"attrKey\" foreign=\"id\"/>\n"+ 163 " </foreign-key>\n"+ 164 " </table>\n"+ 165 "</database>", 166 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 167 } 168 169 public void testProxy3() 171 { 172 addClass( 173 "test.A", 174 "package test;\n"+ 175 "/** @ojb.class */\n"+ 176 "public class A {\n"+ 177 "/** @ojb.field primarykey=\"true\" */\n"+ 178 " private int id;\n"+ 179 "/** @ojb.collection element-class-ref=\"test.B\"\n"+ 180 " * foreignkey=\"aid\"\n"+ 181 " * proxy=\"false\"\n"+ 182 " * database-foreignkey=\"false\"\n"+ 183 " */\n"+ 184 " private java.util.List objs;\n"+ 185 "}\n"); 186 addClass( 187 "test.B", 188 "package test;\n"+ 189 "/** @ojb.class */\n"+ 190 "public class B {\n"+ 191 "/** @ojb.field */\n"+ 192 " private int aid;\n"+ 193 "}\n"); 194 addClass( 195 "test.C", 196 "package test;\n"+ 197 "/** @ojb.class\n" + 198 " * @ojb.modify-inherited name=\"objs\"\n"+ 199 " * proxy=\"true\"\n"+ 200 " */\n"+ 201 "public class C extends A {}\n"); 202 203 assertEqualsOjbDescriptorFile( 204 "<class-descriptor\n"+ 205 " class=\"test.A\"\n"+ 206 " table=\"A\"\n"+ 207 ">\n"+ 208 " <extent-class class-ref=\"test.C\"/>\n"+ 209 " <field-descriptor\n"+ 210 " name=\"id\"\n"+ 211 " column=\"id\"\n"+ 212 " jdbc-type=\"INTEGER\"\n"+ 213 " primarykey=\"true\"\n"+ 214 " >\n"+ 215 " </field-descriptor>\n"+ 216 " <collection-descriptor\n"+ 217 " name=\"objs\"\n"+ 218 " element-class-ref=\"test.B\"\n"+ 219 " proxy=\"false\"\n"+ 220 " >\n"+ 221 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 222 " </collection-descriptor>\n"+ 223 "</class-descriptor>\n"+ 224 "<class-descriptor\n"+ 225 " class=\"test.B\"\n"+ 226 " table=\"B\"\n"+ 227 ">\n"+ 228 " <field-descriptor\n"+ 229 " name=\"aid\"\n"+ 230 " column=\"aid\"\n"+ 231 " jdbc-type=\"INTEGER\"\n"+ 232 " >\n"+ 233 " </field-descriptor>\n"+ 234 "</class-descriptor>\n"+ 235 "<class-descriptor\n"+ 236 " class=\"test.C\"\n"+ 237 " table=\"C\"\n"+ 238 ">\n"+ 239 " <field-descriptor\n"+ 240 " name=\"id\"\n"+ 241 " column=\"id\"\n"+ 242 " jdbc-type=\"INTEGER\"\n"+ 243 " primarykey=\"true\"\n"+ 244 " >\n"+ 245 " </field-descriptor>\n"+ 246 " <collection-descriptor\n"+ 247 " name=\"objs\"\n"+ 248 " element-class-ref=\"test.B\"\n"+ 249 " proxy=\"true\"\n"+ 250 " >\n"+ 251 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 252 " </collection-descriptor>\n"+ 253 "</class-descriptor>", 254 runOjbXDoclet(OJB_DEST_FILE)); 255 assertEqualsTorqueSchemaFile( 256 "<database name=\"ojbtest\">\n"+ 257 " <table name=\"A\">\n"+ 258 " <column name=\"id\"\n"+ 259 " javaName=\"id\"\n"+ 260 " type=\"INTEGER\"\n"+ 261 " primaryKey=\"true\"\n"+ 262 " required=\"true\"\n"+ 263 " />\n"+ 264 " </table>\n"+ 265 " <table name=\"B\">\n"+ 266 " <column name=\"aid\"\n"+ 267 " javaName=\"aid\"\n"+ 268 " type=\"INTEGER\"\n"+ 269 " />\n"+ 270 " </table>\n"+ 271 " <table name=\"C\">\n"+ 272 " <column name=\"id\"\n"+ 273 " javaName=\"id\"\n"+ 274 " type=\"INTEGER\"\n"+ 275 " primaryKey=\"true\"\n"+ 276 " required=\"true\"\n"+ 277 " />\n"+ 278 " </table>\n"+ 279 "</database>", 280 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 281 } 282 283 public void testProxy4() 285 { 286 addClass( 287 "test.A", 288 "package test;\n"+ 289 "/** @ojb.class\n"+ 290 " * @ojb.field name=\"attr\"\n"+ 291 " * jdbc-type=\"INTEGER\"\n"+ 292 " */\n" + 293 "public class A {}"); 294 addClass( 295 "test.B", 296 "package test;\n"+ 297 "/** @ojb.class\n" + 298 " * @ojb.modify-inherited name=\"attr\"\n"+ 299 " * proxy=\"false\"\n"+ 300 " */\n"+ 301 "public class B extends A {}\n"); 302 303 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 304 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 305 } 306 307 public void testProxy5() 309 { 310 addClass( 311 "test.A", 312 "package test;\n"+ 313 "/** @ojb.class */\n"+ 314 "public class A {\n"+ 315 "/** @ojb.field */\n"+ 316 " private int attrKey;\n"+ 317 "/** @ojb.reference foreignkey=\"attrKey\"\n"+ 318 " * proxy=\"true\"\n"+ 319 " */\n"+ 320 " private test.B attr;\n"+ 321 "}\n"); 322 addClass( 323 "test.B", 324 "package test;\n"+ 325 "/** @ojb.class */\n"+ 326 "public class B {\n"+ 327 "/** @ojb.field primarykey=\"true\" */\n"+ 328 " private int id;\n"+ 329 "}\n"); 330 addClass( 331 "test.C", 332 "package test;\n"+ 333 "/** @ojb.class\n" + 334 " * @ojb.modify-inherited name=\"attr\"\n"+ 335 " * proxy=\"no\"\n"+ 336 " */\n"+ 337 "public class C extends A {}\n"); 338 339 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 340 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 341 } 342 343 public void testProxyPrefetchingLimit1() 345 { 346 addClass( 347 "test.A", 348 "package test;\n"+ 349 "/** @ojb.class */\n" + 350 "public class A {\n"+ 351 " /** @ojb.field */\n"+ 352 " private int attr;\n"+ 353 "}"); 354 addClass( 355 "test.B", 356 "package test;\n"+ 357 "/** @ojb.class\n" + 358 " * @ojb.modify-inherited name=\"attr\"\n"+ 359 " * proxy-prefetching-limit=\"true\"\n"+ 360 " */\n"+ 361 "public class B extends A {}\n"); 362 363 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 364 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 365 } 366 367 public void testProxyPrefetchingLimit2() 369 { 370 addClass( 371 "test.A", 372 "package test;\n"+ 373 "/** @ojb.class */\n"+ 374 "public class A {\n"+ 375 "/** @ojb.field */\n"+ 376 " private int attrKey;\n"+ 377 "/** @ojb.reference foreignkey=\"attrKey\"\n"+ 378 " * proxy=\"true\"\n"+ 379 " */\n"+ 380 " private test.B attr;\n"+ 381 "}\n"); 382 addClass( 383 "test.B", 384 "package test;\n"+ 385 "/** @ojb.class */\n"+ 386 "public class B {\n"+ 387 "/** @ojb.field primarykey=\"true\" */\n"+ 388 " private int id;\n"+ 389 "}\n"); 390 addClass( 391 "test.C", 392 "package test;\n"+ 393 "/** @ojb.class\n" + 394 " * @ojb.modify-inherited name=\"attr\"\n"+ 395 " * proxy-prefetching-limit=\"2\"\n"+ 396 " */\n"+ 397 "public class C extends A {}\n"); 398 399 assertEqualsOjbDescriptorFile( 400 "<class-descriptor\n"+ 401 " class=\"test.A\"\n"+ 402 " table=\"A\"\n"+ 403 ">\n"+ 404 " <extent-class class-ref=\"test.C\"/>\n"+ 405 " <field-descriptor\n"+ 406 " name=\"attrKey\"\n"+ 407 " column=\"attrKey\"\n"+ 408 " jdbc-type=\"INTEGER\"\n"+ 409 " >\n"+ 410 " </field-descriptor>\n"+ 411 " <reference-descriptor\n"+ 412 " name=\"attr\"\n"+ 413 " class-ref=\"test.B\"\n"+ 414 " proxy=\"true\"\n"+ 415 " >\n"+ 416 " <foreignkey field-ref=\"attrKey\"/>\n"+ 417 " </reference-descriptor>\n"+ 418 "</class-descriptor>\n"+ 419 "<class-descriptor\n"+ 420 " class=\"test.B\"\n"+ 421 " table=\"B\"\n"+ 422 ">\n"+ 423 " <field-descriptor\n"+ 424 " name=\"id\"\n"+ 425 " column=\"id\"\n"+ 426 " jdbc-type=\"INTEGER\"\n"+ 427 " primarykey=\"true\"\n"+ 428 " >\n"+ 429 " </field-descriptor>\n"+ 430 "</class-descriptor>\n"+ 431 "<class-descriptor\n"+ 432 " class=\"test.C\"\n"+ 433 " table=\"C\"\n"+ 434 ">\n"+ 435 " <field-descriptor\n"+ 436 " name=\"attrKey\"\n"+ 437 " column=\"attrKey\"\n"+ 438 " jdbc-type=\"INTEGER\"\n"+ 439 " >\n"+ 440 " </field-descriptor>\n"+ 441 " <reference-descriptor\n"+ 442 " name=\"attr\"\n"+ 443 " class-ref=\"test.B\"\n"+ 444 " proxy=\"true\"\n"+ 445 " proxy-prefetching-limit=\"2\"\n"+ 446 " >\n"+ 447 " <foreignkey field-ref=\"attrKey\"/>\n"+ 448 " </reference-descriptor>\n"+ 449 "</class-descriptor>", 450 runOjbXDoclet(OJB_DEST_FILE)); 451 assertEqualsTorqueSchemaFile( 452 "<database name=\"ojbtest\">\n"+ 453 " <table name=\"A\">\n"+ 454 " <column name=\"attrKey\"\n"+ 455 " javaName=\"attrKey\"\n"+ 456 " type=\"INTEGER\"\n"+ 457 " />\n"+ 458 " <foreign-key foreignTable=\"B\">\n"+ 459 " <reference local=\"attrKey\" foreign=\"id\"/>\n"+ 460 " </foreign-key>\n"+ 461 " </table>\n"+ 462 " <table name=\"B\">\n"+ 463 " <column name=\"id\"\n"+ 464 " javaName=\"id\"\n"+ 465 " type=\"INTEGER\"\n"+ 466 " primaryKey=\"true\"\n"+ 467 " required=\"true\"\n"+ 468 " />\n"+ 469 " </table>\n"+ 470 " <table name=\"C\">\n"+ 471 " <column name=\"attrKey\"\n"+ 472 " javaName=\"attrKey\"\n"+ 473 " type=\"INTEGER\"\n"+ 474 " />\n"+ 475 " <foreign-key foreignTable=\"B\">\n"+ 476 " <reference local=\"attrKey\" foreign=\"id\"/>\n"+ 477 " </foreign-key>\n"+ 478 " </table>\n"+ 479 "</database>", 480 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 481 } 482 483 public void testProxyPrefetchingLimit3() 485 { 486 addClass( 487 "test.A", 488 "package test;\n"+ 489 "/** @ojb.class */\n"+ 490 "public class A {\n"+ 491 "/** @ojb.field */\n"+ 492 " private int attrKey;\n"+ 493 "/** @ojb.reference foreignkey=\"attrKey\" */\n"+ 494 " private test.B attr;\n"+ 495 "}\n"); 496 addClass( 497 "test.B", 498 "package test;\n"+ 499 "/** @ojb.class */\n"+ 500 "public class B {\n"+ 501 "/** @ojb.field primarykey=\"true\" */\n"+ 502 " private int id;\n"+ 503 "}\n"); 504 addClass( 505 "test.C", 506 "package test;\n"+ 507 "/** @ojb.class\n" + 508 " * @ojb.modify-inherited name=\"attr\"\n"+ 509 " * proxy-prefetching-limit=\"1\"\n"+ 510 " * proxy=\"true\"\n"+ 511 " */\n"+ 512 "public class C extends A {}\n"); 513 514 assertEqualsOjbDescriptorFile( 515 "<class-descriptor\n"+ 516 " class=\"test.A\"\n"+ 517 " table=\"A\"\n"+ 518 ">\n"+ 519 " <extent-class class-ref=\"test.C\"/>\n"+ 520 " <field-descriptor\n"+ 521 " name=\"attrKey\"\n"+ 522 " column=\"attrKey\"\n"+ 523 " jdbc-type=\"INTEGER\"\n"+ 524 " >\n"+ 525 " </field-descriptor>\n"+ 526 " <reference-descriptor\n"+ 527 " name=\"attr\"\n"+ 528 " class-ref=\"test.B\"\n"+ 529 " >\n"+ 530 " <foreignkey field-ref=\"attrKey\"/>\n"+ 531 " </reference-descriptor>\n"+ 532 "</class-descriptor>\n"+ 533 "<class-descriptor\n"+ 534 " class=\"test.B\"\n"+ 535 " table=\"B\"\n"+ 536 ">\n"+ 537 " <field-descriptor\n"+ 538 " name=\"id\"\n"+ 539 " column=\"id\"\n"+ 540 " jdbc-type=\"INTEGER\"\n"+ 541 " primarykey=\"true\"\n"+ 542 " >\n"+ 543 " </field-descriptor>\n"+ 544 "</class-descriptor>\n"+ 545 "<class-descriptor\n"+ 546 " class=\"test.C\"\n"+ 547 " table=\"C\"\n"+ 548 ">\n"+ 549 " <field-descriptor\n"+ 550 " name=\"attrKey\"\n"+ 551 " column=\"attrKey\"\n"+ 552 " jdbc-type=\"INTEGER\"\n"+ 553 " >\n"+ 554 " </field-descriptor>\n"+ 555 " <reference-descriptor\n"+ 556 " name=\"attr\"\n"+ 557 " class-ref=\"test.B\"\n"+ 558 " proxy=\"true\"\n"+ 559 " proxy-prefetching-limit=\"1\"\n"+ 560 " >\n"+ 561 " <foreignkey field-ref=\"attrKey\"/>\n"+ 562 " </reference-descriptor>\n"+ 563 "</class-descriptor>", 564 runOjbXDoclet(OJB_DEST_FILE)); 565 assertEqualsTorqueSchemaFile( 566 "<database name=\"ojbtest\">\n"+ 567 " <table name=\"A\">\n"+ 568 " <column name=\"attrKey\"\n"+ 569 " javaName=\"attrKey\"\n"+ 570 " type=\"INTEGER\"\n"+ 571 " />\n"+ 572 " <foreign-key foreignTable=\"B\">\n"+ 573 " <reference local=\"attrKey\" foreign=\"id\"/>\n"+ 574 " </foreign-key>\n"+ 575 " </table>\n"+ 576 " <table name=\"B\">\n"+ 577 " <column name=\"id\"\n"+ 578 " javaName=\"id\"\n"+ 579 " type=\"INTEGER\"\n"+ 580 " primaryKey=\"true\"\n"+ 581 " required=\"true\"\n"+ 582 " />\n"+ 583 " </table>\n"+ 584 " <table name=\"C\">\n"+ 585 " <column name=\"attrKey\"\n"+ 586 " javaName=\"attrKey\"\n"+ 587 " type=\"INTEGER\"\n"+ 588 " />\n"+ 589 " <foreign-key foreignTable=\"B\">\n"+ 590 " <reference local=\"attrKey\" foreign=\"id\"/>\n"+ 591 " </foreign-key>\n"+ 592 " </table>\n"+ 593 "</database>", 594 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 595 } 596 597 public void testProxyPrefetchingLimit4() 599 { 600 addClass( 601 "test.A", 602 "package test;\n"+ 603 "/** @ojb.class */\n"+ 604 "public class A {\n"+ 605 "/** @ojb.field */\n"+ 606 " private int attrKey;\n"+ 607 "/** @ojb.reference foreignkey=\"attrKey\"\n"+ 608 " * proxy=\"true\"\n"+ 609 " */\n"+ 610 " private test.B attr;\n"+ 611 "}\n"); 612 addClass( 613 "test.B", 614 "package test;\n"+ 615 "/** @ojb.class */\n"+ 616 "public class B {\n"+ 617 "/** @ojb.field primarykey=\"true\" */\n"+ 618 " private int id;\n"+ 619 "}\n"); 620 addClass( 621 "test.C", 622 "package test;\n"+ 623 "/** @ojb.class\n" + 624 " * @ojb.modify-inherited name=\"attr\"\n"+ 625 " * proxy-prefetching-limit=\"1\"\n"+ 626 " * proxy=\"false\"\n"+ 627 " */\n"+ 628 "public class C extends A {}\n"); 629 630 assertEqualsOjbDescriptorFile( 631 "<class-descriptor\n"+ 632 " class=\"test.A\"\n"+ 633 " table=\"A\"\n"+ 634 ">\n"+ 635 " <extent-class class-ref=\"test.C\"/>\n"+ 636 " <field-descriptor\n"+ 637 " name=\"attrKey\"\n"+ 638 " column=\"attrKey\"\n"+ 639 " jdbc-type=\"INTEGER\"\n"+ 640 " >\n"+ 641 " </field-descriptor>\n"+ 642 " <reference-descriptor\n"+ 643 " name=\"attr\"\n"+ 644 " class-ref=\"test.B\"\n"+ 645 " proxy=\"true\"\n"+ 646 " >\n"+ 647 " <foreignkey field-ref=\"attrKey\"/>\n"+ 648 " </reference-descriptor>\n"+ 649 "</class-descriptor>\n"+ 650 "<class-descriptor\n"+ 651 " class=\"test.B\"\n"+ 652 " table=\"B\"\n"+ 653 ">\n"+ 654 " <field-descriptor\n"+ 655 " name=\"id\"\n"+ 656 " column=\"id\"\n"+ 657 " jdbc-type=\"INTEGER\"\n"+ 658 " primarykey=\"true\"\n"+ 659 " >\n"+ 660 " </field-descriptor>\n"+ 661 "</class-descriptor>\n"+ 662 "<class-descriptor\n"+ 663 " class=\"test.C\"\n"+ 664 " table=\"C\"\n"+ 665 ">\n"+ 666 " <field-descriptor\n"+ 667 " name=\"attrKey\"\n"+ 668 " column=\"attrKey\"\n"+ 669 " jdbc-type=\"INTEGER\"\n"+ 670 " >\n"+ 671 " </field-descriptor>\n"+ 672 " <reference-descriptor\n"+ 673 " name=\"attr\"\n"+ 674 " class-ref=\"test.B\"\n"+ 675 " proxy=\"false\"\n"+ 676 " >\n"+ 677 " <foreignkey field-ref=\"attrKey\"/>\n"+ 678 " </reference-descriptor>\n"+ 679 "</class-descriptor>", 680 runOjbXDoclet(OJB_DEST_FILE)); 681 assertEqualsTorqueSchemaFile( 682 "<database name=\"ojbtest\">\n"+ 683 " <table name=\"A\">\n"+ 684 " <column name=\"attrKey\"\n"+ 685 " javaName=\"attrKey\"\n"+ 686 " type=\"INTEGER\"\n"+ 687 " />\n"+ 688 " <foreign-key foreignTable=\"B\">\n"+ 689 " <reference local=\"attrKey\" foreign=\"id\"/>\n"+ 690 " </foreign-key>\n"+ 691 " </table>\n"+ 692 " <table name=\"B\">\n"+ 693 " <column name=\"id\"\n"+ 694 " javaName=\"id\"\n"+ 695 " type=\"INTEGER\"\n"+ 696 " primaryKey=\"true\"\n"+ 697 " required=\"true\"\n"+ 698 " />\n"+ 699 " </table>\n"+ 700 " <table name=\"C\">\n"+ 701 " <column name=\"attrKey\"\n"+ 702 " javaName=\"attrKey\"\n"+ 703 " type=\"INTEGER\"\n"+ 704 " />\n"+ 705 " <foreign-key foreignTable=\"B\">\n"+ 706 " <reference local=\"attrKey\" foreign=\"id\"/>\n"+ 707 " </foreign-key>\n"+ 708 " </table>\n"+ 709 "</database>", 710 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 711 } 712 713 public void testProxyPrefetchingLimit5() 715 { 716 addClass( 717 "test.A", 718 "package test;\n"+ 719 "/** @ojb.class */\n"+ 720 "public class A {\n"+ 721 "/** @ojb.field */\n"+ 722 " private int attrKey;\n"+ 723 "/** @ojb.reference foreignkey=\"attrKey\"\n"+ 724 " * proxy=\"true\"\n"+ 725 " */\n"+ 726 " private test.B attr;\n"+ 727 "}\n"); 728 addClass( 729 "test.B", 730 "package test;\n"+ 731 "/** @ojb.class */\n"+ 732 "public class B {\n"+ 733 "/** @ojb.field primarykey=\"true\" */\n"+ 734 " private int id;\n"+ 735 "}\n"); 736 addClass( 737 "test.C", 738 "package test;\n"+ 739 "/** @ojb.class\n" + 740 " * @ojb.modify-inherited name=\"attr\"\n"+ 741 " * proxy-prefetching-limit=\"-1\"\n"+ 742 " */\n"+ 743 "public class C extends A {}\n"); 744 745 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 746 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 747 } 748 749 public void testProxyPrefetchingLimit6() 751 { 752 addClass( 753 "test.A", 754 "package test;\n"+ 755 "/** @ojb.class */\n"+ 756 "public class A {\n"+ 757 "/** @ojb.field primarykey=\"true\" */\n"+ 758 " private int id;\n"+ 759 "/** @ojb.collection element-class-ref=\"test.B\"\n"+ 760 " * foreignkey=\"aid\"\n"+ 761 " * proxy=\"true\"\n"+ 762 " * database-foreignkey=\"false\"\n"+ 763 " */\n"+ 764 " private java.util.List objs;\n"+ 765 "}\n"); 766 addClass( 767 "test.B", 768 "package test;\n"+ 769 "/** @ojb.class */\n"+ 770 "public class B {\n"+ 771 "/** @ojb.field */\n"+ 772 " private int aid;\n"+ 773 "}\n"); 774 addClass( 775 "test.C", 776 "package test;\n"+ 777 "/** @ojb.class\n" + 778 " * @ojb.modify-inherited name=\"objs\"\n"+ 779 " * proxy-prefetching-limit=\"10\"\n"+ 780 " */\n"+ 781 "public class C extends A {}\n"); 782 783 assertEqualsOjbDescriptorFile( 784 "<class-descriptor\n"+ 785 " class=\"test.A\"\n"+ 786 " table=\"A\"\n"+ 787 ">\n"+ 788 " <extent-class class-ref=\"test.C\"/>\n"+ 789 " <field-descriptor\n"+ 790 " name=\"id\"\n"+ 791 " column=\"id\"\n"+ 792 " jdbc-type=\"INTEGER\"\n"+ 793 " primarykey=\"true\"\n"+ 794 " >\n"+ 795 " </field-descriptor>\n"+ 796 " <collection-descriptor\n"+ 797 " name=\"objs\"\n"+ 798 " element-class-ref=\"test.B\"\n"+ 799 " proxy=\"true\"\n"+ 800 " >\n"+ 801 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 802 " </collection-descriptor>\n"+ 803 "</class-descriptor>\n"+ 804 "<class-descriptor\n"+ 805 " class=\"test.B\"\n"+ 806 " table=\"B\"\n"+ 807 ">\n"+ 808 " <field-descriptor\n"+ 809 " name=\"aid\"\n"+ 810 " column=\"aid\"\n"+ 811 " jdbc-type=\"INTEGER\"\n"+ 812 " >\n"+ 813 " </field-descriptor>\n"+ 814 "</class-descriptor>\n"+ 815 "<class-descriptor\n"+ 816 " class=\"test.C\"\n"+ 817 " table=\"C\"\n"+ 818 ">\n"+ 819 " <field-descriptor\n"+ 820 " name=\"id\"\n"+ 821 " column=\"id\"\n"+ 822 " jdbc-type=\"INTEGER\"\n"+ 823 " primarykey=\"true\"\n"+ 824 " >\n"+ 825 " </field-descriptor>\n"+ 826 " <collection-descriptor\n"+ 827 " name=\"objs\"\n"+ 828 " element-class-ref=\"test.B\"\n"+ 829 " proxy=\"true\"\n"+ 830 " proxy-prefetching-limit=\"10\"\n"+ 831 " >\n"+ 832 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 833 " </collection-descriptor>\n"+ 834 "</class-descriptor>", 835 runOjbXDoclet(OJB_DEST_FILE)); 836 assertEqualsTorqueSchemaFile( 837 "<database name=\"ojbtest\">\n"+ 838 " <table name=\"A\">\n"+ 839 " <column name=\"id\"\n"+ 840 " javaName=\"id\"\n"+ 841 " type=\"INTEGER\"\n"+ 842 " primaryKey=\"true\"\n"+ 843 " required=\"true\"\n"+ 844 " />\n"+ 845 " </table>\n"+ 846 " <table name=\"B\">\n"+ 847 " <column name=\"aid\"\n"+ 848 " javaName=\"aid\"\n"+ 849 " type=\"INTEGER\"\n"+ 850 " />\n"+ 851 " </table>\n"+ 852 " <table name=\"C\">\n"+ 853 " <column name=\"id\"\n"+ 854 " javaName=\"id\"\n"+ 855 " type=\"INTEGER\"\n"+ 856 " primaryKey=\"true\"\n"+ 857 " required=\"true\"\n"+ 858 " />\n"+ 859 " </table>\n"+ 860 "</database>", 861 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 862 } 863 864 public void testProxyPrefetchingLimit7() 866 { 867 addClass( 868 "test.A", 869 "package test;\n"+ 870 "/** @ojb.class */\n"+ 871 "public class A {\n"+ 872 "/** @ojb.field primarykey=\"true\" */\n"+ 873 " private int id;\n"+ 874 "/** @ojb.collection element-class-ref=\"test.B\"\n"+ 875 " * foreignkey=\"aid\"\n"+ 876 " * proxy=\"false\"\n"+ 877 " * database-foreignkey=\"false\"\n"+ 878 " */\n"+ 879 " private java.util.List objs;\n"+ 880 "}\n"); 881 addClass( 882 "test.B", 883 "package test;\n"+ 884 "/** @ojb.class */\n"+ 885 "public class B {\n"+ 886 "/** @ojb.field */\n"+ 887 " private int aid;\n"+ 888 "}\n"); 889 addClass( 890 "test.C", 891 "package test;\n"+ 892 "/** @ojb.class\n" + 893 " * @ojb.modify-inherited name=\"objs\"\n"+ 894 " * proxy-prefetching-limit=\"10\"\n"+ 895 " * proxy=\"true\"\n"+ 896 " */\n"+ 897 "public class C extends A {}\n"); 898 899 assertEqualsOjbDescriptorFile( 900 "<class-descriptor\n"+ 901 " class=\"test.A\"\n"+ 902 " table=\"A\"\n"+ 903 ">\n"+ 904 " <extent-class class-ref=\"test.C\"/>\n"+ 905 " <field-descriptor\n"+ 906 " name=\"id\"\n"+ 907 " column=\"id\"\n"+ 908 " jdbc-type=\"INTEGER\"\n"+ 909 " primarykey=\"true\"\n"+ 910 " >\n"+ 911 " </field-descriptor>\n"+ 912 " <collection-descriptor\n"+ 913 " name=\"objs\"\n"+ 914 " element-class-ref=\"test.B\"\n"+ 915 " proxy=\"false\"\n"+ 916 " >\n"+ 917 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 918 " </collection-descriptor>\n"+ 919 "</class-descriptor>\n"+ 920 "<class-descriptor\n"+ 921 " class=\"test.B\"\n"+ 922 " table=\"B\"\n"+ 923 ">\n"+ 924 " <field-descriptor\n"+ 925 " name=\"aid\"\n"+ 926 " column=\"aid\"\n"+ 927 " jdbc-type=\"INTEGER\"\n"+ 928 " >\n"+ 929 " </field-descriptor>\n"+ 930 "</class-descriptor>\n"+ 931 "<class-descriptor\n"+ 932 " class=\"test.C\"\n"+ 933 " table=\"C\"\n"+ 934 ">\n"+ 935 " <field-descriptor\n"+ 936 " name=\"id\"\n"+ 937 " column=\"id\"\n"+ 938 " jdbc-type=\"INTEGER\"\n"+ 939 " primarykey=\"true\"\n"+ 940 " >\n"+ 941 " </field-descriptor>\n"+ 942 " <collection-descriptor\n"+ 943 " name=\"objs\"\n"+ 944 " element-class-ref=\"test.B\"\n"+ 945 " proxy=\"true\"\n"+ 946 " proxy-prefetching-limit=\"10\"\n"+ 947 " >\n"+ 948 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 949 " </collection-descriptor>\n"+ 950 "</class-descriptor>", 951 runOjbXDoclet(OJB_DEST_FILE)); 952 assertEqualsTorqueSchemaFile( 953 "<database name=\"ojbtest\">\n"+ 954 " <table name=\"A\">\n"+ 955 " <column name=\"id\"\n"+ 956 " javaName=\"id\"\n"+ 957 " type=\"INTEGER\"\n"+ 958 " primaryKey=\"true\"\n"+ 959 " required=\"true\"\n"+ 960 " />\n"+ 961 " </table>\n"+ 962 " <table name=\"B\">\n"+ 963 " <column name=\"aid\"\n"+ 964 " javaName=\"aid\"\n"+ 965 " type=\"INTEGER\"\n"+ 966 " />\n"+ 967 " </table>\n"+ 968 " <table name=\"C\">\n"+ 969 " <column name=\"id\"\n"+ 970 " javaName=\"id\"\n"+ 971 " type=\"INTEGER\"\n"+ 972 " primaryKey=\"true\"\n"+ 973 " required=\"true\"\n"+ 974 " />\n"+ 975 " </table>\n"+ 976 "</database>", 977 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 978 } 979 980 public void testProxyPrefetchingLimit8() 982 { 983 addClass( 984 "test.A", 985 "package test;\n"+ 986 "/** @ojb.class */\n"+ 987 "public class A {\n"+ 988 "/** @ojb.field primarykey=\"true\" */\n"+ 989 " private int id;\n"+ 990 "/** @ojb.collection element-class-ref=\"test.B\"\n"+ 991 " * foreignkey=\"aid\"\n"+ 992 " * proxy=\"true\"\n"+ 993 " * database-foreignkey=\"false\"\n"+ 994 " */\n"+ 995 " private java.util.List objs;\n"+ 996 "}\n"); 997 addClass( 998 "test.B", 999 "package test;\n"+ 1000 "/** @ojb.class */\n"+ 1001 "public class B {\n"+ 1002 "/** @ojb.field */\n"+ 1003 " private int aid;\n"+ 1004 "}\n"); 1005 addClass( 1006 "test.C", 1007 "package test;\n"+ 1008 "/** @ojb.class\n" + 1009 " * @ojb.modify-inherited name=\"objs\"\n"+ 1010 " * proxy-prefetching-limit=\"10\"\n"+ 1011 " * proxy=\"false\"\n"+ 1012 " */\n"+ 1013 "public class C extends A {}\n"); 1014 1015 assertEqualsOjbDescriptorFile( 1016 "<class-descriptor\n"+ 1017 " class=\"test.A\"\n"+ 1018 " table=\"A\"\n"+ 1019 ">\n"+ 1020 " <extent-class class-ref=\"test.C\"/>\n"+ 1021 " <field-descriptor\n"+ 1022 " name=\"id\"\n"+ 1023 " column=\"id\"\n"+ 1024 " jdbc-type=\"INTEGER\"\n"+ 1025 " primarykey=\"true\"\n"+ 1026 " >\n"+ 1027 " </field-descriptor>\n"+ 1028 " <collection-descriptor\n"+ 1029 " name=\"objs\"\n"+ 1030 " element-class-ref=\"test.B\"\n"+ 1031 " proxy=\"true\"\n"+ 1032 " >\n"+ 1033 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 1034 " </collection-descriptor>\n"+ 1035 "</class-descriptor>\n"+ 1036 "<class-descriptor\n"+ 1037 " class=\"test.B\"\n"+ 1038 " table=\"B\"\n"+ 1039 ">\n"+ 1040 " <field-descriptor\n"+ 1041 " name=\"aid\"\n"+ 1042 " column=\"aid\"\n"+ 1043 " jdbc-type=\"INTEGER\"\n"+ 1044 " >\n"+ 1045 " </field-descriptor>\n"+ 1046 "</class-descriptor>\n"+ 1047 "<class-descriptor\n"+ 1048 " class=\"test.C\"\n"+ 1049 " table=\"C\"\n"+ 1050 ">\n"+ 1051 " <field-descriptor\n"+ 1052 " name=\"id\"\n"+ 1053 " column=\"id\"\n"+ 1054 " jdbc-type=\"INTEGER\"\n"+ 1055 " primarykey=\"true\"\n"+ 1056 " >\n"+ 1057 " </field-descriptor>\n"+ 1058 " <collection-descriptor\n"+ 1059 " name=\"objs\"\n"+ 1060 " element-class-ref=\"test.B\"\n"+ 1061 " proxy=\"false\"\n"+ 1062 " >\n"+ 1063 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 1064 " </collection-descriptor>\n"+ 1065 "</class-descriptor>", 1066 runOjbXDoclet(OJB_DEST_FILE)); 1067 assertEqualsTorqueSchemaFile( 1068 "<database name=\"ojbtest\">\n"+ 1069 " <table name=\"A\">\n"+ 1070 " <column name=\"id\"\n"+ 1071 " javaName=\"id\"\n"+ 1072 " type=\"INTEGER\"\n"+ 1073 " primaryKey=\"true\"\n"+ 1074 " required=\"true\"\n"+ 1075 " />\n"+ 1076 " </table>\n"+ 1077 " <table name=\"B\">\n"+ 1078 " <column name=\"aid\"\n"+ 1079 " javaName=\"aid\"\n"+ 1080 " type=\"INTEGER\"\n"+ 1081 " />\n"+ 1082 " </table>\n"+ 1083 " <table name=\"C\">\n"+ 1084 " <column name=\"id\"\n"+ 1085 " javaName=\"id\"\n"+ 1086 " type=\"INTEGER\"\n"+ 1087 " primaryKey=\"true\"\n"+ 1088 " required=\"true\"\n"+ 1089 " />\n"+ 1090 " </table>\n"+ 1091 "</database>", 1092 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 1093 } 1094 1095 public void testProxyPrefetchingLimit9() 1097 { 1098 addClass( 1099 "test.A", 1100 "package test;\n"+ 1101 "/** @ojb.class */\n"+ 1102 "public class A {\n"+ 1103 "/** @ojb.field primarykey=\"true\" */\n"+ 1104 " private int id;\n"+ 1105 "/** @ojb.collection element-class-ref=\"test.B\"\n"+ 1106 " * foreignkey=\"aid\"\n"+ 1107 " * database-foreignkey=\"false\"\n"+ 1108 " */\n"+ 1109 " private java.util.List objs;\n"+ 1110 "}\n"); 1111 addClass( 1112 "test.B", 1113 "package test;\n"+ 1114 "/** @ojb.class */\n"+ 1115 "public class B {\n"+ 1116 "/** @ojb.field */\n"+ 1117 " private int aid;\n"+ 1118 "}\n"); 1119 addClass( 1120 "test.C", 1121 "package test;\n"+ 1122 "/** @ojb.class\n" + 1123 " * @ojb.modify-inherited name=\"objs\"\n"+ 1124 " * proxy-prefetching-limit=\"10\"\n"+ 1125 " */\n"+ 1126 "public class C extends A {}\n"); 1127 1128 assertEqualsOjbDescriptorFile( 1129 "<class-descriptor\n"+ 1130 " class=\"test.A\"\n"+ 1131 " table=\"A\"\n"+ 1132 ">\n"+ 1133 " <extent-class class-ref=\"test.C\"/>\n"+ 1134 " <field-descriptor\n"+ 1135 " name=\"id\"\n"+ 1136 " column=\"id\"\n"+ 1137 " jdbc-type=\"INTEGER\"\n"+ 1138 " primarykey=\"true\"\n"+ 1139 " >\n"+ 1140 " </field-descriptor>\n"+ 1141 " <collection-descriptor\n"+ 1142 " name=\"objs\"\n"+ 1143 " element-class-ref=\"test.B\"\n"+ 1144 " >\n"+ 1145 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 1146 " </collection-descriptor>\n"+ 1147 "</class-descriptor>\n"+ 1148 "<class-descriptor\n"+ 1149 " class=\"test.B\"\n"+ 1150 " table=\"B\"\n"+ 1151 ">\n"+ 1152 " <field-descriptor\n"+ 1153 " name=\"aid\"\n"+ 1154 " column=\"aid\"\n"+ 1155 " jdbc-type=\"INTEGER\"\n"+ 1156 " >\n"+ 1157 " </field-descriptor>\n"+ 1158 "</class-descriptor>\n"+ 1159 "<class-descriptor\n"+ 1160 " class=\"test.C\"\n"+ 1161 " table=\"C\"\n"+ 1162 ">\n"+ 1163 " <field-descriptor\n"+ 1164 " name=\"id\"\n"+ 1165 " column=\"id\"\n"+ 1166 " jdbc-type=\"INTEGER\"\n"+ 1167 " primarykey=\"true\"\n"+ 1168 " >\n"+ 1169 " </field-descriptor>\n"+ 1170 " <collection-descriptor\n"+ 1171 " name=\"objs\"\n"+ 1172 " element-class-ref=\"test.B\"\n"+ 1173 " >\n"+ 1174 " <inverse-foreignkey field-ref=\"aid\"/>\n"+ 1175 " </collection-descriptor>\n"+ 1176 "</class-descriptor>", 1177 runOjbXDoclet(OJB_DEST_FILE)); 1178 assertEqualsTorqueSchemaFile( 1179 "<database name=\"ojbtest\">\n"+ 1180 " <table name=\"A\">\n"+ 1181 " <column name=\"id\"\n"+ 1182 " javaName=\"id\"\n"+ 1183 " type=\"INTEGER\"\n"+ 1184 " primaryKey=\"true\"\n"+ 1185 " required=\"true\"\n"+ 1186 " />\n"+ 1187 " </table>\n"+ 1188 " <table name=\"B\">\n"+ 1189 " <column name=\"aid\"\n"+ 1190 " javaName=\"aid\"\n"+ 1191 " type=\"INTEGER\"\n"+ 1192 " />\n"+ 1193 " </table>\n"+ 1194 " <table name=\"C\">\n"+ 1195 " <column name=\"id\"\n"+ 1196 " javaName=\"id\"\n"+ 1197 " type=\"INTEGER\"\n"+ 1198 " primaryKey=\"true\"\n"+ 1199 " required=\"true\"\n"+ 1200 " />\n"+ 1201 " </table>\n"+ 1202 "</database>", 1203 runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 1204 } 1205 1206 public void testProxyPrefetchingLimit10() 1208 { 1209 addClass( 1210 "test.A", 1211 "package test;\n"+ 1212 "/** @ojb.class */\n"+ 1213 "public class A {\n"+ 1214 "/** @ojb.field primarykey=\"true\" */\n"+ 1215 " private int id;\n"+ 1216 "/** @ojb.collection element-class-ref=\"test.B\"\n"+ 1217 " * foreignkey=\"aid\"\n"+ 1218 " * proxy=\"true\"\n"+ 1219 " */\n"+ 1220 " private java.util.List objs;\n"+ 1221 "}\n"); 1222 addClass( 1223 "test.B", 1224 "package test;\n"+ 1225 "/** @ojb.class */\n"+ 1226 "public class B {\n"+ 1227 "/** @ojb.field */\n"+ 1228 " private int aid;\n"+ 1229 "}\n"); 1230 addClass( 1231 "test.C", 1232 "package test;\n"+ 1233 "/** @ojb.class\n" + 1234 " * @ojb.modify-inherited name=\"objs\"\n"+ 1235 " * proxy-prefetching-limit=\"a\"\n"+ 1236 " */\n"+ 1237 "public class C extends A {}\n"); 1238 1239 assertNull(runOjbXDoclet(OJB_DEST_FILE)); 1240 assertNull(runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest")); 1241 } 1242} 1243 | Popular Tags |