use of com.alibaba.dubbo.common.URL in project dubbo by alibaba.
the class DubboLazyConnectTest method testSticky2.
@Test
public void testSticky2() {
URL url = URL.valueOf("dubbo://127.0.0.1:9090/hi?" + Constants.LAZY_CONNECT_KEY + "=true");
ProtocolUtils.refer(IDemoService.class, url);
}
use of com.alibaba.dubbo.common.URL in project dubbo by alibaba.
the class DubboLazyConnectTest method testSticky4.
@Test
public void testSticky4() {
int port = NetUtils.getAvailablePort();
URL url = URL.valueOf("dubbo://127.0.0.1:" + port + "/hi?" + Constants.LAZY_CONNECT_KEY + "=true");
ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
IDemoService service = (IDemoService) ProtocolUtils.refer(IDemoService.class, url);
Assert.assertEquals("ok", service.get());
}
use of com.alibaba.dubbo.common.URL in project dubbo by alibaba.
the class DubboLazyConnectTest method testSticky3.
@Test(expected = RpcException.class)
public void testSticky3() {
URL url = URL.valueOf("dubbo://127.0.0.1:9090/hi?" + Constants.LAZY_CONNECT_KEY + "=true");
IDemoService service = (IDemoService) ProtocolUtils.refer(IDemoService.class, url);
service.get();
}
use of com.alibaba.dubbo.common.URL in project dubbo by alibaba.
the class FutureFilterTest method testSyncCallbackHasException.
@Test(expected = RuntimeException.class)
public void testSyncCallbackHasException() throws RpcException, Throwable {
@SuppressWarnings("unchecked") Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class);
EasyMock.expect(invoker.isAvailable()).andReturn(true).anyTimes();
EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class).anyTimes();
RpcResult result = new RpcResult();
result.setException(new RuntimeException());
EasyMock.expect(invoker.invoke(invocation)).andReturn(result).anyTimes();
URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1&" + Constants.ON_THROW_METHOD_KEY + "=echo");
EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes();
EasyMock.replay(invoker);
eventFilter.invoke(invoker, invocation).recreate();
}
use of com.alibaba.dubbo.common.URL in project dubbo by alibaba.
the class FutureFilterTest method testSyncCallback.
@Test
public void testSyncCallback() {
@SuppressWarnings("unchecked") Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class);
EasyMock.expect(invoker.isAvailable()).andReturn(true).anyTimes();
EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class).anyTimes();
RpcResult result = new RpcResult();
result.setValue("High");
EasyMock.expect(invoker.invoke(invocation)).andReturn(result).anyTimes();
URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1");
EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes();
EasyMock.replay(invoker);
Result filterResult = eventFilter.invoke(invoker, invocation);
assertEquals("High", filterResult.getValue());
}
Aggregations