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

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

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

EasyMock.verify介绍

[英]Verifies the given mock object (more exactly: the control of the mock object).
[中]验证给定的模拟对象(更确切地说:模拟对象的控件)。

代码示例

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

  1. @Test(expected = NoSuchElementException.class)
  2. public void testExceptionInNext()
  3. {
  4. boolean expected = false;
  5. EasyMock.expect(peekIterator.hasNext()).andReturn(expected);
  6. EasyMock.replay(peekIterator);
  7. testingIterator.next();
  8. EasyMock.verify(peekIterator);
  9. }

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

  1. private void runWithMocks(Runnable toRun, Object... mocks)
  2. {
  3. EasyMock.replay(mocks);
  4. toRun.run();
  5. EasyMock.verify(mocks);
  6. EasyMock.reset(mocks);
  7. }

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

  1. @Test
  2. public void testStart() throws Exception
  3. {
  4. serviceProvider.start();
  5. EasyMock.replay(serviceProvider);
  6. serverDiscoverySelector.start();
  7. EasyMock.verify(serviceProvider);
  8. }

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

  1. @Test
  2. public void testGetAllTiers()
  3. {
  4. Assert.assertEquals(
  5. ImmutableSet.of("tier1", "tier2"),
  6. lookupNodeDiscovery.getAllTiers()
  7. );
  8. EasyMock.verify(druidNodeDiscoveryProvider, druidNodeDiscovery);
  9. }
  10. }

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

  1. @Test
  2. public void testChunking()
  3. {
  4. Query query = queryBuilder.intervals("2015-01-01T00:00:00.000/2015-01-11T00:00:00.000").context(ImmutableMap.of("chunkPeriod", "P1D")).build();
  5. executors.execute(EasyMock.anyObject(Runnable.class));
  6. EasyMock.expectLastCall().times(10);
  7. EasyMock.replay(executors);
  8. EasyMock.replay(toolChest);
  9. QueryRunner runner = decorator.decorate(baseRunner, toolChest);
  10. runner.run(QueryPlus.wrap(query), Collections.EMPTY_MAP);
  11. EasyMock.verify(executors);
  12. }

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

  1. @Before
  2. public void setUp()
  3. {
  4. resourceFactory = (ResourceFactory<String, String>) EasyMock.createMock(ResourceFactory.class);
  5. EasyMock.replay(resourceFactory);
  6. pool = new ResourcePool<String, String>(
  7. resourceFactory,
  8. new ResourcePoolConfig(2, TimeUnit.MINUTES.toMillis(4))
  9. );
  10. EasyMock.verify(resourceFactory);
  11. EasyMock.reset(resourceFactory);
  12. }

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

  1. @Test
  2. public void testGetEmitter()
  3. {
  4. ComposingEmitterConfig config = EasyMock.createMock(ComposingEmitterConfig.class);
  5. EasyMock.expect(config.getEmitters()).andReturn(Collections.singletonList(testEmitterType)).anyTimes();
  6. Injector injector = EasyMock.createMock(Injector.class);
  7. EasyMock.expect(injector.getInstance(Key.get(Emitter.class, Names.named(testEmitterType)))).andReturn(emitter);
  8. EasyMock.replay(config, injector);
  9. Emitter composingEmitter = new ComposingEmitterModule().getEmitter(config, injector);
  10. composingEmitter.start();
  11. EasyMock.verify(config, emitter, injector);
  12. }

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

  1. @Test
  2. public void testStop() throws IOException
  3. {
  4. serviceProvider.close();
  5. EasyMock.replay(serviceProvider);
  6. serverDiscoverySelector.stop();
  7. EasyMock.verify(serviceProvider);
  8. }
  9. }

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

  1. /**
  2. * If "full" is specified, then dimensions/metrics that exist in an incompelte segment should be ingored
  3. */
  4. @Test
  5. public void testGetDatasourceFullWithIncompleteSegment()
  6. {
  7. Map<String, Object> actual = resource.getDatasource(dataSource, "2015-04-03/2015-04-05", "true");
  8. Map<String, Object> expected = ImmutableMap.of();
  9. EasyMock.verify(serverInventoryView, timelineServerView);
  10. Assert.assertEquals(expected, actual);
  11. }

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

  1. @Test
  2. public void testHasNext()
  3. {
  4. boolean expected = true;
  5. EasyMock.expect(peekIterator.hasNext()).andReturn(expected);
  6. EasyMock.replay(peekIterator);
  7. boolean actual = testingIterator.hasNext();
  8. EasyMock.verify(peekIterator);
  9. Assert.assertEquals("The hasNext function is broken", expected, actual);
  10. }

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

  1. @Test
  2. public void testResourcesFilteringAccess()
  3. {
  4. setUpMockExpectations(requestPath, true, requestMethod);
  5. EasyMock.replay(req, request, authorizerMapper);
  6. resourceFilter.getRequestFilter().filter(request);
  7. EasyMock.verify(req, request, authorizerMapper);
  8. }

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

  1. @Test
  2. public void testMissingProducerSequence() throws IOException
  3. {
  4. setUpRequestExpectations("producer", null);
  5. final InputStream inputStream = IOUtils.toInputStream(inputRow, StandardCharsets.UTF_8);
  6. final Response response = firehose.addAll(inputStream, req);
  7. Assert.assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
  8. inputStream.close();
  9. EasyMock.verify(req);
  10. firehose.close();
  11. }

代码示例来源:origin: org.apache.commons/commons-lang3

  1. /**
  2. * Tests a successful initializeUnchecked() operation.
  3. *
  4. * @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
  5. */
  6. @Test
  7. public void testInitializeUnchecked() throws ConcurrentException {
  8. @SuppressWarnings("unchecked")
  9. final
  10. ConcurrentInitializer<Object> init = EasyMock
  11. .createMock(ConcurrentInitializer.class);
  12. final Object result = new Object();
  13. EasyMock.expect(init.get()).andReturn(result);
  14. EasyMock.replay(init);
  15. assertSame("Wrong result object", result, ConcurrentUtils
  16. .initializeUnchecked(init));
  17. EasyMock.verify(init);
  18. }

代码示例来源:origin: org.apache.commons/commons-lang3

  1. /**
  2. * Tests a successful initialize() operation.
  3. *
  4. * @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
  5. */
  6. @Test
  7. public void testInitialize() throws ConcurrentException {
  8. @SuppressWarnings("unchecked")
  9. final
  10. ConcurrentInitializer<Object> init = EasyMock
  11. .createMock(ConcurrentInitializer.class);
  12. final Object result = new Object();
  13. EasyMock.expect(init.get()).andReturn(result);
  14. EasyMock.replay(init);
  15. assertSame("Wrong result object", result, ConcurrentUtils
  16. .initialize(init));
  17. EasyMock.verify(init);
  18. }

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

  1. @Test
  2. public void testFalseBranchNext()
  3. {
  4. boolean expected = true;
  5. EasyMock.expect(peekIterator.hasNext()).andReturn(expected);
  6. expected = false;
  7. EasyMock.expect(peekIterator.hasNext()).andReturn(expected);
  8. EasyMock.replay(peekIterator);
  9. Object res = testingIterator.next();
  10. EasyMock.verify(peekIterator);
  11. Assert.assertNull("Should be null", res);
  12. }

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

  1. @Test
  2. public void testGetRedirectURL()
  3. {
  4. String query = "foo=bar&x=y";
  5. String request = "/request";
  6. EasyMock.expect(druidCoordinator.getCurrentLeader()).andReturn("http://localhost").anyTimes();
  7. EasyMock.replay(druidCoordinator);
  8. URL url = coordinatorRedirectInfo.getRedirectURL(query, request);
  9. Assert.assertEquals("http://localhost/request?foo=bar&x=y", url.toString());
  10. EasyMock.verify(druidCoordinator);
  11. }
  12. }

代码示例来源:origin: org.apache.commons/commons-lang3

  1. /**
  2. * Tests whether the thread name is not modified if no naming pattern is
  3. * set.
  4. */
  5. @Test
  6. public void testNewThreadNoNamingPattern() {
  7. final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
  8. final Runnable r = EasyMock.createMock(Runnable.class);
  9. final String name = "unchangedThreadName";
  10. final Thread t = new Thread(name);
  11. EasyMock.expect(wrapped.newThread(r)).andReturn(t);
  12. EasyMock.replay(wrapped, r);
  13. final BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
  14. assertSame("Wrong thread", t, factory.newThread(r));
  15. assertEquals("Name was changed", name, t.getName());
  16. EasyMock.verify(wrapped, r);
  17. }

代码示例来源:origin: org.apache.commons/commons-lang3

  1. /**
  2. * Tests whether the original priority is not changed if no priority is
  3. * specified.
  4. */
  5. @Test
  6. public void testNewThreadNoPriority() {
  7. final ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
  8. final Runnable r = EasyMock.createMock(Runnable.class);
  9. final int orgPriority = Thread.NORM_PRIORITY + 1;
  10. final Thread t = new Thread();
  11. t.setPriority(orgPriority);
  12. EasyMock.expect(wrapped.newThread(r)).andReturn(t);
  13. EasyMock.replay(wrapped, r);
  14. final BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
  15. assertSame("Wrong thread", t, factory.newThread(r));
  16. assertEquals("Wrong priority", orgPriority, t.getPriority());
  17. EasyMock.verify(wrapped, r);
  18. }

代码示例来源:origin: org.apache.commons/commons-lang3

  1. /**
  2. * Tests createIfAbsent() if a null map is passed in.
  3. *
  4. * @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
  5. */
  6. @Test
  7. public void testCreateIfAbsentNullMap() throws ConcurrentException {
  8. @SuppressWarnings("unchecked")
  9. final
  10. ConcurrentInitializer<Integer> init = EasyMock
  11. .createMock(ConcurrentInitializer.class);
  12. EasyMock.replay(init);
  13. assertNull("Wrong result",
  14. ConcurrentUtils.createIfAbsent(null, "test", init));
  15. EasyMock.verify(init);
  16. }

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

  1. @Test
  2. public void testGetMethod() throws Exception {
  3. MethodInvocation mock = createMock(MethodInvocation.class);
  4. Method method = AopAllianceMethodInvocationAdapterTest.class.getMethod("testGetMethod");
  5. expect(mock.getMethod()).andReturn(method);
  6. AopAllianceMethodInvocationAdapter underTest = new AopAllianceMethodInvocationAdapter(mock);
  7. replay(mock);
  8. assertSame(method, underTest.getMethod());
  9. verify(mock);
  10. }

相关文章