### Question:
MessageArchive implements AutoCloseable { public void close() { try { currentFileName = ""; if (indexFile != null){ indexFile.close(); indexFile = null; } if (dataFile != null){ dataFile.close(); dataFile = null; } currentFileName = ""; } catch (Exception exp) { LoggingService.logError(MODULE_NAME, exp.getMessage(), exp); } } MessageArchive(String name); void close(); List<Message> messageQuery(long from, long to);  }### Answer:
@Test public void testClose() { try { messageArchive.save(message.getBytes(UTF_8),timestamp); messageArchive.close(); PowerMockito.verifyPrivate(messageArchive).invoke("openFiles", anyLong()); Mockito.verify(randomAccessFile, Mockito.atLeastOnce()).seek(anyLong()); Mockito.verify(randomAccessFile, Mockito.atLeastOnce()).length(); Mockito.verify(randomAccessFile, Mockito.atLeastOnce()).getFilePointer(); Mockito.verify(randomAccessFile, Mockito.atLeastOnce()).close(); } catch (Exception e) { fail("This shall never happen"); } }