Skip to content
This repository was archived by the owner on Apr 7, 2022. It is now read-only.

Commit fae090e

Browse files
committed
Update to HtmlUnit 2.11
1 parent 7d615f7 commit fae090e

8 files changed

Lines changed: 2619 additions & 2594 deletions

File tree

jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ResponseServletTest.java

Lines changed: 80 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
package net.sourceforge.jwebunit.tests;
2121

22+
import org.junit.Test;
23+
24+
import java.net.SocketTimeoutException;
25+
2226
import static net.sourceforge.jwebunit.junit.JWebUnit.assertHeaderEquals;
2327
import static net.sourceforge.jwebunit.junit.JWebUnit.assertHeaderMatches;
2428
import static net.sourceforge.jwebunit.junit.JWebUnit.assertHeaderNotPresent;
@@ -36,98 +40,99 @@
3640
import static org.junit.Assert.assertTrue;
3741
import static org.junit.Assert.fail;
3842

39-
import java.net.SocketTimeoutException;
40-
41-
import org.junit.Test;
42-
4343
/**
4444
* Test redirection support.
45-
*
45+
*
4646
* @author Julien Henry
4747
*/
4848
public class ResponseServletTest extends JWebUnitAPITestCase {
4949

50-
public void setUp() throws Exception {
51-
super.setUp();
52-
setIgnoreFailingStatusCodes(true); // ignore failing status codes
53-
setBaseUrl(HOST_PATH + "/ResponseServletTest");
54-
}
50+
public void setUp() throws Exception {
51+
super.setUp();
52+
setIgnoreFailingStatusCodes(true); // ignore failing status codes
53+
setBaseUrl(HOST_PATH + "/ResponseServletTest");
54+
}
5555

56-
/*
57-
* currently we can't get the response code from HtmlUnit unless it is a failing code
58-
*/
59-
@Test public void testDefault() {
60-
beginAt("/SimpleForm.html");
61-
submit();
62-
assertResponseCodeBetween(200, 299);
63-
64-
// test the headers
65-
assertHeaderPresent("Test");
66-
assertHeaderNotPresent("Not-present");
67-
assertHeaderEquals("Test", "test2");
68-
assertHeaderMatches("Header-Added", "[0-9]{2}");
69-
}
56+
/*
57+
* currently we can't get the response code from HtmlUnit unless it is a failing code
58+
*/
59+
@Test
60+
public void testDefault() {
61+
beginAt("/SimpleForm.html");
62+
submit();
63+
assertResponseCodeBetween(200, 299);
7064

71-
@Test public void testResponse200() {
72-
beginAt("/SimpleForm.html");
73-
setTextField("status", "200");
74-
submit();
75-
assertResponseCode(200);
76-
}
65+
// test the headers
66+
assertHeaderPresent("Test");
67+
assertHeaderNotPresent("Not-present");
68+
assertHeaderEquals("Test", "test2");
69+
assertHeaderMatches("Header-Added", "[0-9]{2}");
70+
}
71+
72+
@Test
73+
public void testResponse200() {
74+
beginAt("/SimpleForm.html");
75+
setTextField("status", "200");
76+
submit();
77+
assertResponseCode(200);
78+
}
7779

78-
/*
79-
* HtmlUnit cannot handle a 301 without a valid Location: header
80+
/*
81+
* HtmlUnit cannot handle a 301 without a valid Location: header
8082
@Test public void testResponse301() {
8183
beginAt("/SimpleForm.html");
8284
setTextField("status", "301");
8385
submit();
8486
assertResponseCode(301);
8587
}
86-
*/
88+
*/
8789

88-
@Test public void testResponse404() {
89-
beginAt("/SimpleForm.html");
90-
assertTitleEquals("response form");
91-
setTextField("status", "404");
92-
submit();
93-
assertResponseCode(404);
94-
}
90+
@Test
91+
public void testResponse404() {
92+
beginAt("/SimpleForm.html");
93+
assertTitleEquals("response form");
94+
setTextField("status", "404");
95+
submit();
96+
assertResponseCode(404);
97+
}
9598

96-
@Test public void testResponse501() {
97-
beginAt("/SimpleForm.html");
98-
assertTitleEquals("response form");
99-
setTextField("status", "501");
100-
submit();
101-
assertResponseCode(501);
102-
}
103-
104-
/**
105-
* Issue 1674646: add support for specifying the timeout of pages
106-
*/
107-
@Test public void testTimeout() {
108-
109-
// test that timeout was fired
110-
setTimeout(500); // specify a global timeout of 0.5 seconds (must be set before the WebConnection is initialised)
111-
beginAt("/SimpleForm.html");
112-
assertTitleEquals("response form");
113-
setTextField("timeout", "1"); // server wait for 1 seconds
114-
try {
115-
submit();
116-
fail("timeout was not called"); // we should not get here
117-
} catch (RuntimeException e) {
118-
assertTrue("timeout caused by SocketTimeoutException, but was " + e.getCause().getClass(), e.getCause() instanceof SocketTimeoutException);
119-
}
120-
121-
// close and reset the browser
122-
closeBrowser();
123-
124-
// test that timeout wasn't fired
125-
setTimeout(2000); // specify a global timeout of 2 seconds (must be set before the WebConnection is initialised)
126-
beginAt("/SimpleForm.html");
127-
assertTitleEquals("response form");
128-
setTextField("timeout", "1"); // server wait for 1 seconds
129-
submit();
130-
assertTextPresent("hello, world!");
99+
@Test
100+
public void testResponse501() {
101+
beginAt("/SimpleForm.html");
102+
assertTitleEquals("response form");
103+
setTextField("status", "501");
104+
submit();
105+
assertResponseCode(501);
106+
}
107+
108+
/**
109+
* Issue 1674646: add support for specifying the timeout of pages
110+
*/
111+
@Test
112+
public void testTimeout() {
113+
114+
// test that timeout was fired
115+
setTimeout(500); // specify a global timeout of 0.5 seconds (must be set before the WebConnection is initialised)
116+
beginAt("/SimpleForm.html");
117+
assertTitleEquals("response form");
118+
setTextField("timeout", "1"); // server wait for 1 seconds
119+
try {
120+
submit();
121+
fail("timeout was not called"); // we should not get here
122+
} catch (RuntimeException e) {
123+
assertTrue("timeout caused by SocketTimeoutException, but was " + e.getCause().getClass(), e.getCause() instanceof SocketTimeoutException);
131124
}
132125

126+
// close and reset the browser
127+
closeBrowser();
128+
129+
// test that timeout wasn't fired
130+
setTimeout(2000); // specify a global timeout of 2 seconds (must be set before the WebConnection is initialised)
131+
beginAt("/SimpleForm.html");
132+
assertTitleEquals("response form");
133+
setTextField("timeout", "1"); // server wait for 1 seconds
134+
submit();
135+
assertTextPresent("hello, world!");
136+
}
137+
133138
}

jwebunit-htmlunit-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<dependency>
2424
<groupId>net.sourceforge.htmlunit</groupId>
2525
<artifactId>htmlunit</artifactId>
26-
<version>2.10</version>
26+
<version>2.11</version>
2727
<exclusions>
2828
<exclusion>
2929
<artifactId>commons-logging</artifactId>

0 commit comments

Comments
 (0)