use of net.morimekta.providence.client.internal.NoLogging in project providence by morimekta.
the class HttpClientHandlerTest method setUp.
@Before
public void setUp() throws Exception {
Awaitility.setDefaultPollDelay(50, TimeUnit.MILLISECONDS);
Log.setLog(new NoLogging());
impl = mock(net.morimekta.test.thrift.client.TestService.Iface.class);
TProcessor processor = new net.morimekta.test.thrift.client.TestService.Processor<>(impl);
instrumentation = mock(ServiceCallInstrumentation.class);
provider = new DefaultSerializerProvider();
server = new Server(0);
ServletContextHandler handler = new ServletContextHandler();
handler.addServlet(new ServletHolder(new TServlet(processor, new TBinaryProtocol.Factory())), "/" + ENDPOINT);
handler.addServlet(new ServletHolder(new HttpServlet() {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.sendError(HttpServletResponse.SC_NOT_FOUND);
}
}), "/" + NOT_FOUND);
handler.addServlet(new ServletHolder(new HttpServlet() {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setStatus(HttpServletResponse.SC_OK);
resp.setContentType("text/html");
resp.getWriter().print("<html></html>");
}
}), "/" + HTML);
handler.addServlet(new ServletHolder(new HttpServlet() {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setStatus(HttpServletResponse.SC_OK);
Serializer serializer = provider.getDefault();
resp.setContentType(serializer.mediaType());
serializer.serialize(resp.getOutputStream(), reply.get());
}
}), "/" + RESPONSE);
contentTypes = new ArrayList<>();
reply = new AtomicReference<>();
server.setHandler(handler);
server.setRequestLog((request, response) -> contentTypes.addAll(Collections.list(request.getHeaders("Content-Type")).stream().map(Object::toString).collect(Collectors.toList())));
server.start();
port = getExposedPort(server);
}
Aggregations