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