### Question:
LocalDirectoryTransport extends Transport { @Override public void openFile(String repositoryHash, String filename, Date currentDate) throws JournalException { try { super.testStateChange(State.FILE_OPEN); journalFile = new TransportOutputFile(directory, filename); xmlWriter = new IndentingXMLEventWriter(XMLOutputFactory.newInstance() .createXMLEventWriter(journalFile.open())); parent.writeDocumentHeader(xmlWriter, repositoryHash, currentDate); super.setState(State.FILE_OPEN); } catch (FactoryConfigurationError e) { throw new JournalException(e); } catch (XMLStreamException e) { throw new JournalException(e); } catch (IOException e) { throw new JournalException(e); } } LocalDirectoryTransport(Map<String, String> parameters,
                                   boolean crucial,
                                   TransportParent parent); @Override void openFile(String repositoryHash,
                         String filename,
                         Date currentDate); @Override XMLEventWriter getWriter(); @Override void closeFile(); @Override void shutdown(); static final String PARAMETER_DIRECTORY_PATH; }### Answer:
@Test public void testUnableToCreateFile() throws JournalException { LocalDirectoryTransport transport = new LocalDirectoryTransport(parameters, CRUCIAL, null); try { transport.openFile("firstSillyHash", ":", new Date()); fail("expecting JournalException"); } catch (JournalException e) { } }
@Test public void testOpenAfterOpen() throws JournalException { Transport transport = new LocalDirectoryTransport(parameters, CRUCIAL, parent); transport.openFile("firstSillyHash", "Open", new Date()); try { transport.openFile("firstSillyHash", "OpenOpen", new Date()); fail("Expected a JournalException"); } catch (JournalException e) { } }