All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.powermock.api.easymock.mockpolicies.JclMockPolicy Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.powermock.api.easymock.mockpolicies;


/**
 * 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:
 * 
    *
  1. Prepares all classes in the org.apache.commons.logging for test * as well as org.apache.log4j.Appender and * org.apache.log4j.xml.DOMConfigurator.
  2. *
  3. 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.
  4. *
*/ public class JclMockPolicy extends AbstractEasyMockLogPolicyBase { /** * Loads all log4j classes with the mock classloader. */ protected String[] getFullyQualifiedNamesOfClassesToLoadByMockClassloader() { return new String[] { "org.apache.commons.logging.*", "org.apache.log4j.Appender", "org.apache.log4j.xml.DOMConfigurator" }; } @Override protected String getLogFrameworkName() { return "commons-logging"; } @Override protected String getLoggerClassToMock() { return "org.apache.commons.logging.Log"; } @Override protected String getLoggerFactoryClassName() { return "org.apache.commons.logging.LogFactory"; } @Override protected String getLoggerMethodName() { return "getLog"; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy