Search in sources :

Example 6 with ClientErrorException

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

the class JAXRSClientIT method constructorStringStatusThrowableThrowsIAETest.

/*
   * @testName: constructorStringStatusThrowableThrowsIAETest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1063;
   * 
   * @test_Strategy: Construct a new client error exception.
   * java.lang.IllegalArgumentException - in case the status code is null or if
   * it is not from the Response.Status.Family.CLIENT_ERROR status code family.
   */
@Test
public void constructorStringStatusThrowableThrowsIAETest() throws Fault {
    for (Status status : Status.values()) if (Status.Family.familyOf(status.getStatusCode()) != Status.Family.CLIENT_ERROR)
        try {
            ClientErrorException e = new ClientErrorException(MESSAGE, status, new 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) ClientErrorException(jakarta.ws.rs.ClientErrorException) Test(org.junit.jupiter.api.Test)

Example 7 with ClientErrorException

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

the class JAXRSClientIT method constructorStringStatusNullThrowableThrowsIAETest.

/*
   * @testName: constructorStringStatusNullThrowableThrowsIAETest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1063;
   * 
   * @test_Strategy: Construct a new client error exception.
   * java.lang.IllegalArgumentException - in case the status code is null or if
   * it is not from the Response.Status.Family.CLIENT_ERROR status code family.
   */
@Test
public void constructorStringStatusNullThrowableThrowsIAETest() throws Fault {
    try {
        ClientErrorException e = new ClientErrorException(MESSAGE, (Status) null, new 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 : ClientErrorException(jakarta.ws.rs.ClientErrorException) Test(org.junit.jupiter.api.Test)

Example 8 with ClientErrorException

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

the class JAXRSClientIT method constructorStringResponseThrowsIEATest.

/*
   * @testName: constructorStringResponseThrowsIEATest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1062;
   * 
   * @test_Strategy: Construct a new client error exception.
   * java.lang.IllegalArgumentException - in case the response status code is
   * not from the Response.Status.Family.CLIENT_ERROR status code family.
   */
@Test
public void constructorStringResponseThrowsIEATest() throws Fault {
    for (Status status : Status.values()) if (Status.Family.familyOf(status.getStatusCode()) != Status.Family.CLIENT_ERROR)
        try {
            Response response = Response.status(status).build();
            ClientErrorException e = new ClientErrorException(MESSAGE, response);
            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) Response(jakarta.ws.rs.core.Response) ClientErrorException(jakarta.ws.rs.ClientErrorException) Test(org.junit.jupiter.api.Test)

Example 9 with ClientErrorException

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

the class JAXRSClientIT method constructorStringStatusThrowsIAETest.

/*
   * @testName: constructorStringStatusThrowsIAETest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1060;
   * 
   * @test_Strategy: Construct a new client error exception.
   * java.lang.IllegalArgumentException - in case the status code is null or if
   * it is not from the Response.Status.Family.CLIENT_ERROR status code family.
   */
@Test
public void constructorStringStatusThrowsIAETest() throws Fault {
    for (Status status : Status.values()) if (Status.Family.familyOf(status.getStatusCode()) != Status.Family.CLIENT_ERROR)
        try {
            ClientErrorException e = new ClientErrorException(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) ClientErrorException(jakarta.ws.rs.ClientErrorException) Test(org.junit.jupiter.api.Test)

Example 10 with ClientErrorException

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

the class JAXRSClientIT method constructorIntThrowsExceptionTest.

/*
   * @testName: constructorIntThrowsExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:311;
   * 
   * @test_Strategy: Construct a new client error exception.
   * java.lang.IllegalArgumentException - in case the status code is not a valid
   * HTTP status code or if it is not from the
   * Response.Status.Family.CLIENT_ERROR status code family.
   */
@Test
public void constructorIntThrowsExceptionTest() throws Fault {
    for (Status status : Status.values()) if (Status.Family.familyOf(status.getStatusCode()) != Status.Family.CLIENT_ERROR)
        try {
            ClientErrorException e = new ClientErrorException(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) ClientErrorException(jakarta.ws.rs.ClientErrorException) Test(org.junit.jupiter.api.Test)

Aggregations

ClientErrorException (jakarta.ws.rs.ClientErrorException)16 Test (org.junit.jupiter.api.Test)16 Status (jakarta.ws.rs.core.Response.Status)12 Response (jakarta.ws.rs.core.Response)4