1 19 package org.netbeans.tax; 20 21 import org.netbeans.tax.TreeElementDecl.ContentType; 22 import org.netbeans.tests.xml.XTest; 23 import org.openide.util.Utilities; 24 25 abstract class AbstractFactoryTest extends XTest { 26 final private static String NOT_EXCEPTION = "The InvalidArgumetException wasn't throwed "; 27 28 public AbstractFactoryTest(String testName) { 29 super(testName); 30 } 31 32 33 35 36 static TreeAttlistDecl createAttlistDecl(java.lang.String string, String view) throws Exception { 37 TreeAttlistDecl node = new TreeAttlistDecl(string); 38 39 assertEquals(node, view); 40 cloneNodeTest(node, view); 41 return node; 42 } 43 44 static void createAttlistDeclInvalid(java.lang.String string) throws Exception { 45 try { 46 new TreeAttlistDecl(string); 47 fail(NOT_EXCEPTION + "from: new TreeAttlistDecl(string)"); 49 } catch (InvalidArgumentException e) { 50 } 52 } 53 54 55 57 58 static TreeAttribute createAttribute(java.lang.String string, java.lang.String string1, boolean boolean_val, String view) throws Exception { 59 TreeAttribute node = new TreeAttribute(string, string1, boolean_val); 60 61 assertEquals(node, view); 62 cloneNodeTest(node, view); 63 return node; 64 } 65 66 static void createAttributeInvalid(java.lang.String string, java.lang.String string1, boolean boolean_val) throws Exception { 67 try { 68 new TreeAttribute(string, string1, boolean_val); 69 fail(NOT_EXCEPTION + "from: new TreeAttribute(string, string1, boolean_val)"); 71 } catch (InvalidArgumentException e) { 72 } 74 } 75 76 77 79 80 static TreeAttribute createAttribute(java.lang.String string, java.lang.String string1, String view) throws Exception { 81 TreeAttribute node = new TreeAttribute(string, string1); 82 83 assertEquals(node, view); 84 cloneNodeTest(node, view); 85 return node; 86 } 87 88 static void createAttributeInvalid(java.lang.String string, java.lang.String string1) throws Exception { 89 try { 90 new TreeAttribute(string, string1); 91 fail(NOT_EXCEPTION + "from: new TreeAttribute(string, string1)"); 93 } catch (InvalidArgumentException e) { 94 } 96 } 97 98 99 101 102 static TreeCDATASection createCDATASection(java.lang.String string, String view) throws Exception { 103 TreeCDATASection node = new TreeCDATASection(string); 104 105 assertEquals(node, view); 106 cloneNodeTest(node, view); 107 return node; 108 } 109 110 static void createCDATASectionInvalid(java.lang.String string) throws Exception { 111 try { 112 new TreeCDATASection(string); 113 fail(NOT_EXCEPTION + "from: new TreeCDATASection(string)"); 115 } catch (InvalidArgumentException e) { 116 } 118 } 119 120 121 123 124 static TreeCharacterReference createCharacterReference(java.lang.String string, String view) throws Exception { 125 TreeCharacterReference node = new TreeCharacterReference(string); 126 127 assertEquals(node, view); 128 cloneNodeTest(node, view); 129 return node; 130 } 131 132 static void createCharacterReferenceInvalid(java.lang.String string) throws Exception { 133 try { 134 new TreeCharacterReference(string); 135 fail(NOT_EXCEPTION + "from: new TreeCharacterReference(string)"); 137 } catch (InvalidArgumentException e) { 138 } 140 } 141 142 143 145 146 static TreeComment createComment(java.lang.String string, String view) throws Exception { 147 TreeComment node = new TreeComment(string); 148 149 assertEquals(node, view); 150 cloneNodeTest(node, view); 151 return node; 152 } 153 154 static void createCommentInvalid(java.lang.String string) throws Exception { 155 try { 156 new TreeComment(string); 157 fail(NOT_EXCEPTION + "from: new TreeComment(string)"); 159 } catch (InvalidArgumentException e) { 160 } 162 } 163 164 165 167 168 static TreeConditionalSection createConditionalSection(boolean boolean_val, String view) throws Exception { 169 TreeConditionalSection node = new TreeConditionalSection(boolean_val); 170 171 assertEquals(node, view); 172 cloneNodeTest(node, view); 173 return node; 174 } 175 176 177 179 180 static TreeDTD createDTD(java.lang.String string, java.lang.String string1, String view) throws Exception { 181 TreeDTD node = new TreeDTD(string, string1); 182 183 assertEquals(node, view); 184 cloneNodeTest(node, view); 185 return node; 186 } 187 188 static void createDTDInvalid(java.lang.String string, java.lang.String string1) throws Exception { 189 try { 190 new TreeDTD(string, string1); 191 fail(NOT_EXCEPTION + "from: new TreeDTD(string, string1)"); 193 } catch (InvalidArgumentException e) { 194 } 196 } 197 198 199 201 202 static TreeDocument createDocument(java.lang.String string, java.lang.String string1, java.lang.String string2, String view) throws Exception { 203 TreeDocument node = new TreeDocument(string, string1, string2); 204 205 assertEquals(node, view); 206 cloneNodeTest(node, view); 207 return node; 208 } 209 210 static void createDocumentInvalid(java.lang.String string, java.lang.String string1, java.lang.String string2) throws Exception { 211 try { 212 new TreeDocument(string, string1, string2); 213 fail(NOT_EXCEPTION + "from: new TreeDocument(string, string1, string2)"); 215 } catch (InvalidArgumentException e) { 216 } 218 } 219 220 221 223 224 static TreeDocumentFragment createDocumentFragment(java.lang.String string, java.lang.String string1, String view) throws Exception { 225 TreeDocumentFragment node = new TreeDocumentFragment(string, string1); 226 227 assertEquals(node, view); 228 cloneNodeTest(node, view); 229 return node; 230 } 231 232 static void createDocumentFragmentInvalid(java.lang.String string, java.lang.String string1) throws Exception { 233 try { 234 new TreeDocumentFragment(string, string1); 235 fail(NOT_EXCEPTION + "from: new TreeDocumentFragment(string, string1)"); 237 } catch (InvalidArgumentException e) { 238 } 240 } 241 242 243 245 246 static TreeDocumentType createDocumentType(java.lang.String string, java.lang.String string1, java.lang.String string2, String view) throws Exception { 247 TreeDocumentType node = new TreeDocumentType(string, string1, string2); 248 249 assertEquals(node, view); 250 cloneNodeTest(node, view); 251 return node; 252 } 253 254 static void createDocumentTypeInvalid(java.lang.String string, java.lang.String string1, java.lang.String string2) throws Exception { 255 try { 256 new TreeDocumentType(string, string1, string2); 257 fail(NOT_EXCEPTION + "from: new TreeDocumentType(string, string1, string2)"); 259 } catch (InvalidArgumentException e) { 260 } 262 } 263 264 265 267 268 static TreeDocumentType createDocumentType(java.lang.String string, String view) throws Exception { 269 TreeDocumentType node = new TreeDocumentType(string); 270 271 assertEquals(node, view); 272 cloneNodeTest(node, view); 273 return node; 274 } 275 276 static void createDocumentTypeInvalid(java.lang.String string) throws Exception { 277 try { 278 new TreeDocumentType(string); 279 fail(NOT_EXCEPTION + "from: new TreeDocumentType(string)"); 281 } catch (InvalidArgumentException e) { 282 } 284 } 285 286 287 289 290 static TreeElement createElement(java.lang.String string, boolean boolean_val, String view) throws Exception { 291 TreeElement node = new TreeElement(string, boolean_val); 292 293 assertEquals(node, view); 294 cloneNodeTest(node, view); 295 return node; 296 } 297 298 static void createElementInvalid(java.lang.String string, boolean boolean_val) throws Exception { 299 try { 300 new TreeElement(string, boolean_val); 301 fail(NOT_EXCEPTION + "from: new TreeElement(string, boolean_val)"); 303 } catch (InvalidArgumentException e) { 304 } 306 } 307 308 309 311 312 static TreeElement createElement(java.lang.String string, String view) throws Exception { 313 TreeElement node = new TreeElement(string); 314 315 assertEquals(node, view); 316 cloneNodeTest(node, view); 317 return node; 318 } 319 320 static void createElementInvalid(java.lang.String string) throws Exception { 321 try { 322 new TreeElement(string); 323 fail(NOT_EXCEPTION + "from: new TreeElement(string)"); 325 } catch (InvalidArgumentException e) { 326 } 328 } 329 330 331 333 334 static TreeElementDecl createElementDecl(java.lang.String string, ContentType treeelementdecl$contenttype, String view) throws Exception { 335 TreeElementDecl node = new TreeElementDecl(string, treeelementdecl$contenttype); 336 337 assertEquals(node, view); 338 cloneNodeTest(node, view); 339 return node; 340 } 341 342 static void createElementDeclInvalid(java.lang.String string, ContentType treeelementdecl$contenttype) throws Exception { 343 try { 344 new TreeElementDecl(string, treeelementdecl$contenttype); 345 fail(NOT_EXCEPTION + "from: new TreeElementDecl(string, treeelementdecl$contenttype)"); 347 } catch (InvalidArgumentException e) { 348 } 350 } 351 352 353 355 375 377 378 static TreeEntityDecl createEntityDecl(boolean boolean_val, java.lang.String string, java.lang.String string2, String view) throws Exception { 379 TreeEntityDecl node = new TreeEntityDecl(boolean_val, string, string2); 380 381 assertEquals(node, view); 382 cloneNodeTest(node, view); 383 return node; 384 } 385 386 static void createEntityDeclInvalid(boolean boolean_val, java.lang.String string, java.lang.String string2) throws Exception { 387 try { 388 new TreeEntityDecl(boolean_val, string, string2); 389 fail(NOT_EXCEPTION + "from: new TreeEntityDecl(boolean_val, string, string2)"); 391 } catch (InvalidArgumentException e) { 392 } 394 } 395 396 397 399 400 static TreeEntityDecl createEntityDecl(java.lang.String string, java.lang.String string1, String view) throws Exception { 401 TreeEntityDecl node = new TreeEntityDecl(string, string1); 402 403 assertEquals(node, view); 404 cloneNodeTest(node, view); 405 return node; 406 } 407 408 static void createEntityDeclInvalid(java.lang.String string, java.lang.String string1) throws Exception { 409 try { 410 new TreeEntityDecl(string, string1); 411 fail(NOT_EXCEPTION + "from: new TreeEntityDecl(string, string1)"); 413 } catch (InvalidArgumentException e) { 414 } 416 } 417 418 419 421 422 static TreeEntityDecl createEntityDecl(boolean boolean_val, java.lang.String string, java.lang.String string2, java.lang.String string3, String view) throws Exception { 423 TreeEntityDecl node = new TreeEntityDecl(boolean_val, string, string2, string3); 424 425 assertEquals(node, view); 426 cloneNodeTest(node, view); 427 return node; 428 } 429 430 static void createEntityDeclInvalid(boolean boolean_val, java.lang.String string, java.lang.String string2, java.lang.String string3) throws Exception { 431 try { 432 new TreeEntityDecl(boolean_val, string, string2, string3); 433 fail(NOT_EXCEPTION + "from: new TreeEntityDecl(boolean_val, string, string2, string3)"); 435 } catch (InvalidArgumentException e) { 436 } 438 } 439 440 441 443 444 static TreeEntityDecl createEntityDecl(java.lang.String string, java.lang.String string1, java.lang.String string2, String view) throws Exception { 445 TreeEntityDecl node = new TreeEntityDecl(string, string1, string2); 446 447 assertEquals(node, view); 448 cloneNodeTest(node, view); 449 return node; 450 } 451 452 static void createEntityDeclInvalid(java.lang.String string, java.lang.String string1, java.lang.String string2) throws Exception { 453 try { 454 new TreeEntityDecl(string, string1, string2); 455 fail(NOT_EXCEPTION + "from: new TreeEntityDecl(string, string1, string2)"); 457 } catch (InvalidArgumentException e) { 458 } 460 } 461 462 463 465 466 static TreeEntityDecl createEntityDecl(java.lang.String string, java.lang.String string1, java.lang.String string2, java.lang.String string3, String view) throws Exception { 467 TreeEntityDecl node = new TreeEntityDecl(string, string1, string2, string3); 468 469 assertEquals(node, view); 470 cloneNodeTest(node, view); 471 return node; 472 } 473 474 static void createEntityDeclInvalid(java.lang.String string, java.lang.String string1, java.lang.String string2, java.lang.String string3) throws Exception { 475 try { 476 new TreeEntityDecl(string, string1, string2, string3); 477 fail(NOT_EXCEPTION + "from: new TreeEntityDecl(string, string1, string2, string3)"); 479 } catch (InvalidArgumentException e) { 480 } 482 } 483 484 485 487 488 static TreeGeneralEntityReference createGeneralEntityReference(java.lang.String string, String view) throws Exception { 489 TreeGeneralEntityReference node = new TreeGeneralEntityReference(string); 490 491 assertEquals(node, view); 492 cloneNodeTest(node, view); 493 return node; 494 } 495 496 static void createGeneralEntityReferenceInvalid(java.lang.String string) throws Exception { 497 try { 498 new TreeGeneralEntityReference(string); 499 fail(NOT_EXCEPTION + "from: new TreeGeneralEntityReference(string)"); 501 } catch (InvalidArgumentException e) { 502 } 504 } 505 506 507 509 510 static TreeNotationDecl createNotationDecl(java.lang.String string, java.lang.String string1, java.lang.String string2, String view) throws Exception { 511 TreeNotationDecl node = new TreeNotationDecl(string, string1, string2); 512 513 assertEquals(node, view); 514 cloneNodeTest(node, view); 515 return node; 516 } 517 518 static void createNotationDeclInvalid(java.lang.String string, java.lang.String string1, java.lang.String string2) throws Exception { 519 try { 520 new TreeNotationDecl(string, string1, string2); 521 fail(NOT_EXCEPTION + "from: new TreeNotationDecl(string, string1, string2)"); 523 } catch (InvalidArgumentException e) { 524 } 526 } 527 528 529 531 532 static TreeParameterEntityReference createParameterEntityReference(java.lang.String string, String view) throws Exception { 533 TreeParameterEntityReference node = new TreeParameterEntityReference(string); 534 535 assertEquals(node, view); 536 cloneNodeTest(node, view); 537 return node; 538 } 539 540 static void createParameterEntityReferenceInvalid(java.lang.String string) throws Exception { 541 try { 542 new TreeParameterEntityReference(string); 543 fail(NOT_EXCEPTION + "from: new TreeParameterEntityReference(string)"); 545 } catch (InvalidArgumentException e) { 546 } 548 } 549 550 551 553 554 static TreeProcessingInstruction createProcessingInstruction(java.lang.String string, java.lang.String string1, String view) throws Exception { 555 TreeProcessingInstruction node = new TreeProcessingInstruction(string, string1); 556 557 assertEquals(node, view); 558 cloneNodeTest(node, view); 559 return node; 560 } 561 562 static void createProcessingInstructionInvalid(java.lang.String string, java.lang.String string1) throws Exception { 563 try { 564 new TreeProcessingInstruction(string, string1); 565 fail(NOT_EXCEPTION + "from: new TreeProcessingInstruction(string, string1)"); 567 } catch (InvalidArgumentException e) { 568 } 570 } 571 572 573 575 576 static TreeText createText(java.lang.String string, String view) throws Exception { 577 TreeText node = new TreeText(string); 578 579 assertEquals(node, view); 580 cloneNodeTest(node, view); 581 return node; 582 } 583 584 static void createTextInvalid(java.lang.String string) throws Exception { 585 try { 586 new TreeText(string); 587 fail(NOT_EXCEPTION + "from: new TreeText(string)"); 589 } catch (InvalidArgumentException e) { 590 } 592 } 593 594 595 private static void cloneNodeTest(TreeParentNode node, String view) throws Exception { 596 TreeParentNode clone = (TreeParentNode) node.clone(true); 597 assertNotEquals(clone, node); 598 assertEquals(clone, view); 599 600 clone = (TreeParentNode) node.clone(false); 601 assertNotEquals(clone, node); 602 assertEquals(clone, view); 603 } 604 605 private static void cloneNodeTest(TreeNode node, String view) throws Exception { 606 TreeNode clone = (TreeNode) node.clone(); 607 assertNotEquals(clone, node); 608 assertEquals(clone, view); 609 } 610 611 private static void assertNotEquals(Object orig, Object clone) { 612 if (orig == clone) { 613 fail("Invalid clone."); 614 } 615 } 616 617 private static void assertEquals(TreeNode node, String view) throws TreeException{ 618 String str = Utilities.replaceString(TestUtil.nodeToString(node), "\n", ""); 619 if (!!! str.equals(view)) { 620 fail("Invalid node view \n is : \"" + str + "\"\n should be: \"" + view + "\""); 621 } 622 } 623 } 624 | Popular Tags |