use of com.alibaba.dubbo.remoting.http.HttpHandler in project dubbo by alibaba.
the class JettyHttpBinderTest method shouldAbleHandleRequestForJettyBinder.
@Test
public void shouldAbleHandleRequestForJettyBinder() throws Exception {
int port = TestUtil.getFreePort();
URL url = new URL("http", "localhost", port, new String[] { Constants.BIND_PORT_KEY, String.valueOf(port) });
HttpServer httpServer = new JettyHttpServer(url, new HttpHandler() {
@Override
public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.getWriter().write("Jetty");
}
});
String response = Request.Get(url.toJavaURL().toURI()).execute().returnContent().asString();
assertThat(response, is("Jetty"));
httpServer.close();
}
use of com.alibaba.dubbo.remoting.http.HttpHandler in project dubbo by alibaba.
the class TomcatHttpBinderTest method shouldAbleHandleRequestForTomcatBinder.
@Test
public void shouldAbleHandleRequestForTomcatBinder() throws Exception {
int port = TestUtil.getFreePort();
URL url = new URL("http", "localhost", port, new String[] { Constants.BIND_PORT_KEY, String.valueOf(port) });
HttpServer httpServer = new TomcatHttpBinder().bind(url, new HttpHandler() {
@Override
public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.getWriter().write("Tomcat");
}
});
String response = Request.Get(url.toJavaURL().toURI()).execute().returnContent().asString();
assertThat(response, is("Tomcat"));
httpServer.close();
}
Aggregations