Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests
In directory sc8-pr-cvs1:/tmp/cvs-serv9188/org/htmlparser/tests/scannersTests
Modified Files:
LabelScannerTest.java
Log Message:
Fixed bug #757337 Standalone attributes should remain standalone
Changing to a HashMap was not adopted for two reasons. The first is that it would break Java 1.1.x
compatibility (which I believe we still maintain, although I haven't checked lately), and using a HashMap
would return the attributes in a different order, leading to a *lot* of broken tests that rely on toHTML()
returning a specific string with attributes in a certain order (if I'm going to fix a bunch of tests I would
like the attributes to come out in the order they were originally, so this will need an AttributeStorage class
when the attribute parser is rewritten).
The solution adopted is to subclass HashTable and store two special values, which are new constants in
the Tag class. For naive programs, and for backward compatibility, this SpecialHashtable class translates
these constants into null and "" respectively, so the old behavior is the same.
However, savvy programs, and the toHTML() method in the Tag class can call getRaw() on this hashtable
to get at these special constants and behave appropriately. For this specific bug, toHTML returns the
stand-alone attribute as is, but the missing value case is also handled.
Index: LabelScannerTest.java
===================================================================
RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests/LabelScannerTest.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** LabelScannerTest.java 27 Jul 2003 19:19:21 -0000 1.29
--- LabelScannerTest.java 2 Aug 2003 16:22:57 -0000 1.30
***************
*** 124,128 ****
LabelTag labelTag = (LabelTag) node[0];
! assertStringEquals("Label","<LABEL ID=\"attr1\" ></LABEL>",labelTag.toHtml());
labelTag = (LabelTag) node[1];
assertStringEquals("Label","<LABEL>Jane Doe</LABEL>",labelTag.toHtml());
--- 124,128 ----
LabelTag labelTag = (LabelTag) node[0];
! assertStringEquals("Label","<LABEL ID=\"attr1\"></LABEL>",labelTag.toHtml());
labelTag = (LabelTag) node[1];
assertStringEquals("Label","<LABEL>Jane Doe</LABEL>",labelTag.toHtml());
|