Search in sources :

Example 1 with ForbiddenException

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

the class JAXRSClientIT method constructorResponseThrowsExceptionTest.

/*
   * @testName: constructorResponseThrowsExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:971;
   * 
   * @test_Strategy: Construct a new "forbidden" exception.
   * java.lang.IllegalArgumentException - in case the status code set in the
   * response is not HTTP 403.
   */
@Test
public void constructorResponseThrowsExceptionTest() throws Fault {
    for (Status status : Status.values()) if (status != STATUS)
        try {
            Response response = Response.status(status).build();
            ForbiddenException e = new ForbiddenException(response);
            fault("IllegalArgumentException has not been thrown; exception", e);
        } catch (IllegalArgumentException e) {
            logMsg("IllegalArgumentException has been thrown for status", status, "as expected");
        }
}
Also used : Status(jakarta.ws.rs.core.Response.Status) Response(jakarta.ws.rs.core.Response) ForbiddenException(jakarta.ws.rs.ForbiddenException) Test(org.junit.jupiter.api.Test)

Example 2 with ForbiddenException

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

the class JAXRSClientIT method constructorThrowableTest.

/*
   * @testName: constructorThrowableTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:972; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new "forbidden" exception. cause - the
   * underlying cause of the exception.
   * 
   * getResponse
   */
@Test
public void constructorThrowableTest() throws Fault {
    Throwable[] throwables = new Throwable[] { new RuntimeException(), new IOException(), new Error(), new Throwable() };
    for (Throwable t : throwables) {
        ForbiddenException e = new ForbiddenException(t);
        assertResponse(e);
        assertCause(e, t);
    }
}
Also used : ForbiddenException(jakarta.ws.rs.ForbiddenException) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Example 3 with ForbiddenException

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

the class JAXRSClientIT method constructorResponseThrowableTest.

/*
   * @testName: constructorResponseThrowableTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:973; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new "forbidden" exception.
   * java.lang.IllegalArgumentException - in case the status code set in the
   * response is not HTTP 403.
   * 
   * getResponse
   */
@Test
public void constructorResponseThrowableTest() throws Fault {
    Response response = buildResponse();
    Throwable[] throwables = new Throwable[] { new RuntimeException(), new IOException(), new Error(), new Throwable() };
    for (Throwable t : throwables) {
        ForbiddenException e = new ForbiddenException(response, t);
        assertResponse(e, HOST);
        assertCause(e, t);
    }
}
Also used : Response(jakarta.ws.rs.core.Response) ForbiddenException(jakarta.ws.rs.ForbiddenException) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Example 4 with ForbiddenException

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

the class JAXRSClientIT method constructorTest.

/*
   * @testName: constructorTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:970; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new "forbidden" exception.
   * 
   * getResponse
   */
@Test
public void constructorTest() throws Fault {
    ForbiddenException e = new ForbiddenException();
    assertResponse(e);
}
Also used : ForbiddenException(jakarta.ws.rs.ForbiddenException) Test(org.junit.jupiter.api.Test)

Example 5 with ForbiddenException

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

the class JAXRSClientIT method constructorStringResponseThrowsIAETest.

/*
   * @testName: constructorStringResponseThrowsIAETest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1067;
   * 
   * @test_Strategy: Construct a new "forbidden" exception.
   * java.lang.IllegalArgumentException - in case the status code set in the
   * response is not HTTP 403.
   */
@Test
public void constructorStringResponseThrowsIAETest() throws Fault {
    for (Status status : Status.values()) if (status != STATUS)
        try {
            Response response = Response.status(status).build();
            ForbiddenException e = new ForbiddenException(MESSAGE, response);
            fault("IllegalArgumentException has not been thrown; exception", e);
        } catch (IllegalArgumentException e) {
            logMsg("IllegalArgumentException has been thrown for status", status, "as expected");
        }
}
Also used : Status(jakarta.ws.rs.core.Response.Status) Response(jakarta.ws.rs.core.Response) ForbiddenException(jakarta.ws.rs.ForbiddenException) Test(org.junit.jupiter.api.Test)

Aggregations

ForbiddenException (jakarta.ws.rs.ForbiddenException)10 Test (org.junit.jupiter.api.Test)10 Response (jakarta.ws.rs.core.Response)6 IOException (java.io.IOException)4 Status (jakarta.ws.rs.core.Response.Status)2