Use capture and clear convenience method

This commit is contained in:
Jason Tedor 2016-01-14 16:51:36 -05:00
parent 8f67dcc348
commit 7f78d52c72
2 changed files with 3 additions and 6 deletions

View File

@ -566,8 +566,7 @@ public class TransportReplicationActionTests extends ESTestCase {
// force a new cluster state to simulate a new master having been elected // force a new cluster state to simulate a new master having been elected
clusterService.setState(ClusterState.builder(clusterService.state())); clusterService.setState(ClusterState.builder(clusterService.state()));
transport.handleResponse(currentRequest.requestId, new NotMasterException("shard-failed-test")); transport.handleResponse(currentRequest.requestId, new NotMasterException("shard-failed-test"));
CapturingTransport.CapturedRequest[] retryRequests = transport.capturedRequests(); CapturingTransport.CapturedRequest[] retryRequests = transport.getCapturedRequestsAndClear();
transport.clear();
assertEquals(1, retryRequests.length); assertEquals(1, retryRequests.length);
currentRequest = retryRequests[0]; currentRequest = retryRequests[0];
} }

View File

@ -182,8 +182,7 @@ public class ShardStateActionTests extends ESTestCase {
} }
}); });
final CapturingTransport.CapturedRequest[] capturedRequests = transport.capturedRequests(); final CapturingTransport.CapturedRequest[] capturedRequests = transport.getCapturedRequestsAndClear();
transport.clear();
assertThat(capturedRequests.length, equalTo(1)); assertThat(capturedRequests.length, equalTo(1));
assertFalse(success.get()); assertFalse(success.get());
List<Exception> possibleExceptions = new ArrayList<>(); List<Exception> possibleExceptions = new ArrayList<>();
@ -243,8 +242,7 @@ public class ShardStateActionTests extends ESTestCase {
invoked.set(true); invoked.set(true);
// assert a retry request was sent // assert a retry request was sent
final CapturingTransport.CapturedRequest[] capturedRequests = transport.capturedRequests(); final CapturingTransport.CapturedRequest[] capturedRequests = transport.getCapturedRequestsAndClear();
transport.clear();
retried.set(capturedRequests.length == 1); retried.set(capturedRequests.length == 1);
if (retried.get()) { if (retried.get()) {
// finish the request // finish the request