Class JclMockPolicy
java.lang.Object
org.powermock.api.easymock.mockpolicies.AbstractEasyMockLogPolicyBase
org.powermock.api.easymock.mockpolicies.JclMockPolicy
- All Implemented Interfaces:
PowerMockPolicy
A Jakarta Commons-Logging (JCL) mock policy. This mock policy deals with
solving JCL related mocking issues. It takes care of loading all concerned
JCL classes through the correct class-loader and automatically prepares and
injects logger instances. This policy does the following:
- Prepares all classes in the org.apache.commons.logging for test as well as org.apache.log4j.Appender and org.apache.log4j.xml.DOMConfigurator.
- All calls to the org.apache.commons.logging.LogFactory#getLog(..) methods are intercepted and returns a nice mock of type org.apache.commons.logging.Log.
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.powermock.api.easymock.mockpolicies.AbstractEasyMockLogPolicyBase
applyClassLoadingPolicy, applyInterceptionPolicy
-
Constructor Details
-
JclMockPolicy
public JclMockPolicy()
-
-
Method Details
-
getFullyQualifiedNamesOfClassesToLoadByMockClassloader
Loads all log4j classes with the mock classloader.- Specified by:
getFullyQualifiedNamesOfClassesToLoadByMockClassloader
in classAbstractEasyMockLogPolicyBase
- Returns:
- The fully-qualified names of the classes that should be loaded by the mock classloader.
-
getLogFrameworkName
- Specified by:
getLogFrameworkName
in classAbstractEasyMockLogPolicyBase
- Returns:
- The name of the log framework. Used in error messages, for
example if the
AbstractEasyMockLogPolicyBase.getLoggerFactoryClassName()
cannot be found in the classpath.
-
getLoggerClassToMock
- Specified by:
getLoggerClassToMock
in classAbstractEasyMockLogPolicyBase
- 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
- Specified by:
getLoggerFactoryClassName
in classAbstractEasyMockLogPolicyBase
- Returns:
- The fully-qualified class name of the Logger Factory that contains the methods that should return a mock upon invocation.
-
getLoggerMethodName
- Specified by:
getLoggerMethodName
in classAbstractEasyMockLogPolicyBase
- Returns:
- The name of the methods in the Logger Factory that should return a mock upon invocation.
-