提交 984c4cf4 编写于 作者: J Jesse Glick

Setting a nonempty contextPath turned up a couple problems in the test...

Setting a nonempty contextPath turned up a couple problems in the test harness; goTo must be given a relative path.
https://ci.jenkins-ci.org/job/jenkins_main_trunk/2602/testReport/junit/hudson.model/JobTest/readPermission/
com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: 404 Not Found for http://localhost:47898/jenkins//j_acegi_security_check
	at com.gargoylesoftware.htmlunit.WebClient.throwFailingHttpStatusCodeExceptionIfNecessary(WebClient.java:549)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:333)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:357)
	at com.gargoylesoftware.htmlunit.html.HtmlForm.submit(HtmlForm.java:196)
	at org.jvnet.hudson.test.JenkinsRule$WebClient.login(JenkinsRule.java:1776)
	at org.jvnet.hudson.test.JenkinsRule$WebClient.login(JenkinsRule.java:1788)
	at hudson.model.JobTest.readPermission(JobTest.java:182)
上级 bff177df
......@@ -1033,7 +1033,7 @@ public class JenkinsRule implements TestRule, MethodRule, RootAction {
}
public <N extends Node> N configRoundtrip(N node) throws Exception {
submit(createWebClient().goTo("/computer/" + node.getNodeName() + "/configure").getFormByName("config"));
submit(createWebClient().goTo("computer/" + node.getNodeName() + "/configure").getFormByName("config"));
return (N)jenkins.getNode(node.getNodeName());
}
......@@ -1767,7 +1767,7 @@ public class JenkinsRule implements TestRule, MethodRule, RootAction {
* Logs in to Hudson.
*/
public WebClient login(String username, String password) throws Exception {
HtmlPage page = goTo("/login");
HtmlPage page = goTo("login");
// page = (HtmlPage) page.getFirstAnchorByText("Login").click();
HtmlForm form = page.getFormByName("login");
......@@ -1913,6 +1913,7 @@ public class JenkinsRule implements TestRule, MethodRule, RootAction {
}
public Page goTo(String relative, String expectedContentType) throws IOException, SAXException {
assert !relative.startsWith("/");
Page p = super.getPage(getContextPath() + relative);
assertThat(p.getWebResponse().getContentType(), is(expectedContentType));
return p;
......@@ -1940,6 +1941,7 @@ public class JenkinsRule implements TestRule, MethodRule, RootAction {
* @since 1.504
*/
public void assertFails(String url, int statusCode) throws Exception {
assert !url.startsWith("/");
try {
fail(url + " should have been rejected but produced: " + super.getPage(getContextPath() + url).getWebResponse().getContentAsString());
} catch (FailingHttpStatusCodeException x) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册