Source:
<code>public void testAbfsHttpResponseStatistics() throws IOException { describe("Test to check correct values of statistics after Http " + "Response is processed."); AzureBlobFileSystem fs = getFileSystem(); Path getResponsePath = path(getMethodName()); Map<String, Long> metricMap; String testResponseString = "some response"; FSDataOutputStream out = null; FSDataInputStream in = null; try { out = fs.create(getResponsePath); out.write(testResponseString.getBytes()); out.hflush(); in = fs.open(getResponsePath); int result = in.read(); LOG.info("Result of read operation : {}", result); metricMap = fs.getInstrumentationMap(); assertAbfsStatistics(AbfsStatistic.GET_RESPONSE, 8, metricMap); long bytesSend = metricMap.get(AbfsStatistic.BYTES_SEND.getStatName()); assertAbfsStatistics(AbfsStatistic.BYTES_RECEIVED, bytesSend, metricMap); } finally { IOUtils.cleanupWithLogger(LOG, out, in); } <START> fs.initialize(fs.getUri(), fs.getConf()); <END> try { StringBuilder largeBuffer = new StringBuilder(); out = fs.create(getResponsePath); for (int i = 0; i < LARGE_OPERATIONS; i++) { out.write(testResponseString.getBytes()); out.hflush(); largeBuffer.append(testResponseString); } in = fs.open(getResponsePath); in.read(0, largeBuffer.toString().getBytes(), 0, largeBuffer.toString().getBytes().length); metricMap = fs.getInstrumentationMap(); assertAbfsStatistics(AbfsStatistic.BYTES_RECEIVED, LARGE_OPERATIONS * (testResponseString.getBytes().length), metricMap); assertAbfsStatistics(AbfsStatistic.GET_RESPONSE, 5 + 2 * LARGE_OPERATIONS, metricMap); } finally { IOUtils.cleanupWithLogger(LOG, out, in); } }</code><technical_language>reluctant re-init FS. create a new instance better, save values now, assert diff values expected</technical_language>

Target:
public void testAbfsHttpResponseStatistics() throws IOException { describe("Test to check correct values of statistics after Http " + "Response is processed."); AzureBlobFileSystem fs = getFileSystem(); Path getResponsePath = path(getMethodName()); Map<String, Long> metricMap; String testResponseString = "some response"; long getResponses, bytesReceived; FSDataOutputStream out = null; FSDataInputStream in = null; try { out = fs.create(getResponsePath); out.write(testResponseString.getBytes()); out.hflush(); in = fs.open(getResponsePath); int result = in.read(); LOG.info("Result of read operation : {}", result); metricMap = fs.getInstrumentationMap(); getResponses = assertAbfsStatistics(AbfsStatistic.GET_RESPONSES, 8, metricMap); long bytesSend = metricMap.get(AbfsStatistic.BYTES_SENT.getStatName()); bytesReceived = assertAbfsStatistics(AbfsStatistic.BYTES_RECEIVED, bytesSend, metricMap); } finally { IOUtils.cleanupWithLogger(LOG, out, in); } getResponses++; try { StringBuilder largeBuffer = new StringBuilder(); out = fs.create(getResponsePath); for (int i = 0; i < LARGE_OPERATIONS; i++) { out.write(testResponseString.getBytes()); out.hflush(); largeBuffer.append(testResponseString); } in = fs.open(getResponsePath); in.read(0, largeBuffer.toString().getBytes(), 0, largeBuffer.toString().getBytes().length); metricMap = fs.getInstrumentationMap(); assertAbfsStatistics(AbfsStatistic.BYTES_RECEIVED, bytesReceived + LARGE_OPERATIONS * (testResponseString.getBytes().length), metricMap); assertAbfsStatistics(AbfsStatistic.GET_RESPONSES, getResponses + 3 + 2 * LARGE_OPERATIONS, metricMap); } finally { IOUtils.cleanupWithLogger(LOG, out, in); } }