Search in sources :

Example 11 with URLBuilder

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();
}
Also used : Tomcat(org.apache.catalina.startup.Tomcat) URL(org.apache.dubbo.common.URL) URLBuilder(org.apache.dubbo.common.URLBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

URLBuilder (org.apache.dubbo.common.URLBuilder)11 URL (org.apache.dubbo.common.URL)10 Test (org.junit.jupiter.api.Test)8 MonitorService (org.apache.dubbo.monitor.MonitorService)3 Tomcat (org.apache.catalina.startup.Tomcat)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 MetadataService (org.apache.dubbo.metadata.MetadataService)1 Monitor (org.apache.dubbo.monitor.Monitor)1 MonitorFactory (org.apache.dubbo.monitor.MonitorFactory)1 DEFAULT_STUB_EVENT (org.apache.dubbo.rpc.Constants.DEFAULT_STUB_EVENT)1 Invoker (org.apache.dubbo.rpc.Invoker)1 Protocol (org.apache.dubbo.rpc.Protocol)1 ProxyFactory (org.apache.dubbo.rpc.ProxyFactory)1 RpcException (org.apache.dubbo.rpc.RpcException)1 CustomMatcher (org.hamcrest.CustomMatcher)1