@Test public void process_returns_response_from_server() throws Exception { Request request = new Request("", new Timestamp(0)); Response expected = new Response("", request); server.output = responseFromServer(expected); processor = new StreamServerAsTransactionProcessor(server, io, log); Response response = processor.process(request); assertEquals(expected, response); }
@Test public void process_writes_request() throws Exception { Request request = new Request("", new Timestamp(0)); try { processor.process(request); fail("There is nothing to read"); } catch (DeserializationException e) { } Request writtenRequest = requestThatWasWritten(); assertEquals(request, writtenRequest); }
@Test public void process_logs_exceptions() throws Exception { Request request = new Request("", new Timestamp(0)); Response expected = new Response("", request); server.output = responseFromServer(expected); FakeLog log = new FakeLog(); FakeIO io = new FakeIO() { @Override public void write(OutputStream out, Transaction transaction) { throw new NullPointerException(); }; }; processor = new StreamServerAsTransactionProcessor(server, io, log); try { processor.process(request); fail("Request is not serializable"); } catch (Exception e) { assertEquals(e, log.exception); } }