use of org.jboss.test.audit.annotations.SpecAssertion 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 org.jboss.test.audit.annotations.SpecAssertion 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 org.jboss.test.audit.annotations.SpecAssertion 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 org.jboss.test.audit.annotations.SpecAssertion 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"));
}
use of org.jboss.test.audit.annotations.SpecAssertion 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"));
}
Aggregations