use of javax.ws.rs.ProcessingException in project jersey by jersey.
the class InMemoryConnector method apply.
@Override
public Future<?> apply(final ClientRequest request, final AsyncConnectorCallback callback) {
CompletableFuture<ClientResponse> future = new CompletableFuture<>();
try {
ClientResponse response = apply(request);
callback.response(response);
future.complete(response);
} catch (ProcessingException ex) {
future.completeExceptionally(ex);
} catch (Throwable t) {
callback.failure(t);
future.completeExceptionally(t);
}
return future;
}
use of javax.ws.rs.ProcessingException in project jersey by jersey.
the class EmptyEntityTest method testReceiveEmptyCharacter.
@Test
public void testReceiveEmptyCharacter() {
WebTarget target = target("empty/getempty");
final Response response = target.request("text/plain").get();
assertEquals(200, response.getStatus());
try {
response.readEntity(Character.class);
fail("ProcessingException expected.");
} catch (ProcessingException ex) {
assertSame(NoContentException.class, ex.getCause().getClass());
}
try {
target.request("text/plain").get(Character.class);
fail("ResponseProcessingException expected.");
} catch (ResponseProcessingException ex) {
assertSame(NoContentException.class, ex.getCause().getClass());
}
}
use of javax.ws.rs.ProcessingException in project jersey by jersey.
the class BeanStreamingTest method testBean.
@Test
public void testBean() throws Exception {
Bean b = new Bean("bean", 123, 3.1415f);
// the following should work using BeanProvider which
// supports Bean.class for type application/bean
WebTarget r = target().path("/bean");
r.request().post(Entity.entity(b, "application/bean"), Bean.class);
try {
r = target().path("/plain");
r.request().post(Entity.entity(b, "text/plain"), Bean.class);
assertFalse(false);
} catch (ProcessingException ex) {
assertTrue(true);
}
}
use of javax.ws.rs.ProcessingException in project jersey by jersey.
the class EmptyEntityTest method testReceiveEmptyJAXBbean.
@Test
public void testReceiveEmptyJAXBbean() {
WebTarget target = target("empty/getempty");
final Response response = target.request("application/xml").get();
assertEquals(200, response.getStatus());
try {
response.readEntity(TestJaxbBean.class);
fail("ProcessingException expected.");
} catch (ProcessingException ex) {
assertSame(NoContentException.class, ex.getCause().getClass());
}
try {
target.request("application/xml").get(TestJaxbBean.class);
fail("ResponseProcessingException expected.");
} catch (ResponseProcessingException ex) {
assertSame(NoContentException.class, ex.getCause().getClass());
}
}
use of javax.ws.rs.ProcessingException in project jersey by jersey.
the class EmptyEntityTest method testReceiveEmptyJAXBlist.
@Test
public void testReceiveEmptyJAXBlist() {
WebTarget target = target("empty/getempty");
final Response response = target.request("application/xml").get();
assertEquals(200, response.getStatus());
try {
response.readEntity(new GenericType<List<TestJaxbBean>>() {
});
fail("ProcessingException expected.");
} catch (ProcessingException ex) {
assertSame(NoContentException.class, ex.getCause().getClass());
}
try {
target.request("application/xml").get(new GenericType<List<TestJaxbBean>>() {
});
fail("ResponseProcessingException expected.");
} catch (ResponseProcessingException ex) {
assertSame(NoContentException.class, ex.getCause().getClass());
}
}
Aggregations