当前位置: 首页>>代码示例>>Java>>正文


Java EasyMock.verify方法代码示例

本文整理汇总了Java中org.easymock.EasyMock.verify方法的典型用法代码示例。如果您正苦于以下问题:Java EasyMock.verify方法的具体用法?Java EasyMock.verify怎么用?Java EasyMock.verify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.easymock.EasyMock的用法示例。


在下文中一共展示了EasyMock.verify方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testTruncateNotCalledIfSizeIsBiggerThanTargetSize

import org.easymock.EasyMock; //导入方法依赖的package包/类
/**
 * Expect a KafkaException if targetSize is bigger than the size of
 * the FileRecords.
 */
@Test
public void testTruncateNotCalledIfSizeIsBiggerThanTargetSize() throws IOException {
    FileChannel channelMock = EasyMock.createMock(FileChannel.class);

    EasyMock.expect(channelMock.size()).andReturn(42L).atLeastOnce();
    EasyMock.expect(channelMock.position(42L)).andReturn(null);
    EasyMock.replay(channelMock);

    FileRecords fileRecords = new FileRecords(tempFile(), channelMock, 0, Integer.MAX_VALUE, false);

    try {
        fileRecords.truncateTo(43);
        fail("Should throw KafkaException");
    } catch (KafkaException e) {
        // expected
    }

    EasyMock.verify(channelMock);
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:24,代码来源:FileRecordsTest.java

示例2: testEmptyOption

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test public void testEmptyOption() throws Exception
{
    IniParser parser = new IniParser();
    IniHandler handler = EasyMock.createMock(IniHandler.class);

    handler.startIni();
    handler.startSection(SECTION);
    handler.handleOption(OPTION, null);
    handler.endSection();
    handler.endIni();
    EasyMock.replay(handler);
    Config cfg = new Config();

    cfg.setEmptyOption(true);
    parser.setConfig(cfg);
    parser.parse(new StringReader(CFG_EMPTY_OPTION), handler);
    EasyMock.verify(handler);
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:19,代码来源:IniParserTest.java

示例3: testInvalidSHA256Password

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test
public void testInvalidSHA256Password() throws Exception {
    final UserPasswordDao userPasswordDao = EasyMock.createMock(UserPasswordDao.class);
    EasyMock.expect(userPasswordDao.getPasswordHash("student"))
            .andReturn("(SHA256)KwAQC001SoPq/CjHMLSz2o0aAqx7WrKeRFgWOeM2GEyLXGZd+1/XkA==");

    final PersonDirAuthenticationHandler authenticationHandler =
            new PersonDirAuthenticationHandler();
    authenticationHandler.setUserPasswordDao(userPasswordDao);

    final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials();
    credentials.setUsername("student");
    credentials.setPassword("student");

    EasyMock.replay(userPasswordDao);

    final boolean auth =
            authenticationHandler.authenticateUsernamePasswordInternal(credentials);

    EasyMock.verify(userPasswordDao);

    assertFalse(auth);
}
 
开发者ID:Jasig,项目名称:uPortal-start,代码行数:24,代码来源:PersonDirAuthenticationHandlerTest.java

示例4: testTruncateIfSizeIsDifferentToTargetSize

import org.easymock.EasyMock; //导入方法依赖的package包/类
/**
 * see #testTruncateNotCalledIfSizeIsSameAsTargetSize
 */
@Test
public void testTruncateIfSizeIsDifferentToTargetSize() throws IOException {
    FileChannel channelMock = EasyMock.createMock(FileChannel.class);

    EasyMock.expect(channelMock.size()).andReturn(42L).atLeastOnce();
    EasyMock.expect(channelMock.position(42L)).andReturn(null).once();
    EasyMock.expect(channelMock.truncate(23L)).andReturn(null).once();
    EasyMock.replay(channelMock);

    FileRecords fileRecords = new FileRecords(tempFile(), channelMock, 0, Integer.MAX_VALUE, false);
    fileRecords.truncateTo(23);

    EasyMock.verify(channelMock);
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:18,代码来源:FileRecordsTest.java

示例5: testReadFullyOrFailWithPartialFileChannelReads

import org.easymock.EasyMock; //导入方法依赖的package包/类
/**
 * Tests that `readFullyOrFail` behaves correctly if multiple `FileChannel.read` operations are required to fill
 * the destination buffer.
 */
@Test
public void testReadFullyOrFailWithPartialFileChannelReads() throws IOException {
    FileChannel channelMock = EasyMock.createMock(FileChannel.class);
    final int bufferSize = 100;
    ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
    StringBuilder expectedBufferContent = new StringBuilder();
    fileChannelMockExpectReadWithRandomBytes(channelMock, expectedBufferContent, bufferSize);
    EasyMock.replay(channelMock);
    Utils.readFullyOrFail(channelMock, buffer, 0L, "test");
    assertEquals("The buffer should be populated correctly", expectedBufferContent.toString(),
            new String(buffer.array()));
    assertFalse("The buffer should be filled", buffer.hasRemaining());
    EasyMock.verify(channelMock);
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:19,代码来源:UtilsTest.java

示例6: testDataStoreChangeDoesNotPropagateExceptions

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test
public void testDataStoreChangeDoesNotPropagateExceptions() {
    TransactionEvent event = EasyMock.createNiceMock(TransactionEvent.class);
    EasyMock.expect(event.getSource()).andStubThrow(new RuntimeException("This exception should be eaten to prevent the transaction from failing"));
    EasyMock.replay(catalog, featureType1, featureType2, event);
    
    listener.dataStoreChange(event);
    
    EasyMock.verify(catalog, featureType1, featureType2, event);
}
 
开发者ID:MapStory,项目名称:ms-gs-plugins,代码行数:11,代码来源:BoundsUpdateTransactionListenerTest.java

示例7: testAfterTransactionUncommitted

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test
public void testAfterTransactionUncommitted() {
    TransactionType request = EasyMock.createNiceMock(TransactionType.class);
    EasyMock.replay(catalog, featureType1, featureType2, request);
    TransactionResponseType result = EasyMock.createNiceMock(TransactionResponseType.class);
    boolean committed = false;
    
    listener.afterTransaction(request, result, committed);
    
    EasyMock.verify(catalog, featureType1, featureType2, request);
}
 
开发者ID:MapStory,项目名称:ms-gs-plugins,代码行数:12,代码来源:BoundsUpdateTransactionListenerTest.java

示例8: testInterceptorPartitionSetOnTooLargeRecord

import org.easymock.EasyMock; //导入方法依赖的package包/类
@PrepareOnlyThisForTest(Metadata.class)
@Test
public void testInterceptorPartitionSetOnTooLargeRecord() throws Exception {
    Properties props = new Properties();
    props.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9999");
    props.setProperty(ProducerConfig.MAX_REQUEST_SIZE_CONFIG, "1");
    String topic = "topic";
    ProducerRecord<String, String> record = new ProducerRecord<>(topic, "value");
    
    KafkaProducer<String, String> producer = new KafkaProducer<>(props, new StringSerializer(),
            new StringSerializer());
    Metadata metadata = PowerMock.createNiceMock(Metadata.class);
    MemberModifier.field(KafkaProducer.class, "metadata").set(producer, metadata);
    final Cluster cluster = new Cluster(
        "dummy",
        Collections.singletonList(new Node(0, "host1", 1000)),
        Arrays.asList(new PartitionInfo(topic, 0, null, null, null)),
        Collections.<String>emptySet(),
        Collections.<String>emptySet());
    EasyMock.expect(metadata.fetch()).andReturn(cluster).once();
    
    // Mock interceptors field
    ProducerInterceptors interceptors = PowerMock.createMock(ProducerInterceptors.class);
    EasyMock.expect(interceptors.onSend(record)).andReturn(record);
    interceptors.onSendError(EasyMock.eq(record), EasyMock.<TopicPartition>notNull(), EasyMock.<Exception>notNull());
    EasyMock.expectLastCall();
    MemberModifier.field(KafkaProducer.class, "interceptors").set(producer, interceptors);
    
    PowerMock.replay(metadata);
    EasyMock.replay(interceptors);
    producer.send(record);
    
    EasyMock.verify(interceptors);
    
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:36,代码来源:KafkaProducerTest.java

示例9: testExecutionInProgress

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test
public void testExecutionInProgress() throws InterruptedException, KafkaCruiseControlException {
  LinkedBlockingDeque<Anomaly> anomalies = new LinkedBlockingDeque<>();
  AnomalyNotifier mockAnomalyNotifier = EasyMock.mock(AnomalyNotifier.class);
  BrokerFailureDetector mockBrokerFailureDetector = EasyMock.createNiceMock(BrokerFailureDetector.class);
  GoalViolationDetector mockGoalViolationDetector = EasyMock.createNiceMock(GoalViolationDetector.class);
  ScheduledExecutorService mockDetectorScheduler = EasyMock.mock(ScheduledExecutorService.class);
  ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
  KafkaCruiseControl mockKafkaCruiseControl = EasyMock.mock(KafkaCruiseControl.class);

  // Starting periodic goal violation detection.
  EasyMock.expect(mockDetectorScheduler.scheduleAtFixedRate(EasyMock.eq(mockGoalViolationDetector),
                                                            EasyMock.anyLong(),
                                                            EasyMock.eq(3000L),
                                                            EasyMock.eq(TimeUnit.MILLISECONDS)))
          .andReturn(null);

  // Starting anomaly handler
  EasyMock.expect(mockDetectorScheduler.submit(EasyMock.isA(AnomalyDetector.AnomalyHandlerTask.class)))
          .andDelegateTo(executorService);
  // For detector shutdown.
  mockDetectorScheduler.shutdown();
  EasyMock.expectLastCall().andDelegateTo(executorService);
  EasyMock.expect(mockDetectorScheduler.awaitTermination(3000L, TimeUnit.MILLISECONDS)).andDelegateTo(executorService);
  EasyMock.expect(mockDetectorScheduler.isTerminated()).andDelegateTo(executorService);

  // The following state are used to test the delayed check when executor is busy.
  EasyMock.expect(mockKafkaCruiseControl.state())
          .andReturn(new KafkaCruiseControlState(
              ExecutorState.replicaMovementInProgress(1, Collections.emptySet(), Collections.emptySet(),
                                                      1, 1),
              null, null));

  EasyMock.replay(mockAnomalyNotifier);
  EasyMock.replay(mockBrokerFailureDetector);
  EasyMock.replay(mockGoalViolationDetector);
  EasyMock.replay(mockDetectorScheduler);
  EasyMock.replay(mockKafkaCruiseControl);

  AnomalyDetector anomalyDetector = new AnomalyDetector(anomalies, 3000L, mockKafkaCruiseControl, mockAnomalyNotifier,
                                                        mockGoalViolationDetector, mockBrokerFailureDetector,
                                                        mockDetectorScheduler);

  try {
    anomalyDetector.startDetection();
    anomalies.add(new GoalViolations());
    while (!anomalies.isEmpty()) {
      // Just wait for the anomalies to be drained.
    }
    anomalyDetector.shutdown();
    assertTrue(executorService.awaitTermination(5000, TimeUnit.MILLISECONDS));

    EasyMock.verify(mockAnomalyNotifier, mockDetectorScheduler, mockKafkaCruiseControl);
  } finally {
    executorService.shutdown();
  }
}
 
开发者ID:linkedin,项目名称:cruise-control,代码行数:58,代码来源:AnomalyDetectorTest.java

示例10: tearDown

import org.easymock.EasyMock; //导入方法依赖的package包/类
@After
public void tearDown() {
    EasyMock.verify(invoker, dic);

}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:6,代码来源:FailbackClusterInvokerTest.java

示例11: tearDown

import org.easymock.EasyMock; //导入方法依赖的package包/类
@After
public void tearDown(){
    EasyMock.verify(invoker1,dic);
    
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:6,代码来源:FailfastClusterInvokerTest.java

示例12: testAfterTransactionLayerGroupRecursive

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test
public void testAfterTransactionLayerGroupRecursive() throws Exception {
    Map<Object, Object> extendedProperties = new HashMap<Object, Object>();
    ReferencedEnvelope affectedBounds1 = new ReferencedEnvelope(-180, 0, 0, 90, WGS84);
    ReferencedEnvelope affectedBounds2 = new ReferencedEnvelope(0, 180, 0, 90, WGS84);
    ReferencedEnvelope oldBounds = new ReferencedEnvelope(-90, 0, 0, 45, WGS84);
    ReferencedEnvelope newBounds = new ReferencedEnvelope(oldBounds);
    newBounds.expandToInclude(affectedBounds1);
    newBounds.expandToInclude(affectedBounds2);
    
    EasyMock.expect(catalog.getFeatureTypeByName(featureTypeName1)).andStubReturn(featureType1);
    EasyMock.expect(featureType1.getNativeBoundingBox()).andStubReturn(oldBounds);
    
    LayerInfo layer = mockLayer(featureType1, "layer");
    LayerInfo otherLayer = mockLayer(featureType2, "otherLayer");
    
    List<LayerGroupInfo> groups = new ArrayList<>();
    
    LayerGroupInfo direct = mockGroup("direct", oldBounds, otherLayer, layer);
    direct.setBounds(EasyMock.eq(newBounds));EasyMock.expectLastCall().once(); 
    catalog.save(direct);EasyMock.expectLastCall().once();
    groups.add(direct);
    
    LayerGroupInfo indirect1 = mockGroup("indirect1", oldBounds, otherLayer, direct);
    indirect1.setBounds(EasyMock.eq(newBounds));EasyMock.expectLastCall().once(); 
    catalog.save(indirect1);EasyMock.expectLastCall().once();
    groups.add(indirect1);
    
    LayerGroupInfo indirect2 = mockGroup("indirect2", oldBounds, otherLayer, indirect1);
    indirect2.setBounds(EasyMock.eq(newBounds));EasyMock.expectLastCall().once(); 
    catalog.save(indirect2);EasyMock.expectLastCall().once();
    groups.add(indirect2);
    
    mockLayerGroupList(groups);
    
    // Verify the FT is updated
    featureType1.setNativeBoundingBox(EasyMock.eq(newBounds));EasyMock.expectLastCall().once(); 
    catalog.save(featureType1);EasyMock.expectLastCall().once();

    
    EasyMock.replay(catalog, featureType1, featureType2, layer, otherLayer);
    groups.forEach(EasyMock::replay);
    
    issueInsert(extendedProperties, affectedBounds1);
    
    issueInsert(extendedProperties, affectedBounds2);
    
    TransactionType request = EasyMock.createNiceMock(TransactionType.class);
    TransactionResponseType result = EasyMock.createNiceMock(TransactionResponseType.class);
    EasyMock.expect(request.getExtendedProperties()).andReturn(extendedProperties);
    EasyMock.replay(request, result);
    
    listener.afterTransaction(request, result, true);
    
    ReferencedEnvelope expectedEnv = new ReferencedEnvelope(affectedBounds1);
    expectedEnv.expandToInclude(affectedBounds2);
    
    EasyMock.verify(catalog, featureType1, featureType2, request, result, layer, otherLayer);
    groups.forEach(EasyMock::verify);
    
}
 
开发者ID:MapStory,项目名称:ms-gs-plugins,代码行数:62,代码来源:BoundsUpdateTransactionListenerTest.java

示例13: tearDown

import org.easymock.EasyMock; //导入方法依赖的package包/类
@After
public void tearDown() {
    EasyMock.verify(invoker1, dic);

}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:6,代码来源:ForkingClusterInvokerTest.java

示例14: testAfterTransaction

import org.easymock.EasyMock; //导入方法依赖的package包/类
@Test
public void testAfterTransaction() throws Exception {
    Map<Object, Object> extendedProperties = new HashMap<Object, Object>();
    ReferencedEnvelope affectedBounds1 = new ReferencedEnvelope(-180, 0, 0, 90, WGS84);
    ReferencedEnvelope affectedBounds2 = new ReferencedEnvelope(0, 180, 0, 90, WGS84);
    ReferencedEnvelope oldBounds = new ReferencedEnvelope(-90, 0, 0, 45, WGS84);
    ReferencedEnvelope newBounds = new ReferencedEnvelope(oldBounds);
    newBounds.expandToInclude(affectedBounds1);
    newBounds.expandToInclude(affectedBounds2);
    
    LayerInfo layer = mockLayer(featureType1, "layer");
    
    EasyMock.expect(catalog.getFeatureTypeByName(featureTypeName1)).andStubReturn(featureType1);
    EasyMock.expect(featureType1.getNativeBoundingBox()).andStubReturn(oldBounds);
    
    // Verify the FT is updated
    featureType1.setNativeBoundingBox(EasyMock.eq(newBounds));EasyMock.expectLastCall().once(); 
    catalog.save(featureType1);EasyMock.expectLastCall().once();
    
    EasyMock.expect(catalog.list(EasyMock.eq(LayerGroupInfo.class), EasyMock.anyObject()))
        .andStubAnswer(()-> new CloseableIteratorAdapter<LayerGroupInfo>(
                Collections.emptyListIterator()));
    
    EasyMock.replay(catalog, featureType1, featureType2, layer);
    
    issueInsert(extendedProperties, affectedBounds1);
    
    issueInsert(extendedProperties, affectedBounds2);
    
    TransactionType request = EasyMock.createNiceMock(TransactionType.class);
    TransactionResponseType result = EasyMock.createNiceMock(TransactionResponseType.class);
    EasyMock.expect(request.getExtendedProperties()).andReturn(extendedProperties);
    EasyMock.replay(request, result);
    
    listener.afterTransaction(request, result, true);
    
    ReferencedEnvelope expectedEnv = new ReferencedEnvelope(affectedBounds1);
    expectedEnv.expandToInclude(affectedBounds2);
    
    EasyMock.verify(catalog, featureType1, featureType2, request, result, layer);
    
}
 
开发者ID:MapStory,项目名称:ms-gs-plugins,代码行数:43,代码来源:BoundsUpdateTransactionListenerTest.java


注:本文中的org.easymock.EasyMock.verify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。