Search in sources :

Example 51 with URL

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);
}
Also used : URL(com.alibaba.dubbo.common.URL) Test(org.junit.Test)

Example 52 with 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());
}
Also used : URL(com.alibaba.dubbo.common.URL) Test(org.junit.Test)

Example 53 with URL

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();
}
Also used : URL(com.alibaba.dubbo.common.URL) Test(org.junit.Test)

Example 54 with URL

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();
}
Also used : RpcResult(com.alibaba.dubbo.rpc.RpcResult) DemoService(com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService) URL(com.alibaba.dubbo.common.URL) Test(org.junit.Test)

Example 55 with URL

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());
}
Also used : RpcResult(com.alibaba.dubbo.rpc.RpcResult) DemoService(com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService) URL(com.alibaba.dubbo.common.URL) Result(com.alibaba.dubbo.rpc.Result) RpcResult(com.alibaba.dubbo.rpc.RpcResult) Test(org.junit.Test)

Aggregations

URL (com.alibaba.dubbo.common.URL)297 Test (org.junit.Test)169 ArrayList (java.util.ArrayList)73 RpcInvocation (com.alibaba.dubbo.rpc.RpcInvocation)64 HashMap (java.util.HashMap)45 Result (com.alibaba.dubbo.rpc.Result)37 Invoker (com.alibaba.dubbo.rpc.Invoker)36 Map (java.util.Map)36 List (java.util.List)30 Invocation (com.alibaba.dubbo.rpc.Invocation)29 ConcurrentMap (java.util.concurrent.ConcurrentMap)29 RegistryDirectory (com.alibaba.dubbo.registry.integration.RegistryDirectory)28 RpcException (com.alibaba.dubbo.rpc.RpcException)22 NotifyListener (com.alibaba.dubbo.registry.NotifyListener)20 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)18 RpcResult (com.alibaba.dubbo.rpc.RpcResult)17 DemoService (com.alibaba.dubbo.rpc.support.DemoService)12 Set (java.util.Set)12 ConcurrentHashSet (com.alibaba.dubbo.common.utils.ConcurrentHashSet)11 Protocol (com.alibaba.dubbo.rpc.Protocol)11