Search in sources :

Example 46 with Status

use of jakarta.ws.rs.core.Response.Status 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 47 with Status

use of jakarta.ws.rs.core.Response.Status 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 48 with Status

use of jakarta.ws.rs.core.Response.Status in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorStringThrowableStatusTest.

/*
   * @testName: constructorStringThrowableStatusTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1118; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new instance with a message and specified HTTP
   * status code.
   * 
   * getResponse
   */
@Test
public void constructorStringThrowableStatusTest() throws Fault {
    Throwable[] throwables = new Throwable[] { new RuntimeException(), new IOException(), new Error(), new Throwable() };
    for (Status status : Status.values()) {
        for (Throwable t : throwables) {
            WebApplicationException e = new WebApplicationException(MESSAGE, t, status);
            assertResponse(e, status);
            assertMessage(e);
            assertCause(e, t);
        }
    }
}
Also used : Status(jakarta.ws.rs.core.Response.Status) WebApplicationException(jakarta.ws.rs.WebApplicationException) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Example 49 with Status

use of jakarta.ws.rs.core.Response.Status in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorStringThrowableResponseTest.

/*
   * @testName: constructorStringThrowableResponseTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1116; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new instance using the supplied response.
   * 
   * getResponse
   */
@Test
public void constructorStringThrowableResponseTest() throws Fault {
    Throwable[] throwables = new Throwable[] { new RuntimeException(), new IOException(), new Error(), new Throwable() };
    for (Status status : Status.values()) {
        Response response = buildResponse(status);
        for (Throwable t : throwables) {
            WebApplicationException e = new WebApplicationException(MESSAGE, t, response);
            assertResponse(e, status, HOST);
            assertMessage(e);
            assertCause(e, t);
        }
    }
}
Also used : Status(jakarta.ws.rs.core.Response.Status) Response(jakarta.ws.rs.core.Response) WebApplicationException(jakarta.ws.rs.WebApplicationException) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Example 50 with Status

use of jakarta.ws.rs.core.Response.Status in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorStringStatusTest.

/*
   * @testName: constructorStringStatusTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1114; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new instance with a message and specified HTTP
   * status code.
   * 
   * getResponse
   */
@Test
public void constructorStringStatusTest() throws Fault {
    for (Status status : Status.values()) {
        WebApplicationException e = new WebApplicationException(MESSAGE, status);
        assertResponse(e, status);
        assertMessage(e);
    }
}
Also used : Status(jakarta.ws.rs.core.Response.Status) WebApplicationException(jakarta.ws.rs.WebApplicationException) Test(org.junit.jupiter.api.Test)

Aggregations

Status (jakarta.ws.rs.core.Response.Status)68 Test (org.junit.jupiter.api.Test)58 Response (jakarta.ws.rs.core.Response)25 ClientErrorException (jakarta.ws.rs.ClientErrorException)12 ServerErrorException (jakarta.ws.rs.ServerErrorException)12 RedirectionException (jakarta.ws.rs.RedirectionException)10 Path (jakarta.ws.rs.Path)9 GET (jakarta.ws.rs.GET)6 WebApplicationException (jakarta.ws.rs.WebApplicationException)6 ReadableWritableEntity (ee.jakarta.tck.ws.rs.ee.rs.ext.messagebodyreaderwriter.ReadableWritableEntity)4 BadRequestException (jakarta.ws.rs.BadRequestException)4 InternalServerErrorException (jakarta.ws.rs.InternalServerErrorException)4 POST (jakarta.ws.rs.POST)3 IOException (java.io.IOException)3 Consumes (jakarta.ws.rs.Consumes)2 ForbiddenException (jakarta.ws.rs.ForbiddenException)2 NotAcceptableException (jakarta.ws.rs.NotAcceptableException)2 StatusType (jakarta.ws.rs.core.Response.StatusType)2 AnyExceptionExceptionMapper (ee.jakarta.tck.ws.rs.ee.rs.ext.exceptionmapper.AnyExceptionExceptionMapper)1 SyncInvoker (jakarta.ws.rs.client.SyncInvoker)1