本文整理汇总了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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}