本文整理了Java中org.easymock.EasyMock.replay()
方法的一些代码示例,展示了EasyMock.replay()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EasyMock.replay()
方法的具体详情如下:
包路径:org.easymock.EasyMock
类名称:EasyMock
方法名:replay
[英]Switches the given mock object (more exactly: the control of the mock object) to replay mode. For details, see the EasyMock documentation.
[中]将给定的模拟对象(更确切地说:模拟对象的控件)切换到重播模式。有关详细信息,请参阅EasyMock文档。
代码示例来源:origin: apache/incubator-druid
@Test(expected = NoSuchElementException.class)
public void testExceptionInNext()
{
boolean expected = false;
EasyMock.expect(peekIterator.hasNext()).andReturn(expected);
EasyMock.replay(peekIterator);
testingIterator.next();
EasyMock.verify(peekIterator);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testStart() throws Exception
{
serviceProvider.start();
EasyMock.replay(serviceProvider);
serverDiscoverySelector.start();
EasyMock.verify(serviceProvider);
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test(expected = Error.class)
public void testWhenComputableThrowsError() throws Exception {
final Integer input = 1;
final Memoizer<Integer, Integer> memoizer = new Memoizer<>(computable);
final Error error = new Error();
expect(computable.compute(input)).andThrow(error);
replay(computable);
memoizer.compute(input);
}
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testChunking()
{
Query query = queryBuilder.intervals("2015-01-01T00:00:00.000/2015-01-11T00:00:00.000").context(ImmutableMap.of("chunkPeriod", "P1D")).build();
executors.execute(EasyMock.anyObject(Runnable.class));
EasyMock.expectLastCall().times(10);
EasyMock.replay(executors);
EasyMock.replay(toolChest);
QueryRunner runner = decorator.decorate(baseRunner, toolChest);
runner.run(QueryPlus.wrap(query), Collections.EMPTY_MAP);
EasyMock.verify(executors);
}
代码示例来源:origin: apache/incubator-druid
@Before
public void setUp()
{
mapper.registerSubtypes(SomeBeanClass.class);
req = EasyMock.createNiceMock(HttpServletRequest.class);
EasyMock.expect(req.getContentType()).andReturn(MediaType.APPLICATION_JSON).anyTimes();
EasyMock.replay(req);
}
代码示例来源:origin: apache/incubator-druid
@Before
public void setUp()
{
resourceFactory = (ResourceFactory<String, String>) EasyMock.createMock(ResourceFactory.class);
EasyMock.replay(resourceFactory);
pool = new ResourcePool<String, String>(
resourceFactory,
new ResourcePoolConfig(2, TimeUnit.MINUTES.toMillis(4))
);
EasyMock.verify(resourceFactory);
EasyMock.reset(resourceFactory);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testGetEmitter()
{
ComposingEmitterConfig config = EasyMock.createMock(ComposingEmitterConfig.class);
EasyMock.expect(config.getEmitters()).andReturn(Collections.singletonList(testEmitterType)).anyTimes();
Injector injector = EasyMock.createMock(Injector.class);
EasyMock.expect(injector.getInstance(Key.get(Emitter.class, Names.named(testEmitterType)))).andReturn(emitter);
EasyMock.replay(config, injector);
Emitter composingEmitter = new ComposingEmitterModule().getEmitter(config, injector);
composingEmitter.start();
EasyMock.verify(config, emitter, injector);
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test(expected = RuntimeException.class)
public void testWhenComputableThrowsRuntimeException() throws Exception {
final Integer input = 1;
final Memoizer<Integer, Integer> memoizer = new Memoizer<>(computable);
final RuntimeException runtimeException = new RuntimeException("Some runtime exception");
expect(computable.compute(input)).andThrow(runtimeException);
replay(computable);
memoizer.compute(input);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testStop() throws IOException
{
serviceProvider.close();
EasyMock.replay(serviceProvider);
serverDiscoverySelector.stop();
EasyMock.verify(serviceProvider);
}
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testDatasourcesResourcesFilteringBadPath()
{
final String badRequestPath = WORD.matcher(requestPath).replaceAll("droid");
EasyMock.expect(request.getPath()).andReturn(badRequestPath).anyTimes();
EasyMock.replay(req, request, authorizerMapper);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testHasNext()
{
boolean expected = true;
EasyMock.expect(peekIterator.hasNext()).andReturn(expected);
EasyMock.replay(peekIterator);
boolean actual = testingIterator.hasNext();
EasyMock.verify(peekIterator);
Assert.assertEquals("The hasNext function is broken", expected, actual);
}
代码示例来源:origin: apache/incubator-druid
private Task createMockTask(String type)
{
Task mock = EasyMock.createMock(Task.class);
EasyMock.expect(mock.getType()).andReturn(type).anyTimes();
EasyMock.replay(mock);
return mock;
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Tests a successful initializeUnchecked() operation.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/
@Test
public void testInitializeUnchecked() throws ConcurrentException {
@SuppressWarnings("unchecked")
final
ConcurrentInitializer<Object> init = EasyMock
.createMock(ConcurrentInitializer.class);
final Object result = new Object();
EasyMock.expect(init.get()).andReturn(result);
EasyMock.replay(init);
assertSame("Wrong result object", result, ConcurrentUtils
.initializeUnchecked(init));
EasyMock.verify(init);
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Tests a successful initialize() operation.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/
@Test
public void testInitialize() throws ConcurrentException {
@SuppressWarnings("unchecked")
final
ConcurrentInitializer<Object> init = EasyMock
.createMock(ConcurrentInitializer.class);
final Object result = new Object();
EasyMock.expect(init.get()).andReturn(result);
EasyMock.replay(init);
assertSame("Wrong result object", result, ConcurrentUtils
.initialize(init));
EasyMock.verify(init);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testFalseBranchNext()
{
boolean expected = true;
EasyMock.expect(peekIterator.hasNext()).andReturn(expected);
expected = false;
EasyMock.expect(peekIterator.hasNext()).andReturn(expected);
EasyMock.replay(peekIterator);
Object res = testingIterator.next();
EasyMock.verify(peekIterator);
Assert.assertNull("Should be null", res);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testGetRedirectURL()
{
String query = "foo=bar&x=y";
String request = "/request";
EasyMock.expect(druidCoordinator.getCurrentLeader()).andReturn("http://localhost").anyTimes();
EasyMock.replay(druidCoordinator);
URL url = coordinatorRedirectInfo.getRedirectURL(query, request);
Assert.assertEquals("http://localhost/request?foo=bar&x=y", url.toString());
EasyMock.verify(druidCoordinator);
}
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testGetRedirectURL()
{
String host = "http://localhost";
String query = "foo=bar&x=y";
String request = "/request";
EasyMock.expect(taskMaster.getCurrentLeader()).andReturn(host).anyTimes();
EasyMock.replay(taskMaster);
URL url = redirectInfo.getRedirectURL(query, request);
Assert.assertEquals("http://localhost/request?foo=bar&x=y", url.toString());
EasyMock.verify(taskMaster);
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Tests whether the thread name is not modified if no naming pattern is
* set.
*/
@Test
public void testNewThreadNoNamingPattern() {
final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
final Runnable r = EasyMock.createMock(Runnable.class);
final String name = "unchangedThreadName";
final Thread t = new Thread(name);
EasyMock.expect(wrapped.newThread(r)).andReturn(t);
EasyMock.replay(wrapped, r);
final BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
assertSame("Wrong thread", t, factory.newThread(r));
assertEquals("Name was changed", name, t.getName());
EasyMock.verify(wrapped, r);
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Tests whether the original priority is not changed if no priority is
* specified.
*/
@Test
public void testNewThreadNoPriority() {
final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
final Runnable r = EasyMock.createMock(Runnable.class);
final int orgPriority = Thread.NORM_PRIORITY + 1;
final Thread t = new Thread();
t.setPriority(orgPriority);
EasyMock.expect(wrapped.newThread(r)).andReturn(t);
EasyMock.replay(wrapped, r);
final BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
assertSame("Wrong thread", t, factory.newThread(r));
assertEquals("Wrong priority", orgPriority, t.getPriority());
EasyMock.verify(wrapped, r);
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Tests createIfAbsent() if a null map is passed in.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/
@Test
public void testCreateIfAbsentNullMap() throws ConcurrentException {
@SuppressWarnings("unchecked")
final
ConcurrentInitializer<Integer> init = EasyMock
.createMock(ConcurrentInitializer.class);
EasyMock.replay(init);
assertNull("Wrong result",
ConcurrentUtils.createIfAbsent(null, "test", init));
EasyMock.verify(init);
}
内容来源于网络,如有侵权,请联系作者删除!