### Question:
RmiTransportWriter extends Writer { @Override public void close() throws IOException { try { if (!m_closed) { receiver.closeFile(); m_closed= true; } } catch (JournalException e) { throw new IOException(e); } } RmiTransportWriter(RmiJournalReceiverInterface receiver,
                              String repositoryHash,
                              String filename); @Override void write(char[] cbuf, int off, int len); @Override void close(); @Override void flush();  }### Answer:
@Test public void testConstructorOpensConnection() throws JournalException, IOException { RmiTransportWriter rtw = new RmiTransportWriter(receiver, repositoryHash, "theFilename"); rtw.close(); assertCorrectNumberOfCalls(receiver, 1, 0, 0); assertEquals(repositoryHash, receiver.getRepositoryHash()); assertEquals("theFilename", receiver.getFilename()); }
@Test(expected = JournalException.class) public void testConstructorGetsException() throws JournalException, IOException { receiver.setOpenFileThrowsException(true); RmiTransportWriter rtw = new RmiTransportWriter(receiver, repositoryHash, "theFilename"); rtw.close(); }
@Test public void testCloseClosesFile() throws JournalException, IOException { RmiTransportWriter writer = new RmiTransportWriter(receiver, repositoryHash, "theFilename"); writer.close(); assertCorrectNumberOfCalls(receiver, 1, 0, 1); }
@Test(expected = IOException.class) public void testCloseThrowsException() throws JournalException, IOException { receiver.setCloseFileThrowsException(true); RmiTransportWriter writer = new RmiTransportWriter(receiver, repositoryHash, "theFilename"); writer.close(); }