Search in sources :

Example 6 with InternalServerErrorException

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

the class JAXRSClientIT method constructorStringResponseThrowableTest.

/*
   * @testName: constructorStringResponseThrowableTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1073; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new internal server error exception.
   * 
   * getResponse
   */
@Test
public void constructorStringResponseThrowableTest() throws Fault {
    Response response = buildResponse();
    Throwable[] throwables = new Throwable[] { new RuntimeException(), new IOException(), new Error(), new Throwable() };
    for (Throwable t : throwables) {
        InternalServerErrorException e = new InternalServerErrorException(MESSAGE, response, t);
        assertResponse(e, HOST);
        assertCause(e, t);
        assertMessage(e);
    }
}
Also used : Response(jakarta.ws.rs.core.Response) InternalServerErrorException(jakarta.ws.rs.InternalServerErrorException) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Example 7 with InternalServerErrorException

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

the class JAXRSClientIT method constructorStringResponseThrowsIAETest.

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

Example 8 with InternalServerErrorException

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

the class JAXRSClientIT method constructorThrowableTest.

/*
   * @testName: constructorThrowableTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:321; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new internal server error exception. cause -
   * the underlying cause of the exception.
   * 
   * getResponse
   */
@Test
public void constructorThrowableTest() throws Fault {
    Throwable[] throwables = new Throwable[] { new RuntimeException(), new IOException(), new Error(), new Throwable() };
    for (Throwable t : throwables) {
        InternalServerErrorException e = new InternalServerErrorException(t);
        assertResponse(e);
        assertCause(e, t);
    }
}
Also used : InternalServerErrorException(jakarta.ws.rs.InternalServerErrorException) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Example 9 with InternalServerErrorException

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

the class JAXRSClientIT method constructorResponseTest.

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

Example 10 with InternalServerErrorException

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

the class JAXRSClientIT method constructorResponseThrowableThrowsExceptionTest.

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

Aggregations

InternalServerErrorException (jakarta.ws.rs.InternalServerErrorException)12 Test (org.junit.jupiter.api.Test)12 Response (jakarta.ws.rs.core.Response)8 Status (jakarta.ws.rs.core.Response.Status)4 IOException (java.io.IOException)4