@Test public void processError() throws DriverException, CloseException { final String input = "{\"content\":\"package\"}\n"; final InputStream in = new ByteArrayInputStream(input.getBytes()); final RequestReader reader = new RequestReader(in); final ByteArrayOutputStream out = new ByteArrayOutputStream(); final ResponseWriter writer = new ResponseWriter(out); final Driver driver = new Driver(reader, writer); driver.processOne(); assertThat(out.toString()).contains("\"status\":\"error\""); }
public void processOne() throws DriverException, CloseException { Request request; try { request = this.reader.read(); } catch (CloseException ex) { throw ex; } catch (Exception ex) { final Response response = createFatalResponse(ex); try { this.writer.write(response); } catch (IOException ex2) { throw new DriverException("exception while writing fatal response", ex2); } return; } final Response response = this.processRequest(request); this.writer.setContent(request.content); try { this.writer.write(response); } catch (IOException ex) { throw new DriverException("exception writing response", ex); } }
Driver { public void processOne() throws DriverException, CloseException { Request request; try { request = this.reader.read(); } catch (CloseException ex) { throw ex; } catch (Exception ex) { final Response response = createFatalResponse(ex); try { this.writer.write(response); } catch (IOException ex2) { throw new DriverException("exception while writing fatal response", ex2); } return; } final Response response = this.processRequest(request); this.writer.setContent(request.content); try { this.writer.write(response); } catch (IOException ex) { throw new DriverException("exception writing response", ex); } } }
Driver { public void processOne() throws DriverException, CloseException { Request request; try { request = this.reader.read(); } catch (CloseException ex) { throw ex; } catch (Exception ex) { final Response response = createFatalResponse(ex); try { this.writer.write(response); } catch (IOException ex2) { throw new DriverException("exception while writing fatal response", ex2); } return; } final Response response = this.processRequest(request); this.writer.setContent(request.content); try { this.writer.write(response); } catch (IOException ex) { throw new DriverException("exception writing response", ex); } } Driver(final RequestReader reader, final ResponseWriter writer); }
Driver { public void processOne() throws DriverException, CloseException { Request request; try { request = this.reader.read(); } catch (CloseException ex) { throw ex; } catch (Exception ex) { final Response response = createFatalResponse(ex); try { this.writer.write(response); } catch (IOException ex2) { throw new DriverException("exception while writing fatal response", ex2); } return; } final Response response = this.processRequest(request); this.writer.setContent(request.content); try { this.writer.write(response); } catch (IOException ex) { throw new DriverException("exception writing response", ex); } } Driver(final RequestReader reader, final ResponseWriter writer); void run(); void processOne(); }
Driver { public void processOne() throws DriverException, CloseException { Request request; try { request = this.reader.read(); } catch (CloseException ex) { throw ex; } catch (Exception ex) { final Response response = createFatalResponse(ex); try { this.writer.write(response); } catch (IOException ex2) { throw new DriverException("exception while writing fatal response", ex2); } return; } final Response response = this.processRequest(request); this.writer.setContent(request.content); try { this.writer.write(response); } catch (IOException ex) { throw new DriverException("exception writing response", ex); } } Driver(final RequestReader reader, final ResponseWriter writer); void run(); void processOne();  }