Search in sources :

Example 6 with DemoService

use of com.alibaba.dubbo.rpc.support.DemoService in project dubbo by alibaba.

the class EchoFilterTest method testNonEcho.

@SuppressWarnings("unchecked")
@Test
public void testNonEcho() {
    Invocation invocation = EasyMock.createMock(Invocation.class);
    EasyMock.expect(invocation.getMethodName()).andReturn("echo").anyTimes();
    EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] { Enum.class }).anyTimes();
    EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes();
    EasyMock.expect(invocation.getAttachments()).andReturn(null).anyTimes();
    EasyMock.replay(invocation);
    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 = echoFilter.invoke(invoker, invocation);
    assertEquals("High", filterResult.getValue());
}
Also used : Invocation(com.alibaba.dubbo.rpc.Invocation) RpcResult(com.alibaba.dubbo.rpc.RpcResult) DemoService(com.alibaba.dubbo.rpc.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

DemoService (com.alibaba.dubbo.rpc.support.DemoService)6 Test (org.junit.Test)6 URL (com.alibaba.dubbo.common.URL)5 Invocation (com.alibaba.dubbo.rpc.Invocation)4 Result (com.alibaba.dubbo.rpc.Result)3 RpcResult (com.alibaba.dubbo.rpc.RpcResult)3 MockInvocation (com.alibaba.dubbo.rpc.support.MockInvocation)3 MyInvoker (com.alibaba.dubbo.rpc.support.MyInvoker)2 Logger (com.alibaba.dubbo.common.logger.Logger)1 RpcException (com.alibaba.dubbo.rpc.RpcException)1 RpcInvocation (com.alibaba.dubbo.rpc.RpcInvocation)1