本文整理汇总了Java中org.powermock.mockpolicies.MockPolicyInterceptionSettings类的典型用法代码示例。如果您正苦于以下问题:Java MockPolicyInterceptionSettings类的具体用法?Java MockPolicyInterceptionSettings怎么用?Java MockPolicyInterceptionSettings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MockPolicyInterceptionSettings类属于org.powermock.mockpolicies包,在下文中一共展示了MockPolicyInterceptionSettings类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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());
}
示例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());
}
}
示例4: getInterceptionSettings
import org.powermock.mockpolicies.MockPolicyInterceptionSettings; //导入依赖的package包/类
private MockPolicyInterceptionSettings getInterceptionSettings() {
MockPolicyInterceptionSettings settings = new MockPolicyInterceptionSettingsImpl();
for (PowerMockPolicy mockPolicy : mockPolicies) {
mockPolicy.applyInterceptionPolicy(settings);
}
return settings;
}
示例5: applyInterceptionPolicy
import org.powermock.mockpolicies.MockPolicyInterceptionSettings; //导入依赖的package包/类
public void applyInterceptionPolicy(MockPolicyInterceptionSettings settings) {
for (String packageName : getPackageNames()) {
for (Class<?> clazz : getClassesFromPackage(packageName)) {
for (Method m : getSpiedMethodsForClass(clazz)) {
settings.proxyMethod(m, getInvocationHandler(m));
}
}
}
}
示例6: 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);
}
示例7: applyInterceptionPolicy
import org.powermock.mockpolicies.MockPolicyInterceptionSettings; //导入依赖的package包/类
public void applyInterceptionPolicy(MockPolicyInterceptionSettings settings) {
Method calculateMethod = Whitebox.getMethod(ResultCalculator.class);
settings.stubMethod(calculateMethod, 4);
}
示例8: 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);
}
示例9: applyInterceptionPolicy
import org.powermock.mockpolicies.MockPolicyInterceptionSettings; //导入依赖的package包/类
/**
* Apply the interception policies, for example which methods that should be
* suppressed or which methods that should be intercepted and return some
* else than their original value.
*
* @param settings
* The settings objects where the interception policies can be
* applied.
*/
void applyInterceptionPolicy(MockPolicyInterceptionSettings settings);