Search in sources :

Example 16 with ServerErrorException

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

the class JAXRSClientIT method constructorStringResponseTest.

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

Example 17 with ServerErrorException

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

the class JAXRSClientIT method constructorStatusNullThrowsExceptionTest.

/*
   * @testName: constructorStatusNullThrowsExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:351;
   * 
   * @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 constructorStatusNullThrowsExceptionTest() throws Fault {
    try {
        ServerErrorException e = new ServerErrorException((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 18 with ServerErrorException

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

the class JAXRSClientIT method constructorStatusThrowsExceptionTest.

/*
   * @testName: constructorStatusThrowsExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:351;
   * 
   * @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 constructorStatusThrowsExceptionTest() throws Fault {
    for (Status status : getStatusesOutsideFamily()) {
        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 : Status(jakarta.ws.rs.core.Response.Status) ServerErrorException(jakarta.ws.rs.ServerErrorException) Test(org.junit.jupiter.api.Test)

Example 19 with ServerErrorException

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

the class JAXRSClientIT method constructorStatusNullThrowableThrowsExceptionTest.

/*
   * @testName: constructorStatusNullThrowableThrowsExceptionTest
   * 
   * @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 constructorStatusNullThrowableThrowsExceptionTest() throws Fault {
    Throwable throwable = new Throwable();
    try {
        ServerErrorException e = new ServerErrorException((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 20 with ServerErrorException

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

the class JAXRSClientIT method constructorIntNotValidStatusThrowableThrowsExceptionTest.

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