本文整理了Java中org.easymock.EasyMock.eq()
方法的一些代码示例,展示了EasyMock.eq()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EasyMock.eq()
方法的具体详情如下:
包路径:org.easymock.EasyMock
类名称:EasyMock
方法名:eq
[英]Expects a byte that is equal to the given value.
[中]需要一个等于给定值的字节。
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Prepares an executor service mock to expect the start of the timer.
*
* @param service the mock
* @param future the future
*/
private void prepareStartTimer(final ScheduledExecutorService service,
final ScheduledFuture<?> future) {
service.scheduleAtFixedRate((Runnable) EasyMock.anyObject(), EasyMock
.eq(PERIOD), EasyMock.eq(PERIOD), EasyMock.eq(UNIT));
EasyMock.expectLastCall().andReturn(future);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testGetDatasourceRuleHistoryWithWrongCount()
{
EasyMock.expect(auditManager.fetchAuditHistory(EasyMock.eq("datasource1"), EasyMock.eq("rules"), EasyMock.eq(-1)))
.andThrow(new IllegalArgumentException("Limit must be greater than zero!"))
.once();
EasyMock.replay(auditManager);
RulesResource rulesResource = new RulesResource(databaseRuleManager, auditManager);
Response response = rulesResource.getDatasourceRuleHistory("datasource1", null, -1);
Map<String, Object> rulesHistory = (Map) response.getEntity();
Assert.assertEquals(400, response.getStatus());
Assert.assertTrue(rulesHistory.containsKey("error"));
Assert.assertEquals("Limit must be greater than zero!", rulesHistory.get("error"));
EasyMock.verify(auditManager);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testQueryRegistration()
{
QueryRunner baseRunner = (queryPlus, responseContext) -> null;
QueryWatcher mock = EasyMock.createMock(QueryWatcher.class);
mock.registerQuery(EasyMock.eq(query), EasyMock.anyObject(ListenableFuture.class));
EasyMock.replay(mock);
AsyncQueryRunner asyncRunner = new AsyncQueryRunner<>(baseRunner, executor, mock);
asyncRunner.run(QueryPlus.wrap(query), Collections.EMPTY_MAP);
EasyMock.verify(mock);
}
}
代码示例来源:origin: confluentinc/ksql
@Test
public void shouldWaitIfCommandSequenceNumberSpecified() throws Exception {
// Given:
commandQueue.ensureConsumedPast(eq(3L), anyObject());
expectLastCall();
replay(commandQueue);
// When:
testResource.streamQuery(new KsqlRequest(queryString, Collections.emptyMap(), 3L));
// Then:
verify(commandQueue);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testNext()
{
boolean expected = true;
EasyMock.expect(peekIterator.hasNext()).andReturn(expected).times(4);
String defaultString = "S1";
String resString = "S2";
EasyMock.expect(peekIterator.next()).andReturn(defaultString);
EasyMock.expect(binaryFn.apply(EasyMock.eq(defaultString), EasyMock.isNull()))
.andReturn(resString);
EasyMock.expect(peekIterator.next()).andReturn(defaultString);
EasyMock.expect(comparator.compare(EasyMock.eq(resString), EasyMock.eq(defaultString)))
.andReturn(0);
EasyMock.expect(peekIterator.next()).andReturn(defaultString);
EasyMock.expect(binaryFn.apply(EasyMock.eq(resString), EasyMock.eq(defaultString)))
.andReturn(resString);
EasyMock.expect(comparator.compare(EasyMock.eq(resString), EasyMock.eq(defaultString)))
.andReturn(1);
EasyMock.replay(peekIterator);
EasyMock.replay(binaryFn);
EasyMock.replay(comparator);
String actual = testingIterator.next();
Assert.assertEquals(resString, actual);
EasyMock.verify(peekIterator);
EasyMock.verify(comparator);
EasyMock.verify(binaryFn);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testStartCorrect()
{
final Announcer announcer = EasyMock.createStrictMock(Announcer.class);
final HostAndPortWithScheme node = HostAndPortWithScheme.fromString("some_host");
final ListenerResourceAnnouncer resourceAnnouncer = new ListenerResourceAnnouncer(
announcer,
listeningAnnouncerConfig,
listenerKey,
node
)
{
};
announcer.announce(
EasyMock.eq(ZKPaths.makePath(announcePath, StringUtils.format("%s:%s", node.getScheme(), node.getHostText()))),
EasyMock.aryEq(resourceAnnouncer.getAnnounceBytes())
);
EasyMock.expectLastCall().once();
EasyMock.replay(announcer);
resourceAnnouncer.start();
EasyMock.verify(announcer);
}
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testGetAllDatasourcesRuleHistoryWithWrongCount()
{
EasyMock.expect(auditManager.fetchAuditHistory(EasyMock.eq("rules"), EasyMock.eq(-1)))
.andThrow(new IllegalArgumentException("Limit must be greater than zero!"))
.once();
EasyMock.replay(auditManager);
RulesResource rulesResource = new RulesResource(databaseRuleManager, auditManager);
Response response = rulesResource.getDatasourceRuleHistory(null, -1);
Map<String, Object> rulesHistory = (Map) response.getEntity();
Assert.assertEquals(400, response.getStatus());
Assert.assertTrue(rulesHistory.containsKey("error"));
Assert.assertEquals("Limit must be greater than zero!", rulesHistory.get("error"));
EasyMock.verify(auditManager);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testMissingGetLookup()
{
final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(
LookupCoordinatorManager.class);
EasyMock.expect(lookupCoordinatorManager.getLookup(EasyMock.eq(LOOKUP_TIER), EasyMock.eq(LOOKUP_NAME)))
.andReturn(null)
.once();
EasyMock.replay(lookupCoordinatorManager);
final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(
lookupCoordinatorManager,
mapper,
mapper
);
final Response response = lookupCoordinatorResource.getSpecificLookup(LOOKUP_TIER, LOOKUP_NAME);
Assert.assertEquals(404, response.getStatus());
EasyMock.verify(lookupCoordinatorManager);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testSimpleGetLookup()
{
final LookupExtractorFactoryMapContainer container = new LookupExtractorFactoryMapContainer(
"v0",
new HashMap<String, Object>()
);
final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(
LookupCoordinatorManager.class);
EasyMock.expect(lookupCoordinatorManager.getLookup(EasyMock.eq(LOOKUP_TIER), EasyMock.eq(LOOKUP_NAME)))
.andReturn(container)
.once();
EasyMock.replay(lookupCoordinatorManager);
final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(
lookupCoordinatorManager,
mapper,
mapper
);
final Response response = lookupCoordinatorResource.getSpecificLookup(LOOKUP_TIER, LOOKUP_NAME);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals(container, response.getEntity());
EasyMock.verify(lookupCoordinatorManager);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testExceptionalGetLookup()
{
final String errMsg = "some message";
final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(
LookupCoordinatorManager.class);
EasyMock.expect(lookupCoordinatorManager.getLookup(EasyMock.eq(LOOKUP_TIER), EasyMock.eq(LOOKUP_NAME)))
.andThrow(new RuntimeException(errMsg))
.once();
EasyMock.replay(lookupCoordinatorManager);
final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(
lookupCoordinatorManager,
mapper,
mapper
);
final Response response = lookupCoordinatorResource.getSpecificLookup(LOOKUP_TIER, LOOKUP_NAME);
Assert.assertEquals(500, response.getStatus());
Assert.assertEquals(ImmutableMap.of("error", errMsg), response.getEntity());
EasyMock.verify(lookupCoordinatorManager);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testKillPendingSegments()
{
expectAuthorizationTokenCheck();
EasyMock.expect(taskMaster.isLeader()).andReturn(true);
EasyMock
.expect(
indexerMetadataStorageAdapter.deletePendingSegments(
EasyMock.eq("allow"),
EasyMock.anyObject(Interval.class)
)
)
.andReturn(2);
EasyMock.replay(taskRunner, taskMaster, taskStorageQueryAdapter, indexerMetadataStorageAdapter, req);
final Map<String, Integer> response = (Map<String, Integer>) overlordResource
.killPendingSegments("allow", new Interval(DateTimes.MIN, DateTimes.nowUtc()).toString(), req)
.getEntity();
Assert.assertEquals(2, response.get("numDeleted").intValue());
}
代码示例来源:origin: confluentinc/ksql
@Test
public void shouldAdjustCursorWhenInTrimmedResult() {
expect(delegate.parse(anyString(), eq(2), anyObject()))
.andReturn(parsedLine);
replay(delegate);
parser.parse(" line ", 4, UNSPECIFIED);
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testWriteWithFlush() throws IOException {
expect(storageRpcMock.open(BLOB_INFO.toPb(), EMPTY_RPC_OPTIONS)).andReturn(UPLOAD_ID);
Capture<byte[]> capturedBuffer = Capture.newInstance();
storageRpcMock.write(
eq(UPLOAD_ID), capture(capturedBuffer), eq(0), eq(0L), eq(CUSTOM_CHUNK_SIZE), eq(false));
replay(storageRpcMock);
writer = new BlobWriteChannel(options, BLOB_INFO, EMPTY_RPC_OPTIONS);
writer.setChunkSize(CUSTOM_CHUNK_SIZE);
ByteBuffer buffer = randomBuffer(CUSTOM_CHUNK_SIZE);
assertEquals(CUSTOM_CHUNK_SIZE, writer.write(buffer));
assertArrayEquals(buffer.array(), capturedBuffer.getValue());
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testWriteClosed() throws IOException {
expect(storageRpcMock.open(BLOB_INFO.toPb(), EMPTY_RPC_OPTIONS)).andReturn(UPLOAD_ID);
Capture<byte[]> capturedBuffer = Capture.newInstance();
storageRpcMock.write(eq(UPLOAD_ID), capture(capturedBuffer), eq(0), eq(0L), eq(0), eq(true));
replay(storageRpcMock);
writer = new BlobWriteChannel(options, BLOB_INFO, EMPTY_RPC_OPTIONS);
writer.close();
try {
writer.write(ByteBuffer.allocate(MIN_CHUNK_SIZE));
fail("Expected BlobWriteChannel write to throw IOException");
} catch (IOException ex) {
// expected
}
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testUpdateLookupAdds()
{
final LookupCoordinatorManager manager = new LookupCoordinatorManager(
client,
druidNodeDiscoveryProvider,
mapper,
configManager,
lookupCoordinatorManagerConfig
)
{
@Override
public Map<String, Map<String, LookupExtractorFactoryMapContainer>> getKnownLookups()
{
return EMPTY_TIERED_LOOKUP;
}
};
manager.start();
final AuditInfo auditInfo = new AuditInfo("author", "comment", "localhost");
EasyMock.reset(configManager);
EasyMock.expect(configManager.set(
EasyMock.eq(LookupCoordinatorManager.LOOKUP_CONFIG_KEY),
EasyMock.eq(TIERED_LOOKUP_MAP_V0),
EasyMock.eq(auditInfo)
)).andReturn(SetResult.ok()).once();
EasyMock.replay(configManager);
manager.updateLookup(LOOKUP_TIER, SINGLE_LOOKUP_NAME, SINGLE_LOOKUP_SPEC_V0, auditInfo);
EasyMock.verify(configManager);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testUpdateLookupsUpdates()
{
final LookupCoordinatorManager manager = new LookupCoordinatorManager(
client,
druidNodeDiscoveryProvider,
mapper,
configManager,
lookupCoordinatorManagerConfig
)
{
@Override
public Map<String, Map<String, LookupExtractorFactoryMapContainer>> getKnownLookups()
{
return TIERED_LOOKUP_MAP_V0;
}
};
manager.start();
final AuditInfo auditInfo = new AuditInfo("author", "comment", "localhost");
EasyMock.reset(configManager);
EasyMock.expect(configManager.set(
EasyMock.eq(LookupCoordinatorManager.LOOKUP_CONFIG_KEY),
EasyMock.eq(TIERED_LOOKUP_MAP_V1),
EasyMock.eq(auditInfo)
)).andReturn(SetResult.ok()).once();
EasyMock.replay(configManager);
manager.updateLookups(TIERED_LOOKUP_MAP_V1, auditInfo);
EasyMock.verify(configManager);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testUpdateLookupsInitialization()
{
final LookupCoordinatorManager manager = new LookupCoordinatorManager(
client,
druidNodeDiscoveryProvider,
mapper,
configManager,
lookupCoordinatorManagerConfig
)
{
@Override
public Map<String, Map<String, LookupExtractorFactoryMapContainer>> getKnownLookups()
{
return null;
}
};
manager.start();
final AuditInfo auditInfo = new AuditInfo("author", "comment", "localhost");
EasyMock.reset(configManager);
EasyMock.expect(
configManager.set(
EasyMock.eq(LookupCoordinatorManager.LOOKUP_CONFIG_KEY),
EasyMock.eq(EMPTY_TIERED_LOOKUP),
EasyMock.eq(auditInfo)
)).andReturn(SetResult.ok()).once();
EasyMock.replay(configManager);
manager.updateLookups(EMPTY_TIERED_LOOKUP, auditInfo);
EasyMock.verify(configManager);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testGetDatasourceRuleHistoryWithCount()
DateTimes.of("2013-01-01T00:00:00Z")
);
EasyMock.expect(auditManager.fetchAuditHistory(EasyMock.eq("datasource1"), EasyMock.eq("rules"), EasyMock.eq(2)))
.andReturn(ImmutableList.of(entry1, entry2))
.once();
EasyMock.replay(auditManager);
Assert.assertEquals(2, rulesHistory.size());
Assert.assertEquals(entry1, rulesHistory.get(0));
Assert.assertEquals(entry2, rulesHistory.get(1));
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testWriterWithKmsKeyName() throws Exception {
initializeExpectedBlob(2);
BlobWriteChannel channel = createMock(BlobWriteChannel.class);
expect(storage.getOptions()).andReturn(mockOptions);
expect(storage.writer(eq(expectedBlob), eq(BlobWriteOption.kmsKeyName(KMS_KEY_NAME))))
.andReturn(channel);
replay(storage);
initializeBlob();
assertSame(channel, blob.writer(BlobWriteOption.kmsKeyName(KMS_KEY_NAME)));
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testWriter() throws Exception {
initializeExpectedBlob(2);
BlobWriteChannel channel = createMock(BlobWriteChannel.class);
expect(storage.getOptions()).andReturn(mockOptions);
expect(storage.writer(eq(expectedBlob))).andReturn(channel);
replay(storage);
initializeBlob();
assertSame(channel, blob.writer());
}
内容来源于网络,如有侵权,请联系作者删除!