use of org.apache.dubbo.common.URLBuilder in project dubbo by alibaba.
the class WebserviceProtocolTest method testWebserviceServlet.
@Test
public void testWebserviceServlet() throws LifecycleException {
int port = NetUtils.getAvailablePort();
Tomcat tomcat = buildTomcat("/dubbo-webservice", "/services/*", port);
DemoService service = new DemoServiceImpl();
URLBuilder builder = new URLBuilder().setProtocol("webservice").setHost("127.0.0.1").setPort(port).setPath("dubbo-webservice2/" + DemoService.class.getName()).addParameter("server", "servlet").addParameter("bind.port", port).addParameter("contextpath", "dubbo-webservice2").addParameter(SERVICE_PATH_PREFIX, "dubbo-webservice/services").addParameter("codec", "exchange").addParameter("timeout", 600000);
URL url = builder.build();
tomcat.start();
Exporter<DemoService> exporter = protocol.export(proxy.getInvoker(service, DemoService.class, url));
service = proxy.getProxy(protocol.refer(DemoService.class, url));
assertEquals(service.getSize(new String[] { "", "", "" }), 3);
exporter.unexport();
tomcat.stop();
tomcat.destroy();
}
Aggregations