org.easymock.Capture.getValues()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(123)

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

Capture.getValues介绍

[英]Return all captured values. It returns the actual list so you can modify it's content if needed
[中]

代码示例

代码示例来源:origin: thinkaurelius/titan

  1. @After
  2. public void verifyMocks() {
  3. ctrl.verify();
  4. ctrl.reset();
  5. // Check capture created in the @Before method
  6. assertTrue(txConfigCapture.hasCaptured());
  7. List<BaseTransactionConfig> txCfgs = txConfigCapture.getValues();
  8. assertEquals(2, txCfgs.size());
  9. // First backing store transaction should use default tx config
  10. assertEquals("default", txCfgs.get(0).getCustomOption(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID));
  11. // Second backing store transaction should use global strong consistency config
  12. assertEquals("global", txCfgs.get(1).getCustomOption(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID));
  13. // The order in which these transactions are opened isn't really significant;
  14. // testing them in order is kind of overspecifying the impl's behavior.
  15. // Could probably relax the ordering selectively here with some thought, but
  16. // I want to keep order checking on in general for the EasyMock control.
  17. }

代码示例来源:origin: JanusGraph/janusgraph

  1. @After
  2. public void verifyMocks() {
  3. ctrl.verify();
  4. ctrl.reset();
  5. // Check capture created in the @Before method
  6. assertTrue(txConfigCapture.hasCaptured());
  7. List<BaseTransactionConfig> transactionConfigurations = txConfigCapture.getValues();
  8. assertEquals(2, transactionConfigurations.size());
  9. // First backing store transaction should use default tx config
  10. assertEquals("default", transactionConfigurations.get(0).getCustomOption(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID));
  11. // Second backing store transaction should use global strong consistency config
  12. assertEquals("global", transactionConfigurations.get(1).getCustomOption(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID));
  13. // The order in which these transactions are opened isn't really significant;
  14. // testing them in order is kind of over-specifying the implementation's behavior.
  15. // Could probably relax the ordering selectively here with some thought, but
  16. // I want to keep order checking on in general for the EasyMock control.
  17. }

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

  1. @Test
  2. public void testStopSendingAfterClose() {
  3. replayOnSubscribe();
  4. EasyMock.expect(session.getAsyncRemote()).andReturn(async).anyTimes();
  5. final Capture<String> json = EasyMock.newCapture(CaptureType.ALL);
  6. async.sendText(EasyMock.capture(json), EasyMock.anyObject());
  7. subscription.request(1);
  8. subscription.cancel();
  9. EasyMock.replay(subscription, session, async);
  10. subscriber.onNext(ImmutableList.of(ImmutableMap.of("a", 1)));
  11. subscriber.close();
  12. subscriber.onNext(ImmutableList.of(ImmutableMap.of("b", 2), ImmutableMap.of("c", 3)));
  13. assertEquals(ImmutableList.of("{\"a\":1}"), json.getValues());
  14. EasyMock.verify(subscription, session, async);
  15. }

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

  1. Assert.assertTrue(eventCapture.hasCaptured());
  2. final List<Map<String, Object>> events = Lists.transform(
  3. eventCapture.getValues(),
  4. new Function<ServiceEventBuilder<ServiceMetricEvent>, Map<String, Object>>()

代码示例来源:origin: googleapis/google-cloud-java

  1. @Test
  2. public void testSaveAndRestore() throws IOException {
  3. expect(storageRpcMock.open(BLOB_INFO.toPb(), EMPTY_RPC_OPTIONS)).andReturn(UPLOAD_ID);
  4. Capture<byte[]> capturedBuffer = Capture.newInstance(CaptureType.ALL);
  5. Capture<Long> capturedPosition = Capture.newInstance(CaptureType.ALL);
  6. storageRpcMock.write(
  7. eq(UPLOAD_ID),
  8. capture(capturedBuffer),
  9. eq(0),
  10. captureLong(capturedPosition),
  11. eq(DEFAULT_CHUNK_SIZE),
  12. eq(false));
  13. expectLastCall().times(2);
  14. replay(storageRpcMock);
  15. ByteBuffer buffer1 = randomBuffer(DEFAULT_CHUNK_SIZE);
  16. ByteBuffer buffer2 = randomBuffer(DEFAULT_CHUNK_SIZE);
  17. writer = new BlobWriteChannel(options, BLOB_INFO, EMPTY_RPC_OPTIONS);
  18. assertEquals(DEFAULT_CHUNK_SIZE, writer.write(buffer1));
  19. assertArrayEquals(buffer1.array(), capturedBuffer.getValues().get(0));
  20. assertEquals(new Long(0L), capturedPosition.getValues().get(0));
  21. RestorableState<WriteChannel> writerState = writer.capture();
  22. WriteChannel restoredWriter = writerState.restore();
  23. assertEquals(DEFAULT_CHUNK_SIZE, restoredWriter.write(buffer2));
  24. assertArrayEquals(buffer2.array(), capturedBuffer.getValues().get(1));
  25. assertEquals(new Long(DEFAULT_CHUNK_SIZE), capturedPosition.getValues().get(1));
  26. }

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

  1. DruidNode param = captured.getValues().get(0);
  2. Assert.assertEquals(TEST_SERVICE_NAME, param.getServiceName());
  3. Assert.assertEquals(TEST_HOST, param.getHost());
  4. verifyAll();
  5. param = captured.getValues().get(0);
  6. Assert.assertEquals(TEST_SERVICE_NAME, param.getServiceName());
  7. Assert.assertEquals(TEST_HOST, param.getHost());

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

  1. @Test
  2. public void testSanity() throws Exception {
  3. replayOnSubscribe();
  4. EasyMock.expect(session.getAsyncRemote()).andReturn(async).anyTimes();
  5. final Capture<String> json = EasyMock.newCapture(CaptureType.ALL);
  6. async.sendText(EasyMock.capture(json), EasyMock.anyObject());
  7. EasyMock.expectLastCall().times(3);
  8. subscription.request(1);
  9. EasyMock.expectLastCall().once();
  10. session.close(EasyMock.anyObject());
  11. EasyMock.expectLastCall().once();
  12. subscription.cancel();
  13. EasyMock.replay(subscription, session, async);
  14. subscriber.onNext(ImmutableList.of(ImmutableMap.of("a", 1), ImmutableMap.of("b", 2), ImmutableMap.of("c", 3)));
  15. assertEquals(ImmutableList.of("{\"a\":1}","{\"b\":2}","{\"c\":3}"), json.getValues());
  16. subscriber.onComplete();
  17. subscriber.close();
  18. EasyMock.verify(subscription, session, async);
  19. }

代码示例来源:origin: googleapis/google-cloud-java

  1. writer = new TableDataWriteChannel(options, JOB_INFO.getJobId(), LOAD_CONFIGURATION);
  2. assertEquals(DEFAULT_CHUNK_SIZE, writer.write(buffer1));
  3. assertArrayEquals(buffer1.array(), capturedBuffer.getValues().get(0));
  4. assertEquals(new Long(0L), capturedPosition.getValues().get(0));
  5. assertNull(writer.getJob());
  6. RestorableState<WriteChannel> writerState = writer.capture();
  7. WriteChannel restoredWriter = writerState.restore();
  8. assertEquals(DEFAULT_CHUNK_SIZE, restoredWriter.write(buffer2));
  9. assertArrayEquals(buffer2.array(), capturedBuffer.getValues().get(1));
  10. assertEquals(new Long(DEFAULT_CHUNK_SIZE), capturedPosition.getValues().get(1));

代码示例来源:origin: org.easymock/com.springsource.org.easymock

  1. /**
  2. * Return captured value
  3. *
  4. * @throws AssertionError
  5. * if nothing was captured yet or if more than one value was
  6. * captured
  7. * @return The last captured value
  8. */
  9. public T getValue() {
  10. if (values.isEmpty()) {
  11. throw new AssertionError("Nothing captured yet");
  12. }
  13. if (values.size() > 1) {
  14. throw new AssertionError("More than one value captured: "
  15. + getValues());
  16. }
  17. return values.get(values.size() - 1);
  18. }

代码示例来源:origin: GeoWebCache/geowebcache

  1. /** Override because setValue with anyTimes() resets the list of values */
  2. @Override
  3. public void setValue(TileObject o) {
  4. super.getValues().add(o);
  5. }
  6. };

代码示例来源:origin: org.hawkular.titan/titan-test

  1. @After
  2. public void verifyMocks() {
  3. ctrl.verify();
  4. ctrl.reset();
  5. // Check capture created in the @Before method
  6. assertTrue(txConfigCapture.hasCaptured());
  7. List<BaseTransactionConfig> txCfgs = txConfigCapture.getValues();
  8. assertEquals(2, txCfgs.size());
  9. // First backing store transaction should use default tx config
  10. assertEquals("default", txCfgs.get(0).getCustomOption(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID));
  11. // Second backing store transaction should use global strong consistency config
  12. assertEquals("global", txCfgs.get(1).getCustomOption(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID));
  13. // The order in which these transactions are opened isn't really significant;
  14. // testing them in order is kind of overspecifying the impl's behavior.
  15. // Could probably relax the ordering selectively here with some thought, but
  16. // I want to keep order checking on in general for the EasyMock control.
  17. }

代码示例来源:origin: com.nesscomputing.components/ness-quartz

  1. @Test
  2. public void testSimple() throws Exception
  3. {
  4. AdHocQuartzJob.forClass(DummyJob.class).name("test-simple").submitConditional(scheduler, nessJobConfig);
  5. Assert.assertNotNull(jobDetailCapture.getValues());
  6. Assert.assertEquals(0, jobAddCapture.getValues().size());
  7. Assert.assertEquals(1, jobDetailCapture.getValues().size());
  8. Assert.assertNotNull(jobDetailCapture.getValue());
  9. Assert.assertEquals(DummyJob.class, jobDetailCapture.getValue().getJobClass());
  10. }

代码示例来源:origin: com.nesscomputing.components/ness-quartz

  1. @Test
  2. public void testExplicitSkipped() throws Exception
  3. {
  4. AdHocQuartzJob.forClass(DummyJob.class).name("testExplicitSkipped").conditional("ness.job.explicit-never.run.enabled").submitConditional(scheduler, nessJobConfig);
  5. Assert.assertNotNull(jobDetailCapture.getValues());
  6. Assert.assertEquals(0, jobDetailCapture.getValues().size());
  7. Assert.assertEquals(1, jobAddCapture.getValues().size());
  8. Assert.assertNotNull(jobAddCapture.getValue());
  9. Assert.assertEquals(DummyJob.class, jobAddCapture.getValue().getJobClass());
  10. }

代码示例来源:origin: com.nesscomputing.components/ness-quartz

  1. @Test
  2. public void testExplicitRunning() throws Exception
  3. {
  4. AdHocQuartzJob.forClass(DummyJob.class).name("testExplicitRunning").conditional("ness.job.explicit-running.enabled").submitConditional(scheduler, nessJobConfig);
  5. Assert.assertEquals(0, jobAddCapture.getValues().size());
  6. Assert.assertNotNull(jobDetailCapture.getValues());
  7. Assert.assertEquals(1, jobDetailCapture.getValues().size());
  8. Assert.assertNotNull(jobDetailCapture.getValue());
  9. Assert.assertEquals(DummyJob.class, jobDetailCapture.getValue().getJobClass());
  10. }

代码示例来源:origin: com.nesscomputing.components/ness-quartz

  1. @Test
  2. public void testSkipped() throws Exception
  3. {
  4. AdHocQuartzJob.forClass(DummyJob.class).name("testSkipped").conditional("never-run").submitConditional(scheduler, nessJobConfig);
  5. Assert.assertNotNull(jobDetailCapture.getValues());
  6. Assert.assertEquals(0, jobDetailCapture.getValues().size());
  7. Assert.assertEquals(1, jobAddCapture.getValues().size());
  8. Assert.assertNotNull(jobAddCapture.getValue());
  9. Assert.assertEquals(DummyJob.class, jobAddCapture.getValue().getJobClass());
  10. }

代码示例来源:origin: com.nesscomputing.components/ness-quartz

  1. @Test
  2. public void testRunningLong() throws Exception
  3. {
  4. AdHocQuartzJob.forClass(DummyJob.class).name("testRunningLong").conditional("running-long").submitConditional(scheduler, nessJobConfig);
  5. Assert.assertNotNull(jobDetailCapture.getValues());
  6. Assert.assertEquals(0, jobAddCapture.getValues().size());
  7. Assert.assertEquals(1, jobDetailCapture.getValues().size());
  8. Assert.assertNotNull(jobDetailCapture.getValue());
  9. Assert.assertEquals(DummyJob.class, jobDetailCapture.getValue().getJobClass());
  10. }

代码示例来源:origin: GeoWebCache/geowebcache

  1. Sets.newHashSet(config.getLayers()), is(Sets.newHashSet(layerCapture.getValues())));

代码示例来源:origin: GeoWebCache/geowebcache

  1. layer.seedTile(tile, tryCache);
  2. assertEquals(9, captured.getValues().size());
  3. verify(mockStorageBroker);

代码示例来源:origin: org.apache.mahout/mahout-mrlegacy

  1. assertEquals(mapNbTrees, capturedKeys.getValues().size());
  2. for (TreeID k : capturedKeys.getValues()) {
  3. assertEquals(partition, k.partition());
  4. assertEquals(treeIndex, k.treeId());

代码示例来源:origin: GeoWebCache/geowebcache

  1. layer.seedTile(tile, tryCache);
  2. assertEquals(1, captured.getValues().size());
  3. TileObject value = captured.getValue();
  4. assertNotNull(value);

相关文章