Source:
<code>public void testNormalOperation() throws Exception { int conns = 5; int reqs = 500; InetSocketAddress addr = new InetSocketAddress("localhost", server.port); for (int i = 0; i < conns; i++) { selector.connect("" + i, addr, BUFFER_SIZE, BUFFER_SIZE); } int[] requests = new int[conns]; int[] responses = new int[conns]; int responseCount = 0; List<NetworkSend> sends = new ArrayList<NetworkSend>(); for (int i = 0; i < conns; i++) { <START> sends.add(createSend("" + i, i + "-" + 0)); <END> } while (responseCount < conns * reqs) { selector.poll(0L, sends); assertEquals("No disconnects should have occurred.", 0, selector.disconnected().size()); for (NetworkReceive receive : selector.completedReceives()) { String[] pieces = asString(receive).split("-"); assertEquals("Should be in the form 'conn-counter'", 2, pieces.length); assertEquals("Check the source", receive.getConnectionId(), pieces[0]); assertEquals("Check that the receive has kindly been rewound", 0, receive.getReceivedBytes().getPayload().position()); assertEquals("Check the request counter", responses[Integer.parseInt(receive.getConnectionId())], Integer.parseInt(pieces[1])); responses[Integer.parseInt(receive.getConnectionId())]++; responseCount++; } sends.clear(); for (NetworkSend send : selector.completedSends()) { String dest = send.getConnectionId(); requests[Integer.parseInt(dest)]++; if (requests[Integer.parseInt(dest)] < reqs) { sends.add(createSend(dest, dest + "-" + requests[Integer.parseInt(dest)])); } } } }</code><technical_language>want consider a prefix for connectionId differentiate string sent</technical_language>

Target:
public void testNormalOperation() throws Exception { int conns = 5; int reqs = 500; InetSocketAddress addr = new InetSocketAddress("localhost", server.port); ArrayList<String> connectionIds = new ArrayList<String>(); for (int i = 0; i < conns; i++) { String connectionId = selector.connect(addr, BUFFER_SIZE, BUFFER_SIZE); connectionIds.add(connectionId); } int[] requests = new int[conns]; int[] responses = new int[conns]; int responseCount = 0; List<NetworkSend> sends = new ArrayList<NetworkSend>(); for (int i = 0; i < conns; i++) { String connectionId = connectionIds.get(i); sends.add(createSend(connectionId, connectionId + "&" + 0)); } while (responseCount < conns * reqs) { selector.poll(0L, sends); assertEquals("No disconnects should have occurred.", 0, selector.disconnected().size()); for (NetworkReceive receive : selector.completedReceives()) { String[] pieces = asString(receive).split("&"); assertEquals("Should be in the form 'conn-counter'", 2, pieces.length); assertEquals("Check the source", receive.getConnectionId(), pieces[0]); assertEquals("Check that the receive has kindly been rewound", 0, receive.getReceivedBytes().getPayload().position()); int index = Integer.parseInt(receive.getConnectionId().split("_")[1]); assertEquals("Check the request counter", responses[index], Integer.parseInt(pieces[1])); responses[index]++; responseCount++; } sends.clear(); for (NetworkSend send : selector.completedSends()) { String dest = send.getConnectionId(); String[] pieces = dest.split("_"); int index = Integer.parseInt(pieces[1]); requests[index]++; if (requests[index] < reqs) { sends.add(createSend(dest, dest + "&" + requests[index])); } } } }