use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class WebApplicationExceptionMapper method toResponse.
@Override
public Response toResponse(WebApplicationException exception) {
Response response = exception.getResponse();
Status status = Status.fromStatusCode(response.getStatus());
StringBuilder sb = new StringBuilder();
// Note mapper applied
sb.append(getClass().getSimpleName());
// note what status there might have been
if (status != null)
sb.append("|status=").append(status.name());
// Note what source exceptions there might have been
for (Throwable t = exception.getCause(); t != null; t = t.getCause()) {
sb.append("|msg=").append(t.getMessage());
sb.append("|ex=").append(t.getClass().getName());
}
return Response.ok(sb.toString()).build();
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method methodWithCallbackWithEntityThrowsNoWebApplicationExceptionForResponseTest.
/*
* @testName:
* methodWithCallbackWithEntityThrowsNoWebApplicationExceptionForResponseTest
*
* @assertion_ids: JAXRS:JAVADOC:392;
*
* @test_Strategy: Note that calling the Future.get() method on the returned
* Future instance may throw an ExecutionException that wraps a
* WebApplicationException or one of its subclasses thrown in case the
* received response status code is not successful and the specified response
* type is not Response.
*/
@Test
public void methodWithCallbackWithEntityThrowsNoWebApplicationExceptionForResponseTest() throws Fault {
Future<Response> future = null;
InvocationCallback<Response> callback = createCallback(false);
for (String method : ENTITY_METHODS) {
AsyncInvoker async = startAsyncInvokerForMethod(method.toLowerCase() + "notok");
Entity<String> entity = Entity.entity(method, MediaType.WILDCARD_TYPE);
future = async.method(method, entity, callback);
checkFutureStatusResponseNoTime(future, Status.NOT_ACCEPTABLE);
}
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method methodWithCallbackWhileServerWaitTest.
/*
* @testName: methodWithCallbackWhileServerWaitTest
*
* @assertion_ids: JAXRS:JAVADOC:388;
*
* @test_Strategy: Invoke an arbitrary method for the current request
* asynchronously.
*/
@Test
public void methodWithCallbackWhileServerWaitTest() throws Fault {
InvocationCallback<Response> callback = createCallback(true);
Future<Response> future = null;
for (String method : METHODS) {
AsyncInvoker async = startAsyncInvokerForMethod(method.toLowerCase() + "andwait");
future = async.method(method, callback);
checkFutureOkResponse(future);
assertCallbackCall();
}
// return future;
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method optionsWhileServerWaitTest.
/*
* @testName: optionsWhileServerWaitTest
*
* @assertion_ids: JAXRS:JAVADOC:393;
*
* @test_Strategy: Invoke HTTP options method for the current request
* asynchronously.
*/
@Test
public void optionsWhileServerWaitTest() throws Fault {
AsyncInvoker async = startAsyncInvokerForMethod("optionsandwait");
Future<Response> future = async.options();
checkFutureOkResponse(future);
// return future;
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getThrowsProcessingExceptionTest.
/*
* @testName: getThrowsProcessingExceptionTest
*
* @assertion_ids: JAXRS:JAVADOC:379;
*
* @test_Strategy: Note that calling the Future.get() method on the returned
* Future instance may throw an ExecutionException that wraps an
* jakarta.ws.rs.ProcessingException thrown in case of an invocation processing
* failure.
*/
@Test
public void getThrowsProcessingExceptionTest() throws Fault {
_hostname = NONEXISTING_SITE;
AsyncInvoker async = startAsyncInvokerForMethod("get");
Future<Response> future = async.get();
assertExceptionWithProcessingExceptionIsThrownAndLog(future);
}
Aggregations