當前位置: 首頁>>代碼示例>>Java>>正文


Java PowerMock.verifyAll方法代碼示例

本文整理匯總了Java中org.powermock.api.easymock.PowerMock.verifyAll方法的典型用法代碼示例。如果您正苦於以下問題:Java PowerMock.verifyAll方法的具體用法?Java PowerMock.verifyAll怎麽用?Java PowerMock.verifyAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.powermock.api.easymock.PowerMock的用法示例。


在下文中一共展示了PowerMock.verifyAll方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testErrorInRebalancePartitionAssignment

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testErrorInRebalancePartitionAssignment() throws Exception {
    RuntimeException exception = new RuntimeException("Assignment error");

    expectInitializeTask();
    expectPollInitialAssignment();
    expectRebalanceAssignmentError(exception);

    PowerMock.replayAll();

    workerTask.initialize(TASK_CONFIG);
    workerTask.initializeAndStart();
    workerTask.iteration();
    try {
        workerTask.iteration();
        fail("Poll should have raised the rebalance exception");
    } catch (RuntimeException e) {
        assertEquals(exception, e);
    }

    PowerMock.verifyAll();
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:23,代碼來源:WorkerSinkTaskTest.java

示例2: testRestartConnector

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testRestartConnector() throws Exception {
    expectAdd(SourceSink.SOURCE);

    Map<String, String> config = connectorConfig(SourceSink.SOURCE);
    expectConfigValidation(config);

    worker.stopConnector(CONNECTOR_NAME);
    EasyMock.expectLastCall().andReturn(true);

    worker.startConnector(EasyMock.eq(CONNECTOR_NAME), EasyMock.eq(config),
            EasyMock.anyObject(HerderConnectorContext.class), EasyMock.eq(herder), EasyMock.eq(TargetState.STARTED));
    EasyMock.expectLastCall().andReturn(true);

    PowerMock.replayAll();

    herder.putConnectorConfig(CONNECTOR_NAME, config, false, createCallback);

    FutureCallback<Void> cb = new FutureCallback<>();
    herder.restartConnector(CONNECTOR_NAME, cb);
    cb.get(1000L, TimeUnit.MILLISECONDS);

    PowerMock.verifyAll();
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:25,代碼來源:StandaloneHerderTest.java

示例3: testDownloadFileWithNonExistingFile

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testDownloadFileWithNonExistingFile() throws IOException {
  IllegalArgumentException expectedException = new IllegalArgumentException();
  MockHttpServletRequest request = new MockHttpServletRequest(DOWNLOAD_URL +
      "file/1234/" + FORM1_QUALIFIED_NAME + "1");
  String nonExistentFile = FORM1_QUALIFIED_NAME + "1";
  expect(exporterMock.exportFile(USER_ID, PROJECT_ID, nonExistentFile))
      .andThrow(expectedException);
  PowerMock.replayAll();
  DownloadServlet download = new DownloadServlet();
  try {
    download.doGet(request, new MockHttpServletResponse());
    fail();
  } catch (IllegalArgumentException ex) {
    assertEquals(expectedException, ex);
  }
  PowerMock.verifyAll();
  }
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:19,代碼來源:DownloadServletTest.java

示例4: testSaveRestore

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testSaveRestore() throws Exception {
    Callback<Void> setCallback = expectSuccessfulSetCallback();
    Callback<Map<ByteBuffer, ByteBuffer>> getCallback = expectSuccessfulGetCallback();
    PowerMock.replayAll();

    store.set(firstSet, setCallback).get();
    store.stop();

    // Restore into a new store to ensure correct reload from scratch
    FileOffsetBackingStore restore = new FileOffsetBackingStore();
    restore.configure(config);
    restore.start();
    Map<ByteBuffer, ByteBuffer> values = restore.get(Arrays.asList(buffer("key")), getCallback).get();
    assertEquals(buffer("value"), values.get(buffer("key")));

    PowerMock.verifyAll();
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:19,代碼來源:FileOffsetBackingStoreTest.java

示例5: testMultipleHost

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testMultipleHost(){
  PowerMock.replayAll();
  final Map<String, String> sourceProperties = new HashMap<>();
  sourceProperties.put("topic", "nats");
  sourceProperties.put("nats.subject", "POST");
  sourceProperties.put("nats.url", "nats://localhost:4222,localhost:4223");
  sourceProperties.put("nats.queue.group", "nats-queue");

  connector.start(sourceProperties);
  List<Map<String, String>> taskConfigs = connector.taskConfigs(1);
  Assert.assertEquals(1, taskConfigs.size());
  Assert.assertEquals("nats", taskConfigs.get(0).get("topic"));
  Assert.assertEquals("POST", taskConfigs.get(0).get("nats.subject"));
  Assert.assertEquals("nats://localhost:4222,localhost:4223", taskConfigs.get(0).get("nats.url"));
  Assert.assertEquals("nats-queue", taskConfigs.get(0).get("nats.queue.group"));
  PowerMock.verifyAll();
}
 
開發者ID:oystparis,項目名稱:kafka-connect-nats,代碼行數:19,代碼來源:NatsSourceConnectorTest.java

示例6: testStartStop

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testStartStop() throws Exception {
    expectConfigure();
    expectStart(Collections.EMPTY_LIST, Collections.EMPTY_MAP);
    expectStop();

    PowerMock.replayAll();

    configStorage.setupAndCreateKafkaBasedLog(TOPIC, DEFAULT_DISTRIBUTED_CONFIG);

    assertEquals(TOPIC, capturedTopic.getValue());
    assertEquals("org.apache.kafka.common.serialization.StringSerializer", capturedProducerProps.getValue().get(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG));
    assertEquals("org.apache.kafka.common.serialization.ByteArraySerializer", capturedProducerProps.getValue().get(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG));
    assertEquals("org.apache.kafka.common.serialization.StringDeserializer", capturedConsumerProps.getValue().get(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG));
    assertEquals("org.apache.kafka.common.serialization.ByteArrayDeserializer", capturedConsumerProps.getValue().get(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG));

    assertEquals(TOPIC, capturedNewTopic.getValue().name());
    assertEquals(1, capturedNewTopic.getValue().numPartitions());
    assertEquals(TOPIC_REPLICATION_FACTOR, capturedNewTopic.getValue().replicationFactor());
    configStorage.start();
    configStorage.stop();

    PowerMock.verifyAll();
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:25,代碼來源:KafkaConfigBackingStoreTest.java

示例7: testSinkTasksWithRowKeyConfig

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
  public void testSinkTasksWithRowKeyConfig() {
    PowerMock.replayAll();
    sinkProperties.put("ampool.tables.rowkey.column", "topic3:id");
    connector.start(sinkProperties);
    List<Map<String, String>> taskConfigs = connector.taskConfigs(1);
    Assert.assertEquals(1, taskConfigs.size());
    Assert.assertEquals("localhost", taskConfigs.get(0).get("locator.host"));
    Assert.assertEquals("12345", taskConfigs.get(0).get("locator.port"));
    Assert.assertEquals("100", taskConfigs.get(0).get("batch.size"));;
    Assert.assertEquals("topic1, topic2, topic3", taskConfigs.get(0).get("topics"));
    Assert.assertEquals("table1, table2, table3", taskConfigs.get(0).get("ampool.tables"));
    Assert.assertEquals("topic3:id", taskConfigs.get(0).get("ampool.tables.rowkey.column"));

//    System.out.println(taskConfigs.get(0).get("locator.host"));
//    System.out.println(taskConfigs.get(0).get("locator.port"));
//    System.out.println(taskConfigs.get(0).get("batch.size"));
//    System.out.println(taskConfigs.get(0).get("topics"));
//    System.out.println(taskConfigs.get(0).get("ampool.tables"));
//    System.out.println(taskConfigs.get(0).get("ampool.tables.rowkey.column"));
    PowerMock.verifyAll();
  }
 
開發者ID:ampool,項目名稱:monarch,代碼行數:23,代碼來源:AmpoolSinkConnectorTest.java

示例8: testPutConnectorConfig

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testPutConnectorConfig() throws Throwable {
    final Capture<Callback<Herder.Created<ConnectorInfo>>> cb = Capture.newInstance();
    herder.putConnectorConfig(EasyMock.eq(CONNECTOR_NAME), EasyMock.eq(CONNECTOR_CONFIG), EasyMock.eq(true), EasyMock.capture(cb));
    expectAndCallbackResult(cb, new Herder.Created<>(false, new ConnectorInfo(CONNECTOR_NAME, CONNECTOR_CONFIG, CONNECTOR_TASK_NAMES)));

    PowerMock.replayAll();

    connectorsResource.putConnectorConfig(CONNECTOR_NAME, FORWARD, CONNECTOR_CONFIG);

    PowerMock.verifyAll();
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:13,代碼來源:ConnectorsResourceTest.java

示例9: testWriteFlush

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testWriteFlush() throws Exception {
    @SuppressWarnings("unchecked")
    Callback<Void> callback = PowerMock.createMock(Callback.class);
    expectStore(OFFSET_KEY, OFFSET_KEY_SERIALIZED, OFFSET_VALUE, OFFSET_VALUE_SERIALIZED, callback, false, null);

    PowerMock.replayAll();

    writer.offset(OFFSET_KEY, OFFSET_VALUE);

    assertTrue(writer.beginFlush());
    writer.doFlush(callback).get(1000, TimeUnit.MILLISECONDS);

    PowerMock.verifyAll();
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:16,代碼來源:OffsetStorageWriterTest.java

示例10: testCommitFailure

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testCommitFailure() throws Exception {
    expectInitializeTask();
    expectPollInitialAssignment();

    Capture<Collection<SinkRecord>> capturedRecords = expectPolls(WorkerConfig.OFFSET_COMMIT_INTERVAL_MS_DEFAULT);
    expectOffsetCommit(1L, new RuntimeException(), null, 0, true);
    // Should rewind to last known good positions, which in this case will be the offsets loaded during initialization
    // for all topic partitions
    consumer.seek(TOPIC_PARTITION, FIRST_OFFSET);
    PowerMock.expectLastCall();
    consumer.seek(TOPIC_PARTITION2, FIRST_OFFSET);
    PowerMock.expectLastCall();
    consumer.seek(TOPIC_PARTITION3, FIRST_OFFSET);
    PowerMock.expectLastCall();
    expectStopTask();

    PowerMock.replayAll();

    workerTask.initialize(TASK_CONFIG);
    workerTask.initializeAndStart();

    // Initialize partition assignment
    workerTask.iteration();
    // Fetch some data
    workerTask.iteration();
    // Trigger the commit
    workerTask.iteration();

    assertEquals(1, workerTask.commitFailures());
    assertEquals(false, Whitebox.getInternalState(workerTask, "committing"));
    workerTask.stop();
    workerTask.close();

    PowerMock.verifyAll();
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:37,代碼來源:WorkerSinkTaskThreadedTest.java

示例11: testGetConnectorConfig

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testGetConnectorConfig() throws Throwable {
    final Capture<Callback<Map<String, String>>> cb = Capture.newInstance();
    herder.connectorConfig(EasyMock.eq(CONNECTOR_NAME), EasyMock.capture(cb));
    expectAndCallbackResult(cb, CONNECTOR_CONFIG);

    PowerMock.replayAll();

    Map<String, String> connConfig = connectorsResource.getConnectorConfig(CONNECTOR_NAME, FORWARD);
    assertEquals(CONNECTOR_CONFIG, connConfig);

    PowerMock.verifyAll();
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:14,代碼來源:ConnectorsResourceTest.java

示例12: testPollsInBackground

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testPollsInBackground() throws Exception {
    expectInitializeTask();
    expectPollInitialAssignment();

    Capture<Collection<SinkRecord>> capturedRecords = expectPolls(1L);
    expectStopTask();

    PowerMock.replayAll();

    workerTask.initialize(TASK_CONFIG);
    workerTask.initializeAndStart();

    // First iteration initializes partition assignment
    workerTask.iteration();

    // Then we iterate to fetch data
    for (int i = 0; i < 10; i++) {
        workerTask.iteration();
    }
    workerTask.stop();
    workerTask.close();

    // Verify contents match expected values, i.e. that they were translated properly. With max
    // batch size 1 and poll returns 1 message at a time, we should have a matching # of batches
    assertEquals(10, capturedRecords.getValues().size());
    int offset = 0;
    for (Collection<SinkRecord> recs : capturedRecords.getValues()) {
        assertEquals(1, recs.size());
        for (SinkRecord rec : recs) {
            SinkRecord referenceSinkRecord
                    = new SinkRecord(TOPIC, PARTITION, KEY_SCHEMA, KEY, VALUE_SCHEMA, VALUE, FIRST_OFFSET + offset, TIMESTAMP, TIMESTAMP_TYPE);
            assertEquals(referenceSinkRecord, rec);
            offset++;
        }
    }

    PowerMock.verifyAll();
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:40,代碼來源:WorkerSinkTaskThreadedTest.java

示例13: testSourceTasksStdin

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testSourceTasksStdin() {
    PowerMock.replayAll();

    sourceProperties.remove(FileStreamSourceConnector.FILE_CONFIG);
    connector.start(sourceProperties);
    List<Map<String, String>> taskConfigs = connector.taskConfigs(1);
    assertEquals(1, taskConfigs.size());
    assertNull(taskConfigs.get(0).get(FileStreamSourceConnector.FILE_CONFIG));

    PowerMock.verifyAll();
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:13,代碼來源:FileStreamSourceConnectorTest.java

示例14: testDownloadProjectSourceZipWithoutTitle

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testDownloadProjectSourceZipWithoutTitle() throws Exception {
  MockHttpServletRequest request = new MockHttpServletRequest(DOWNLOAD_URL +
      "project-source/1234");
  expect(exporterMock.exportProjectSourceZip(USER_ID, PROJECT_ID, true, false, null, false, false, false, false))
      .andReturn(dummyZip);
  PowerMock.replayAll();
  DownloadServlet download = new DownloadServlet();
  MockHttpServletResponse response = new MockHttpServletResponse();
  download.doGet(request, response);
  checkResponseHeader(response, "attachment; filename=\"filename123.aia\"");
  assertEquals("application/zip; charset=utf-8", response.getContentType());
  PowerMock.verifyAll();
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:15,代碼來源:DownloadServletTest.java

示例15: testPollsInBackground

import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testPollsInBackground() throws Exception {
    createWorkerTask();

    sourceTask.initialize(EasyMock.anyObject(SourceTaskContext.class));
    EasyMock.expectLastCall();
    sourceTask.start(TASK_PROPS);
    EasyMock.expectLastCall();
    statusListener.onStartup(taskId);
    EasyMock.expectLastCall();

    final CountDownLatch pollLatch = expectPolls(10);
    // In this test, we don't flush, so nothing goes any further than the offset writer

    sourceTask.stop();
    EasyMock.expectLastCall();
    expectOffsetFlush(true);

    statusListener.onShutdown(taskId);
    EasyMock.expectLastCall();

    producer.close(EasyMock.anyLong(), EasyMock.anyObject(TimeUnit.class));
    EasyMock.expectLastCall();

    transformationChain.close();
    EasyMock.expectLastCall();

    PowerMock.replayAll();

    workerTask.initialize(TASK_CONFIG);
    Future<?> taskFuture = executor.submit(workerTask);

    assertTrue(awaitLatch(pollLatch));
    workerTask.stop();
    assertTrue(workerTask.awaitStop(1000));

    taskFuture.get();

    PowerMock.verifyAll();
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:41,代碼來源:WorkerSourceTaskTest.java


注:本文中的org.powermock.api.easymock.PowerMock.verifyAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。