Search in sources :

Example 1 with ServerErrorException

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

the class JAXRSClientIT method constructorStringIntNotValidStatusThrowableThrowsExceptionTest.

/*
   * @testName: constructorStringIntNotValidStatusThrowableThrowsExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1102;
   * 
   * @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 constructorStringIntNotValidStatusThrowableThrowsExceptionTest() throws Fault {
    Throwable throwable = new Throwable();
    for (int status : new int[] { -1, Integer.MAX_VALUE, Integer.MIN_VALUE }) {
        try {
            ServerErrorException e = new ServerErrorException(MESSAGE, 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 : ServerErrorException(jakarta.ws.rs.ServerErrorException) Test(org.junit.jupiter.api.Test)

Example 2 with ServerErrorException

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

the class JAXRSClientIT method constructorStringIntTest.

/*
   * @testName: constructorStringIntTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1099; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new server error exception.
   * 
   * getResponse
   */
@Test
public void constructorStringIntTest() throws Fault {
    for (Status status : getStatusesFromFamily()) {
        ServerErrorException e = new ServerErrorException(MESSAGE, status.getStatusCode());
        assertResponse(e, status);
        assertMessage(e);
    }
}
Also used : Status(jakarta.ws.rs.core.Response.Status) ServerErrorException(jakarta.ws.rs.ServerErrorException) Test(org.junit.jupiter.api.Test)

Example 3 with ServerErrorException

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

the class JAXRSClientIT method constructorStringStatusNullThrowsExceptionTest.

/*
   * @testName: constructorStringStatusNullThrowsExceptionTest
   * 
   * @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 constructorStringStatusNullThrowsExceptionTest() throws Fault {
    try {
        ServerErrorException e = new ServerErrorException(MESSAGE, (Status) null);
        fault("IllegalArgumentException has not been thrown for null status", "; exception", e);
    } catch (IllegalArgumentException e) {
        logMsg("IllegalArgumentException has been thrown as expected for null status");
    }
}
Also used : ServerErrorException(jakarta.ws.rs.ServerErrorException) Test(org.junit.jupiter.api.Test)

Example 4 with ServerErrorException

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

the class JAXRSClientIT method constructorStringStatusNullThrowableThrowsExceptionTest.

/*
   * @testName: constructorStringStatusNullThrowableThrowsExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1101;
   * 
   * @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 constructorStringStatusNullThrowableThrowsExceptionTest() throws Fault {
    Throwable throwable = new Throwable();
    try {
        ServerErrorException e = new ServerErrorException(MESSAGE, (Status) null, throwable);
        fault("IllegalArgumentException has not been thrown for null status", "; exception", e);
    } catch (IllegalArgumentException e) {
        logMsg("IllegalArgumentException has been thrown as expected for null status");
    }
}
Also used : ServerErrorException(jakarta.ws.rs.ServerErrorException) Test(org.junit.jupiter.api.Test)

Example 5 with ServerErrorException

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

the class JAXRSClientIT method constructorStringStatusThrowableThrowsIAETest.

/*
   * @testName: constructorStringStatusThrowableThrowsIAETest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1101;
   * 
   * @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 constructorStringStatusThrowableThrowsIAETest() throws Fault {
    Throwable throwable = new Throwable();
    for (Status status : getStatusesOutsideFamily()) {
        try {
            ServerErrorException e = new ServerErrorException(MESSAGE, 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)

Aggregations

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