Search in sources :

Example 1 with NotAcceptableException

use of jakarta.ws.rs.NotAcceptableException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorResponseThrowableTest.

/*
   * @testName: constructorResponseThrowableTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:329; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new "request not acceptable" exception.
   * java.lang.IllegalArgumentException - in case the status code set in the
   * response is not HTTP 406.
   * 
   * getResponse
   */
@Test
public void constructorResponseThrowableTest() throws Fault {
    Response response = buildResponse();
    Throwable[] throwables = new Throwable[] { new RuntimeException(), new IOException(), new Error(), new Throwable() };
    for (Throwable t : throwables) {
        NotAcceptableException e = new NotAcceptableException(response, t);
        assertResponse(e, HOST);
        assertCause(e, t);
    }
}
Also used : Response(jakarta.ws.rs.core.Response) NotAcceptableException(jakarta.ws.rs.NotAcceptableException) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Example 2 with NotAcceptableException

use of jakarta.ws.rs.NotAcceptableException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorStringResponseTest.

/*
   * @testName: constructorStringResponseTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1075; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new "request not acceptable" exception.
   * 
   * getResponse
   */
@Test
public void constructorStringResponseTest() throws Fault {
    Response response = buildResponse();
    NotAcceptableException e = new NotAcceptableException(MESSAGE, response);
    assertResponse(e, HOST);
    assertMessage(e);
}
Also used : Response(jakarta.ws.rs.core.Response) NotAcceptableException(jakarta.ws.rs.NotAcceptableException) Test(org.junit.jupiter.api.Test)

Example 3 with NotAcceptableException

use of jakarta.ws.rs.NotAcceptableException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorStringResponseThrowsIAETest.

/*
   * @testName: constructorStringResponseThrowsIAETest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1075;
   * 
   * @test_Strategy: Construct a new "request not acceptable" exception.
   * java.lang.IllegalArgumentException - in case the status code set in the
   * response is not HTTP 406.
   */
@Test
public void constructorStringResponseThrowsIAETest() throws Fault {
    for (Status status : Status.values()) if (status != STATUS)
        try {
            Response response = Response.status(status).build();
            NotAcceptableException e = new NotAcceptableException(MESSAGE, response);
            fault("IllegalArgumentException has not been thrown; exception", e);
        } catch (IllegalArgumentException e) {
            logMsg("IllegalArgumentException has been thrown for status", status, "as expected");
        }
}
Also used : Status(jakarta.ws.rs.core.Response.Status) Response(jakarta.ws.rs.core.Response) NotAcceptableException(jakarta.ws.rs.NotAcceptableException) Test(org.junit.jupiter.api.Test)

Example 4 with NotAcceptableException

use of jakarta.ws.rs.NotAcceptableException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorResponseTest.

/*
   * @testName: constructorResponseTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:327; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new "request not acceptable" exception.
   * java.lang.IllegalArgumentException - in case the status code set in the
   * response is not HTTP 406.
   * 
   * getResponse
   */
@Test
public void constructorResponseTest() throws Fault {
    Response response = buildResponse();
    NotAcceptableException e = new NotAcceptableException(response);
    assertResponse(e, HOST);
}
Also used : Response(jakarta.ws.rs.core.Response) NotAcceptableException(jakarta.ws.rs.NotAcceptableException) Test(org.junit.jupiter.api.Test)

Example 5 with NotAcceptableException

use of jakarta.ws.rs.NotAcceptableException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorResponseThrowsExceptionTest.

/*
   * @testName: constructorResponseThrowsExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:327;
   * 
   * @test_Strategy: Construct a new "request not acceptable" exception.
   * java.lang.IllegalArgumentException - in case the status code set in the
   * response is not HTTP 406.
   */
@Test
public void constructorResponseThrowsExceptionTest() throws Fault {
    for (Status status : Status.values()) if (status != STATUS)
        try {
            Response response = Response.status(status).build();
            NotAcceptableException e = new NotAcceptableException(response);
            fault("IllegalArgumentException has not been thrown; exception", e);
        } catch (IllegalArgumentException e) {
            logMsg("IllegalArgumentException has been thrown for status", status, "as expected");
        }
}
Also used : Status(jakarta.ws.rs.core.Response.Status) Response(jakarta.ws.rs.core.Response) NotAcceptableException(jakarta.ws.rs.NotAcceptableException) Test(org.junit.jupiter.api.Test)

Aggregations

NotAcceptableException (jakarta.ws.rs.NotAcceptableException)10 Test (org.junit.jupiter.api.Test)10 Response (jakarta.ws.rs.core.Response)6 IOException (java.io.IOException)4 Status (jakarta.ws.rs.core.Response.Status)2