@Test public void roundtripsInputsAndOutputs() throws Exception { RequestStreamHandler handler = new JacksonRequestStreamHandler<>(mapper, new TestHandler()); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); handler.handleRequest( new ByteArrayInputStream("{\"input\":\"input\"}".getBytes()), outputStream, null); assertThat(outputStream.toString(), is("{\"output\":\"input\"}")); }
@Override public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException { IN request = reader.readValue(input); log.debug("Request: {}", request); OUT response = innerHandler.handleRequest(request, context); log.debug("Response: {}", response); writer.writeValue(output, response); }
JacksonRequestStreamHandler implements RequestStreamHandler { @Override public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException { IN request = reader.readValue(input); log.debug("Request: {}", request); OUT response = innerHandler.handleRequest(request, context); log.debug("Response: {}", response); writer.writeValue(output, response); } }
JacksonRequestStreamHandler implements RequestStreamHandler { @Override public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException { IN request = reader.readValue(input); log.debug("Request: {}", request); OUT response = innerHandler.handleRequest(request, context); log.debug("Response: {}", response); writer.writeValue(output, response); } @Autowired  JacksonRequestStreamHandler(ObjectMapper mapper, RequestHandler<IN, OUT> innerHandler); }
JacksonRequestStreamHandler implements RequestStreamHandler { @Override public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException { IN request = reader.readValue(input); log.debug("Request: {}", request); OUT response = innerHandler.handleRequest(request, context); log.debug("Response: {}", response); writer.writeValue(output, response); } @Autowired  JacksonRequestStreamHandler(ObjectMapper mapper, RequestHandler<IN, OUT> innerHandler); @Override void handleRequest(InputStream input, OutputStream output, Context context); }
JacksonRequestStreamHandler implements RequestStreamHandler { @Override public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException { IN request = reader.readValue(input); log.debug("Request: {}", request); OUT response = innerHandler.handleRequest(request, context); log.debug("Response: {}", response); writer.writeValue(output, response); } @Autowired  JacksonRequestStreamHandler(ObjectMapper mapper, RequestHandler<IN, OUT> innerHandler); @Override void handleRequest(InputStream input, OutputStream output, Context context);  }