提交 cc7d3955 编写于 作者: T tfennelly

FormFieldValidatorTest fixes

上级 d5a19e9d
......@@ -30,6 +30,7 @@ import com.gargoylesoftware.htmlunit.DefaultCssErrorHandler;
import com.gargoylesoftware.htmlunit.ElementNotFoundException;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClientUtil;
import com.gargoylesoftware.htmlunit.WebRequest;
import com.gargoylesoftware.htmlunit.WebResponse;
import com.gargoylesoftware.htmlunit.WebResponseListener;
......@@ -2085,7 +2086,11 @@ public class JenkinsRule implements TestRule, MethodRule, RootAction {
@SuppressWarnings("unchecked")
@Override
public Page getPage(String url) throws IOException, FailingHttpStatusCodeException {
return super.getPage(url);
try {
return super.getPage(url);
} finally {
WebClientUtil.waitForJSExec(this);
}
}
/**
......@@ -2117,6 +2122,7 @@ public class JenkinsRule implements TestRule, MethodRule, RootAction {
Page p;
try {
p = super.getPage(getContextPath() + relative);
WebClientUtil.waitForJSExec(this);
} catch (IOException x) {
Throwable cause = x.getCause();
if (cause instanceof SocketTimeoutException) {
......
......@@ -25,11 +25,13 @@ package hudson.util;
import static org.junit.Assert.fail;
import com.gargoylesoftware.htmlunit.WebResponseListener;
import hudson.model.FreeStyleProject;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Publisher;
import hudson.util.FormFieldValidatorTest.BrokenFormValidatorBuilder.DescriptorImpl;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
......@@ -83,13 +85,16 @@ public class FormFieldValidatorTest {
try {
FreeStyleProject p = j.createFreeStyleProject();
p.getPublishersList().add(new BrokenFormValidatorBuilder());
j.createWebClient().getPage(p, "configure");
fail("should have failed");
} catch(AssertionError e) {
if(e.getMessage().contains("doCheckXyz is broken"))
; // expected
else
throw e;
JenkinsRule.WebClient webclient = j.createWebClient();
WebResponseListener.StatusListener statusListener = new WebResponseListener.StatusListener(500);
webclient.addWebResponseListener(statusListener);
webclient.getPage(p, "configure");
statusListener.assertHasResponses();
String contentAsString = statusListener.getResponses().get(0).getContentAsString();
Assert.assertTrue(contentAsString.contains("doCheckXyz is broken"));
} finally {
Publisher.all().remove(d);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册