當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。