Source:
<code>public void testBasicSendAndPoll() { DataNodeId dataNodeId = localPlainTextDataNodes.get(0); ReplicaId replicaId = sslDisabledClusterMap.getReplicaIds(dataNodeId).get(0); List<RequestInfo> requestInfoList = new ArrayList<>(); List<ResponseInfo> responseInfoList; requestInfoList.add( new RequestInfo(dataNodeId.getHostname(), dataNodeId.getPortToConnectTo(), new MockSend(1), replicaId)); requestInfoList.add( new RequestInfo(dataNodeId.getHostname(), dataNodeId.getPortToConnectTo(), new MockSend(2), replicaId)); int requestCount = requestInfoList.size(); int responseCount = 0; do { <START> responseInfoList = networkClient.sendAndPoll(requestInfoList, Collections.emptyList(), POLL_TIMEOUT_MS); <END> requestInfoList.clear(); for (ResponseInfo responseInfo : responseInfoList) { MockSend send = (MockSend) responseInfo.getRequestInfo().getRequest(); NetworkClientErrorCode error = responseInfo.getError(); ByteBuffer response = responseInfo.getResponse(); Assert.assertNull("Should not have encountered an error", error); Assert.assertNotNull("Should receive a valid response", response); int correlationIdInRequest = send.getCorrelationId(); int correlationIdInResponse = response.getInt(); Assert.assertEquals("Received response for the wrong request", correlationIdInRequest, correlationIdInResponse); responseCount++; } } while (requestCount > responseCount); Assert.assertEquals("Should receive only as many responses as there were requests", requestCount, responseCount); responseInfoList = networkClient.sendAndPoll(requestInfoList, Collections.emptyList(), POLL_TIMEOUT_MS); requestInfoList.clear(); Assert.assertEquals("No responses are expected at this time", 0, responseInfoList.size()); }</code><technical_language>write a real test cases for dropping connections</technical_language>

Target:
public void testBasicSendAndPoll() { DataNodeId dataNodeId = localPlainTextDataNodes.get(0); ReplicaId replicaId = sslDisabledClusterMap.getReplicaIds(dataNodeId).get(0); List<RequestInfo> requestInfoList = new ArrayList<>(); List<ResponseInfo> responseInfoList; requestInfoList.add( new RequestInfo(dataNodeId.getHostname(), dataNodeId.getPortToConnectTo(), new MockSend(1), replicaId)); requestInfoList.add( new RequestInfo(dataNodeId.getHostname(), dataNodeId.getPortToConnectTo(), new MockSend(2), replicaId)); int requestCount = requestInfoList.size(); int responseCount = 0; do { responseInfoList = networkClient.sendAndPoll(requestInfoList, Collections.emptySet(), POLL_TIMEOUT_MS); requestInfoList.clear(); for (ResponseInfo responseInfo : responseInfoList) { MockSend send = (MockSend) responseInfo.getRequestInfo().getRequest(); NetworkClientErrorCode error = responseInfo.getError(); ByteBuffer response = responseInfo.getResponse(); Assert.assertNull("Should not have encountered an error", error); Assert.assertNotNull("Should receive a valid response", response); int correlationIdInRequest = send.getCorrelationId(); int correlationIdInResponse = response.getInt(); Assert.assertEquals("Received response for the wrong request", correlationIdInRequest, correlationIdInResponse); responseCount++; } } while (requestCount > responseCount); Assert.assertEquals("Should receive only as many responses as there were requests", requestCount, responseCount); responseInfoList = networkClient.sendAndPoll(requestInfoList, Collections.emptySet(), POLL_TIMEOUT_MS); requestInfoList.clear(); Assert.assertEquals("No responses are expected at this time", 0, responseInfoList.size()); }