Class Slf4jMockPolicy
java.lang.Object
org.powermock.api.easymock.mockpolicies.Slf4jMockPolicy
- All Implemented Interfaces:
PowerMockPolicy
An slf4j mock policy. This mock policy deals with solving slf4j related
mocking issues. It takes care of loading all concerned slf4j and log4j
classes through the correct class-loader and automatically prepares and
injects logger instances. This policy does the following:
- Prepares org.apache.log4j.Appender, org.slf4j.LoggerFactory and org.apache.log4j.xml.DOMConfigurator for testing.
- All calls to the org.slf4j.LoggerFactory#getLogger(..) methods are intercepted and returns a nice mock of type org.slf4j.Logger.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidApply all class-loading related policies that must be present before the interception policies can take place.voidApply 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.protected String[]protected Stringprotected Stringprotected Stringprotected String
-
Constructor Details
-
Slf4jMockPolicy
public Slf4jMockPolicy()
-
-
Method Details
-
getFullyQualifiedNamesOfClassesToLoadByMockClassloader
- Returns:
- The fully-qualified names of the classes that should be loaded by the mock classloader.
-
getLogFrameworkName
- Returns:
- The name of the log framework. Used in error messages, for
example if the
getLoggerFactoryClassName()cannot be found in the classpath.
-
getLoggerClassToMock
- Returns:
- The fully-qualified class name of the class that should be mocked. The mock instance of this class will then be returned each time a specified method in the Logger Factory is invoked.
-
getLoggerFactoryClassName
- Returns:
- The fully-qualified class name of the Logger Factory that contains the methods that should return a mock upon invocation.
-
getLoggerMethodName
- Returns:
- The name of the methods in the Logger Factory that should return a mock upon invocation.
-
applyClassLoadingPolicy
Description copied from interface:PowerMockPolicyApply all class-loading related policies that must be present before the interception policies can take place.- Specified by:
applyClassLoadingPolicyin interfacePowerMockPolicy- Parameters:
settings- The settings objects where the class-loading policies can be applied.
-
applyInterceptionPolicy
Description copied from interface:PowerMockPolicyApply 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.- Specified by:
applyInterceptionPolicyin interfacePowerMockPolicy- Parameters:
settings- The settings objects where the interception policies can be applied.
-