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


Java EasyMock.replay方法代码示例

本文整理汇总了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);
}
 
开发者ID:os72,项目名称:protobuf-java-shaded-261,代码行数:25,代码来源:LazyMessageLiteTest.java

示例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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:17,代码来源:WorkerThreadTest.java

示例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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:17,代码来源:QueueExtractorTest.java

示例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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:17,代码来源:HttpServletRequestAdapterTest.java

示例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");
}
 
开发者ID:jyang,项目名称:google-feedserver,代码行数:19,代码来源:FeedServerClientTest.java

示例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");
}
 
开发者ID:jyang,项目名称:google-feedserver,代码行数:20,代码来源:TypelessFeedServerClientTest.java

示例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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:9,代码来源:HttpServletRequestAdapterTest.java

示例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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:12,代码来源:HttpServletRequestAdapterTest.java

示例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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:8,代码来源:HttpServletRequestAdapterTest.java

示例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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:9,代码来源:HttpServletRequestAdapterTest.java

示例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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:9,代码来源:HttpServletRequestAdapterTest.java

示例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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:8,代码来源:HttpServletRequestAdapterTest.java

示例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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:8,代码来源:HttpServletRequestAdapterTest.java

示例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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:8,代码来源:HttpServletRequestAdapterTest.java

示例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);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:9,代码来源:HttpServletRequestAdapterTest.java


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