Created
August 20, 2016 12:04
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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