Created
October 28, 2010 13:33
-
-
Save jfarcand/651348 to your computer and use it in GitHub Desktop.
This file contains hidden or 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(groups = {"standalone", "async"}) | |
public void asyncConnectInvalidFuture() throws Throwable { | |
AsyncHttpClient c = new AsyncHttpClient(); | |
final AtomicInteger count = new AtomicInteger(); | |
for (int i = 0; i < 20; i++) { | |
try { | |
Response response = c.preparePost("http://127.0.0.1:9999/").execute(new AsyncCompletionHandlerAdapter() { | |
/* @Override */ | |
public void onThrowable(Throwable t) { | |
count.incrementAndGet(); | |
} | |
}).get(); | |
assertNull(response, "Should have thrown ExecutionException"); | |
} catch (ExecutionException ex) { | |
Throwable cause = ex.getCause(); | |
if (!(cause instanceof ConnectException)) { | |
fail("Should have been caused by ConnectException, not by " + cause.getClass().getName()); | |
} | |
} | |
} | |
assertEquals(count.get(), 20); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment