@Test
  public void testExceptionFromCriticalTransport() throws JournalException {
    createJournalWriterAndTransports();
    transport2.setThrowExceptionOnGetWriter(true);

    // Writing a journal entry should cause a high-level log message, and a
    // mode change.
    journalWriter.prepareToWriteJournalEntry();
    journalWriter.writeJournalEntry(SampleJournalEntries.ENTRY_1);
    assertCorrectNumberOfRequests(1, 1, 0, 0);
    assertEquals(
        "should be a mode change.", JournalOperatingMode.READ_ONLY, JournalOperatingMode.getMode());

    assertExpectedLogMessages(
        "FATAL - Exception thrown from " + "crucial Journal Transport: 'two'");
  }
  @Test
  public void testExceptionFromNonCriticalTransport() throws JournalException {
    createJournalWriterAndTransports();
    transport1.setThrowExceptionOnGetWriter(true);

    // Writing a journal entry should cause a high-level log message, but no
    // mode change.
    journalWriter.prepareToWriteJournalEntry();
    journalWriter.writeJournalEntry(SampleJournalEntries.ENTRY_1);
    assertCorrectNumberOfRequests(1, 1, 0, 0);
    assertEquals(
        "should be no mode change.", JournalOperatingMode.NORMAL, JournalOperatingMode.getMode());

    assertExpectedLogMessages(
        "ERROR - Exception thrown from " + "non-crucial Journal Transport: 'one'");
  }
 @Before
 public void initializeJournalOperatingMode() {
   JournalOperatingMode.setMode(JournalOperatingMode.NORMAL);
 }