本文整理了Java中org.easymock.EasyMock.anyString()
方法的一些代码示例,展示了EasyMock.anyString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EasyMock.anyString()
方法的具体详情如下:
包路径:org.easymock.EasyMock
类名称:EasyMock
方法名:anyString
[英]Expect any string whatever its content is. Exactly the same as #anyObject() but prevents typing issues for the much used String type. Consider this method to be a syntactic sugar.
[中]期望任何字符串,无论其内容是什么。与#anyObject()完全相同,但防止了常用字符串类型的键入问题。认为这个方法是句法糖。
代码示例来源:origin: confluentinc/ksql
private void givenPredicateWillReturnTrue() {
EasyMock.reset(cliLinePredicate);
EasyMock.expect(cliLinePredicate.test(anyString())).andReturn(true);
EasyMock.replay(cliLinePredicate);
}
}
代码示例来源:origin: confluentinc/ksql
@Before
public void setUp() {
EasyMock.expect(cliLinePredicate.test(anyString())).andReturn(false);
EasyMock.replay(cliLinePredicate);
parser = new KsqlLineParser(delegate, cliLinePredicate);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testShutdownAllTasksForNonExistingDataSource()
{
final TaskQueue taskQueue = EasyMock.createMock(TaskQueue.class);
EasyMock.expect(taskMaster.isLeader()).andReturn(true).anyTimes();
EasyMock.expect(taskMaster.getTaskQueue()).andReturn(Optional.of(taskQueue)).anyTimes();
EasyMock.expect(taskStorageQueryAdapter.getActiveTaskInfo(EasyMock.anyString())).andReturn(Collections.emptyList());
EasyMock.replay(taskRunner, taskMaster, taskStorageQueryAdapter, indexerMetadataStorageAdapter, req);
final Response response = overlordResource.shutdownTasksForDataSource("notExisting");
Assert.assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus());
}
代码示例来源:origin: apache/incubator-druid
private ImmutableWorkerInfo createMockWorker(int currCapacityUsed, boolean canRunTask, boolean isValidVersion)
{
ImmutableWorkerInfo worker = EasyMock.createMock(ImmutableWorkerInfo.class);
EasyMock.expect(worker.canRunTask(EasyMock.anyObject(Task.class))).andReturn(canRunTask).anyTimes();
EasyMock.expect(worker.getCurrCapacityUsed()).andReturn(currCapacityUsed).anyTimes();
EasyMock.expect(worker.isValidVersion(EasyMock.anyString())).andReturn(isValidVersion).anyTimes();
EasyMock.replay(worker);
return worker;
}
代码示例来源:origin: apache/incubator-druid
@Before
public void setUp()
{
EasyMock.expect(lookupReferencesManager.get("lookupId")).andReturn(
new LookupExtractorFactoryContainer(
"v0",
lookupExtractorFactory
)
).anyTimes();
EasyMock.expect(lookupReferencesManager.get(EasyMock.anyString())).andReturn(null).anyTimes();
EasyMock.replay(lookupReferencesManager);
}
@Test
代码示例来源:origin: confluentinc/ksql
@Test
public void shouldPrintServerAddressWhenEmptyStringArg() throws Exception {
expect(restClient.makeRootRequest()).andReturn(RestResponse.successful(SERVER_INFO));
expect(restClient.getServerAddress()).andReturn(new URI(INITIAL_SERVER_ADDRESS));
restClient.setServerAddress(anyString());
expectLastCall().andThrow(new AssertionError("should not set address"));
replay(restClient);
command.execute(ImmutableList.of(), terminal);
assertThat(out.toString(), equalTo(INITIAL_SERVER_ADDRESS + "\n"));
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testServiceAnnouncementDELETEExceptionInHandler()
{
final ListenerHandler handler = EasyMock.createStrictMock(ListenerHandler.class);
EasyMock.expect(handler.handleDELETE(EasyMock.anyString())).andThrow(new RuntimeException("test"));
final ListenerResource resource = new ListenerResource(
mapper,
mapper,
handler
)
{
};
EasyMock.replay(handler);
Assert.assertEquals(
Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
resource.serviceAnnouncementDELETE("id").getStatus()
);
EasyMock.verify(handler);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testServiceAnnouncementGETExceptionInHandler()
{
final ListenerHandler handler = EasyMock.createStrictMock(ListenerHandler.class);
EasyMock.expect(handler.handleGET(EasyMock.anyString())).andThrow(new RuntimeException("test"));
final ListenerResource resource = new ListenerResource(
mapper,
mapper,
handler
)
{
};
EasyMock.replay(handler);
Assert.assertEquals(
Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
resource.serviceAnnouncementGET("id").getStatus()
);
EasyMock.verify(handler);
}
代码示例来源:origin: confluentinc/ksql
@Before
public void setUp() {
propsWithMockParser = new LocalProperties(INITIAL, parser);
expect(parser.parse(anyString(), anyObject()))
.andReturn("parsed-val");
replay(parser);
realProps = new LocalProperties(ImmutableMap.of());
}
代码示例来源:origin: apache/incubator-druid
EasyMock.expect(tsqa.getTask(EasyMock.anyString())).andReturn(Optional.of(noopTask)).anyTimes();
EasyMock.replay(tsqa);
mockedOnceTsqa = true;
EasyMock.expect(supervisorManager.getSupervisorSpec(EasyMock.anyString()))
.andReturn(Optional.of(supervisorSpec))
.anyTimes();
代码示例来源:origin: confluentinc/ksql
@Test
public void shouldAdjustCursorWhenInTrimmedResult() {
expect(delegate.parse(anyString(), eq(2), anyObject()))
.andReturn(parsedLine);
replay(delegate);
parser.parse(" line ", 4, UNSPECIFIED);
}
代码示例来源:origin: apache/incubator-druid
@Test
public void testServiceAnnouncementPOSTExceptionInHandler()
{
final ListenerHandler handler = EasyMock.createStrictMock(ListenerHandler.class);
EasyMock.expect(handler.handlePOST(
EasyMock.anyObject(),
EasyMock.anyObject(),
EasyMock.anyString()
)).andThrow(new RuntimeException("test"));
final ListenerResource resource = new ListenerResource(
mapper,
mapper,
handler
)
{
};
EasyMock.replay(handler);
Assert.assertEquals(
Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
resource.serviceAnnouncementPOST("id", EMPTY_JSON_MAP.get(), req).getStatus()
);
EasyMock.verify(req, handler);
}
代码示例来源:origin: confluentinc/ksql
@Test
public void shouldAdjustCursorIfInRightWhiteSpace() {
expect(delegate.parse(anyString(), eq(4), anyObject()))
.andReturn(parsedLine).anyTimes();
replay(delegate);
parser.parse(" line ", 6, UNSPECIFIED);
parser.parse(" line ", 7, UNSPECIFIED);
parser.parse(" line ", 8, UNSPECIFIED);
}
代码示例来源:origin: confluentinc/ksql
@Test
public void shouldAdjustCursorIfInLeftWhiteSpace() {
expect(delegate.parse(anyString(), eq(0), anyObject()))
.andReturn(parsedLine).anyTimes();
replay(delegate);
parser.parse(" line ", 0, UNSPECIFIED);
parser.parse(" line ", 1, UNSPECIFIED);
parser.parse(" line ", 2, UNSPECIFIED);
}
代码示例来源:origin: apache/incubator-druid
EasyMock.expect(
segmentManager.getUnusedSegmentIntervals(
EasyMock.anyString(),
EasyMock.anyObject(Interval.class),
EasyMock.anyInt()
代码示例来源:origin: confluentinc/ksql
@Test
public void shouldMatchAvroFormatter() throws Exception {
// Given:
final Schema schema = parseAvroSchema(
"{\n" +
" \"fields\": [\n" +
" { \"name\": \"str1\", \"type\": \"string\" }\n" +
" ],\n" +
" \"name\": \"myrecord\",\n" +
" \"type\": \"record\"\n" +
"}");
final GenericData.Record avroRecord = new GenericData.Record(schema);
avroRecord.put("str1", "My first string");
expect(schemaRegistryClient.register(anyString(), anyObject())).andReturn(1);
expect(schemaRegistryClient.getById(anyInt())).andReturn(schema).times(2);
replay(schemaRegistryClient);
final byte[] avroData = serializeAvroRecord(avroRecord);
// When:
final Result result = getFormatter(avroData);
// Then:
assertThat(result.format, is(Format.AVRO));
assertThat(result.formatted, endsWith(", key, {\"str1\": \"My first string\"}\n"));
}
代码示例来源:origin: confluentinc/ksql
@Test
public void shouldReturn400OnBadStatement() throws Exception {
// Given:
reset(mockStatementParser);
expect(mockStatementParser.parseSingleStatement(anyString()))
.andThrow(new IllegalArgumentException("some error message"));
replay(mockStatementParser);
// Expect
expectedException.expect(KsqlRestException.class);
expectedException.expect(exceptionStatusCode(is(Code.BAD_REQUEST)));
expectedException.expect(exceptionKsqlErrorMessage(errorMessage(is("some error message"))));
expectedException.expect(
exceptionKsqlErrorMessage(errorCode(is(Errors.ERROR_CODE_BAD_STATEMENT))));
// When:
testResource.streamQuery(new KsqlRequest("query", Collections.emptyMap(), null));
}
代码示例来源:origin: apache/incubator-druid
EasyMock
.expect(
indexerMetadataStorageCoordinator.deletePendingSegments(EasyMock.anyString(), EasyMock.eq(deleteInterval))
代码示例来源:origin: apache/incubator-druid
@Test
public void testDeletePendingSegments()
{
final List<TaskInfo<Task, TaskStatus>> taskInfos = ImmutableList.of(
new TaskInfo<>(
"id1",
DateTimes.of("2017-12-01"),
TaskStatus.running("id1"),
"dataSource",
NoopTask.create("id1", 0)
),
new TaskInfo<>(
"id1",
DateTimes.of("2017-12-02"),
TaskStatus.running("id2"),
"dataSource",
NoopTask.create("id2", 0)
)
);
EasyMock.expect(taskStorageQueryAdapter.getActiveTaskInfo("dataSource")).andReturn(taskInfos);
final Interval deleteInterval = Intervals.of("2017-01-01/2017-12-01");
EasyMock
.expect(
indexerMetadataStorageCoordinator.deletePendingSegments(EasyMock.anyString(), EasyMock.eq(deleteInterval))
)
.andReturn(10);
EasyMock.replay(taskStorageQueryAdapter, indexerMetadataStorageCoordinator);
Assert.assertEquals(10, indexerMetadataStorageAdapter.deletePendingSegments("dataSource", deleteInterval));
}
代码示例来源:origin: apache/incubator-druid
.expect(
handoffNotifierFactory.createSegmentHandoffNotifier(EasyMock
.anyString())).andReturn(handoffNotifier).anyTimes();
EasyMock
.expect(
内容来源于网络,如有侵权,请联系作者删除!