下面列出了怎么用com.alibaba.dubbo.rpc.cluster.filter.DemoService的API类实例代码及写法,或者点击链接到github查看源代码。
@Test()
public void testNoInvoke() {
dic = mock(Directory.class);
given(dic.getUrl()).willReturn(url);
given(dic.list(invocation)).willReturn(null);
given(dic.getInterface()).willReturn(DemoService.class);
invocation.setMethodName("method1");
resetInvokerToNoException();
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
LogUtil.start();
invoker.invoke(invocation);
assertTrue(LogUtil.findMessage("No provider") > 0);
LogUtil.stop();
}
@Test()
public void testNoInvoke() {
dic = EasyMock.createMock(Directory.class);
EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(dic.list(invocation)).andReturn(null).anyTimes();
EasyMock.expect(dic.getInterface()).andReturn(DemoService.class).anyTimes();
invocation.setMethodName("method1");
EasyMock.replay(dic);
resetInvokerToNoException();
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
LogUtil.start();
invoker.invoke(invocation);
assertTrue(LogUtil.findMessage("No provider") > 0);
LogUtil.stop();
}
@Test()
public void testNoInvoke() {
dic = EasyMock.createMock(Directory.class);
EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(dic.list(invocation)).andReturn(null).anyTimes();
EasyMock.expect(dic.getInterface()).andReturn(DemoService.class).anyTimes();
invocation.setMethodName("method1");
EasyMock.replay(dic);
resetInvokerToNoException();
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
LogUtil.start();
invoker.invoke(invocation);
assertTrue(LogUtil.findMessage("No provider") > 0);
LogUtil.stop();
}
@Test()
public void testNoInvoke() {
dic = EasyMock.createMock(Directory.class);
EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(dic.list(invocation)).andReturn(null).anyTimes();
EasyMock.expect(dic.getInterface()).andReturn(DemoService.class).anyTimes();
invocation.setMethodName("method1");
EasyMock.replay(dic);
resetInvokerToNoException();
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
LogUtil.start();
invoker.invoke(invocation);
assertTrue(LogUtil.findMessage("No provider") > 0);
LogUtil.stop();
}
@Test()
public void testNoInvoke() {
dic = EasyMock.createMock(Directory.class);
EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(dic.list(invocation)).andReturn(null).anyTimes();
EasyMock.expect(dic.getInterface()).andReturn(DemoService.class).anyTimes();
invocation.setMethodName("method1");
EasyMock.replay(dic);
resetInvokerToNoException();
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
LogUtil.start();
invoker.invoke(invocation);
assertTrue(LogUtil.findMessage("No provider") > 0);
LogUtil.stop();
}
@Test()
public void testNoInvoke() {
dic = EasyMock.createMock(Directory.class);
EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(dic.list(invocation)).andReturn(null).anyTimes();
EasyMock.expect(dic.getInterface()).andReturn(DemoService.class).anyTimes();
invocation.setMethodName("method1");
EasyMock.replay(dic);
resetInvokerToNoException();
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
LogUtil.start();
invoker.invoke(invocation);
assertTrue(LogUtil.findMessage("No provider") > 0);
LogUtil.stop();
}
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
dic = mock(Directory.class);
given(dic.getUrl()).willReturn(url);
given(dic.list(invocation)).willReturn(invokers);
given(dic.getInterface()).willReturn(DemoService.class);
invocation.setMethodName("method1");
invokers.add(invoker);
}
@Test
public void testInvokeExceptoin() {
resetInvokerToException();
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
invoker.invoke(invocation);
Assert.assertNull(RpcContext.getContext().getInvoker());
}
@Test()
public void testInvokeNoExceptoin() {
resetInvokerToNoException();
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
Result ret = invoker.invoke(invocation);
Assert.assertSame(result, ret);
}
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
dic = EasyMock.createMock(Directory.class);
EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(dic.list(invocation)).andReturn(invokers).anyTimes();
EasyMock.expect(dic.getInterface()).andReturn(DemoService.class).anyTimes();
invocation.setMethodName("method1");
EasyMock.replay(dic);
invokers.add(invoker);
}
private void resetInvokerToException(){
EasyMock.reset(invoker);
EasyMock.expect(invoker.invoke(invocation)).andThrow(new RuntimeException()).anyTimes();
EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class).anyTimes();
EasyMock.replay(invoker);
}
private void resetInvokerToNoException(){
EasyMock.reset(invoker);
EasyMock.expect(invoker.invoke(invocation)).andReturn(result).anyTimes();
EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class).anyTimes();
EasyMock.replay(invoker);
}
@Test
public void testInvokeExceptoin() {
resetInvokerToException();
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
invoker.invoke(invocation);
Assert.assertNull(RpcContext.getContext().getInvoker());
}
@Test()
public void testInvokeNoExceptoin() {
resetInvokerToNoException();
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
Result ret = invoker.invoke(invocation);
Assert.assertSame(result, ret);
}
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
dic = EasyMock.createMock(Directory.class);
EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(dic.list(invocation)).andReturn(invokers).anyTimes();
EasyMock.expect(dic.getInterface()).andReturn(DemoService.class).anyTimes();
invocation.setMethodName("method1");
EasyMock.replay(dic);
invokers.add(invoker);
}
private void resetInvokerToException(){
EasyMock.reset(invoker);
EasyMock.expect(invoker.invoke(invocation)).andThrow(new RuntimeException()).anyTimes();
EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class).anyTimes();
EasyMock.replay(invoker);
}
private void resetInvokerToNoException(){
EasyMock.reset(invoker);
EasyMock.expect(invoker.invoke(invocation)).andReturn(result).anyTimes();
EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class).anyTimes();
EasyMock.replay(invoker);
}
@Test
public void testInvokeExceptoin() {
resetInvokerToException();
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
invoker.invoke(invocation);
Assert.assertNull(RpcContext.getContext().getInvoker());
}
@Test()
public void testInvokeNoExceptoin() {
resetInvokerToNoException();
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
Result ret = invoker.invoke(invocation);
Assert.assertSame(result, ret);
}
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
dic = EasyMock.createMock(Directory.class);
EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(dic.list(invocation)).andReturn(invokers).anyTimes();
EasyMock.expect(dic.getInterface()).andReturn(DemoService.class).anyTimes();
invocation.setMethodName("method1");
EasyMock.replay(dic);
invokers.add(invoker);
}
private void resetInvokerToException(){
EasyMock.reset(invoker);
EasyMock.expect(invoker.invoke(invocation)).andThrow(new RuntimeException()).anyTimes();
EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class).anyTimes();
EasyMock.replay(invoker);
}
private void resetInvokerToNoException(){
EasyMock.reset(invoker);
EasyMock.expect(invoker.invoke(invocation)).andReturn(result).anyTimes();
EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class).anyTimes();
EasyMock.replay(invoker);
}
@Test
public void testInvokeExceptoin() {
resetInvokerToException();
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
invoker.invoke(invocation);
Assert.assertNull(RpcContext.getContext().getInvoker());
}
@Test()
public void testInvokeNoExceptoin() {
resetInvokerToNoException();
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
Result ret = invoker.invoke(invocation);
Assert.assertSame(result, ret);
}
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
dic = EasyMock.createMock(Directory.class);
EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(dic.list(invocation)).andReturn(invokers).anyTimes();
EasyMock.expect(dic.getInterface()).andReturn(DemoService.class).anyTimes();
invocation.setMethodName("method1");
EasyMock.replay(dic);
invokers.add(invoker);
}
private void resetInvokerToException(){
EasyMock.reset(invoker);
EasyMock.expect(invoker.invoke(invocation)).andThrow(new RuntimeException()).anyTimes();
EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class).anyTimes();
EasyMock.replay(invoker);
}
private void resetInvokerToNoException(){
EasyMock.reset(invoker);
EasyMock.expect(invoker.invoke(invocation)).andReturn(result).anyTimes();
EasyMock.expect(invoker.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(invoker.getInterface()).andReturn(DemoService.class).anyTimes();
EasyMock.replay(invoker);
}
@Test
public void testInvokeExceptoin() {
resetInvokerToException();
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
invoker.invoke(invocation);
Assert.assertNull(RpcContext.getContext().getInvoker());
}
@Test()
public void testInvokeNoExceptoin() {
resetInvokerToNoException();
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
Result ret = invoker.invoke(invocation);
Assert.assertSame(result, ret);
}
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
dic = EasyMock.createMock(Directory.class);
EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
EasyMock.expect(dic.list(invocation)).andReturn(invokers).anyTimes();
EasyMock.expect(dic.getInterface()).andReturn(DemoService.class).anyTimes();
invocation.setMethodName("method1");
EasyMock.replay(dic);
invokers.add(invoker);
}