Java Code Examples for com.alibaba.dubbo.rpc.cluster.filter.DemoService

The following examples show how to use com.alibaba.dubbo.rpc.cluster.filter.DemoService. These examples are extracted from open source projects. 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 Project: dubbo-2.6.5   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 2
Source Project: dubbox   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 3
Source Project: dubbox-hystrix   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 4
Source Project: dubbo3   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 5
Source Project: dubbox   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 6
Source Project: dubbox   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 7
Source Project: dubbo-2.6.5   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @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);
}
 
Example 8
Source Project: dubbo-2.6.5   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testInvokeExceptoin() {
    resetInvokerToException();
    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    invoker.invoke(invocation);
    Assert.assertNull(RpcContext.getContext().getInvoker());
}
 
Example 9
Source Project: dubbo-2.6.5   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test()
public void testInvokeNoExceptoin() {

    resetInvokerToNoException();

    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    Result ret = invoker.invoke(invocation);
    Assert.assertSame(result, ret);
}
 
Example 10
Source Project: dubbox   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @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);
}
 
Example 11
Source Project: dubbox   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 12
Source Project: dubbox   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 13
Source Project: dubbox   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testInvokeExceptoin() {
    resetInvokerToException();
    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    invoker.invoke(invocation);
    Assert.assertNull(RpcContext.getContext().getInvoker());
}
 
Example 14
Source Project: dubbox   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test()
public void testInvokeNoExceptoin() {
    
    resetInvokerToNoException();
    
    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    Result ret = invoker.invoke(invocation);
    Assert.assertSame(result, ret);
}
 
Example 15
Source Project: dubbox-hystrix   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @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);
}
 
Example 16
Source Project: dubbox-hystrix   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 17
Source Project: dubbox-hystrix   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 18
Source Project: dubbox-hystrix   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testInvokeExceptoin() {
    resetInvokerToException();
    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    invoker.invoke(invocation);
    Assert.assertNull(RpcContext.getContext().getInvoker());
}
 
Example 19
Source Project: dubbox-hystrix   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test()
public void testInvokeNoExceptoin() {
    
    resetInvokerToNoException();
    
    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    Result ret = invoker.invoke(invocation);
    Assert.assertSame(result, ret);
}
 
Example 20
Source Project: dubbo3   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @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);
}
 
Example 21
Source Project: dubbo3   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 22
Source Project: dubbo3   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 23
Source Project: dubbo3   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testInvokeExceptoin() {
    resetInvokerToException();
    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    invoker.invoke(invocation);
    Assert.assertNull(RpcContext.getContext().getInvoker());
}
 
Example 24
Source Project: dubbo3   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test()
public void testInvokeNoExceptoin() {
    
    resetInvokerToNoException();
    
    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    Result ret = invoker.invoke(invocation);
    Assert.assertSame(result, ret);
}
 
Example 25
Source Project: dubbox   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @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);
}
 
Example 26
Source Project: dubbox   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 27
Source Project: dubbox   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 28
Source Project: dubbox   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testInvokeExceptoin() {
    resetInvokerToException();
    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    invoker.invoke(invocation);
    Assert.assertNull(RpcContext.getContext().getInvoker());
}
 
Example 29
Source Project: dubbox   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test()
public void testInvokeNoExceptoin() {
    
    resetInvokerToNoException();
    
    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    Result ret = invoker.invoke(invocation);
    Assert.assertSame(result, ret);
}
 
Example 30
Source Project: dubbox   Source File: FailSafeClusterInvokerTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @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);
}