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

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

本文整理了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

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

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

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

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

  1. EasyMock.anyString(),
  2. EasyMock.anyObject(Interval.class),
  3. EasyMock.anyInt()

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

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

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

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

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

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

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

  1. @Test
  2. public void shouldMatchAvroFormatter() throws Exception {
  3. // Given:
  4. final Schema schema = parseAvroSchema(
  5. "{\n" +
  6. " \"fields\": [\n" +
  7. " { \"name\": \"str1\", \"type\": \"string\" }\n" +
  8. " ],\n" +
  9. " \"name\": \"myrecord\",\n" +
  10. " \"type\": \"record\"\n" +
  11. "}");
  12. final GenericData.Record avroRecord = new GenericData.Record(schema);
  13. avroRecord.put("str1", "My first string");
  14. expect(schemaRegistryClient.register(anyString(), anyObject())).andReturn(1);
  15. expect(schemaRegistryClient.getById(anyInt())).andReturn(schema).times(2);
  16. replay(schemaRegistryClient);
  17. final byte[] avroData = serializeAvroRecord(avroRecord);
  18. // When:
  19. final Result result = getFormatter(avroData);
  20. // Then:
  21. assertThat(result.format, is(Format.AVRO));
  22. assertThat(result.formatted, endsWith(", key, {\"str1\": \"My first string\"}\n"));
  23. }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. private FetchResponse mockFetchResponse(List<MyMessage> myMessages) {
  2. FetchResponse fetchResponse = EasyMock.createMock(FetchResponse.class);
  3. EasyMock.expect(fetchResponse.hasError()).andReturn(false).times(1);
  4. List<Message> messages = new ArrayList<Message>();
  5. for (MyMessage myMessage:myMessages) {
  6. String payload = gson.toJson(myMessage);
  7. String msgKey = Integer.toString(PARTITION_1_ID);
  8. Message message = new Message(payload.getBytes(), msgKey.getBytes());
  9. messages.add(message);
  10. }
  11. ByteBufferMessageSet messageSet = new ByteBufferMessageSet(messages);
  12. EasyMock.expect(fetchResponse.messageSet(EasyMock.anyString(), EasyMock.anyInt())).andReturn(messageSet).times(1);
  13. mocks.add(fetchResponse);
  14. return fetchResponse;
  15. }

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

  1. public void testActionStatusError() {
  2. ActionApi actionApi = EasyMock.createMock(ActionApi.class);
  3. DigitalOcean2Api api = EasyMock.createMock(DigitalOcean2Api.class);
  4. expect(actionApi.get(anyInt())).andReturn(action(Action.Status.ERRORED));
  5. expect(api.actionApi()).andReturn(actionApi);
  6. replay(actionApi, api);
  7. ActionDonePredicate predicate = new ActionDonePredicate(api);
  8. try {
  9. predicate.apply(1);
  10. fail("Method should have thrown an IllegalStateException");
  11. } catch (IllegalStateException ex) {
  12. assertEquals(ex.getMessage(), "Resource is in invalid status: ERRORED");
  13. }
  14. }

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

  1. /**
  2. * @deprecated since 5.6.
  3. */
  4. @Deprecated
  5. public static void mockObservation(MockHierarchyManager hm) throws RepositoryException, UnsupportedRepositoryOperationException {
  6. // fake observation
  7. Workspace ws = createMock(Workspace.class);
  8. ObservationManager om = createMock(ObservationManager.class);
  9. om.addEventListener(isA(EventListener.class), anyInt(), isA(String.class), anyBoolean(), (String[]) anyObject(), (String[]) anyObject(), anyBoolean());
  10. expect(ws.getObservationManager()).andStubReturn(om);
  11. hm.setWorkspace(ws);
  12. replay(ws, om);
  13. }

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

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

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

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

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

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

相关文章