當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。