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


Java MockPolicyInterceptionSettings.stubMethod方法代码示例

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


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

示例1: applyInterceptionPolicy

import org.powermock.mockpolicies.MockPolicyInterceptionSettings; //导入方法依赖的package包/类
/**
 * Every time the {@link Dependency#getData()} method is invoked we return a
 * custom instance of a {@link DataObject}.
 */
@Override
public void applyInterceptionPolicy(MockPolicyInterceptionSettings settings) {
	final Method getDataMethod = Whitebox.getMethod(Dependency.class);
	final DataObject dataObject = new DataObject("Policy generated data object");
	settings.stubMethod(getDataMethod, dataObject);
}
 
开发者ID:powermock,项目名称:powermock-examples-maven,代码行数:11,代码来源:MyCustomMockPolicy.java

示例2: applyInterceptionPolicy

import org.powermock.mockpolicies.MockPolicyInterceptionSettings; //导入方法依赖的package包/类
public void applyInterceptionPolicy(MockPolicyInterceptionSettings settings) {
	final ResultCalculator calculatorMock = createMock(ResultCalculator.class);
	expect(calculatorMock.calculate()).andReturn(2.0);

	replay(calculatorMock);

	Method calculateMethod = Whitebox.getMethod(ResultCalculator.class, "calculate");
	settings.stubMethod(calculateMethod, calculatorMock.calculate());
}
 
开发者ID:awenblue,项目名称:powermock,代码行数:10,代码来源:MockPolicyWithExpectationsTest.java

示例3: applyInterceptionPolicy

import org.powermock.mockpolicies.MockPolicyInterceptionSettings; //导入方法依赖的package包/类
public void applyInterceptionPolicy(MockPolicyInterceptionSettings mockPolicyInterceptionSettings) {
    LogPolicySupport logPolicySupport = new LogPolicySupport();

    Method[] loggerFactoryMethods = logPolicySupport.getLoggerMethods(LOGGER_FACTORY_CLASS_NAME,
            LOGGER_FACTORY_METHOD_NAME, FRAMEWORK_NAME);

    initializeMockForThread(logPolicySupport);

    for (Method loggerFactoryMethod : loggerFactoryMethods) {
        mockPolicyInterceptionSettings.stubMethod(loggerFactoryMethod, threadLogger.get());
    }
}
 
开发者ID:awenblue,项目名称:powermock,代码行数:13,代码来源:Slf4jMockPolicy.java

示例4: applyInterceptionPolicy

import org.powermock.mockpolicies.MockPolicyInterceptionSettings; //导入方法依赖的package包/类
public void applyInterceptionPolicy(MockPolicyInterceptionSettings settings) {
	final Method doNativeStuffMethod = Whitebox.getMethod(SimpleFramework.class, String.class);
	NativeResult nativeResult = new NativeResult(NATIVE_RESULT_VALUE);
	settings.stubMethod(doNativeStuffMethod, nativeResult);
}
 
开发者ID:awenblue,项目名称:powermock,代码行数:6,代码来源:SimpleFrameworkMockPolicy.java

示例5: applyInterceptionPolicy

import org.powermock.mockpolicies.MockPolicyInterceptionSettings; //导入方法依赖的package包/类
public void applyInterceptionPolicy(MockPolicyInterceptionSettings settings) {
	Method calculateMethod = Whitebox.getMethod(ResultCalculator.class);
	settings.stubMethod(calculateMethod, 4);
}
 
开发者ID:awenblue,项目名称:powermock,代码行数:5,代码来源:MockPolicyUsageExampleTest.java

示例6: applyInterceptionPolicy

import org.powermock.mockpolicies.MockPolicyInterceptionSettings; //导入方法依赖的package包/类
/**
 * Every time the {@link Dependency#getData()} method is invoked we return a
 * custom instance of a {@link DataObject}.
 */
public void applyInterceptionPolicy(MockPolicyInterceptionSettings settings) {
	final Method getDataMethod = Whitebox.getMethod(Dependency.class);
	final DataObject dataObject = new DataObject("Policy generated data object");
	settings.stubMethod(getDataMethod, dataObject);
}
 
开发者ID:awenblue,项目名称:powermock,代码行数:10,代码来源:MyCustomMockPolicy.java


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