use of com.gargoylesoftware.htmlunit.WebClient in project core by weld.
the class HttpRequestFilteringTest method testContextsActive.
@Test
public void testContextsActive() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
WebClient client = new WebClient();
Assert.assertEquals("true", client.getPage(fooContextPath + "/foo.html").getWebResponse().getContentAsString());
Assert.assertEquals("true", client.getPage(barContextPath + "/foo.html").getWebResponse().getContentAsString());
Assert.assertEquals("true", client.getPage(barContextPath + "/foo.css").getWebResponse().getContentAsString());
}
use of com.gargoylesoftware.htmlunit.WebClient in project mvc-tck by mvc-spec.
the class ReturnTypeTest method responseWithNullEntity.
/**
* A JAX-RS Response whose entity's type is one of the above
*/
@Test
@SpecAssertion(section = Sections.MVC_CONTROLLERS, id = "return-response")
public void responseWithNullEntity() throws IOException {
WebResponse response = new WebClient().getPage(baseUrl.toString() + "mvc/return/response-null").getWebResponse();
// null entity
assertThat(response.getStatusCode(), equalTo(200));
assertThat(response.getContentAsString(), containsString("Some rendered view"));
}
use of com.gargoylesoftware.htmlunit.WebClient in project mvc-tck by mvc-spec.
the class ReturnTypeTest method responseWithStringEntity.
/**
* A JAX-RS Response whose entity's type is one of the above
*/
@Test
@SpecAssertion(section = Sections.MVC_CONTROLLERS, id = "return-response")
public void responseWithStringEntity() throws IOException {
WebResponse response = new WebClient().getPage(baseUrl.toString() + "mvc/return/response-string").getWebResponse();
// string entity
assertThat(response.getStatusCode(), equalTo(200));
assertThat(response.getContentAsString(), containsString("Some rendered view"));
}
use of com.gargoylesoftware.htmlunit.WebClient in project mvc-tck by mvc-spec.
the class ReturnTypeTest method voidWithoutViewAnnotation.
/**
* A controller method that returns void is REQUIRED to be decorated by @View
*/
@Test
@SpecAssertion(section = Sections.MVC_CONTROLLERS, id = "return-void")
public void voidWithoutViewAnnotation() throws IOException {
// prepare client not fail for 500 status code
WebClient client = new WebClient();
client.getOptions().setThrowExceptionOnFailingStatusCode(false);
// void without @View must not work
Page page = client.getPage(baseUrl.toString() + "mvc/return/void-no-view");
assertThat("Expected status code != 204", page, notNullValue());
assertThat(page.getWebResponse().getStatusCode(), equalTo(500));
}
use of com.gargoylesoftware.htmlunit.WebClient in project mvc-tck by mvc-spec.
the class ReturnTypeTest method stringWithNullResult.
/**
* The default view MUST be used only when such a non-void controller method returns a null value
*/
@Test
@SpecAssertion(section = Sections.MVC_CONTROLLERS, id = "non-null-viewable")
public void stringWithNullResult() throws IOException {
WebResponse response = new WebClient().getPage(baseUrl.toString() + "mvc/return/string-null").getWebResponse();
// return null from string method uses @View
assertThat(response.getStatusCode(), equalTo(200));
assertThat(response.getContentAsString(), containsString("Some rendered view"));
}
Aggregations