How to test HTML code with dbunit

Posted by Martin Homik | Posted in Java, WebApp | Posted on 22-04-2008

2

As you know, I am working with AppFuse, and one important part of AppFuse is testing. To do that, you need sample data which is imported into the database. The dbunit sample data specifications says, that you can use any parsed character data as value but it does not say how to add html snippets into the database. To do that, you have to escape html entities. Below is an example for a body value element of table storing blog posts:

  1. <value description="body">
  2. &amp;lt;p align="justify"&amp;gt;London is the largest urban area and capital of England and the United Kingdom. &amp;lt;p&amp;gt;
  3. </value>

How to display html snippets in Struts2

Posted by Martin Homik | Posted in Java, WebApp | Posted on 22-04-2008

8

The second problem, I solved today, was to display html snippets in Struts. These snippets were stored in a POJO. If you use the usual Struts property element for displaying data, it will escape html code. Hence, you have to turn off escaping:

  1. <s:property escape="false" value="body"></s:property>