Search in sources :

Example 11 with ClientErrorException

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

the class JAXRSClientIT method constructorStatusNullThrowableThrowsExceptionTest.

/*
   * @testName: constructorStatusNullThrowableThrowsExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:313;
   * 
   * @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 constructorStatusNullThrowableThrowsExceptionTest() throws Fault {
    try {
        ClientErrorException e = new ClientErrorException((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 12 with ClientErrorException

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

the class JAXRSClientIT method constructorIntThrowableThrowsExceptionTest.

/*
   * @testName: constructorIntThrowableThrowsExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:314;
   * 
   * @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 constructorIntThrowableThrowsExceptionTest() throws Fault {
    for (Status status : Status.values()) if (Status.Family.familyOf(status.getStatusCode()) != Status.Family.CLIENT_ERROR)
        try {
            ClientErrorException e = new ClientErrorException(status.getStatusCode(), 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 13 with ClientErrorException

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

the class JAXRSClientIT method constructorStringIntThrowableThrowsIAETest.

/*
   * @testName: constructorStringIntThrowableThrowsIAETest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1064;
   * 
   * @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 constructorStringIntThrowableThrowsIAETest() throws Fault {
    for (Status status : Status.values()) if (Status.Family.familyOf(status.getStatusCode()) != Status.Family.CLIENT_ERROR)
        try {
            ClientErrorException e = new ClientErrorException(MESSAGE, status.getStatusCode(), 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 14 with ClientErrorException

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

the class JAXRSClientIT method constructorStringResponseThrowableThrowsIAETest.

/*
   * @testName: constructorStringResponseThrowableThrowsIAETest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1065;
   * 
   * @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 constructorStringResponseThrowableThrowsIAETest() 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, 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) Response(jakarta.ws.rs.core.Response) ClientErrorException(jakarta.ws.rs.ClientErrorException) Test(org.junit.jupiter.api.Test)

Example 15 with ClientErrorException

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

the class JAXRSClientIT method constructorStringIntThrowsIAETest.

/*
   * @testName: constructorStringIntThrowsIAETest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1061;
   * 
   * @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 constructorStringIntThrowsIAETest() throws Fault {
    for (Status status : Status.values()) if (Status.Family.familyOf(status.getStatusCode()) != Status.Family.CLIENT_ERROR)
        try {
            ClientErrorException e = new ClientErrorException(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) 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