Search in sources :

Example 11 with ServerErrorException

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

the class JAXRSClientIT method constructorIntTest.

/*
   * @testName: constructorIntTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:352; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new server error exception.
   * java.lang.IllegalArgumentException - in case the status code is not a valid
   * HTTP status code or is not from Response.Status.Family.SERVER_ERROR status
   * code family.
   * 
   * getResponse
   */
@Test
public void constructorIntTest() throws Fault {
    for (Status status : getStatusesFromFamily()) {
        ServerErrorException e = new ServerErrorException(status.getStatusCode());
        assertResponse(e, status);
    }
}
Also used : Status(jakarta.ws.rs.core.Response.Status) ServerErrorException(jakarta.ws.rs.ServerErrorException) Test(org.junit.jupiter.api.Test)

Example 12 with ServerErrorException

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

the class JAXRSClientIT method constructorStatusThrowableThrowsExceptionTest.

/*
   * @testName: constructorStatusThrowableThrowsExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:354;
   * 
   * @test_Strategy: Construct a new server error exception.
   * java.lang.IllegalArgumentException - in case the status code is null or is
   * not from Response.Status.Family.SERVER_ERROR status code family.
   */
@Test
public void constructorStatusThrowableThrowsExceptionTest() throws Fault {
    Throwable throwable = new Throwable();
    for (Status status : getStatusesOutsideFamily()) {
        try {
            ServerErrorException e = new ServerErrorException(status, throwable);
            fault("IllegalArgumentException has not 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) ServerErrorException(jakarta.ws.rs.ServerErrorException) Test(org.junit.jupiter.api.Test)

Example 13 with ServerErrorException

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

the class JAXRSClientIT method constructorResponseTest.

/*
   * @testName: constructorResponseTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:353; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new server error exception.
   * java.lang.IllegalArgumentException - in case the response status code is
   * not from the Response.Status.Family.SERVER_ERROR status code family.
   * 
   * getResponse
   */
@Test
public void constructorResponseTest() throws Fault {
    for (Status status : getStatusesFromFamily()) {
        ServerErrorException e = new ServerErrorException(buildResponse(status));
        assertResponse(e, status, HOST);
    }
}
Also used : Status(jakarta.ws.rs.core.Response.Status) ServerErrorException(jakarta.ws.rs.ServerErrorException) Test(org.junit.jupiter.api.Test)

Example 14 with ServerErrorException

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

the class JAXRSClientIT method constructorIntNotValidStatusThrowsExceptionTest.

/*
   * @testName: constructorIntNotValidStatusThrowsExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:352;
   * 
   * @test_Strategy: Construct a new server error exception.
   * java.lang.IllegalArgumentException - in case the status code is not a valid
   * HTTP status code or is not from Response.Status.Family.SERVER_ERROR status
   * code family.
   */
@Test
public void constructorIntNotValidStatusThrowsExceptionTest() throws Fault {
    for (int status : new int[] { -1, Integer.MAX_VALUE, Integer.MIN_VALUE }) {
        try {
            ServerErrorException e = new ServerErrorException(status);
            fault("IllegalArgumentException has not been thrown for status", status, "; exception", e);
        } catch (IllegalArgumentException e) {
            logMsg("IllegalArgumentException has been thrown as expected for status", status);
        }
    }
}
Also used : ServerErrorException(jakarta.ws.rs.ServerErrorException) Test(org.junit.jupiter.api.Test)

Example 15 with ServerErrorException

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

the class JAXRSClientIT method constructorStringStatusThrowsIAETest.

/*
   * @testName: constructorStringStatusThrowsIAETest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1098;
   * 
   * @test_Strategy: Construct a new server error exception.
   * java.lang.IllegalArgumentException - in case the status code is null or is
   * not from Response.Status.Family.SERVER_ERROR status code family.
   */
@Test
public void constructorStringStatusThrowsIAETest() throws Fault {
    for (Status status : getStatusesOutsideFamily()) {
        try {
            ServerErrorException e = new ServerErrorException(MESSAGE, status);
            fault("IllegalArgumentException has not 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) ServerErrorException(jakarta.ws.rs.ServerErrorException) Test(org.junit.jupiter.api.Test)

Aggregations

ServerErrorException (jakarta.ws.rs.ServerErrorException)20 Test (org.junit.jupiter.api.Test)20 Status (jakarta.ws.rs.core.Response.Status)12