MetadataHandler { public void writeAck(final File slotFile, final String id) { synchronized (lock) { try { final BufferedWriter writer = getWriter(slotFile); assert(writer != null); writer.write(id); writer.newLine(); writer.flush(); } catch (IOException e) { LOG.log(Level.WARNING, "Unable to write metadata ack entry.", e); } } } private  MetadataHandler(); static MetadataHandler getInstance(); void writeAck(final File slotFile, final String id); void flush(); void close(); static final String DELIMITER; static final String METADATA_FILE_SUFFIX; static MetadataHandler instance; }
@Test public void testWriteAck() throws IOException { final MetadataHandler handler = MetadataHandler.getInstance(); final File file = temp.newFile("ackfile"); handler.writeAck(file, "id"); Assert.assertTrue(file.exists()); final BufferedReader reader = new BufferedReader( new FileReader(file.getAbsolutePath() + MetadataHandler.METADATA_FILE_SUFFIX)); String line = reader.readLine(); Assert.assertEquals("File content is not correct.", "id", line); reader.close(); }