@Test
public void testGetNitfSegmentsFlowTFBOSThrows() throws IOException, NitfFormatException {

  TemporaryFileBackedOutputStream tfbos = mock(TemporaryFileBackedOutputStream.class);
  doThrow(IOException.class).when(tfbos).write(anyObject(), anyInt(), anyInt());
  catalogOutputAdapter =
      new CatalogOutputAdapter(new Semaphore(3, true)) {
        @Override
        protected TemporaryFileBackedOutputStream createTemporaryFileBackedOutputStream() {
          return tfbos;
        }
      };
  try {
    catalogOutputAdapter.getNitfSegmentsFlow(new ByteArrayInputStream(new byte[] {(byte) 0}));
    fail("expected an exception, shouldn't reach this line");
  } catch (IOException e) {
    assertThat(e, notNullValue());
  }
  verify(tfbos).close();
}