I wish Htmlparser would implement the equals method on all descendants of node.
I am currently writing a JSP custom tag that will transform the html fragment wrapped by this tag depending on some business rules. I need to do something like:
Given the following html fragment:
<input type="text" name="input" value="value"/>
under certain circumstances I need to transform it to be something like:
<input type="hidden" name="input" value="value"/>value
This is all fine but how do I test that my transformations are been done right?
I though doing something like:
HtmlFragment expectedFragment = new HtmlFragment("<input type="hidden" name="input" value="value"/>value");
assertThat(expectedFragment, equalTo(transformer.transform("<input type="text" name="input" value="value"/>")));
For the implementation of HtmlFragment I am planning to use Htmlparser but the fact that none of the Node descendants implement equals makes this very much difficult as I would have to implement wrappers for each one of them in order to provide them with equals..
Logged In: YES
user_id=605407
Originator: NO
The unit tests currently use the toHtml() method and then do a string comparison.
Maybe this could work for you.