26
26
import org .apache .http .HttpResponse ;
27
27
import org .apache .http .ProtocolVersion ;
28
28
import org .apache .http .StatusLine ;
29
+ import org .apache .http .client .protocol .HttpClientContext ;
29
30
import org .apache .http .concurrent .FutureCallback ;
30
31
import org .apache .http .entity .ContentType ;
31
32
import org .apache .http .entity .InputStreamEntity ;
@@ -430,11 +431,11 @@ public void testTooLargeResponse() throws Exception {
430
431
ContentTooLongException tooLong = new ContentTooLongException ("too long!" );
431
432
CloseableHttpAsyncClient httpClient = mock (CloseableHttpAsyncClient .class );
432
433
when (httpClient .<HttpResponse >execute (any (HttpAsyncRequestProducer .class ), any (HttpAsyncResponseConsumer .class ),
433
- any (FutureCallback .class ))).then (new Answer <Future <HttpResponse >>() {
434
+ any (HttpClientContext . class ), any ( FutureCallback .class ))).then (new Answer <Future <HttpResponse >>() {
434
435
@ Override
435
436
public Future <HttpResponse > answer (InvocationOnMock invocationOnMock ) throws Throwable {
436
437
HeapBufferedAsyncResponseConsumer consumer = (HeapBufferedAsyncResponseConsumer ) invocationOnMock .getArguments ()[1 ];
437
- FutureCallback callback = (FutureCallback ) invocationOnMock .getArguments ()[2 ];
438
+ FutureCallback callback = (FutureCallback ) invocationOnMock .getArguments ()[3 ];
438
439
assertEquals (new ByteSizeValue (100 , ByteSizeUnit .MB ).bytesAsInt (), consumer .getBufferLimit ());
439
440
callback .failed (tooLong );
440
441
return null ;
@@ -495,7 +496,7 @@ private RemoteScrollableHitSource sourceWithMockedRemoteCall(boolean mockRemoteV
495
496
496
497
CloseableHttpAsyncClient httpClient = mock (CloseableHttpAsyncClient .class );
497
498
when (httpClient .<HttpResponse >execute (any (HttpAsyncRequestProducer .class ), any (HttpAsyncResponseConsumer .class ),
498
- any (FutureCallback .class ))).thenAnswer (new Answer <Future <HttpResponse >>() {
499
+ any (HttpClientContext . class ), any ( FutureCallback .class ))).thenAnswer (new Answer <Future <HttpResponse >>() {
499
500
500
501
int responseCount = 0 ;
501
502
@@ -504,7 +505,7 @@ public Future<HttpResponse> answer(InvocationOnMock invocationOnMock) throws Thr
504
505
// Throw away the current thread context to simulate running async httpclient's thread pool
505
506
threadPool .getThreadContext ().stashContext ();
506
507
HttpAsyncRequestProducer requestProducer = (HttpAsyncRequestProducer ) invocationOnMock .getArguments ()[0 ];
507
- FutureCallback <HttpResponse > futureCallback = (FutureCallback <HttpResponse >) invocationOnMock .getArguments ()[2 ];
508
+ FutureCallback <HttpResponse > futureCallback = (FutureCallback <HttpResponse >) invocationOnMock .getArguments ()[3 ];
508
509
HttpEntityEnclosingRequest request = (HttpEntityEnclosingRequest )requestProducer .generateRequest ();
509
510
URL resource = resources [responseCount ];
510
511
String path = paths [responseCount ++];
0 commit comments