1 /* 2 * Copyright (c) 2001-2004 World Wide Web Consortium, (Massachusetts Institute 3 * of Technology, Institut National de Recherche en Informatique et en 4 * Automatique, Keio University). All Rights Reserved. This program is 5 * distributed under the W3C's Software Intellectual Property License. This 6 * program is distributed in the hope that it will be useful, but WITHOUT ANY 7 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 8 * FOR A PARTICULAR PURPOSE. See W3C License 9 * http://www.w3.org/Consortium/Legal/ for more details. 10 */ 11 12 package org.w3c.domts; 13 14 import java.lang.reflect.Constructor; 15 import java.lang.reflect.InvocationTargetException; 16 import java.lang.reflect.Method; 17 import java.util.ArrayList; 18 import java.util.Collection; 19 import java.util.List; 20 import java.util.Iterator; 21 22 import org.w3c.dom.NamedNodeMap; 23 import org.w3c.dom.NodeList; 24 25 /** 26 * This is an abstract base class for generated DOM tests 27 */ 28 public abstract class DOMTestCase 29 extends DOMTest { 30 private DOMTestFramework framework; 31 32 /** 33 * This constructor is for DOMTestCase's that make specific demands for 34 * parser configuration. setFactory should be called before the end of the 35 * tests constructor to set the factory. 36 */ DOMTestCase()37 public DOMTestCase() { 38 framework = null; 39 } 40 41 /** 42 * This constructor is for DOMTestCase's that do not add any requirements 43 * for parser configuration. 44 * 45 * @param factory 46 * document factory to be used by test, may not be null. 47 */ DOMTestCase(DOMTestDocumentBuilderFactory factory)48 public DOMTestCase(DOMTestDocumentBuilderFactory factory) { 49 super(factory); 50 framework = null; 51 } 52 53 /** 54 * This method is called by the main() for each test and locates the 55 * appropriate test framework and runs the specified test 56 * 57 * @param testClass 58 * test class 59 * @param args 60 * arguments to test class 61 */ doMain(Class testClass, String[] args)62 public static void doMain(Class testClass, String[] args) { 63 // 64 // Attempt to load JUnitRunner 65 // 66 ClassLoader loader = ClassLoader.getSystemClassLoader(); 67 try { 68 Class runnerClass = loader.loadClass("org.w3c.domts.JUnitRunner"); 69 Constructor runnerFactory = 70 runnerClass.getConstructor(new Class[] {Class.class}); 71 // 72 // create the JUnitRunner 73 // 74 Object junitRun = 75 runnerFactory.newInstance(new Object[] {testClass}); 76 // 77 // find and call its execute method method 78 // 79 Class argsClass = loader.loadClass("[Ljava.lang.String;"); 80 Method execMethod = 81 runnerClass.getMethod("execute", new Class[] {argsClass}); 82 execMethod.invoke(junitRun, new Object[] {args}); 83 } 84 catch (InvocationTargetException ex) { 85 ex.getTargetException().printStackTrace(); 86 } 87 catch (Exception ex) { 88 System.out.println( 89 "junit-run.jar and junit.jar \n must be in same directory or on classpath."); 90 ex.printStackTrace(); 91 } 92 } 93 94 /** 95 * Body of test 96 * 97 * @throws Throwable 98 */ runTest()99 abstract public void runTest() throws Throwable; 100 101 /** 102 * Sets test framework to be used by test. 103 * 104 * @param framework 105 */ setFramework(DOMTestFramework framework)106 public void setFramework(DOMTestFramework framework) { 107 this.framework = framework; 108 } 109 110 /** 111 * Wait 112 * 113 * @param millisecond 114 * milliseconds to wait 115 */ wait(int millisecond)116 public void wait(int millisecond) { 117 framework.wait(millisecond); 118 } 119 120 /** 121 * Fail test 122 * 123 * @param assertID 124 * identifier of assertion 125 */ fail(String assertID)126 public void fail(String assertID) { 127 framework.fail(this, assertID); 128 } 129 130 /** 131 * Asserts that actual==true 132 * 133 * @param assertID 134 * identifier of assertion 135 * @param actual 136 * actual value 137 */ assertTrue(String assertID, boolean actual)138 public void assertTrue(String assertID, boolean actual) { 139 framework.assertTrue(this, assertID, actual); 140 } 141 142 /** 143 * Asserts that actual==true 144 * 145 * @param assertID 146 * identifier of assertion 147 * @param actual 148 * actual value 149 */ assertTrue(String assertID, Object actual)150 public void assertTrue(String assertID, Object actual) { 151 framework.assertTrue(this, assertID, ( (Boolean) actual).booleanValue()); 152 } 153 154 /** 155 * Asserts that actual==false 156 * 157 * @param assertID 158 * identifier of assertion 159 * @param actual 160 * actual value 161 */ assertFalse(String assertID, boolean actual)162 public void assertFalse(String assertID, boolean actual) { 163 framework.assertFalse(this, assertID, actual); 164 } 165 166 /** 167 * Asserts that actual==false 168 * 169 * @param assertID 170 * identifier of assertion 171 * @param actual 172 * actual value 173 */ assertFalse(String assertID, Object actual)174 public void assertFalse(String assertID, Object actual) { 175 framework.assertFalse( 176 this, 177 assertID, 178 ( (Boolean) actual).booleanValue()); 179 } 180 181 /** 182 * Asserts that actual == null 183 * 184 * @param assertID 185 * identifier of assertion 186 * @param actual 187 * actual value 188 */ assertNull(String assertID, Object actual)189 public void assertNull(String assertID, Object actual) { 190 framework.assertNull(this, assertID, actual); 191 } 192 193 /** 194 * Asserts that actual != null 195 * 196 * @param assertID 197 * identifier of assertion 198 * @param actual 199 * actual value 200 */ assertNotNull(String assertID, Object actual)201 public void assertNotNull(String assertID, Object actual) { 202 framework.assertNotNull(this, assertID, actual); 203 } 204 205 /** 206 * Asserts that actual and expected are the same object 207 * 208 * @param assertID 209 * identifier of assertion 210 * @param actual 211 * actual value 212 */ assertSame(String assertID, Object expected, Object actual)213 public void assertSame(String assertID, Object expected, Object actual) { 214 framework.assertSame(this, assertID, expected, actual); 215 } 216 217 /** 218 * Asserts that obj is an instance of cls 219 * 220 * @param assertID 221 * identifier of assertion 222 * @param obj 223 * object 224 * @param cls 225 * class, may not be null. 226 */ assertInstanceOf(String assertID, Class cls, Object obj)227 public void assertInstanceOf(String assertID, Class cls, Object obj) { 228 framework.assertInstanceOf(this, assertID, obj, cls); 229 } 230 231 /** 232 * Asserts that the length of the collection is the expected size. 233 * 234 * @param assertID 235 * identifier of assertion 236 * @param expectedSize 237 * expected size 238 * @param collection 239 * collection 240 */ assertSize( String assertID, int expectedSize, NodeList collection)241 public void assertSize( 242 String assertID, 243 int expectedSize, 244 NodeList collection) { 245 framework.assertSize(this, assertID, expectedSize, collection); 246 } 247 248 /** 249 * Asserts that the length of the collection is the expected size. 250 * 251 * @param assertID 252 * identifier of assertion 253 * @param expectedSize 254 * expected size 255 * @param collection 256 * collection 257 */ assertSize( String assertID, int expectedSize, NamedNodeMap collection)258 public void assertSize( 259 String assertID, 260 int expectedSize, 261 NamedNodeMap collection) { 262 framework.assertSize(this, assertID, expectedSize, collection); 263 } 264 265 /** 266 * Asserts that the length of the collection is the expected size. 267 * 268 * @param assertID 269 * identifier of assertion 270 * @param expectedSize 271 * expected size 272 * @param collection 273 * collection 274 */ assertSize( String assertID, int expectedSize, Collection collection)275 public void assertSize( 276 String assertID, 277 int expectedSize, 278 Collection collection) { 279 framework.assertSize(this, assertID, expectedSize, collection); 280 } 281 282 /** 283 * Asserts that expected.equalsIgnoreCase(actual) is true 284 * 285 * @param assertID 286 * identifier of assertion 287 * @param actual 288 * actual value 289 * @param expected 290 * Expected value, may not be null. 291 */ assertEqualsIgnoreCase( String assertID, String expected, String actual)292 public void assertEqualsIgnoreCase( 293 String assertID, 294 String expected, 295 String actual) { 296 framework.assertEqualsIgnoreCase(this, assertID, expected, actual); 297 } 298 299 /** 300 * Asserts that each entry in actual is matched with an entry in expected 301 * that only differs by case. Order is not significant. 302 * 303 * @param assertID 304 * identifier of assertion 305 * @param actual 306 * actual value 307 * @param expected 308 * Expected value, may not be null. 309 */ assertEqualsIgnoreCase( String assertID, Collection expected, Collection actual)310 public void assertEqualsIgnoreCase( 311 String assertID, 312 Collection expected, 313 Collection actual) { 314 framework.assertEqualsIgnoreCase(this, assertID, expected, actual); 315 } 316 317 /** 318 * Asserts that each entry in actual is matched with an entry in expected 319 * that only differs by case. Order is significant. 320 * 321 * @param assertID 322 * identifier of assertion 323 * @param actual 324 * actual value 325 * @param expected 326 * Expected value, may not be null. 327 */ assertEqualsIgnoreCase( String assertID, List expected, List actual)328 public void assertEqualsIgnoreCase( 329 String assertID, 330 List expected, 331 List actual) { 332 framework.assertEqualsIgnoreCase(this, assertID, expected, actual); 333 } 334 335 /** 336 * Asserts that expected.equalsIgnoreCase(actual) is true 337 * 338 * @param assertID 339 * identifier of assertion 340 * @param actual 341 * actual value 342 * @param expected 343 * Expected value, may not be null. 344 */ assertEqualsAutoCase( String context, String assertID, String expected, String actual)345 public void assertEqualsAutoCase( 346 String context, 347 String assertID, 348 String expected, 349 String actual) { 350 String contentType = getContentType(); 351 // 352 // if the content type is HTML (not XHTML) 353 // 354 if ("text/html".equals(contentType)) { 355 // 356 // if the context is attribute, then use case-insentive comparison 357 // 358 if ("attribute".equals(context)) { 359 framework.assertEqualsIgnoreCase(this, assertID, expected, actual); 360 } 361 else { 362 // 363 // otherwise should be compared against uppercased expectation 364 framework.assertEquals(this, assertID, expected.toUpperCase(), actual); 365 } 366 } 367 else { 368 framework.assertEquals(this, assertID, expected, actual); 369 } 370 } 371 372 /** 373 * Creates an equivalent list where every member has 374 * been uppercased 375 * 376 */ toUpperCase(Collection expected)377 private List toUpperCase(Collection expected) { 378 List upperd = new ArrayList(expected.size()); 379 Iterator iter = expected.iterator(); 380 while (iter.hasNext()) { 381 upperd.add(iter.next().toString().toUpperCase()); 382 } 383 return upperd; 384 } 385 386 /** 387 * Asserts that each entry in actual is matched with an entry in expected 388 * that only differs by case. Order is not significant. 389 * 390 * @param assertID 391 * identifier of assertion 392 * @param actual 393 * actual value 394 * @param expected 395 * Expected value, may not be null. 396 */ assertEqualAutoCase( String context, String assertID, Collection expected, Collection actual)397 public void assertEqualAutoCase( 398 String context, 399 String assertID, 400 Collection expected, 401 Collection actual) { 402 String contentType = getContentType(); 403 if ("text/html".equals(contentType)) { 404 if ("attribute".equals(context)) { 405 assertEqualsIgnoreCase(assertID, expected, actual); 406 } 407 else { 408 framework.assertEquals(this, assertID, toUpperCase(expected), actual); 409 } 410 411 } 412 else { 413 framework.assertEquals(this, assertID, expected, actual); 414 } 415 } 416 417 /** 418 * Asserts that each entry in actual is matched with an entry in expected 419 * that only differs by case. Order is significant. 420 * 421 * @param assertID 422 * identifier of assertion 423 * @param actual 424 * actual value 425 * @param expected 426 * Expected value, may not be null. 427 */ assertEqualsAutoCase( String context, String assertID, List expected, List actual)428 public void assertEqualsAutoCase( 429 String context, 430 String assertID, 431 List expected, 432 List actual) { 433 String contentType = getContentType(); 434 if ("text/html".equals(contentType)) { 435 if ("attribute".equals(context)) { 436 assertEqualsIgnoreCase(assertID, expected, actual); 437 } 438 else { 439 framework.assertEquals(this, assertID, toUpperCase(expected), actual); 440 } 441 442 } 443 else { 444 framework.assertEquals(this, assertID, expected, actual); 445 } 446 } 447 448 /** 449 * Asserts that expected.equals(actual) is true 450 * 451 * @param assertID 452 * identifier of assertion 453 * @param actual 454 * actual value 455 * @param expected 456 * Expected value, may not be null. 457 */ assertEquals(String assertID, String expected, String actual)458 public void assertEquals(String assertID, String expected, String actual) { 459 framework.assertEquals(this, assertID, expected, actual); 460 } 461 462 /** 463 * Asserts that values of expected and actual are equal. 464 * 465 * @param assertID 466 * identifier of assertion 467 * @param actual 468 * actual value 469 * @param expected 470 * Expected value, may not be null. 471 */ assertEquals(String assertID, int expected, int actual)472 public void assertEquals(String assertID, int expected, int actual) { 473 framework.assertEquals(this, assertID, expected, actual); 474 } 475 476 /** 477 * Asserts that values of expected and actual are equal. 478 * 479 * @param assertID 480 * identifier of assertion 481 * @param actual 482 * actual value 483 * @param expected 484 * Expected value, may not be null. 485 */ assertEquals(String assertID, double expected, double actual)486 public void assertEquals(String assertID, double expected, double actual) { 487 framework.assertEquals(this, assertID, expected, actual); 488 } 489 490 /** 491 * Asserts that values of expected and actual are equal. 492 * 493 * @param assertID 494 * identifier of assertion 495 * @param actual 496 * actual value 497 * @param expected 498 * Expected value, may not be null. 499 */ assertEquals( String assertID, boolean expected, boolean actual)500 public void assertEquals( 501 String assertID, 502 boolean expected, 503 boolean actual) { 504 framework.assertEquals(this, assertID, expected, actual); 505 } 506 507 /** 508 * Asserts that each entry in actual exactly matches with an entry in 509 * expected. Order is not significant. 510 * 511 * @param assertID 512 * identifier of assertion 513 * @param actual 514 * actual value 515 * @param expected 516 * Expected value, may not be null. 517 */ assertEquals( String assertID, Collection expected, NodeList actual)518 public void assertEquals( 519 String assertID, 520 Collection expected, 521 NodeList actual) { 522 Collection actualList = new ArrayList(); 523 int actualLen = actual.getLength(); 524 for (int i = 0; i < actualLen; i++) { 525 actualList.add(actual.item(i)); 526 } 527 framework.assertEquals(this, assertID, expected, actualList); 528 } 529 530 /** 531 * Asserts that each entry in actual exactly matches with an entry in 532 * expected. Order is not significant. 533 * 534 * @param assertID 535 * identifier of assertion 536 * @param actual 537 * actual value 538 * @param expected 539 * Expected value, may not be null. 540 */ assertEquals( String assertID, Collection expected, Collection actual)541 public void assertEquals( 542 String assertID, 543 Collection expected, 544 Collection actual) { 545 framework.assertEquals(this, assertID, expected, actual); 546 } 547 548 /** 549 * Asserts that expected.equalsIgnoreCase(actual) is false 550 * 551 * @param assertID 552 * identifier of assertion 553 * @param actual 554 * actual value 555 * @param expected 556 * Expected value, may not be null. 557 */ assertNotEqualsIgnoreCase( String assertID, String expected, String actual)558 public void assertNotEqualsIgnoreCase( 559 String assertID, 560 String expected, 561 String actual) { 562 framework.assertNotEqualsIgnoreCase(this, assertID, expected, actual); 563 } 564 565 /** 566 * Asserts that expected.equalsIgnoreCase(actual) is false 567 * 568 * @param assertID 569 * identifier of assertion 570 * @param actual 571 * actual value 572 * @param expected 573 * Expected value, may not be null. 574 */ assertNotEqualsAutoCase( String context, String assertID, String expected, String actual)575 public void assertNotEqualsAutoCase( 576 String context, 577 String assertID, 578 String expected, 579 String actual) { 580 String contentType = getContentType(); 581 if ("text/html".equals(contentType)) { 582 if ("attribute".equals(context)) { 583 framework.assertNotEqualsIgnoreCase(this, assertID, expected, actual); 584 } 585 else { 586 framework.assertNotEquals(this, assertID, expected.toUpperCase(), 587 actual); 588 } 589 } 590 framework.assertNotEquals(this, assertID, expected, actual); 591 } 592 593 /** 594 * Asserts that values of expected and actual are not equal. 595 * 596 * @param assertID 597 * identifier of assertion 598 * @param actual 599 * actual value 600 * @param expected 601 * Expected value, may not be null. 602 */ assertNotEquals( String assertID, String expected, String actual)603 public void assertNotEquals( 604 String assertID, 605 String expected, 606 String actual) { 607 framework.assertNotEquals(this, assertID, expected, actual); 608 } 609 610 /** 611 * Asserts that values of expected and actual are not equal. 612 * 613 * @param assertID 614 * identifier of assertion 615 * @param actual 616 * actual value 617 * @param expected 618 * Expected value, may not be null. 619 */ assertNotEquals(String assertID, int expected, int actual)620 public void assertNotEquals(String assertID, int expected, int actual) { 621 framework.assertNotEquals(this, assertID, expected, actual); 622 } 623 624 /** 625 * Asserts that values of expected and actual are not equal. 626 * 627 * @param assertID 628 * identifier of assertion 629 * @param actual 630 * actual value 631 * @param expected 632 * Expected value, may not be null. 633 */ assertNotEquals( String assertID, double expected, double actual)634 public void assertNotEquals( 635 String assertID, 636 double expected, 637 double actual) { 638 framework.assertNotEquals(this, assertID, expected, actual); 639 } 640 641 /** 642 * Asserts aspects of a URI 643 * 644 * @param assertID 645 * identifier of assertion 646 * @param scheme 647 * Expected scheme, for example, "file". If null, scheme is 648 * ignored. 649 * @param path 650 * Expected path, for example, "/DOM/Test". If null, path is 651 * ignored. 652 * @param host 653 * Expected host, for example, "www.w3.org". If null, host is 654 * ignored. 655 * @param file 656 * Expected file, for example, "staff.xml". If null, file is 657 * ignored. 658 * @param name 659 * Expected name, for example, "staff". If null, name is 660 * ignored. 661 * @param name 662 * Expected name, for example, "staff". If null, name is 663 * ignored. 664 * @param isAbsolute 665 * if Boolean.TRUE, URI must be absolute. Null indicates no 666 * assertion. 667 * @param actual 668 * URI to be tested. 669 */ assertURIEquals( String assertID, String scheme, String path, String host, String file, String name, String query, String fragment, Boolean isAbsolute, String actual)670 public void assertURIEquals( 671 String assertID, 672 String scheme, 673 String path, 674 String host, 675 String file, 676 String name, 677 String query, 678 String fragment, 679 Boolean isAbsolute, 680 String actual) { 681 // 682 // URI must be non-null 683 assertNotNull(assertID, actual); 684 685 String uri = actual; 686 687 int lastPound = actual.lastIndexOf("#"); 688 String actualFragment = ""; 689 if (lastPound != -1) { 690 // 691 // substring before pound 692 // 693 uri = actual.substring(0, lastPound); 694 actualFragment = actual.substring(lastPound + 1); 695 } 696 if (fragment != null) { 697 assertEquals(assertID, fragment, actualFragment); 698 699 } 700 int lastQuestion = uri.lastIndexOf("?"); 701 String actualQuery = ""; 702 if (lastQuestion != -1) { 703 // 704 // substring before pound 705 // 706 uri = actual.substring(0, lastQuestion); 707 actualQuery = actual.substring(lastQuestion + 1); 708 } 709 if (query != null) { 710 assertEquals(assertID, query, actualQuery); 711 712 } 713 int firstColon = uri.indexOf(":"); 714 int firstSlash = uri.indexOf("/"); 715 String actualPath = uri; 716 String actualScheme = ""; 717 if (firstColon != -1 && firstColon < firstSlash) { 718 actualScheme = uri.substring(0, firstColon); 719 actualPath = uri.substring(firstColon + 1); 720 } 721 722 if (scheme != null) { 723 assertEquals(assertID, scheme, actualScheme); 724 } 725 726 if (path != null) { 727 assertEquals(assertID, path, actualPath); 728 } 729 730 if (host != null) { 731 String actualHost = ""; 732 if (actualPath.startsWith("//")) { 733 int termSlash = actualPath.indexOf("/", 2); 734 actualHost = actualPath.substring(0, termSlash); 735 } 736 assertEquals(assertID, host, actualHost); 737 } 738 739 String actualFile = actualPath; 740 if (file != null || name != null) { 741 int finalSlash = actualPath.lastIndexOf("/"); 742 if (finalSlash != -1) { 743 actualFile = actualPath.substring(finalSlash + 1); 744 } 745 if (file != null) { 746 assertEquals(assertID, file, actualFile); 747 } 748 } 749 750 if (name != null) { 751 String actualName = actualFile; 752 int finalPeriod = actualFile.lastIndexOf("."); 753 if (finalPeriod != -1) { 754 actualName = actualFile.substring(0, finalPeriod); 755 } 756 assertEquals(assertID, name, actualName); 757 } 758 759 if (isAbsolute != null) { 760 // 761 // Jar URL's will have any actual path like file:/c:/somedrive... 762 assertEquals( 763 assertID, 764 isAbsolute.booleanValue(), 765 actualPath.startsWith("/") || actualPath.startsWith("file:/")); 766 } 767 } 768 769 /** 770 * Compares the identity of actual and expected. 771 * 772 * @param expected 773 * expected 774 * @param actual 775 * actual 776 * @return true if actual and expected are the same object. 777 */ same(Object expected, Object actual)778 public boolean same(Object expected, Object actual) { 779 return framework.same(expected, actual); 780 } 781 782 /** 783 * Compares the value of actual and expected ignoring case. 784 * 785 * @param expected 786 * expected 787 * @param actual 788 * actual 789 * @return true if actual and expected are equal ignoring case. 790 */ equalsIgnoreCase(String expected, String actual)791 public boolean equalsIgnoreCase(String expected, String actual) { 792 return framework.equalsIgnoreCase(expected, actual); 793 } 794 795 /** 796 * Compares the values in actual and expected ignoring case and order. 797 * 798 * @param expected 799 * expected 800 * @param actual 801 * actual 802 * @return true if actual and expected are equal ignoring case. 803 */ equalsIgnoreCase(Collection expected, Collection actual)804 public boolean equalsIgnoreCase(Collection expected, Collection actual) { 805 return framework.equalsIgnoreCase(expected, actual); 806 } 807 808 /** 809 * Compares the values in actual and expected ignoring case. 810 * 811 * @param expected 812 * expected 813 * @param actual 814 * actual 815 * @return true if actual and expected are equal ignoring case. 816 */ equalsIgnoreCase(List expected, List actual)817 public boolean equalsIgnoreCase(List expected, List actual) { 818 return framework.equalsIgnoreCase(expected, actual); 819 } 820 821 /** 822 * Compares the value of actual and expected ignoring case. 823 * 824 * @param expected 825 * expected 826 * @param actual 827 * actual 828 * @return true if actual and expected are equal ignoring case. 829 */ equalsAutoCase(String context, String expected, String actual)830 public boolean equalsAutoCase(String context, String expected, String actual) { 831 if ("text/html".equals(getContentType())) { 832 if ("attribute".equals(context)) { 833 return framework.equalsIgnoreCase(expected, actual); 834 } 835 else { 836 return framework.equals(expected.toUpperCase(), actual); 837 } 838 } 839 return framework.equals(expected, actual); 840 } 841 842 /** 843 * Compares the values in actual and expected ignoring case and order. 844 * 845 * @param expected 846 * expected 847 * @param actual 848 * actual 849 * @return true if actual and expected are equal ignoring case. 850 */ equalsAutoCase(String context, Collection expected, Collection actual)851 public boolean equalsAutoCase(String context, Collection expected, 852 Collection actual) { 853 if ("text/html".equals(getContentType())) { 854 if ("attribute".equals(context)) { 855 return framework.equalsIgnoreCase(expected, actual); 856 } 857 else { 858 return framework.equals(toUpperCase(expected), actual); 859 } 860 } 861 return framework.equals(expected, actual); 862 } 863 864 /** 865 * Compares the values in actual and expected ignoring case. 866 * 867 * @param expected 868 * expected 869 * @param actual 870 * actual 871 * @return true if actual and expected are equal ignoring case. 872 */ equalsAutoCase(String context, List expected, List actual)873 public boolean equalsAutoCase(String context, List expected, List actual) { 874 if ("text/html".equals(getContentType())) { 875 if ("attribute".equals(context)) { 876 return framework.equalsIgnoreCase(expected, actual); 877 } 878 else { 879 return framework.equals(toUpperCase(expected), actual); 880 } 881 } 882 return framework.equals(expected, actual); 883 } 884 885 /** 886 * Compares the values of actual and expected. 887 * 888 * @param expected 889 * expected 890 * @param actual 891 * actual 892 * @return true if actual and expected are equal. 893 */ equals(String expected, String actual)894 public boolean equals(String expected, String actual) { 895 return framework.equals(expected, actual); 896 } 897 898 /** 899 * Compares the values of actual and expected. 900 * 901 * @param expected 902 * expected 903 * @param actual 904 * actual 905 * @return true if actual and expected are equal. 906 */ equals(int expected, int actual)907 public boolean equals(int expected, int actual) { 908 return framework.equals(expected, actual); 909 } 910 911 /** 912 * Compares the values of actual and expected. 913 * 914 * @param expected 915 * expected 916 * @param actual 917 * actual 918 * @return true if actual and expected are equal. 919 */ equals(double expected, double actual)920 public boolean equals(double expected, double actual) { 921 return framework.equals(expected, actual); 922 } 923 924 /** 925 * Compares the values in actual and expected ignoring order. 926 * 927 * @param expected 928 * expected 929 * @param actual 930 * actual 931 * @return true if actual and expected are equal. 932 */ equals(Collection expected, Collection actual)933 public boolean equals(Collection expected, Collection actual) { 934 return framework.equals(expected, actual); 935 } 936 937 /** 938 * Compares the values in actual and expected. 939 * 940 * @param expected 941 * expected 942 * @param actual 943 * actual 944 * @return true if actual and expected are equal. 945 */ equals(List expected, List actual)946 public boolean equals(List expected, List actual) { 947 return framework.equals(expected, actual); 948 } 949 950 /** 951 * Gets the size of the collection 952 * 953 * @param collection 954 * collection, may not be null. 955 * @return size of collection 956 */ size(Collection collection)957 public int size(Collection collection) { 958 return framework.size(collection); 959 } 960 961 /** 962 * Gets the size of the collection 963 * 964 * @param collection 965 * collection, may not be null. 966 * @return size of collection 967 */ size(NamedNodeMap collection)968 public int size(NamedNodeMap collection) { 969 return framework.size(collection); 970 } 971 972 /** 973 * Gets the size of the collection 974 * 975 * @param collection 976 * collection, may not be null. 977 * @return size of collection 978 */ size(NodeList collection)979 public int size(NodeList collection) { 980 return framework.size(collection); 981 } 982 983 } 984