Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Created August 20, 2016 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhirockzz/f3be3803a018aa873fe6ce94e3b8be88 to your computer and use it in GitHub Desktop.
Save abhirockzz/f3be3803a018aa873fe6ce94e3b8be88 to your computer and use it in GitHub Desktop.
What happens when a server side failure occurs during an asynchronous invocation using JAX-RS client API
@Test
public void failedMethodCalledAfterServerSideFailureForStringEntity() throws InterruptedException {
CountDownLatch l = new CountDownLatch(1);
ClientBuilder.newClient().target("http://google.com").path("first").request().async().get(new InvocationCallback<String>() {
@Override
public void completed(String response) {
}
@Override
public void failed(Throwable throwable) {
Logger.getAnonymousLogger().log(Level.INFO, "Error message: {0}", throwable.getMessage());
l.countDown();
}
});
boolean result = l.await(3, TimeUnit.SECONDS);
assertTrue("Failed method not called", result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment