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


Java EasyMock.reset方法代码示例

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


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

示例1: testInvokeDefaultSService

import org.easymock.EasyMock; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testInvokeDefaultSService() 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:20883/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.expect(mockChannel.getLocalAddress()).andReturn(NetUtils.toAddress("127.0.0.1:5555")).anyTimes();
    EasyMock.expect(mockChannel.getRemoteAddress()).andReturn(NetUtils.toAddress("127.0.0.1:20883")).anyTimes();
    EasyMock.replay(mockChannel, mockInvoker);
    DubboProtocol.getDubboProtocol().export(mockInvoker);
    String result = invoke.telnet(mockChannel, "DemoService.echo(\"ok\")");
    assertTrue(result.contains("Use default service com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService.\r\n\"ok\"\r\n"));
    EasyMock.reset(mockChannel, mockInvoker);
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:18,代码来源:InvokerTelnetHandlerTest.java

示例2: testInvokeWithRuntimeException

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test
public void testInvokeWithRuntimeException() {
    EasyMock.reset(invoker1);
    EasyMock.expect(invoker1.invoke(invocation)).andThrow(new RuntimeException()).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)).andThrow(new RuntimeException()).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);
    try {
        invoker.invoke(invocation);
        fail();
    } catch (RpcException expected) {
        assertEquals(0, expected.getCode());
        assertFalse(expected.getCause() instanceof RpcException);
    }
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:26,代码来源:FailoverClusterInvokerTest.java

示例3: 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:flychao88,项目名称:dubbocloud,代码行数:21,代码来源:ForkingClusterInvokerTest.java

示例4: resetInvokerToException

import org.easymock.EasyMock; //导入方法依赖的package包/类
private void resetInvokerToException() {
    EasyMock.reset(invoker1);
    EasyMock.expect(invoker1.invoke(invocation)).andThrow(new RuntimeException()).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)).andThrow(new RuntimeException()).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)).andThrow(new RuntimeException()).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:yunhaibin,项目名称:dubbox-hystrix,代码行数:21,代码来源:ForkingClusterInvokerTest.java

示例5: testListDefault

import org.easymock.EasyMock; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testListDefault() 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, "");
    assertEquals("Use default service com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService.\r\n\r\n"
                 + methodsName, result);
    EasyMock.reset(mockChannel);
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:17,代码来源:ListTelnetHandlerTest.java

示例6: resetInvoker1ToException

import org.easymock.EasyMock; //导入方法依赖的package包/类
private void resetInvoker1ToException(){
    EasyMock.reset(invoker1);
    EasyMock.expect(invoker1.invoke(invocation)).andThrow(new RuntimeException()).anyTimes();
    EasyMock.expect(invoker1.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(invoker1.getInterface()).andReturn(FailfastClusterInvokerTest.class).anyTimes();
    EasyMock.replay(invoker1);
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:8,代码来源:FailfastClusterInvokerTest.java

示例7: testPrintLog

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test
public void testPrintLog() throws RemotingException {
    mockChannel = EasyMock.createMock(Channel.class);
    EasyMock.replay(mockChannel);
    String result = log.telnet(mockChannel, "100");
    assertTrue(result.contains("CURRENT LOG APPENDER"));
    EasyMock.reset(mockChannel);
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:9,代码来源:LogTelnetHandlerTest.java

示例8: resetInvokerToException

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

示例9: testUserAgentPrefixAndSuffixAreAdded

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test
public void testUserAgentPrefixAndSuffixAreAdded() throws Exception {
    String prefix = "somePrefix", suffix = "someSuffix";
    Request<?> request = mockRequest(SERVER_NAME, HttpMethodName.PUT, URI_NAME, true);

    HttpResponseHandler<AmazonWebServiceResponse<Object>> handler = createStubResponseHandler();
    EasyMock.replay(handler);
    ClientConfiguration config =
            new ClientConfiguration().withUserAgentPrefix(prefix).withUserAgentSuffix(suffix);

    Capture<HttpRequestBase> capturedRequest = new Capture<HttpRequestBase>();

    EasyMock.reset(httpClient);
    EasyMock
            .expect(httpClient.execute(
                    EasyMock.capture(capturedRequest), EasyMock.<HttpContext>anyObject()))
            .andReturn(createBasicHttpResponse())
            .once();
    EasyMock.replay(httpClient);

    AmazonHttpClient client = new AmazonHttpClient(config, httpClient, null);

    client.requestExecutionBuilder().request(request).execute(handler);

    String userAgent = capturedRequest.getValue().getFirstHeader("User-Agent").getValue();
    Assert.assertTrue(userAgent.startsWith(prefix));
    Assert.assertTrue(userAgent.endsWith(suffix));
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:29,代码来源:AmazonHttpClientTest.java

示例10: testInvaildMessage

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test
public void testInvaildMessage() throws RemotingException {
    mockChannel = EasyMock.createMock(Channel.class);
    EasyMock.expect(mockChannel.getAttribute("telnet.service")).andReturn(null).anyTimes();
    EasyMock.replay(mockChannel);
    String result = list.telnet(mockChannel, "xx");
    assertEquals("No such service xx", result);
    EasyMock.reset(mockChannel);
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:10,代码来源:ListTelnetHandlerTest.java

示例11: resetInvokerToException

import org.easymock.EasyMock; //导入方法依赖的package包/类
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(FailbackClusterInvokerTest.class).anyTimes();
    EasyMock.replay(invoker);
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:8,代码来源:FailbackClusterInvokerTest.java

示例12: resetInvokerToNoException

import org.easymock.EasyMock; //导入方法依赖的package包/类
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(FailbackClusterInvokerTest.class).anyTimes();
    EasyMock.replay(invoker);
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:8,代码来源:FailbackClusterInvokerTest.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:dachengxi,项目名称:EatDubbo,代码行数:11,代码来源:LogTelnetHandlerTest.java

示例14: resetInvokerToNoException

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

示例15: testListDetailService

import org.easymock.EasyMock; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testListDetailService() 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, "-l DemoService");
    assertEquals(detailMethods, result);
    EasyMock.reset(mockChannel, mockInvoker);
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:16,代码来源:ListTelnetHandlerTest.java


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