1
2
3
4
5 package org.w3c.tidy.servlet;
6
7 import com.meterware.httpunit.WebResponse;
8 import com.meterware.httpunit.WebImage;
9
10 import org.w3c.tidy.servlet.Consts;
11
12
13 /***
14 * @author Vlad Skarzhevskyy <a href="mailto:skarzhevskyy@gmail.com">skarzhevskyy@gmail.com </a>
15 * @version $Revision: 1.6 $ ($Author: fgiust $)
16 */
17 public class ReportsTest extends TidyServletCase
18 {
19
20 /***
21 * Instantiates a new test case.
22 * @param name test name
23 */
24 public ReportsTest(String name)
25 {
26 super(name);
27 }
28
29 public void validateReportFromJSP(String jsp) throws Exception
30 {
31 WebResponse response = getJSPResponse(jsp);
32
33 WebImage[] img = response.getImages();
34 assertEquals("Expected 1 image in result.", 1, img.length);
35
36 WebResponse reportResponse = getReportResponse(response);
37
38 validateReport(reportResponse);
39 }
40
41 /***
42 * Check that HTML is correct and validation is fine. Also verify theat Reports are generated.
43 * @param jspName jsp name, with full path
44 * @throws Exception any axception thrown during test.
45 */
46 public void testServletOK() throws Exception
47 {
48 validateReportFromJSP("servlet/FormatedByTagOK.jsp");
49 }
50
51 public void testServletWarnings() throws Exception
52 {
53 validateReportFromJSP("servlet/FormatedByTagWarnings.jsp");
54 }
55
56 public void testTag() throws Exception
57 {
58 WebResponse response = getJSPResponse("servlet/FormatedByTagOK.jsp");
59
60 String requestID1 = response.getNewCookieValue(Consts.ATTRIBUTE_REQUEST_ID);
61
62 WebResponse reportResponse = getResponseQuery(new String[]{"requestID", requestID1});
63
64 validateReport(reportResponse);
65 }
66
67 public void testNoData() throws Exception
68 {
69 WebResponse reportResponse = getResponse();
70 assertTrue("No data should be found", reportResponse.getText().indexOf("No data") > 0);
71
72 reportResponse = getResponseQuery(new String[]{"requestID", "1100"});
73 assertTrue("No data should be found", reportResponse.getText().indexOf("No data") > 0);
74 }
75 }