当前位置: 首页>>代码示例>>Java>>正文


Java EasyMock.replay方法代码示例

本文整理汇总了Java中org.easymock.EasyMock.replay方法的典型用法代码示例。如果您正苦于以下问题:Java EasyMock.replay方法的具体用法?Java EasyMock.replay怎么用?Java EasyMock.replay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.easymock.EasyMock的用法示例。


在下文中一共展示了EasyMock.replay方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRpcException

import org.easymock.EasyMock; //导入方法依赖的package包/类
@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();
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:24,代码来源:ExceptionFilterTest.java

示例2: testNoInvoke

import org.easymock.EasyMock; //导入方法依赖的package包/类
@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();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:20,代码来源:FailSafeClusterInvokerTest.java

示例3: testInvokeWithRPCException

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test()
public void testInvokeWithRPCException() {
    
    EasyMock.reset(invoker1);
    EasyMock.expect(invoker1.invoke(invocation)).andThrow(new RpcException()).anyTimes();
    EasyMock.expect(invoker1.isAvailable()).andReturn(true).anyTimes();
    EasyMock.expect(invoker1.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(invoker1.getInterface()).andReturn(FailoverClusterInvokerTest.class).anyTimes();
    EasyMock.replay(invoker1);
    
    EasyMock.reset(invoker2);
    EasyMock.expect(invoker2.invoke(invocation)).andReturn(result).anyTimes();
    EasyMock.expect(invoker2.isAvailable()).andReturn(true).anyTimes();
    EasyMock.expect(invoker2.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(invoker2.getInterface()).andReturn(FailoverClusterInvokerTest.class).anyTimes();
    EasyMock.replay(invoker2);
    
    FailoverClusterInvoker<FailoverClusterInvokerTest> invoker = new FailoverClusterInvoker<FailoverClusterInvokerTest>(dic);
    for(int i=0;i<100;i++){
        Result ret = invoker.invoke(invocation);
        assertSame(result, ret);
    }
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:24,代码来源:FailoverClusterInvokerTest.java

示例4: testNoInvoke

import org.easymock.EasyMock; //导入方法依赖的package包/类
@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(FailfastClusterInvokerTest.class).anyTimes();
    
    invocation.setMethodName("method1");
    EasyMock.replay(dic);
    
    invokers.add(invoker1);
    
    resetInvoker1ToNoException();
    
    FailfastClusterInvoker<FailfastClusterInvokerTest> invoker = new FailfastClusterInvoker<FailfastClusterInvokerTest>(dic);
    try {
        invoker.invoke(invocation);
        fail();
    } catch (RpcException expected) {
        assertFalse(expected.getCause() instanceof RpcException);
    }
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:24,代码来源:FailfastClusterInvokerTest.java

示例5: testEmptyOption

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test public void testEmptyOption() throws Exception
{
    OptionsParser parser = new OptionsParser();
    OptionsHandler handler = EasyMock.createMock(OptionsHandler.class);

    handler.startOptions();
    handler.handleOption(OPTION, null);
    handler.endOptions();
    EasyMock.replay(handler);
    Config cfg = new Config();

    cfg.setEmptyOption(true);
    parser.setConfig(cfg);
    parser.parse(new StringReader(CFG_EMPTY_OPTION), handler);
    EasyMock.verify(handler);
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:17,代码来源:OptionsParserTest.java

示例6: testInvokerNonJsonPojoSerialization

import org.easymock.EasyMock; //导入方法依赖的package包/类
@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());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:20,代码来源:CompatibleFilterFilterTest.java

示例7: resetInvokerToNoException

import org.easymock.EasyMock; //导入方法依赖的package包/类
private void resetInvokerToNoException() {
    EasyMock.reset(invoker1);
    EasyMock.expect(invoker1.invoke(invocation)).andReturn(result).anyTimes();
    EasyMock.expect(invoker1.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(invoker1.isAvailable()).andReturn(true).anyTimes();
    EasyMock.expect(invoker1.getInterface()).andReturn(ForkingClusterInvokerTest.class).anyTimes();
    EasyMock.replay(invoker1);
    EasyMock.reset(invoker2);
    EasyMock.expect(invoker2.invoke(invocation)).andReturn(result).anyTimes();
    EasyMock.expect(invoker2.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(invoker2.isAvailable()).andReturn(true).anyTimes();
    EasyMock.expect(invoker2.getInterface()).andReturn(ForkingClusterInvokerTest.class).anyTimes();
    EasyMock.replay(invoker2);
    EasyMock.reset(invoker3);
    EasyMock.expect(invoker3.invoke(invocation)).andReturn(result).anyTimes();
    EasyMock.expect(invoker3.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(invoker3.isAvailable()).andReturn(true).anyTimes();
    EasyMock.expect(invoker3.getInterface()).andReturn(ForkingClusterInvokerTest.class).anyTimes();
    EasyMock.replay(invoker3);
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:21,代码来源:ForkingClusterInvokerTest.java

示例8: testListService

import org.easymock.EasyMock; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testListService() throws RemotingException {
    mockInvoker = EasyMock.createMock(Invoker.class);
    EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
    EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20885/demo")).anyTimes();
    EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
    mockChannel = EasyMock.createMock(Channel.class);
    EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService").anyTimes();
    EasyMock.replay(mockChannel, mockInvoker);
    DubboProtocol.getDubboProtocol().export(mockInvoker);
    String result = list.telnet(mockChannel, "DemoService");
    assertEquals(methodsName, result);
    EasyMock.reset(mockChannel, mockInvoker);
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:16,代码来源:ListTelnetHandlerTest.java

示例9: testCloseAvailablecheck

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test
public void testCloseAvailablecheck(){
    LoadBalance lb = EasyMock.createMock(LoadBalance.class);
    EasyMock.expect(lb.select(invokers, url, invocation)).andReturn(invoker1);
    EasyMock.replay(lb);
    initlistsize5();
    
    Invoker sinvoker = cluster_nocheck.select(lb, invocation, invokers, selectedInvokers);
    Assert.assertEquals(false,sinvoker.isAvailable());
    Assert.assertEquals(invoker1,sinvoker);
    
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:13,代码来源:AbstractClusterInvokerTest.java

示例10: setUp

import org.easymock.EasyMock; //导入方法依赖的package包/类
/**
 * @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);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:18,代码来源:FailSafeClusterInvokerTest.java

示例11: testMessageNull

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test
public void testMessageNull() throws RemotingException {
    mockChannel = EasyMock.createMock(Channel.class);
    EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
    EasyMock.replay(mockChannel);
    String result = invoke.telnet(mockChannel, null);
    assertEquals("Please input method name, eg: \r\ninvoke xxxMethod(1234, \"abcd\", {\"prop\" : \"value\"})\r\ninvoke XxxService.xxxMethod(1234, \"abcd\", {\"prop\" : \"value\"})\r\ninvoke com.xxx.XxxService.xxxMethod(1234, \"abcd\", {\"prop\" : \"value\"})",
                 result);
    EasyMock.reset(mockChannel);
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:11,代码来源:InvokerTelnetHandlerTest.java

示例12: testWithoutConfig

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test public void testWithoutConfig() throws Exception
{
    Ini ini = new Ini();
    Ini.Section sec = ini.add(Dwarfs.PROP_BASHFUL);

    sec.put(Dwarf.PROP_FORTUNE_NUMBER, null);
    IniHandler handler = EasyMock.createMock(IniHandler.class);

    handler.startIni();
    handler.startSection(Dwarfs.PROP_BASHFUL);
    handler.endSection();
    handler.endIni();
    EasyMock.replay(handler);
    verify(ini, handler);
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:16,代码来源:IniFormatterTest.java

示例13: testChangeLogLevel

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test
public void testChangeLogLevel() throws RemotingException {
    mockChannel = EasyMock.createMock(Channel.class);
    EasyMock.replay(mockChannel);
    String result = log.telnet(mockChannel, "error");
    assertTrue(result.contains("\r\nCURRENT LOG LEVEL:ERROR"));
    String result2 = log.telnet(mockChannel, "warn");
    assertTrue(result2.contains("\r\nCURRENT LOG LEVEL:WARN"));
    EasyMock.reset(mockChannel);
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:11,代码来源:LogTelnetHandlerTest.java

示例14: testNoInteractionsInUnusedMethods

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test
public void testNoInteractionsInUnusedMethods() {
    TransactionType request = EasyMock.createNiceMock(TransactionType.class);
    EasyMock.replay(catalog, featureType1, featureType2, request);
    
    TransactionType returned = listener.beforeTransaction(request);
    Assert.assertThat(returned, Matchers.sameInstance(request));
    listener.beforeCommit(request);
    
    EasyMock.verify(catalog, featureType1, featureType2, request);
}
 
开发者ID:MapStory,项目名称:ms-gs-plugins,代码行数:12,代码来源:BoundsUpdateTransactionListenerTest.java

示例15: testList

import org.easymock.EasyMock; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testList() throws RemotingException {
    mockInvoker = EasyMock.createMock(Invoker.class);
    EasyMock.expect(mockInvoker.getInterface()).andReturn(DemoService.class).anyTimes();
    EasyMock.expect(mockInvoker.getUrl()).andReturn(URL.valueOf("dubbo://127.0.0.1:20885/demo")).anyTimes();
    EasyMock.expect(mockInvoker.invoke((Invocation) EasyMock.anyObject())).andReturn(new RpcResult("ok")).anyTimes();
    mockChannel = EasyMock.createMock(Channel.class);
    EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
    EasyMock.replay(mockChannel, mockInvoker);
    DubboProtocol.getDubboProtocol().export(mockInvoker);
    String result = list.telnet(mockChannel, "");
    assertEquals("com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService", result);
    EasyMock.reset(mockChannel);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:16,代码来源:ListTelnetHandlerTest.java


注:本文中的org.easymock.EasyMock.replay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。