@ -20,8 +20,10 @@ import java.net.URI;
import java.nio.charset.Charset ;
import java.util.EnumSet ;
import java.util.Set ;
import java.util.concurrent.CountDownLatch ;
import java.util.concurrent.ExecutionException ;
import java.util.concurrent.Future ;
import java.util.concurrent.TimeUnit ;
import org.junit.Before ;
import org.junit.Test ;
@ -321,6 +323,7 @@ public class AsyncRestTemplateIntegrationTests extends AbstractJettyServerTestCa
public void identicalExceptionThroughGetAndCallback ( ) throws Exception {
final HttpClientErrorException [ ] callbackException = new HttpClientErrorException [ 1 ] ;
final CountDownLatch latch = new CountDownLatch ( 1 ) ;
ListenableFuture < ? > future = template . execute ( baseUrl + "/status/notfound" , HttpMethod . GET , null , null ) ;
future . addCallback ( new ListenableFutureCallback < Object > ( ) {
@Override
@ -328,9 +331,10 @@ public class AsyncRestTemplateIntegrationTests extends AbstractJettyServerTestCa
fail ( "onSuccess not expected" ) ;
}
@Override
public void onFailure ( Throwable t ) {
assertTrue ( t instanceof HttpClientErrorException ) ;
callbackException [ 0 ] = ( HttpClientErrorException ) t ;
public void onFailure ( Throwable ex ) {
assertTrue ( ex instanceof HttpClientErrorException ) ;
callbackException [ 0 ] = ( HttpClientErrorException ) ex ;
latch . countDown ( ) ;
}
} ) ;
@ -341,6 +345,7 @@ public class AsyncRestTemplateIntegrationTests extends AbstractJettyServerTestCa
catch ( ExecutionException ex ) {
Throwable cause = ex . getCause ( ) ;
assertTrue ( cause instanceof HttpClientErrorException ) ;
latch . await ( 5 , TimeUnit . SECONDS ) ;
assertSame ( callbackException [ 0 ] , cause ) ;
}
}