use of com.gargoylesoftware.htmlunit.WebRequest in project spring-framework by spring-projects.
the class DelegatingWebConnectionTests method setup.
@BeforeEach
public void setup() throws Exception {
request = new WebRequest(new URL("http://localhost/"));
WebResponseData data = new WebResponseData("".getBytes("UTF-8"), 200, "", Collections.emptyList());
expectedResponse = new WebResponse(data, request, 100L);
webConnection = new DelegatingWebConnection(defaultConnection, new DelegateWebConnection(matcher1, connection1), new DelegateWebConnection(matcher2, connection2));
}
use of com.gargoylesoftware.htmlunit.WebRequest in project promoted-builds-plugin by jenkinsci.
the class PromotionTest method testRebuildPromotionThrowsException.
@Test
public void testRebuildPromotionThrowsException() throws Exception {
FreeStyleProject p = r.createFreeStyleProject("proj1");
JobPropertyImpl promotion = new JobPropertyImpl(p);
p.addProperty(promotion);
PromotionProcess promo1 = promotion.addProcess("promo1");
promo1.conditions.add(new SelfPromotionCondition(false));
FreeStyleBuild b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
// internally, the promotion is still an asynchronous process. It just happens
// right away after the build is complete.
Thread.sleep(1000);
Promotion pb = promo1.getBuilds().getLastBuild();
assertSame(pb.getTargetBuildOrFail(), b);
JenkinsRule.WebClient wc = r.createWebClient();
// spot-check that promotion itself is accessible
wc.goTo(pb.getUrl());
try {
HtmlPage page = wc.getPage(wc.addCrumb(new WebRequest(new URL(r.getURL(), pb.getUrl() + "/rebuild"), HttpMethod.POST)));
fail("rebuilding a promotion directly should fail");
} catch (FailingHttpStatusCodeException x) {
assertEquals("wrong status code", 404, x.getStatusCode());
// TODO(oleg_nenashev): Another error will be returned since 2.107. As long as URL is rejected, we do not really care much
// assertNotEquals("unexpected content", -1, x.getResponse().getContentAsString().indexOf("Promotions may not be rebuilt directly"));
}
}
use of com.gargoylesoftware.htmlunit.WebRequest in project promoted-builds-plugin by jenkinsci.
the class RemoteApiTest method delete.
@Test
public void delete() throws Exception {
FreeStyleProject p = r.createFreeStyleProject("p");
JobPropertyImpl promotion = new JobPropertyImpl(p);
p.addProperty(promotion);
promotion.addProcess("promo").save();
assertEquals(1, promotion.getItems().size());
assertEquals(1, promotion.getActiveItems().size());
JenkinsRule.WebClient wc = r.createWebClient();
wc.getPage(wc.addCrumb(new WebRequest(new URL(r.getURL(), "job/p/promotion/process/promo/doDelete"), HttpMethod.POST)));
assertEquals(0, promotion.getItems().size());
assertEquals(0, promotion.getActiveItems().size());
}
use of com.gargoylesoftware.htmlunit.WebRequest in project support-core-plugin by jenkinsci.
the class SupportActionTest method doBundle.
private WebResponse doBundle(String action, String bundle, String user, String extraBundle) throws IOException {
j.jenkins.setCrumbIssuer(null);
j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
j.jenkins.setAuthorizationStrategy(new MockAuthorizationStrategy().grant(Jenkins.ADMINISTER).everywhere().to("admin").grant(Jenkins.READ).everywhere().to("user"));
WebClient wc = j.createWebClient().withBasicCredentials(user).withThrowExceptionOnFailingStatusCode(false);
String json = "?json={%22bundles%22:[{%22selected%22:+true,%22name%22:+%22" + bundle + "%22}]}";
if (extraBundle != null) {
json = "?json={%22bundles%22:[{%22selected%22:+true,%22name%22:+%22" + bundle + "%22},{%22selected%22:+true,%22name%22:+%22" + extraBundle + "%22}]}";
}
WebRequest request = new WebRequest(new URL(j.getURL() + root.getUrlName() + "/" + action + json), HttpMethod.POST);
return wc.getPage(request).getWebResponse();
}
Aggregations