Search in sources :

Example 1 with SpecAssertion

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"));
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 2 with SpecAssertion

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"));
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 3 with SpecAssertion

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));
}
Also used : Page(com.gargoylesoftware.htmlunit.Page) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 4 with SpecAssertion

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"));
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 5 with SpecAssertion

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"));
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Aggregations

WebClient (com.gargoylesoftware.htmlunit.WebClient)11 SpecAssertion (org.jboss.test.audit.annotations.SpecAssertion)11 Test (org.junit.Test)11 WebResponse (com.gargoylesoftware.htmlunit.WebResponse)9 Page (com.gargoylesoftware.htmlunit.Page)2