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();
}
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));
}
}
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();
}
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();
}
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();
}
Aggregations