1
2
3
4
5 package org.w3c.tidy.servlet;
6
7 import com.meterware.httpunit.WebResponse;
8 import com.meterware.httpunit.WebImage;
9 import com.meterware.httpunit.WebTable;
10
11 import org.w3c.tidy.servlet.Consts;
12
13
14 /***
15 *
16 *
17 */
18 public class ValidationOKTest extends TidyServletCase
19 {
20
21 /***
22 * Instantiates a new test case.
23 * @param name test name
24 */
25 public ValidationOKTest(String name)
26 {
27 super(name);
28 }
29
30 /***
31 * Check that HTML is correct and validation is fine. Also verify theat Request ID is growning after each request.
32 * @param jspName jsp name, with full path
33 * @throws Exception any axception thrown during test.
34 */
35 public void testValidateOnly() throws Exception
36 {
37 WebResponse response = getResponse();
38
39 WebImage[] img = response.getImages();
40 assertEquals("Expected 1 image in result.", 1, img.length);
41 assertEquals("Expected my name Page Validation", "Page Validation", img[0].getAltText());
42
43 WebTable[] tables = response.getTables();
44 assertEquals("Expected 1 table in result.", 1, tables.length);
45 String RequestID1 = response.getNewCookieValue(Consts.ATTRIBUTE_REQUEST_ID);
46 assertEquals("Expected RequestID in Cookie.", RequestID1, tables[0].getSummary());
47
48 response = getResponse();
49 tables = response.getTables();
50 assertEquals("Expected 1 table in result.", 1, tables.length);
51 String RequestID2 = response.getNewCookieValue(Consts.ATTRIBUTE_REQUEST_ID);
52 assertEquals("Expected Next RequestID in Cookie", RequestID2, tables[0].getSummary());
53 assertFalse("Expected Different RequestID in Cookie", RequestID2.equals(RequestID1));
54
55 String src = img[0].getSource();
56
57 WebResponse responseImg = getResponse(src + "&srcOnly=true");
58
59 assertEquals("Image", Consts.DEFAULT_IMAGE_NAME_PREFIX + "ok.png", responseImg.getText());
60 }
61 }