Search in sources :

Example 61 with Status

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

the class Resource method isUsedConstructorWithMostAttributes.

@GET
@Path("mostAttributes")
public Response isUsedConstructorWithMostAttributes() {
    boolean ok = application != null;
    ok &= headers != null;
    ok &= info != null;
    ok &= request != null;
    ok &= provider == null;
    Status status = ok ? Status.OK : Status.NOT_ACCEPTABLE;
    return Response.status(status).build();
}
Also used : Status(jakarta.ws.rs.core.Response.Status) Path(jakarta.ws.rs.Path) GET(jakarta.ws.rs.GET)

Example 62 with Status

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

the class JAXRSClientIT method statusTest.

/*
   * @class.setup_props: webServerHost; webServerPort; ts_home;
   */
/* Run test */
/*
   * @testName: statusTest
   * 
   * @assertion_ids: JAXRS:SPEC:14.2; JAXRS:JAVADOC:131; JAXRS:JAVADOC:139;
   * 
   * @test_Strategy: Client send request to a resource, verify that correct
   * status code returned
   *
   */
@Test
public void statusTest() throws Fault {
    for (Response.Status status : Response.Status.values()) {
        if (status == Status.RESET_CONTENT)
            // it takes some time
            continue;
        setProperty(Property.STATUS_CODE, getStatusCode(status));
        invokeGet("status?status=" + getStatusCode(status));
    }
}
Also used : Response(jakarta.ws.rs.core.Response) Status(jakarta.ws.rs.core.Response.Status) Test(org.junit.jupiter.api.Test)

Example 63 with Status

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

the class ProvidersServlet method isRegisteredRuntimeExceptionMapper.

@GET
@Path("isRegisteredRuntimeExceptionMapper")
public Response isRegisteredRuntimeExceptionMapper() {
    ExceptionMapper<RuntimeException> em = providers.getExceptionMapper(RuntimeException.class);
    Status status = Status.NOT_ACCEPTABLE;
    if (em != null && AnyExceptionExceptionMapper.class.isInstance(em))
        status = Status.OK;
    // This serverError() is to get ResponseBuilder with status != OK
    return Response.serverError().status(status).build();
}
Also used : Status(jakarta.ws.rs.core.Response.Status) AnyExceptionExceptionMapper(ee.jakarta.tck.ws.rs.ee.rs.ext.exceptionmapper.AnyExceptionExceptionMapper) Path(jakarta.ws.rs.Path) GET(jakarta.ws.rs.GET)

Example 64 with Status

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

the class ProvidersServlet method readEntityFromHeader.

@POST
@Consumes(MediaType.TEXT_XML)
@Path("readEntityFromHeader")
public Response readEntityFromHeader(@EntityAnnotation("Header") ReadableWritableEntity entity) {
    Status status = Status.NO_CONTENT;
    if (entity != null) {
        boolean b = entity.toString().equals(EnumProvider.JAXRS.name());
        status = b ? Status.OK : Status.NOT_ACCEPTABLE;
    }
    return Response.status(status).build();
}
Also used : Status(jakarta.ws.rs.core.Response.Status) Path(jakarta.ws.rs.Path) POST(jakarta.ws.rs.POST) Consumes(jakarta.ws.rs.Consumes)

Example 65 with Status

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

the class ProvidersServlet method isRegisteredEntityMessageReaderXml.

@GET
@Path("isRegisteredMessageReaderXml")
public Response isRegisteredEntityMessageReaderXml() {
    MessageBodyReader<ReadableWritableEntity> reader;
    reader = providers.getMessageBodyReader(ReadableWritableEntity.class, null, getArgumentAnnotations("readEntityFromBody"), MediaType.TEXT_XML_TYPE);
    Status status = reader == null ? Status.NOT_ACCEPTABLE : Status.OK;
    return Response.status(status).build();
}
Also used : Status(jakarta.ws.rs.core.Response.Status) ReadableWritableEntity(ee.jakarta.tck.ws.rs.ee.rs.ext.messagebodyreaderwriter.ReadableWritableEntity) Path(jakarta.ws.rs.Path) GET(jakarta.ws.rs.GET)

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