Search in sources :

Example 6 with ServerErrorException

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

the class JAXRSClientIT method constructorStringStatusTest.

/*
   * @testName: constructorStringStatusTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1098; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new server error exception.
   * 
   * getResponse
   */
@Test
public void constructorStringStatusTest() throws Fault {
    for (Status status : getStatusesFromFamily()) {
        ServerErrorException e = new ServerErrorException(MESSAGE, status);
        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 7 with ServerErrorException

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

the class JAXRSClientIT method constructorStringIntThrowsIAETest.

/*
   * @testName: constructorStringIntThrowsIAETest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1099;
   * 
   * @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 constructorStringIntThrowsIAETest() throws Fault {
    for (Status status : getStatusesOutsideFamily()) {
        try {
            ServerErrorException e = new ServerErrorException(MESSAGE, status.getStatusCode());
            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 8 with ServerErrorException

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

the class JAXRSClientIT method constructorStatusTest.

/*
   * @testName: constructorStatusTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:351; JAXRS:JAVADOC:12;
   * 
   * @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.
   * 
   * getResponse
   */
@Test
public void constructorStatusTest() throws Fault {
    for (Status status : getStatusesFromFamily()) {
        ServerErrorException e = new ServerErrorException(status);
        assertResponse(e, status);
    }
}
Also used : Status(jakarta.ws.rs.core.Response.Status) ServerErrorException(jakarta.ws.rs.ServerErrorException) Test(org.junit.jupiter.api.Test)

Example 9 with ServerErrorException

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

the class JAXRSClientIT method constructorIntThrowsExceptionTest.

/*
   * @testName: constructorIntThrowsExceptionTest
   * 
   * @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 constructorIntThrowsExceptionTest() throws Fault {
    for (Status status : getStatusesOutsideFamily()) {
        try {
            ServerErrorException e = new ServerErrorException(status.getStatusCode());
            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 10 with ServerErrorException

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

the class JAXRSClientIT method constructorStringIntNotValidStatusThrowsIAETest.

/*
   * @testName: constructorStringIntNotValidStatusThrowsIAETest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1099;
   * 
   * @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 constructorStringIntNotValidStatusThrowsIAETest() throws Fault {
    for (int status : new int[] { -1, Integer.MAX_VALUE, Integer.MIN_VALUE }) {
        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 : 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