本文整理汇总了Java中org.easymock.classextension.EasyMock.replay方法的典型用法代码示例。如果您正苦于以下问题:Java EasyMock.replay方法的具体用法?Java EasyMock.replay怎么用?Java EasyMock.replay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.easymock.classextension.EasyMock
的用法示例。
在下文中一共展示了EasyMock.replay方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLaziness
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
public void testLaziness() throws InvalidProtocolBufferException {
LazyInnerMessageLite inner = LazyInnerMessageLite.newBuilder()
.setNum(2)
.build();
LazyMessageLite outer = LazyMessageLite.newBuilder()
.setNum(1)
.setInner(inner)
.setOneofInner(inner)
.build();
ByteString bytes = outer.toByteString();
// The parser for inner / oneofInner message shouldn't be used if
// getInner / getOneofInner is not called.
LazyInnerMessageLite.PARSER = EasyMock.createStrictMock(Parser.class);
EasyMock.replay(LazyInnerMessageLite.PARSER);
LazyMessageLite deserialized = LazyMessageLite.parseFrom(bytes);
assertEquals(1, deserialized.getNum());
assertEquals(421, deserialized.getNumWithDefault());
EasyMock.verify(LazyInnerMessageLite.PARSER);
}
示例2: testRun
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
public void testRun() throws Exception {
RunnableQueue q = EasyMock.createMock(RunnableQueue.class);
Runnable task1 = EasyMock.createMock(Runnable.class);
Runnable task2 = EasyMock.createMock(Runnable.class);
EasyMock.expect(q.remove()).andReturn(task1);
task1.run();
EasyMock.expectLastCall();
EasyMock.expect(q.remove()).andReturn(task2);
task2.run();
EasyMock.expectLastCall();
EasyMock.expect(q.remove()).andThrow(new InterruptedException());
EasyMock.replay(q, task1, task2);
WorkerThread worker = new WorkerThread(q, "test thread");
worker.run();
EasyMock.verify(q, task1, task2);
}
示例3: testRunCallsQueuedRunnables
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
public void testRunCallsQueuedRunnables() throws Exception {
RunnableQueue q = EasyMock.createMock(RunnableQueue.class);
Runnable task1 = EasyMock.createMock(Runnable.class);
Runnable task2 = EasyMock.createMock(Runnable.class);
EasyMock.expect(q.remove()).andReturn(task1);
task1.run();
EasyMock.expectLastCall();
EasyMock.expect(q.remove()).andReturn(task2);
task2.run();
EasyMock.expectLastCall();
EasyMock.expect(q.remove()).andThrow(new InterruptedException());
EasyMock.replay(q, task1, task2);
QueueExtractor extractor = new QueueExtractor(q);
extractor.run();
EasyMock.verify(q, task1, task2);
}
示例4: testSetCharacterEncoding_allowsExceptionToPassBack
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Test
public void testSetCharacterEncoding_allowsExceptionToPassBack()
throws UnsupportedEncodingException {
final UnsupportedEncodingException expected
= new UnsupportedEncodingException();
mockSubset.setCharacterEncoding(EasyMock.eq(VALUE));
EasyMock.expectLastCall().andThrow(expected);
EasyMock.replay(mockSubset);
try {
adapter.setCharacterEncoding(VALUE);
fail("Should pass exception through");
} catch (UnsupportedEncodingException actual) {
assertThat(actual, sameInstance(expected));
}
EasyMock.verify(mockSubset);
}
示例5: testGetEntryInvalidUrl
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
public void testGetEntryInvalidUrl() throws Exception {
// Setup
URL badUrl = new URL("http://badUrl");
String errorMsg = "invalid URL";
EasyMock.expect(mockService.getEntry(badUrl, FeedServerEntry.class)).andThrow(
new IOException(errorMsg));
EasyMock.replay(mockService);
// Perform Test
try {
feedServerClient.getEntity(badUrl);
} catch (FeedServerClientException e) {
assertTrue(e.getCause().getMessage().equals(errorMsg));
EasyMock.verify(mockService);
return;
}
fail("Did not get FeedServerClientException");
}
示例6: testGetEntryInvalidUrl
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
public void testGetEntryInvalidUrl() throws Exception {
// Setup
URL badUrl = new URL("http://badUrl");
String errorMsg = "invalid URL";
EasyMock.expect(mockService.getEntry(badUrl, FeedServerEntry.class)).andThrow(
new IOException(errorMsg));
EasyMock.replay(mockService);
// Perform Test
try {
@SuppressWarnings("unused")
Map<String, Object> fetchedMap = feedServerClient.getEntry(badUrl);
} catch (FeedServerClientException e) {
assertTrue(e.getCause().getMessage().equals(errorMsg));
EasyMock.verify(mockService);
return;
}
fail("Did not get FeedServerClientException");
}
示例7: testGetLocale
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Test
public void testGetLocale() {
final Locale locale = Locale.ITALIAN;
EasyMock.expect(mockSubset.getLocale()).andReturn(locale);
EasyMock.replay(mockSubset);
assertThat(adapter.getLocale(), is(locale));
EasyMock.verify(mockSubset);
}
示例8: setUp
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Before
public void setUp() {
mockSubset = EasyMock.createStrictMock(HttpRequest.class);
EasyMock.expect(mockSubset.getConnectionInformation()).andReturn(null);
EasyMock.replay(mockSubset);
adapter = new HttpServletRequestAdapter(mockSubset);
EasyMock.verify(mockSubset);
// We have to do a replay and reset here because HttpServletRequestAdapter
// calls getConnectionInformation() on the HttpRequest in its constructor.
EasyMock.reset(mockSubset);
}
示例9: testGetHeader
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Test
public void testGetHeader() {
EasyMock.expect(mockSubset.getHeader(NAME)).andReturn(VALUE);
EasyMock.replay(mockSubset);
assertThat(adapter.getHeader(NAME), is(VALUE));
EasyMock.verify(mockSubset);
}
示例10: testGetLocales
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Test
public void testGetLocales() {
final Enumeration<Locale> mockEnumeration = createMockEnumeration();
EasyMock.expect(mockSubset.getLocales()).andReturn(mockEnumeration);
EasyMock.replay(mockSubset, mockEnumeration);
assertThat(adapter.getLocales(), sameInstance(mockEnumeration));
EasyMock.verify(mockSubset, mockEnumeration);
}
示例11: testGetHeaderNames
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Test
public void testGetHeaderNames() {
final Enumeration<String> mockEnumeration = createMockEnumeration();
EasyMock.expect(mockSubset.getHeaderNames()).andReturn(mockEnumeration);
EasyMock.replay(mockSubset, mockEnumeration);
assertThat(adapter.getHeaderNames(), sameInstance(mockEnumeration));
EasyMock.verify(mockSubset, mockEnumeration);
}
示例12: testGetMethod
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Test
public void testGetMethod() {
EasyMock.expect(mockSubset.getMethod()).andReturn(NAME);
EasyMock.replay(mockSubset);
assertThat(adapter.getMethod(), is(NAME));
EasyMock.verify(mockSubset);
}
示例13: testGetPathTranslated
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Test
public void testGetPathTranslated() {
EasyMock.expect(mockSubset.getPathTranslated()).andReturn(VALUE);
EasyMock.replay(mockSubset);
assertThat(adapter.getPathTranslated(), is(VALUE));
EasyMock.verify(mockSubset);
}
示例14: testGetQueryString
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Test
public void testGetQueryString() {
EasyMock.expect(mockSubset.getQueryString()).andReturn(VALUE);
EasyMock.replay(mockSubset);
assertThat(adapter.getQueryString(), is(VALUE));
EasyMock.verify(mockSubset);
}
示例15: testGetRequestURL
import org.easymock.classextension.EasyMock; //导入方法依赖的package包/类
@Test
public void testGetRequestURL() {
final StringBuffer requestUrl = new StringBuffer(VALUE);
EasyMock.expect(mockSubset.getRequestURL()).andReturn(requestUrl);
EasyMock.replay(mockSubset);
assertThat(adapter.getRequestURL(), is(requestUrl));
EasyMock.verify(mockSubset);
}