SimulatedLauncher implements IsolatedLauncher { static void writeProp(BufferedWriter output, Entry<String, String> e) { try { output.write(e.getKey() + "=" + e.getValue()); output.newLine(); } catch (IOException e1) { throw new IllegalStateException("Fail to export scanner properties", e1); } } SimulatedLauncher(String version, Logger logger); @Override void execute(Map<String, String> props, LogOutput logOutput); @Override String getVersion();  }
@Test(expected = IllegalStateException.class) public void failToWriteProperty() throws IOException { Map<String, String> props = createProperties(); BufferedWriter writer = mock(BufferedWriter.class); doThrow(new IOException("error")).when(writer).write(anyString()); SimulatedLauncher.writeProp(writer, props.entrySet().iterator().next()); }