org.easymock.EasyMock.anyInt()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(79)

本文整理了Java中org.easymock.EasyMock.anyInt()方法的一些代码示例,展示了EasyMock.anyInt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EasyMock.anyInt()方法的具体详情如下:
包路径:org.easymock.EasyMock
类名称:EasyMock
方法名:anyInt

EasyMock.anyInt介绍

[英]Expects any int argument. For details, see the EasyMock documentation.
[中]需要任何int参数。有关详细信息,请参阅EasyMock文档。

代码示例

代码示例来源:origin: confluentinc/ksql

private void givenDelegateWillReturn(final String line) {
 EasyMock.expect(parsedLine.line()).andReturn(line).anyTimes();
 EasyMock.expect(delegate.parse(anyObject(), anyInt(), anyObject())).andReturn(parsedLine);
 EasyMock.replay(delegate, parsedLine);
}

代码示例来源:origin: apache/incubator-druid

EasyMock.expect(runner.markWorkersLazy(EasyMock.anyObject(), EasyMock.anyInt()))
    .andReturn(Collections.emptyList());
EasyMock.replay(runner);

代码示例来源:origin: apache/incubator-druid

EasyMock.anyString(),
EasyMock.anyObject(Interval.class),
EasyMock.anyInt()

代码示例来源:origin: apache/incubator-druid

EasyMock.expect(runner.markWorkersLazy(EasyMock.anyObject(), EasyMock.anyInt()))
    .andReturn(Collections.emptyList());
EasyMock.replay(runner);

代码示例来源:origin: apache/incubator-druid

EasyMock.expect(runner.markWorkersLazy(EasyMock.anyObject(), EasyMock.anyInt()))
    .andReturn(Collections.emptyList());
EasyMock.replay(runner);

代码示例来源:origin: apache/incubator-druid

EasyMock.expect(runner.markWorkersLazy(EasyMock.anyObject(), EasyMock.anyInt()))
    .andReturn(Collections.emptyList());
EasyMock.replay(runner);

代码示例来源: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: apache/incubator-druid

EasyMock.expect(runner.markWorkersLazy(EasyMock.anyObject(), EasyMock.anyInt()))
    .andReturn(Collections.singletonList(new TestZkWorker(testTask).getWorker()));
EasyMock.expect(runner.getLazyWorkers()).andReturn(new ArrayList<>());

代码示例来源:origin: apache/incubator-druid

EasyMock.expect(runner.markWorkersLazy(EasyMock.anyObject(), EasyMock.anyInt()))
    .andReturn(Collections.singletonList(new TestZkWorker(testTask).getWorker()));
EasyMock.expect(runner.getLazyWorkers()).andReturn(new ArrayList<>());

代码示例来源:origin: apache/incubator-druid

EasyMock.expect(runner.markWorkersLazy(EasyMock.anyObject(), EasyMock.anyInt()))
    .andReturn(Collections.singletonList(new TestZkWorker(testTask).toImmutable().getWorker()));
EasyMock.replay(runner);

代码示例来源:origin: apache/incubator-druid

EasyMock.expect(runner.markWorkersLazy(EasyMock.anyObject(), EasyMock.anyInt()))
    .andReturn(Collections.singletonList(new TestZkWorker(testTask).getWorker()));
EasyMock.replay(runner);

代码示例来源:origin: linkedin/camus

private OffsetResponse mockOffsetResponse(List<MyMessage> myMessages) {
 OffsetResponse offsetResponse = EasyMock.createMock(OffsetResponse.class);
 mocks.add(offsetResponse);
 // The first call is getLatestOffset, we set the value to 1
 EasyMock.expect(offsetResponse.offsets(EasyMock.anyString(), EasyMock.anyInt())).andReturn(new long[]{myMessages.size()}).times(1);
 // The second call is getEarliestOffset, we set the value to 0
 EasyMock.expect(offsetResponse.offsets(EasyMock.anyString(), EasyMock.anyInt())).andReturn(new long[]{0}).times(1);
 EasyMock.expect(offsetResponse.hasError()).andReturn(false).times(2);
 return offsetResponse;
}

代码示例来源:origin: linkedin/camus

private OffsetResponse mockOffsetResponseWithError(List<MyMessage> myMessages) {
 OffsetResponse offsetResponse = EasyMock.createMock(OffsetResponse.class);
 mocks.add(offsetResponse);
 EasyMock.expect(offsetResponse.offsets(EasyMock.anyString(), EasyMock.anyInt())).andReturn(new long[]{myMessages.size()}).times(1);
 EasyMock.expect(offsetResponse.offsets(EasyMock.anyString(), EasyMock.anyInt())).andReturn(new long[]{0}).times(1);
 EasyMock.expect(offsetResponse.hasError()).andReturn(true).times(3);
 return offsetResponse;
}

代码示例来源:origin: linkedin/camus

private OffsetResponse mockOffsetResponseThirdTrySucceed(List<MyMessage> myMessages) {
 OffsetResponse offsetResponse = EasyMock.createMock(OffsetResponse.class);
 mocks.add(offsetResponse);
 EasyMock.expect(offsetResponse.offsets(EasyMock.anyString(), EasyMock.anyInt())).andReturn(new long[]{myMessages.size()}).times(1);
 EasyMock.expect(offsetResponse.offsets(EasyMock.anyString(), EasyMock.anyInt())).andReturn(new long[]{0}).times(1);
 EasyMock.expect(offsetResponse.hasError()).andReturn(true).times(2);
 EasyMock.expect(offsetResponse.hasError()).andReturn(false).times(2);
 return offsetResponse;
}

代码示例来源:origin: linkedin/camus

private FetchResponse mockFetchResponse(List<MyMessage> myMessages) {
 FetchResponse fetchResponse = EasyMock.createMock(FetchResponse.class);
 EasyMock.expect(fetchResponse.hasError()).andReturn(false).times(1);
 List<Message> messages = new ArrayList<Message>();
 for (MyMessage myMessage:myMessages) {
  String payload = gson.toJson(myMessage);
  String msgKey = Integer.toString(PARTITION_1_ID);
  Message message = new Message(payload.getBytes(), msgKey.getBytes());
  messages.add(message);
 }
 ByteBufferMessageSet messageSet = new ByteBufferMessageSet(messages);
 EasyMock.expect(fetchResponse.messageSet(EasyMock.anyString(), EasyMock.anyInt())).andReturn(messageSet).times(1);
 mocks.add(fetchResponse);
 return fetchResponse;
}

代码示例来源:origin: apache/jclouds

public void testActionStatusError() {
 ActionApi actionApi = EasyMock.createMock(ActionApi.class);
 DigitalOcean2Api api = EasyMock.createMock(DigitalOcean2Api.class);
 expect(actionApi.get(anyInt())).andReturn(action(Action.Status.ERRORED));
 expect(api.actionApi()).andReturn(actionApi);
 replay(actionApi, api);
 ActionDonePredicate predicate = new ActionDonePredicate(api);
 try {
   predicate.apply(1);
   fail("Method should have thrown an IllegalStateException");
 } catch (IllegalStateException ex) {
   assertEquals(ex.getMessage(), "Resource is in invalid status: ERRORED");
 }
}

代码示例来源:origin: info.magnolia/magnolia-core

/**
 * @deprecated since 5.6.
 */
@Deprecated
public static void mockObservation(MockHierarchyManager hm) throws RepositoryException, UnsupportedRepositoryOperationException {
  // fake observation
  Workspace ws = createMock(Workspace.class);
  ObservationManager om = createMock(ObservationManager.class);
  om.addEventListener(isA(EventListener.class), anyInt(), isA(String.class), anyBoolean(), (String[]) anyObject(), (String[]) anyObject(), anyBoolean());
  expect(ws.getObservationManager()).andStubReturn(om);
  hm.setWorkspace(ws);
  replay(ws, om);
}

代码示例来源:origin: org.apache.shindig/shindig-gadgets

@Test(expected = ProcessingException.class)
public void testGetProxyDataFail() throws Exception {
 List<String> fields = ImmutableList.of("proxycontent.*");
 Uri resUri = Uri.parse("server.com/gadgets/proxy?url=" + RESOURCE);
 GadgetsHandlerApi.ProxyRequest request = createProxyRequest(RESOURCE, CONTAINER, fields);
 Capture<List<ProxyUri>> uriCapture = new Capture<List<ProxyUri>>();
 expect(proxyUriManager.make(capture(uriCapture), EasyMock.anyInt())).andReturn(
     ImmutableList.of(resUri));
 new HttpResponse("response");
 expect(proxyHandler.fetch(EasyMock.isA(ProxyUri.class))).andThrow(
     new GadgetException(Code.FAILED_TO_RETRIEVE_CONTENT));
 replay();
 gadgetHandler.getProxy(request);
}

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test(expected = ProcessingException.class)
public void testGetProxyDataFail() throws Exception {
 List<String> fields = ImmutableList.of("proxycontent.*");
 Uri resUri = Uri.parse("server.com/gadgets/proxy?url=" + RESOURCE);
 GadgetsHandlerApi.ProxyRequest request = createProxyRequest(RESOURCE, CONTAINER, fields);
 Capture<List<ProxyUri>> uriCapture = new Capture<List<ProxyUri>>();
 expect(proxyUriManager.make(capture(uriCapture), EasyMock.anyInt())).andReturn(
     ImmutableList.of(resUri));
 new HttpResponse("response");
 expect(proxyHandler.fetch(EasyMock.isA(ProxyUri.class))).andThrow(
     new GadgetException(Code.FAILED_TO_RETRIEVE_CONTENT));
 replay();
 gadgetHandler.getProxy(request);
}

代码示例来源:origin: org.apache.shindig/shindig-gadgets

@Test
public void testGetProxySimple() throws Exception {
 List<String> fields = ImmutableList.of("proxyurl");
 Uri resUri = Uri.parse("server.com/gadgets/proxy?url=" + RESOURCE);
 GadgetsHandlerApi.ProxyRequest request = createProxyRequest(RESOURCE, CONTAINER, fields);
 Capture<List<ProxyUri>> uriCapture = new Capture<List<ProxyUri>>();
 expect(proxyUriManager.make(capture(uriCapture), EasyMock.anyInt())).andReturn(
     ImmutableList.of(resUri));
 replay();
 GadgetsHandlerApi.ProxyResponse response = gadgetHandler.getProxy(request);
 assertEquals(1, uriCapture.getValue().size());
 ProxyUri pUri = uriCapture.getValue().get(0);
 assertEquals(CONTAINER, pUri.getContainer());
 assertEquals(resUri, response.getProxyUrl());
 assertNull(response.getProxyContent());
 assertEquals(timeSource.currentTimeMillis() + HttpUtil.getDefaultTtl() * 1000, response
     .getExpireTimeMs().longValue());
 verify();
}

相关文章