com.alibaba.dubbo.rpc.support.DemoService Java Examples
The following examples show how to use
com.alibaba.dubbo.rpc.support.DemoService.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompatibleFilterFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testInvokerJsonPojoSerialization() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("enumlength").anyTimes(); EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] { Type[].class }).anyTimes(); EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes(); EasyMock.replay(invocation); 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&serialization=json"); EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes(); EasyMock.replay(invoker); Result filterResult = compatibleFilter.invoke(invoker, invocation); assertEquals(Type.High, filterResult.getValue()); }
Example #2
Source File: CompatibleFilterFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testInvokerGeneric() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("$enumlength").anyTimes(); EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] { Enum.class }).anyTimes(); EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes(); EasyMock.replay(invocation); 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 = compatibleFilter.invoke(invoker, invocation); assertEquals(filterResult, result); }
Example #3
Source File: ContextFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testSetContext() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("$enumlength").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 = 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); contextFilter.invoke(invoker, invocation); assertNull(RpcContext.getContext().getInvoker()); }
Example #4
Source File: ExceptionFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testRpcException() { Logger logger = EasyMock.createMock(Logger.class); RpcContext.getContext().setRemoteAddress("127.0.0.1", 1234); RpcException exception = new RpcException("TestRpcException"); logger.error(EasyMock.eq("Got unchecked and undeclared exception which called by 127.0.0.1. service: " + DemoService.class.getName() + ", method: sayHello, exception: " + RpcException.class.getName() + ": TestRpcException"), EasyMock.eq(exception)); ExceptionFilter exceptionFilter = new ExceptionFilter(logger); RpcInvocation invocation = new RpcInvocation("sayHello", new Class<?>[]{String.class}, new Object[]{"world"}); Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class); EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class); EasyMock.expect(invoker.invoke(EasyMock.eq(invocation))).andThrow(exception); EasyMock.replay(logger, invoker); try { exceptionFilter.invoke(invoker, invocation); } catch (RpcException e) { assertEquals("TestRpcException", e.getMessage()); } EasyMock.verify(logger, invoker); RpcContext.removeContext(); }
Example #5
Source File: CompatibleFilterFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testInvokerNonJsonPojoSerialization() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("echo").anyTimes(); EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] { String.class }).anyTimes(); EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes(); EasyMock.replay(invocation); 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("hello"); 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 = compatibleFilter.invoke(invoker, invocation); assertEquals("hello", filterResult.getValue()); }
Example #6
Source File: EchoFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testEcho() { 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("hello", filterResult.getValue()); }
Example #7
Source File: CompatibleFilterFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testInvokerNonJsonEnumSerialization() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("enumlength").anyTimes(); EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] { Type[].class }).anyTimes(); EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes(); EasyMock.replay(invocation); 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 = compatibleFilter.invoke(invoker, invocation); assertEquals(Type.High, filterResult.getValue()); }
Example #8
Source File: CompatibleFilterFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testInvokerNonJsonNonPojoSerialization() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("echo").anyTimes(); EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] {String.class }).anyTimes(); EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes(); EasyMock.replay(invocation); 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(new String[]{"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 = compatibleFilter.invoke(invoker, invocation); assertArrayEquals(new String[]{"High"}, (String[])filterResult.getValue()); }
Example #9
Source File: CompatibleFilterFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testInvokerNonJsonPojoSerialization() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("echo").anyTimes(); EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] { String.class }).anyTimes(); EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes(); EasyMock.replay(invocation); 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("hello"); 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 = compatibleFilter.invoke(invoker, invocation); assertEquals("hello", filterResult.getValue()); }
Example #10
Source File: ExceptionFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testRpcException() { Logger logger = EasyMock.createMock(Logger.class); RpcContext.getContext().setRemoteAddress("127.0.0.1", 1234); RpcException exception = new RpcException("TestRpcException"); logger.error(EasyMock.eq("Got unchecked and undeclared exception which called by 127.0.0.1. service: " + DemoService.class.getName() + ", method: sayHello, exception: " + RpcException.class.getName() + ": TestRpcException"), EasyMock.eq(exception)); ExceptionFilter exceptionFilter = new ExceptionFilter(logger); RpcInvocation invocation = new RpcInvocation("sayHello", new Class<?>[]{String.class}, new Object[]{"world"}); Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class); EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class); EasyMock.expect(invoker.invoke(EasyMock.eq(invocation))).andThrow(exception); EasyMock.replay(logger, invoker); try { exceptionFilter.invoke(invoker, invocation); } catch (RpcException e) { assertEquals("TestRpcException", e.getMessage()); } EasyMock.verify(logger, invoker); RpcContext.removeContext(); }
Example #11
Source File: ContextFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testSetContext() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("$enumlength").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 = 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); contextFilter.invoke(invoker, invocation); assertNull(RpcContext.getContext().getInvoker()); }
Example #12
Source File: EchoFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testEcho() { 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("hello", filterResult.getValue()); }
Example #13
Source File: EchoFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@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()); }
Example #14
Source File: CompatibleFilterFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testInvokerJsonPojoSerialization() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("enumlength").anyTimes(); EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] { Type[].class }).anyTimes(); EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes(); EasyMock.replay(invocation); 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&serialization=json"); EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes(); EasyMock.replay(invoker); Result filterResult = compatibleFilter.invoke(invoker, invocation); assertEquals(Type.High, filterResult.getValue()); }
Example #15
Source File: CompatibleFilterFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testInvokerNonJsonEnumSerialization() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("enumlength").anyTimes(); EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] { Type[].class }).anyTimes(); EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes(); EasyMock.replay(invocation); 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 = compatibleFilter.invoke(invoker, invocation); assertEquals(Type.High, filterResult.getValue()); }
Example #16
Source File: CompatibleFilterFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testInvokerNonJsonNonPojoSerialization() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("echo").anyTimes(); EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] {String.class }).anyTimes(); EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes(); EasyMock.replay(invocation); 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(new String[]{"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 = compatibleFilter.invoke(invoker, invocation); assertArrayEquals(new String[]{"High"}, (String[])filterResult.getValue()); }
Example #17
Source File: CompatibleFilterFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testResulthasException() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("enumlength").anyTimes(); EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] { Enum.class }).anyTimes(); EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes(); EasyMock.replay(invocation); 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()); 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 = compatibleFilter.invoke(invoker, invocation); assertEquals(filterResult, result); }
Example #18
Source File: CompatibleFilterFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testInvokerGeneric() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("$enumlength").anyTimes(); EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] { Enum.class }).anyTimes(); EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes(); EasyMock.replay(invocation); 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 = compatibleFilter.invoke(invoker, invocation); assertEquals(filterResult, result); }
Example #19
Source File: EchoFilterTest.java From dubbo3 with Apache License 2.0 | 6 votes |
@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()); }
Example #20
Source File: EchoFilterTest.java From dubbo3 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testEcho() { 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("hello", filterResult.getValue()); }
Example #21
Source File: ContextFilterTest.java From dubbo3 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testSetContext() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("$enumlength").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 = 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); contextFilter.invoke(invoker, invocation); assertNull(RpcContext.getContext().getInvoker()); }
Example #22
Source File: ExceptionFilterTest.java From dubbo3 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testRpcException() { Logger logger = EasyMock.createMock(Logger.class); RpcContext.getContext().setRemoteAddress("127.0.0.1", 1234); RpcException exception = new RpcException("TestRpcException"); logger.error(EasyMock.eq("Got unchecked and undeclared exception which called by 127.0.0.1. service: " + DemoService.class.getName() + ", method: sayHello, exception: " + RpcException.class.getName() + ": TestRpcException"), EasyMock.eq(exception)); ExceptionFilter exceptionFilter = new ExceptionFilter(logger); RpcInvocation invocation = new RpcInvocation("sayHello", new Class<?>[]{String.class}, new Object[]{"world"}); Invoker<DemoService> invoker = EasyMock.createMock(Invoker.class); EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class); EasyMock.expect(invoker.invoke(EasyMock.eq(invocation))).andThrow(exception); EasyMock.replay(logger, invoker); try { exceptionFilter.invoke(invoker, invocation); } catch (RpcException e) { assertEquals("TestRpcException", e.getMessage()); } EasyMock.verify(logger, invoker); RpcContext.removeContext(); }
Example #23
Source File: CompatibleFilterFilterTest.java From dubbo3 with Apache License 2.0 | 6 votes |
@Test public void testInvokerNonJsonPojoSerialization() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("echo").anyTimes(); EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] { String.class }).anyTimes(); EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes(); EasyMock.replay(invocation); 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("hello"); 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 = compatibleFilter.invoke(invoker, invocation); assertEquals("hello", filterResult.getValue()); }
Example #24
Source File: CompatibleFilterFilterTest.java From dubbo3 with Apache License 2.0 | 6 votes |
@Test public void testInvokerNonJsonNonPojoSerialization() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("echo").anyTimes(); EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] {String.class }).anyTimes(); EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes(); EasyMock.replay(invocation); 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(new String[]{"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 = compatibleFilter.invoke(invoker, invocation); assertArrayEquals(new String[]{"High"}, (String[])filterResult.getValue()); }
Example #25
Source File: CompatibleFilterFilterTest.java From dubbo3 with Apache License 2.0 | 6 votes |
@Test public void testInvokerNonJsonEnumSerialization() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("enumlength").anyTimes(); EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] { Type[].class }).anyTimes(); EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes(); EasyMock.replay(invocation); 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 = compatibleFilter.invoke(invoker, invocation); assertEquals(Type.High, filterResult.getValue()); }
Example #26
Source File: CompatibleFilterFilterTest.java From dubbo3 with Apache License 2.0 | 6 votes |
@Test public void testInvokerJsonPojoSerialization() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("enumlength").anyTimes(); EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] { Type[].class }).anyTimes(); EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes(); EasyMock.replay(invocation); 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&serialization=json"); EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes(); EasyMock.replay(invoker); Result filterResult = compatibleFilter.invoke(invoker, invocation); assertEquals(Type.High, filterResult.getValue()); }
Example #27
Source File: CompatibleFilterFilterTest.java From dubbo3 with Apache License 2.0 | 6 votes |
@Test public void testResulthasException() { invocation = EasyMock.createMock(Invocation.class); EasyMock.expect(invocation.getMethodName()).andReturn("enumlength").anyTimes(); EasyMock.expect(invocation.getParameterTypes()).andReturn(new Class<?>[] { Enum.class }).anyTimes(); EasyMock.expect(invocation.getArguments()).andReturn(new Object[] { "hello" }).anyTimes(); EasyMock.replay(invocation); 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()); 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 = compatibleFilter.invoke(invoker, invocation); assertEquals(filterResult, result); }
Example #28
Source File: CompatibleFilterFilterTest.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
@Test public void testInvokerGeneric() { invocation = mock(Invocation.class); given(invocation.getMethodName()).willReturn("$enumlength"); given(invocation.getParameterTypes()).willReturn(new Class<?>[]{Enum.class}); given(invocation.getArguments()).willReturn(new Object[]{"hello"}); invoker = mock(Invoker.class); given(invoker.isAvailable()).willReturn(true); given(invoker.getInterface()).willReturn(DemoService.class); RpcResult result = new RpcResult(); result.setValue("High"); given(invoker.invoke(invocation)).willReturn(result); URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1"); given(invoker.getUrl()).willReturn(url); Result filterResult = compatibleFilter.invoke(invoker, invocation); assertEquals(filterResult, result); }
Example #29
Source File: EchoFilterTest.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
@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()); }
Example #30
Source File: EchoFilterTest.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testEcho() { 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("hello", filterResult.getValue()); }