本文整理了Java中org.easymock.EasyMock.verify()
方法的一些代码示例,展示了EasyMock.verify()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EasyMock.verify()
方法的具体详情如下:
包路径:org.easymock.EasyMock
类名称:EasyMock
方法名:verify
[英]Verifies the given mock object (more exactly: the control of the mock object).
[中]验证给定的模拟对象(更确切地说:模拟对象的控件)。
代码示例来源: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
private void runWithMocks(Runnable toRun, Object... mocks)
{
EasyMock.replay(mocks);
toRun.run();
EasyMock.verify(mocks);
EasyMock.reset(mocks);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testStart() throws Exception
{
serviceProvider.start();
EasyMock.replay(serviceProvider);
serverDiscoverySelector.start();
EasyMock.verify(serviceProvider);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testGetAllTiers()
{
Assert.assertEquals(
ImmutableSet.of("tier1", "tier2"),
lookupNodeDiscovery.getAllTiers()
);
EasyMock.verify(druidNodeDiscoveryProvider, druidNodeDiscovery);
}
}
代码示例来源: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()
{
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: apache/incubator-druid
@Test
public void testStop() throws IOException
{
serviceProvider.close();
EasyMock.replay(serviceProvider);
serverDiscoverySelector.stop();
EasyMock.verify(serviceProvider);
}
}
代码示例来源:origin: apache/incubator-druid
/**
* If "full" is specified, then dimensions/metrics that exist in an incompelte segment should be ingored
*/
@Test
public void testGetDatasourceFullWithIncompleteSegment()
{
Map<String, Object> actual = resource.getDatasource(dataSource, "2015-04-03/2015-04-05", "true");
Map<String, Object> expected = ImmutableMap.of();
EasyMock.verify(serverInventoryView, timelineServerView);
Assert.assertEquals(expected, actual);
}
代码示例来源: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
@Test
public void testResourcesFilteringAccess()
{
setUpMockExpectations(requestPath, true, requestMethod);
EasyMock.replay(req, request, authorizerMapper);
resourceFilter.getRequestFilter().filter(request);
EasyMock.verify(req, request, authorizerMapper);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testMissingProducerSequence() throws IOException
{
setUpRequestExpectations("producer", null);
final InputStream inputStream = IOUtils.toInputStream(inputRow, StandardCharsets.UTF_8);
final Response response = firehose.addAll(inputStream, req);
Assert.assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
inputStream.close();
EasyMock.verify(req);
firehose.close();
}
代码示例来源: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: 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);
}
代码示例来源:origin: apache/shiro
@Test
public void testGetMethod() throws Exception {
MethodInvocation mock = createMock(MethodInvocation.class);
Method method = AopAllianceMethodInvocationAdapterTest.class.getMethod("testGetMethod");
expect(mock.getMethod()).andReturn(method);
AopAllianceMethodInvocationAdapter underTest = new AopAllianceMethodInvocationAdapter(mock);
replay(mock);
assertSame(method, underTest.getMethod());
verify(mock);
}
内容来源于网络,如有侵权,请联系作者删除!