### Question:
LDIFFormatWriter implements FormatWriter { public void printEntry(final Entry entry) throws IOException { if (entry != null) { final ByteStringBuffer buffer = new ByteStringBuffer(); entry.toLDIF(buffer, 77); if (!first) { ldifOutputStream.write(eol); } else { first = false; } ldifOutputStream.write(buffer.toByteArray()); } } LDIFFormatWriter(final OutputStream outputStream); void printEntry(final Entry entry); void close();  }### Answer:
@Test(expected = IOException.class) public void propagatesIOExceptionFromOutputStream() throws Exception { doThrow(IOException.class).when(outputStream).write(any(byte[].class)); final Entry entry = createEntry("ou=People,dc=btmatthews,dc=com", "ou", "People", "objectclass", "organizationalUnit"); formatWriter.printEntry(entry); }
@Test public void writesEntryToOuputStream() throws Exception { final Entry entry = createEntry("ou=People,dc=btmatthews,dc=com", "ou", "People", "objectclass", "organizationalUnit"); formatWriter.printEntry(entry); verify(outputStream).write(any(byte[].class)); verifyNoMoreInteractions(outputStream); }