本文整理匯總了Java中org.powermock.api.easymock.PowerMock.createPartialMock方法的典型用法代碼示例。如果您正苦於以下問題:Java PowerMock.createPartialMock方法的具體用法?Java PowerMock.createPartialMock怎麽用?Java PowerMock.createPartialMock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.powermock.api.easymock.PowerMock
的用法示例。
在下文中一共展示了PowerMock.createPartialMock方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUp
import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
worker = PowerMock.createMock(Worker.class);
EasyMock.expect(worker.isSinkConnector(CONN1)).andStubReturn(Boolean.FALSE);
time = new MockTime();
herder = PowerMock.createPartialMock(DistributedHerder.class, new String[]{"backoff", "updateDeletedConnectorStatus"},
new DistributedConfig(HERDER_CONFIG), worker, WORKER_ID, statusBackingStore, configBackingStore, member, MEMBER_URL, time);
configUpdateListener = herder.new ConfigUpdateListener();
rebalanceListener = herder.new RebalanceListener();
plugins = PowerMock.createMock(Plugins.class);
pluginLoader = PowerMock.createMock(PluginClassLoader.class);
delegatingLoader = PowerMock.createMock(DelegatingClassLoader.class);
PowerMock.mockStatic(Plugins.class);
PowerMock.expectPrivate(herder, "updateDeletedConnectorStatus").andVoid().anyTimes();
}
示例2: setUp
import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Before
public void setUp() {
time = new MockTime();
Map<String, String> workerProps = new HashMap<>();
workerProps.put("key.converter", "org.apache.kafka.connect.json.JsonConverter");
workerProps.put("value.converter", "org.apache.kafka.connect.json.JsonConverter");
workerProps.put("internal.key.converter", "org.apache.kafka.connect.json.JsonConverter");
workerProps.put("internal.value.converter", "org.apache.kafka.connect.json.JsonConverter");
workerProps.put("internal.key.converter.schemas.enable", "false");
workerProps.put("internal.value.converter.schemas.enable", "false");
workerProps.put("offset.storage.file.filename", "/tmp/connect.offsets");
workerConfig = new StandaloneConfig(workerProps);
pluginLoader = PowerMock.createMock(PluginClassLoader.class);
workerTask = PowerMock.createPartialMock(
WorkerSinkTask.class, new String[]{"createConsumer"},
taskId, sinkTask, statusListener, initialState, workerConfig, keyConverter, valueConverter, transformationChain, pluginLoader, time);
recordsReturned = 0;
}
示例3: testStartPaused
import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void testStartPaused() throws Exception {
workerTask = PowerMock.createPartialMock(
WorkerSinkTask.class, new String[]{"createConsumer"},
taskId, sinkTask, statusListener, TargetState.PAUSED, workerConfig, keyConverter, valueConverter, transformationChain, pluginLoader, time);
expectInitializeTask();
expectPollInitialAssignment();
Set<TopicPartition> partitions = new HashSet<>(asList(TOPIC_PARTITION, TOPIC_PARTITION2));
EasyMock.expect(consumer.assignment()).andReturn(partitions);
consumer.pause(partitions);
PowerMock.expectLastCall();
PowerMock.replayAll();
workerTask.initialize(TASK_CONFIG);
workerTask.initializeAndStart();
workerTask.iteration();
PowerMock.verifyAll();
}
示例4: setup
import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void setup() {
super.setup();
time = new MockTime();
Map<String, String> workerProps = new HashMap<>();
workerProps.put("key.converter", "org.apache.kafka.connect.json.JsonConverter");
workerProps.put("value.converter", "org.apache.kafka.connect.json.JsonConverter");
workerProps.put("internal.key.converter", "org.apache.kafka.connect.json.JsonConverter");
workerProps.put("internal.value.converter", "org.apache.kafka.connect.json.JsonConverter");
workerProps.put("internal.key.converter.schemas.enable", "false");
workerProps.put("internal.value.converter.schemas.enable", "false");
workerProps.put("offset.storage.file.filename", "/tmp/connect.offsets");
pluginLoader = PowerMock.createMock(PluginClassLoader.class);
workerConfig = new StandaloneConfig(workerProps);
workerTask = PowerMock.createPartialMock(
WorkerSinkTask.class, new String[]{"createConsumer"},
taskId, sinkTask, statusListener, initialState, workerConfig, keyConverter,
valueConverter, TransformationChain.<SinkRecord>noOp(), pluginLoader, time);
recordsReturned = 0;
}
示例5: whenSaveCalledWithEmptyIdThenExpectCreatedBotConfigToBeReturned
import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Test
public void whenSaveCalledWithEmptyIdThenExpectCreatedBotConfigToBeReturned() throws Exception {
expect(ConfigurationManager.loadConfig(
eq(BotsType.class),
eq(BOTS_CONFIG_XML_FILENAME),
eq(BOTS_CONFIG_XSD_FILENAME))).
andReturn(allTheInternalBotsConfig());
ConfigurationManager.saveConfig(
eq(BotsType.class),
anyObject(BotsType.class),
eq(BOTS_CONFIG_XML_FILENAME));
expect(ConfigurationManager.loadConfig(
eq(BotsType.class),
eq(BOTS_CONFIG_XML_FILENAME),
eq(BOTS_CONFIG_XSD_FILENAME))).
andReturn(allTheInternalBotsConfigPlusNewOne());
final BotConfigRepository botConfigRepository = PowerMock.createPartialMock(
BotConfigRepositoryXmlDatastore.class, MOCKED_GENERATE_UUID_METHOD);
PowerMock.expectPrivate(botConfigRepository, MOCKED_GENERATE_UUID_METHOD).andReturn(GENERATED_BOT_ID);
PowerMock.replayAll();
final BotConfig botConfig = botConfigRepository.save(someNewExternalBotConfig());
assertThat(botConfig.getId()).isNotEmpty(); // uuid has been generated
assertThat(botConfig.getAlias()).isEqualTo(NEW_BOT_NAME);
assertThat(botConfig.getBaseUrl()).isEqualTo(NEW_BOT_URL);
assertThat(botConfig.getUsername()).isEqualTo(NEW_BOT_USERNAME);
assertThat(botConfig.getPassword()).isEqualTo(NEW_BOT_PASSWORD);
PowerMock.verifyAll();
}
示例6: setUp
import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
store = PowerMock.createPartialMock(KafkaBasedLog.class, new String[]{"createConsumer", "createProducer"},
TOPIC, PRODUCER_PROPS, CONSUMER_PROPS, consumedCallback, time, initializer);
consumer = new MockConsumer<>(OffsetResetStrategy.EARLIEST);
consumer.updatePartitions(TOPIC, Arrays.asList(TPINFO0, TPINFO1));
Map<TopicPartition, Long> beginningOffsets = new HashMap<>();
beginningOffsets.put(TP0, 0L);
beginningOffsets.put(TP1, 0L);
consumer.updateBeginningOffsets(beginningOffsets);
}
示例7: setUp
import org.powermock.api.easymock.PowerMock; //導入方法依賴的package包/類
@Before
public void setUp() {
configStorage = PowerMock.createPartialMock(KafkaConfigBackingStore.class, new String[]{"createKafkaBasedLog"}, converter, DEFAULT_DISTRIBUTED_CONFIG);
Whitebox.setInternalState(configStorage, "configLog", storeLog);
configStorage.setUpdateListener(configUpdateListener);
}