@Test(expected = IllegalArgumentException.class) public void constructorWithNullResponse() throws Exception { new MockWebResponseBuilder(0L, new WebRequest(new URL("http://example.com:80/test/this/here")), null); }
private WebResponse getResponse(WebConnection connection, String url) throws IOException { return connection.getResponse(new WebRequest(new URL(url))); }
private WebResponse getResponse(WebClient client, String url) throws IOException { return createResponse(client, new WebRequest(new URL(url))); }
private WebResponse deleteResponse(WebClient client, String url) throws IOException { return createResponse(client, new WebRequest(new URL(url), HttpMethod.DELETE)); }
private WebResponse postResponse(WebClient client, String url) throws IOException { return createResponse(client, new WebRequest(new URL(url), HttpMethod.POST)); }
@Before public void setup() throws Exception { this.webRequest = new WebRequest(new URL("http://example.com:80/test/this/here")); this.responseBuilder = new MockWebResponseBuilder(System.currentTimeMillis(), this.webRequest, this.response); }
protected void assertDoesNotMatch(WebRequestMatcher matcher, String url) throws MalformedURLException { assertFalse(matcher.matches(new WebRequest(new URL(url)))); }
protected void assertMatches(WebRequestMatcher matcher, String url) throws MalformedURLException { assertTrue(matcher.matches(new WebRequest(new URL(url)))); }
@Before public void setup() throws Exception { webRequest = new WebRequest(new URL("http://example.com:80/test/this/here")); webRequest.setHttpMethod(HttpMethod.GET); requestBuilder = new HtmlUnitRequestBuilder(sessions, webClient, webRequest); }
@Before 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)); }
/** * Constructs with all data. * * @param responseData Data that was send back * @param url Where this response came from * @param requestMethod the method used to get this response * @param loadTime How long the response took to be sent */ public WebResponse(final WebResponseData responseData, final URL url, final HttpMethod requestMethod, final long loadTime) { this(responseData, new WebRequest(url, requestMethod), loadTime); }
private static WebRequest buildWebRequest(final URL originatingURL, final Charset charset) { final WebRequest webRequest = new WebRequest(originatingURL, HttpMethod.GET); webRequest.setCharset(charset); return webRequest; }
private static WebRequest buildWebRequest(final URL originatingURL, final Charset charset) { final WebRequest webRequest = new WebRequest(originatingURL, HttpMethod.GET); webRequest.setCharset(charset); return webRequest; }
btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { WebRequest wr=new WebRequest(new Callback() { @Override public void call(String result) { ((EditText)view.findViewById(R.id.editText)).setText(result); } }); wr.execute("http://www.cheesejedi.com/rest_services/get_big_cheese?level=1"); } });
WebClient webClient = new WebClient(); WebRequest request; request = new WebRequest(new URL(<enter URL here>)); Page page = webClient.getPage(request); text = page.getWebResponse().getContentAsString();
/** * Sets this location's URL, triggering a server hit and loading the resultant document * into this location's window. * @param url This location's new URL * @throws IOException if there is a problem loading the new location */ private void setUrl(final URL url) throws IOException { window_.getWebWindow().getWebClient().getPage(window_.getWebWindow(), new WebRequest(url)); }
/** * Sets this location's URL, triggering a server hit and loading the resultant document * into this location's window. * @param url This location's new URL * @throws IOException if there is a problem loading the new location */ private void setUrl(final URL url) throws IOException { window_.getWebWindow().getWebClient().getPage(window_.getWebWindow(), new WebRequest(url)); }
private HistoryEntry(final Page page) { // verify cache-control header values before storing if (HeaderUtils.containsNoStore(page.getWebResponse())) { page_ = null; } else { page_ = new SoftReference<>(page); } final WebRequest request = page.getWebResponse().getWebRequest(); webRequest_ = new WebRequest(request.getUrl(), request.getHttpMethod()); webRequest_.setRequestParameters(request.getRequestParameters()); }
private JSONObject callStepsToJson(String jenkinsFileContent) throws IOException { JenkinsRule.WebClient wc = j.createWebClient(); WebRequest req = new WebRequest(new URL(wc.getContextPath() + ModelConverterAction.PIPELINE_CONVERTER_URL + "/stepsToJson"), HttpMethod.POST); assertNotNull(jenkinsFileContent); NameValuePair pair = new NameValuePair("jenkinsfile", jenkinsFileContent); req.setRequestParameters(Collections.singletonList(pair)); String rawResult = wc.getPage(req).getWebResponse().getContentAsString(); assertNotNull(rawResult); return JSONObject.fromObject(rawResult); } }
private JSONObject callStepToJenkinsFile(String jsonFileName) throws IOException { JenkinsRule.WebClient wc = j.createWebClient(); WebRequest req = new WebRequest(new URL(wc.getContextPath() + ModelConverterAction.PIPELINE_CONVERTER_URL + "/stepsToJenkinsfile"), HttpMethod.POST); String simpleJson = fileContentsFromResources(jsonFileName); assertNotNull(simpleJson); NameValuePair pair = new NameValuePair("json", simpleJson); req.setRequestParameters(Collections.singletonList(pair)); String rawResult = wc.getPage(req).getWebResponse().getContentAsString(); assertNotNull(rawResult); return JSONObject.fromObject(rawResult); }