use of com.gargoylesoftware.htmlunit.WebClient in project mvc-tck by mvc-spec.
the class ReturnTypeTest method voidWithViewAnnotation.
/**
* A controller method that returns void is REQUIRED to be decorated by @View
*/
@Test
@SpecAssertion(section = Sections.MVC_CONTROLLERS, id = "return-void")
public void voidWithViewAnnotation() throws IOException {
WebResponse response = new WebClient().getPage(baseUrl.toString() + "mvc/return/void-with-view").getWebResponse();
// void with @View renders the view referenced in the annotation
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 SimpleTest method shouldDoStuff.
@Test
public void shouldDoStuff() throws IOException {
Page page = new WebClient().getPage(baseUrl.toString() + "mvc/simple");
Assert.assertThat(page.getWebResponse().getContentAsString(), CoreMatchers.containsString("Hello world!"));
}
use of com.gargoylesoftware.htmlunit.WebClient in project mvc-tck by mvc-spec.
the class ControllerAnnotationTest method controllerMethod.
/**
* An MVC controller is a JAX-RS resource method decorated by @Controller
*/
@Test
@SpecAssertion(section = Sections.MVC_CONTROLLERS, id = "ctrl-method")
public void controllerMethod() throws IOException {
// view rendered because method is a controller
WebResponse response = new WebClient().getPage(baseUrl.toString() + "mvc/method/view1").getWebResponse();
assertThat(response.getStatusCode(), equalTo(200));
assertThat(response.getContentAsString(), containsString("Rendered view #1"));
}
use of com.gargoylesoftware.htmlunit.WebClient in project mvc-tck by mvc-spec.
the class ControllerAnnotationTest method controllerClass.
/*
* If this annotation is applied to a class, then all resource methods in it are regarded as controllers
*/
@Test
@SpecAssertion(section = Sections.MVC_CONTROLLERS, id = "ctrl-class")
public void controllerClass() throws IOException {
WebClient client = new WebClient();
// view rendered because method is a controller
WebResponse response1 = client.getPage(baseUrl.toString() + "mvc/class/view1").getWebResponse();
assertThat(response1.getStatusCode(), equalTo(200));
assertThat(response1.getContentAsString(), containsString("Rendered view #1"));
// view rendered because method is a controller
WebResponse response2 = client.getPage(baseUrl.toString() + "mvc/class/view2").getWebResponse();
assertThat(response2.getStatusCode(), equalTo(200));
assertThat(response2.getContentAsString(), containsString("Rendered view #2"));
}
use of com.gargoylesoftware.htmlunit.WebClient in project mvc-tck by mvc-spec.
the class MediaTypeTest method defaultMediaType.
/**
* Moreover, the default media type for a response is assumed to be text/html, but otherwise can be declared
* using @Produces just like in JAX-RS
*/
@Test
@SpecAssertion(section = Sections.MVC_CONTROLLERS, id = "default-mediatype")
public void defaultMediaType() throws IOException {
WebResponse response = new WebClient().getPage(baseUrl.toString() + "mvc/mediatype/default").getWebResponse();
// default content-type of text/html
assertThat(response.getStatusCode(), equalTo(200));
assertThat(response.getContentType(), equalTo("text/html"));
assertThat(response.getContentAsString(), containsString("Some rendered view"));
}
Aggregations