From ad8195a1a277c72f72cdc7fc1834101f30d9308c Mon Sep 17 00:00:00 2001 From: John Blum Date: Wed, 10 Apr 2019 10:20:43 -0700 Subject: [PATCH] DATAGEODE-180 - Switch from Apache Commons Logging to SLF4J. --- .../data/gemfire/GemfireAccessor.java | 6 +-- .../data/gemfire/client/Interest.java | 15 ++++--- .../AbstractAnnotationConfigSupport.java | 29 ++++++------- .../GemFireComponentClassTypeScanner.java | 20 ++++----- .../DefinedIndexesApplicationListener.java | 15 +++---- .../DiskStoreDirectoryBeanPostProcessor.java | 16 +++---- .../config/xml/AbstractRegionParser.java | 6 +-- .../function/FunctionServiceFactoryBean.java | 13 +++--- .../function/GemfireFunctionUtils.java | 18 ++++---- .../gemfire/function/PojoFunctionWrapper.java | 12 +++--- ...unctionExecutionBeanDefinitionBuilder.java | 6 +-- .../execution/AbstractFunctionExecution.java | 6 +-- .../ContinuousQueryListenerContainer.java | 13 +++--- .../ContinuousQueryListenerAdapter.java | 6 +-- .../repository/query/GemfireQueryCreator.java | 22 +++------- .../serialization/json/JSONRegionAdvice.java | 14 +++---- .../snapshot/SnapshotServiceFactoryBean.java | 27 ++++++------ .../support/AbstractFactoryBeanSupport.java | 28 ++++++------- .../support/GemfireBeanFactoryLocator.java | 6 +-- ...SpringContextBootstrappingInitializer.java | 10 ++--- .../wan/AbstractWANComponentFactoryBean.java | 6 +-- .../data/gemfire/IndexFactoryBeanTest.java | 42 ++++++++++--------- ...edIndexesApplicationListenerUnitTests.java | 21 ++++++---- .../SnapshotServiceFactoryBeanTest.java | 35 ++++++++-------- .../AbstractFactoryBeanSupportUnitTests.java | 17 ++++++-- ...ngContextBootstrappingInitializerTest.java | 32 ++++++++------ ...fireTestApplicationContextInitializer.java | 11 ++--- .../test/GemfireTestBeanPostProcessor.java | 13 +++--- 28 files changed, 235 insertions(+), 230 deletions(-) diff --git a/src/main/java/org/springframework/data/gemfire/GemfireAccessor.java b/src/main/java/org/springframework/data/gemfire/GemfireAccessor.java index 1964bd5a..b3247927 100644 --- a/src/main/java/org/springframework/data/gemfire/GemfireAccessor.java +++ b/src/main/java/org/springframework/data/gemfire/GemfireAccessor.java @@ -16,11 +16,11 @@ package org.springframework.data.gemfire; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.geode.GemFireCheckedException; import org.apache.geode.GemFireException; import org.apache.geode.cache.Region; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.dao.DataAccessException; import org.springframework.util.Assert; @@ -38,7 +38,7 @@ import org.springframework.util.Assert; */ public class GemfireAccessor implements InitializingBean { - protected final Log log = LogFactory.getLog(getClass()); + protected final Logger logger = LoggerFactory.getLogger(getClass()); private Region region; diff --git a/src/main/java/org/springframework/data/gemfire/client/Interest.java b/src/main/java/org/springframework/data/gemfire/client/Interest.java index fd480b25..0e5d7f97 100644 --- a/src/main/java/org/springframework/data/gemfire/client/Interest.java +++ b/src/main/java/org/springframework/data/gemfire/client/Interest.java @@ -20,9 +20,9 @@ import java.util.List; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.geode.cache.InterestResultPolicy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.Constants; import org.springframework.util.Assert; @@ -48,7 +48,7 @@ public class Interest implements InitializingBean { private static final Constants constants = new Constants(InterestResultPolicy.class); - protected final Log logger = LogFactory.getLog(getClass()); + protected final Logger logger = LoggerFactory.getLogger(getClass()); private boolean durable = false; private boolean receiveValues = true; @@ -121,6 +121,7 @@ public class Interest implements InitializingBean { * @see #afterPropertiesSet() */ public Interest(K key, InterestResultPolicy policy, boolean durable, boolean receiveValues) { + this.key = key; this.policy = policy; this.durable = durable; @@ -133,7 +134,9 @@ public class Interest implements InitializingBean { * @inheritDoc */ public void afterPropertiesSet() { - Assert.notNull(key, "Key is required"); + + Assert.notNull(this.key, "Key is required"); + setType(resolveType(getType())); } @@ -287,6 +290,7 @@ public class Interest implements InitializingBean { * @see org.apache.geode.cache.InterestResultPolicy */ public void setPolicy(Object policy) { + if (policy instanceof InterestResultPolicy) { this.policy = (InterestResultPolicy) policy; } @@ -294,8 +298,7 @@ public class Interest implements InitializingBean { this.policy = (InterestResultPolicy) constants.asObject(String.valueOf(policy)); } else { - throw new IllegalArgumentException(String.format( - "Unknown argument type [%s] for property 'policy'", policy)); + throw new IllegalArgumentException(String.format("Unknown argument type [%s] for property policy", policy)); } } diff --git a/src/main/java/org/springframework/data/gemfire/config/annotation/support/AbstractAnnotationConfigSupport.java b/src/main/java/org/springframework/data/gemfire/config/annotation/support/AbstractAnnotationConfigSupport.java index 2093be72..bdf4d43b 100644 --- a/src/main/java/org/springframework/data/gemfire/config/annotation/support/AbstractAnnotationConfigSupport.java +++ b/src/main/java/org/springframework/data/gemfire/config/annotation/support/AbstractAnnotationConfigSupport.java @@ -31,8 +31,8 @@ import java.util.Optional; import java.util.Set; import java.util.function.Supplier; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanFactory; @@ -99,7 +99,7 @@ public abstract class AbstractAnnotationConfigSupport private final EvaluationContext evaluationContext; - private final Log log; + private final Logger log; /** * Determines whether the given {@link Number} has value. The {@link Number} is valuable @@ -193,14 +193,14 @@ public abstract class AbstractAnnotationConfigSupport } /** - * Constructs a new instance of {@link Log} to log statements printed by Spring Data GemFire/Geode. + * Constructs a new instance of {@link Logger} to log statements printed by Spring Data GemFire/Geode. * - * @return a new instance of {@link Log}. + * @return a new instance of {@link Logger}. * @see org.apache.commons.logging.LogFactory#getLog(Class) * @see org.apache.commons.logging.Log */ - protected Log newLog() { - return LogFactory.getLog(getClass()); + protected Logger newLog() { + return LoggerFactory.getLogger(getClass()); } /** @@ -492,12 +492,12 @@ public abstract class AbstractAnnotationConfigSupport } /** - * Returns a reference to the {@link Log} used by this class to log {@link String messages}. + * Returns a reference to the {@link Logger} used by this class to log {@link String messages}. * - * @return a reference to the {@link Log} used by this class to log {@link String messages}. + * @return a reference to the {@link Logger} used by this class to log {@link String messages}. * @see org.apache.commons.logging.Log */ - protected Log getLog() { + protected Logger getLog() { return this.log; } @@ -522,7 +522,7 @@ public abstract class AbstractAnnotationConfigSupport */ protected void logDebug(Supplier message) { Optional.ofNullable(getLog()) - .filter(Log::isDebugEnabled) + .filter(Logger::isDebugEnabled) .ifPresent(log -> log.debug(message.get())); } @@ -547,7 +547,7 @@ public abstract class AbstractAnnotationConfigSupport */ protected void logInfo(Supplier message) { Optional.ofNullable(getLog()) - .filter(Log::isInfoEnabled) + .filter(Logger::isInfoEnabled) .ifPresent(log -> log.info(message.get())); } @@ -572,7 +572,7 @@ public abstract class AbstractAnnotationConfigSupport */ protected void logWarning(Supplier message) { Optional.ofNullable(getLog()) - .filter(Log::isWarnEnabled) + .filter(Logger::isWarnEnabled) .ifPresent(log -> log.info(message.get())); } @@ -597,7 +597,7 @@ public abstract class AbstractAnnotationConfigSupport */ protected void logError(Supplier message) { Optional.ofNullable(getLog()) - .filter(Log::isWarnEnabled) + .filter(Logger::isWarnEnabled) .ifPresent(log -> log.info(message.get())); } @@ -797,6 +797,7 @@ public abstract class AbstractAnnotationConfigSupport * For non-{@link String} values, this means the value must not be {@literal null}. * @see #resolveProperty(String, Class, Object) */ + @SuppressWarnings("all") protected T requireProperty(String propertyName, Class type) { return Optional.of(propertyName) diff --git a/src/main/java/org/springframework/data/gemfire/config/annotation/support/GemFireComponentClassTypeScanner.java b/src/main/java/org/springframework/data/gemfire/config/annotation/support/GemFireComponentClassTypeScanner.java index 86cfacf8..305338ce 100644 --- a/src/main/java/org/springframework/data/gemfire/config/annotation/support/GemFireComponentClassTypeScanner.java +++ b/src/main/java/org/springframework/data/gemfire/config/annotation/support/GemFireComponentClassTypeScanner.java @@ -30,8 +30,8 @@ import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; import java.util.stream.Collectors; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; import org.springframework.core.env.Environment; @@ -90,7 +90,7 @@ public class GemFireComponentClassTypeScanner implements Iterable { private Set excludes = new HashSet<>(); private Set includes = new HashSet<>(); - protected final Log log = LogFactory.getLog(getClass()); + protected final Logger logger = LoggerFactory.getLogger(getClass()); private final Set basePackages; @@ -210,7 +210,7 @@ public class GemFireComponentClassTypeScanner implements Iterable { stream(this.spliterator(), true) .flatMap(packageName -> componentProvider.findCandidateComponents(packageName).stream()) - .forEach(beanDefinition -> { + .forEach(beanDefinition -> Optional.ofNullable(beanDefinition.getBeanClassName()) .filter(StringUtils::hasText) .ifPresent(beanClassName -> { @@ -218,11 +218,11 @@ public class GemFireComponentClassTypeScanner implements Iterable { componentClasses.add(ClassUtils.forName(beanClassName, entityClassLoader)); } catch (ClassNotFoundException ignore) { - log.warn(String.format("Class for component type [%s] not found", + logger.warn(String.format("Class for component type [%s] not found", beanDefinition.getBeanClassName())); } - }); - }); + }) + ); return componentClasses; } @@ -261,35 +261,29 @@ public class GemFireComponentClassTypeScanner implements Iterable { return componentProvider; } - /* (non-Javadoc) */ public GemFireComponentClassTypeScanner with(ClassLoader entityClassLoader) { this.entityClassLoader = entityClassLoader; return this; } - /* (non-Javadoc) */ public GemFireComponentClassTypeScanner with(ConfigurableApplicationContext applicationContext) { this.applicationContext = applicationContext; return this; } - /* (non-Javadoc) */ public GemFireComponentClassTypeScanner withExcludes(TypeFilter... excludes) { return withExcludes(asSet(nullSafeArray(excludes, TypeFilter.class))); } - /* (non-Javadoc) */ public GemFireComponentClassTypeScanner withExcludes(Iterable excludes) { stream(nullSafeIterable(excludes).spliterator(), false).forEach(this.excludes::add); return this; } - /* (non-Javadoc) */ public GemFireComponentClassTypeScanner withIncludes(TypeFilter... includes) { return withIncludes(asSet(nullSafeArray(includes, TypeFilter.class))); } - /* (non-Javadoc) */ public GemFireComponentClassTypeScanner withIncludes(Iterable includes) { stream(nullSafeIterable(includes).spliterator(), false).forEach(this.includes::add); return this; diff --git a/src/main/java/org/springframework/data/gemfire/config/support/DefinedIndexesApplicationListener.java b/src/main/java/org/springframework/data/gemfire/config/support/DefinedIndexesApplicationListener.java index 46fc421f..b621c130 100644 --- a/src/main/java/org/springframework/data/gemfire/config/support/DefinedIndexesApplicationListener.java +++ b/src/main/java/org/springframework/data/gemfire/config/support/DefinedIndexesApplicationListener.java @@ -18,10 +18,10 @@ package org.springframework.data.gemfire.config.support; import java.util.Optional; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.geode.cache.query.MultiIndexCreationException; import org.apache.geode.cache.query.QueryService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; @@ -41,7 +41,7 @@ import org.springframework.data.gemfire.config.xml.GemfireConstants; */ public class DefinedIndexesApplicationListener implements ApplicationListener { - protected final Log logger = initLogger(); + protected final Logger logger = initLogger(); /** * Attempts to create all defined {@link org.apache.geode.cache.query.Index Indexes} using @@ -63,18 +63,16 @@ public class DefinedIndexesApplicationListener implements ApplicationListener, InitializingBean { - private static Log logger = LogFactory.getLog(FunctionServiceFactoryBean.class); + private static Logger logger = LoggerFactory.getLogger(FunctionServiceFactoryBean.class); private List functions; @Override public void afterPropertiesSet() throws Exception { - if (!CollectionUtils.isEmpty(functions)) { - for (Function function : functions) { + + if (!CollectionUtils.isEmpty(this.functions)) { + for (Function function : this.functions) { if (logger.isInfoEnabled()) { - logger.info(String.format("registering Function with ID (%1$s)", function.getId())); + logger.info("registering Function with ID [{}]", function.getId()); } FunctionService.registerFunction(function); } diff --git a/src/main/java/org/springframework/data/gemfire/function/GemfireFunctionUtils.java b/src/main/java/org/springframework/data/gemfire/function/GemfireFunctionUtils.java index fc8a9bee..fa93fd54 100644 --- a/src/main/java/org/springframework/data/gemfire/function/GemfireFunctionUtils.java +++ b/src/main/java/org/springframework/data/gemfire/function/GemfireFunctionUtils.java @@ -26,11 +26,11 @@ import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.geode.cache.execute.Function; import org.apache.geode.cache.execute.FunctionService; import org.apache.geode.security.ResourcePermission; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.annotation.AnnotationUtils; @@ -54,7 +54,7 @@ public abstract class GemfireFunctionUtils { private static final String DEFAULT_FUNCTION_ID = null; - private static Log log = LogFactory.getLog(GemfireFunctionUtils.class); + private static Logger logger = LoggerFactory.getLogger(GemfireFunctionUtils.class); /** * Determines whether the given {@link Method} is a POJO, {@link GemfireFunction} annotated {@link Method}. @@ -366,8 +366,8 @@ public abstract class GemfireFunctionUtils { if (FunctionService.isRegistered(function.getId())) { if (overwrite) { - if (log.isDebugEnabled()) { - log.debug(String.format("Overwrite enabled; Unregistering Function [%s]", function.getId())); + if (logger.isDebugEnabled()) { + logger.debug("Overwrite enabled; Unregistering Function [{}]", function.getId()); } FunctionService.unregisterFunction(function.getId()); @@ -375,16 +375,16 @@ public abstract class GemfireFunctionUtils { } if (FunctionService.isRegistered(function.getId())) { - if (log.isDebugEnabled()) { - log.debug(String.format("Function [%s] is already registered", function.getId())); + if (logger.isDebugEnabled()) { + logger.debug("Function [{}] is already registered", function.getId()); } } else { FunctionService.registerFunction(function); - if (log.isDebugEnabled()) { - log.debug(String.format("Registered Function [%s]", function.getId())); + if (logger.isDebugEnabled()) { + logger.debug("Registered Function [{}]", function.getId()); } } } diff --git a/src/main/java/org/springframework/data/gemfire/function/PojoFunctionWrapper.java b/src/main/java/org/springframework/data/gemfire/function/PojoFunctionWrapper.java index cdcde1c8..bdedfcdc 100644 --- a/src/main/java/org/springframework/data/gemfire/function/PojoFunctionWrapper.java +++ b/src/main/java/org/springframework/data/gemfire/function/PojoFunctionWrapper.java @@ -18,14 +18,14 @@ import java.lang.reflect.Method; import java.util.Collection; import java.util.Collections; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.geode.cache.Region; import org.apache.geode.cache.execute.Function; import org.apache.geode.cache.execute.FunctionContext; import org.apache.geode.cache.execute.ResultSender; import org.apache.geode.management.internal.security.ResourcePermissions; import org.apache.geode.security.ResourcePermission; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.util.ObjectUtils; import org.springframework.util.ReflectionUtils; import org.springframework.util.StringUtils; @@ -50,7 +50,7 @@ import org.springframework.util.StringUtils; @SuppressWarnings("serial") public class PojoFunctionWrapper implements Function { - private static transient Log logger = LogFactory.getLog(PojoFunctionWrapper.class); + private static transient Logger logger = LoggerFactory.getLogger(PojoFunctionWrapper.class); private volatile boolean HA; private volatile boolean hasResult; @@ -162,12 +162,12 @@ public class PojoFunctionWrapper implements Function { if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) { - logger.debug(String.format("About to invoke method [%s] on class [%s] as Function [%s]", - this.method.getName(), this.target.getClass().getName(), getId())); + logger.debug("About to invoke method [{}] on class [{}] as Function [{}]", + this.method.getName(), this.target.getClass().getName(), getId()); } for (Object arg : args) { - logger.debug(String.format("Argument of type [%s] is [%s]", arg.getClass().getName(), arg.toString())); + logger.debug("Argument of type [{}] is [{}]", arg.getClass().getName(), arg.toString()); } } diff --git a/src/main/java/org/springframework/data/gemfire/function/config/AbstractFunctionExecutionBeanDefinitionBuilder.java b/src/main/java/org/springframework/data/gemfire/function/config/AbstractFunctionExecutionBeanDefinitionBuilder.java index fe6506b6..3399f6e0 100644 --- a/src/main/java/org/springframework/data/gemfire/function/config/AbstractFunctionExecutionBeanDefinitionBuilder.java +++ b/src/main/java/org/springframework/data/gemfire/function/config/AbstractFunctionExecutionBeanDefinitionBuilder.java @@ -18,8 +18,8 @@ package org.springframework.data.gemfire.function.config; import java.util.Optional; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; @@ -38,7 +38,7 @@ abstract class AbstractFunctionExecutionBeanDefinitionBuilder { protected final FunctionExecutionConfiguration configuration; - protected final Log log = LogFactory.getLog(getClass()); + protected final Logger logger = LoggerFactory.getLogger(getClass()); AbstractFunctionExecutionBeanDefinitionBuilder(FunctionExecutionConfiguration configuration) { diff --git a/src/main/java/org/springframework/data/gemfire/function/execution/AbstractFunctionExecution.java b/src/main/java/org/springframework/data/gemfire/function/execution/AbstractFunctionExecution.java index 93c28854..dcebca3c 100644 --- a/src/main/java/org/springframework/data/gemfire/function/execution/AbstractFunctionExecution.java +++ b/src/main/java/org/springframework/data/gemfire/function/execution/AbstractFunctionExecution.java @@ -17,13 +17,13 @@ import java.util.Iterator; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.geode.cache.execute.Execution; import org.apache.geode.cache.execute.Function; import org.apache.geode.cache.execute.FunctionException; import org.apache.geode.cache.execute.FunctionService; import org.apache.geode.cache.execute.ResultCollector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.util.Assert; /** @@ -42,7 +42,7 @@ abstract class AbstractFunctionExecution { private Function function; - protected final Log logger = LogFactory.getLog(this.getClass()); + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); private Object[] args; diff --git a/src/main/java/org/springframework/data/gemfire/listener/ContinuousQueryListenerContainer.java b/src/main/java/org/springframework/data/gemfire/listener/ContinuousQueryListenerContainer.java index 598784ae..03d5619a 100644 --- a/src/main/java/org/springframework/data/gemfire/listener/ContinuousQueryListenerContainer.java +++ b/src/main/java/org/springframework/data/gemfire/listener/ContinuousQueryListenerContainer.java @@ -34,8 +34,6 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.Executor; import java.util.function.Supplier; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.geode.cache.RegionService; import org.apache.geode.cache.client.Pool; import org.apache.geode.cache.client.PoolManager; @@ -46,6 +44,8 @@ import org.apache.geode.cache.query.CqListener; import org.apache.geode.cache.query.CqQuery; import org.apache.geode.cache.query.QueryException; import org.apache.geode.cache.query.QueryService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; @@ -120,7 +120,7 @@ public class ContinuousQueryListenerContainer implements BeanFactoryAware, BeanN (beanName, container) -> nullSafeList(this.cqListenerContainerConfigurers).forEach(configurer -> configurer.configure(beanName, container)); - protected final Log logger = LogFactory.getLog(getClass()); + protected final Logger logger = LoggerFactory.getLogger(getClass()); private Queue continuousQueries = new ConcurrentLinkedQueue<>(); @@ -734,8 +734,7 @@ public class ContinuousQueryListenerContainer implements BeanFactoryAware, BeanN boolean active = this.isActive(); if (!active && logger.isDebugEnabled()) { - logger.debug("A CQ listener exception occurred after container shutdown;" - + " ErrorHandler will not be invoked", cause); + logger.debug("A CQ listener exception occurred after container shutdown; ErrorHandler will not be invoked", cause); } return active; @@ -818,11 +817,11 @@ public class ContinuousQueryListenerContainer implements BeanFactoryAware, BeanN ((DisposableBean) it).destroy(); if (logger.isDebugEnabled()) { - logger.debug(String.format("Stopped internally-managed TaskExecutor [%s]", it)); + logger.debug("Stopped internally-managed TaskExecutor {}", it); } } catch (Exception ignore) { - logger.warn(String.format("Failed to properly destroy the managed TaskExecutor [%s]", it)); + logger.warn("Failed to properly destroy the managed TaskExecutor {}", it); } }); } diff --git a/src/main/java/org/springframework/data/gemfire/listener/adapter/ContinuousQueryListenerAdapter.java b/src/main/java/org/springframework/data/gemfire/listener/adapter/ContinuousQueryListenerAdapter.java index ee8c80fc..1d40ec3a 100644 --- a/src/main/java/org/springframework/data/gemfire/listener/adapter/ContinuousQueryListenerAdapter.java +++ b/src/main/java/org/springframework/data/gemfire/listener/adapter/ContinuousQueryListenerAdapter.java @@ -23,11 +23,11 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.geode.cache.Operation; import org.apache.geode.cache.query.CqEvent; import org.apache.geode.cache.query.CqQuery; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.dao.DataAccessException; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.gemfire.listener.ContinuousQueryListener; @@ -79,7 +79,7 @@ public class ContinuousQueryListenerAdapter implements ContinuousQueryListener { // Out-of-the-box value for the default listener handler method "handleEvent". public static final String DEFAULT_LISTENER_METHOD_NAME = "handleEvent"; - protected final Log logger = LogFactory.getLog(getClass()); + protected final Logger logger = LoggerFactory.getLogger(getClass()); private MethodInvoker invoker; diff --git a/src/main/java/org/springframework/data/gemfire/repository/query/GemfireQueryCreator.java b/src/main/java/org/springframework/data/gemfire/repository/query/GemfireQueryCreator.java index 1a629ef9..ec184e7c 100644 --- a/src/main/java/org/springframework/data/gemfire/repository/query/GemfireQueryCreator.java +++ b/src/main/java/org/springframework/data/gemfire/repository/query/GemfireQueryCreator.java @@ -18,8 +18,8 @@ package org.springframework.data.gemfire.repository.query; import java.util.Iterator; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.data.domain.Sort; import org.springframework.data.gemfire.mapping.GemfirePersistentEntity; import org.springframework.data.repository.query.parser.AbstractQueryCreator; @@ -38,7 +38,7 @@ import org.springframework.data.repository.query.parser.PartTree; */ class GemfireQueryCreator extends AbstractQueryCreator { - private static final Log LOG = LogFactory.getLog(GemfireQueryCreator.class); + private static final Logger logger = LoggerFactory.getLogger(GemfireQueryCreator.class); private Iterator indexes; @@ -106,8 +106,8 @@ class GemfireQueryCreator extends AbstractQueryCreator QueryString query = this.queryBuilder.create(criteria).orderBy(sort); - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Created Query [%s]", query.toString())); + if (logger.isDebugEnabled()) { + logger.debug("Created Query [{}]", query.toString()); } return query; @@ -128,29 +128,17 @@ class GemfireQueryCreator extends AbstractQueryCreator this.index = 1; } - /* - * (non-Javadoc) - * @see java.util.Iterator#hasNext() - */ @Override @SuppressWarnings("all") public boolean hasNext() { return (index <= Integer.MAX_VALUE); } - /* - * (non-Javadoc) - * @see java.util.Iterator#next() - */ @Override public Integer next() { return index++; } - /* - * (non-Javadoc) - * @see java.util.Iterator#remove() - */ @Override public void remove() { throw new UnsupportedOperationException(); diff --git a/src/main/java/org/springframework/data/gemfire/serialization/json/JSONRegionAdvice.java b/src/main/java/org/springframework/data/gemfire/serialization/json/JSONRegionAdvice.java index 31f519fa..297c0689 100644 --- a/src/main/java/org/springframework/data/gemfire/serialization/json/JSONRegionAdvice.java +++ b/src/main/java/org/springframework/data/gemfire/serialization/json/JSONRegionAdvice.java @@ -33,8 +33,6 @@ import java.util.stream.Collectors; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.geode.cache.Region; import org.apache.geode.cache.query.SelectResults; import org.apache.geode.cache.query.internal.ResultsBag; @@ -43,6 +41,8 @@ import org.apache.geode.pdx.PdxInstance; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.data.gemfire.GemfireTemplate; import org.springframework.util.CollectionUtils; @@ -66,7 +66,7 @@ public class JSONRegionAdvice { private List includedRegions = new ArrayList<>(); - protected final Log log = LogFactory.getLog(JSONRegionAdvice.class); + protected final Logger logger = LoggerFactory.getLogger(JSONRegionAdvice.class); /** * Flag to convert collections returned from cache from @{link PdxInstance} to JSON String. If the returned @@ -116,7 +116,7 @@ public class JSONRegionAdvice { try { if (isIncludedJsonRegion(pjp.getTarget())) { returnValue = pjp.proceed(); - log.debug("converting " + returnValue + " to JSON string"); + logger.debug("converting {} to JSON string", returnValue); returnValue = convertToJson(returnValue); } else { @@ -173,7 +173,7 @@ public class JSONRegionAdvice { newArgs[1] = convertToPdx(val); returnValue = pjp.proceed(newArgs); - log.debug(String.format("Converting [%s] to JSON", returnValue)); + logger.debug("Converting [{}] to JSON", returnValue); returnValue = convertToJson(returnValue); } else { @@ -295,8 +295,8 @@ public class JSONRegionAdvice { if (isIncludedJsonRegion(toRegionName(region), toRegionPath(region))) { - if (log.isDebugEnabled()) { - log.debug(String.format("Region [%s] is included for JSON conversion", region.getName())); + if (logger.isDebugEnabled()) { + logger.debug("Region [{}] is included for JSON conversion", region.getName()); } result = true; diff --git a/src/main/java/org/springframework/data/gemfire/snapshot/SnapshotServiceFactoryBean.java b/src/main/java/org/springframework/data/gemfire/snapshot/SnapshotServiceFactoryBean.java index dea1816b..e0a94c2a 100644 --- a/src/main/java/org/springframework/data/gemfire/snapshot/SnapshotServiceFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/snapshot/SnapshotServiceFactoryBean.java @@ -36,14 +36,14 @@ import java.util.jar.JarFile; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.geode.cache.Cache; import org.apache.geode.cache.Region; import org.apache.geode.cache.snapshot.CacheSnapshotService; import org.apache.geode.cache.snapshot.RegionSnapshotService; import org.apache.geode.cache.snapshot.SnapshotFilter; import org.apache.geode.cache.snapshot.SnapshotOptions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.context.ApplicationListener; @@ -88,20 +88,17 @@ public class SnapshotServiceFactoryBean extends AbstractFactoryBeanSupport private SnapshotServiceAdapter snapshotServiceAdapter; - /* (non-Javadoc) */ @SuppressWarnings("unchecked") static SnapshotMetadata[] nullSafeArray(SnapshotMetadata[] configurations) { - return (configurations != null ? configurations : EMPTY_ARRAY); + return configurations != null ? configurations : EMPTY_ARRAY; } - /* (non-Javadoc) */ static boolean nullSafeIsDirectory(File file) { - return (file != null && file.isDirectory()); + return file != null && file.isDirectory(); } - /* (non-Javadoc) */ static boolean nullSafeIsFile(File file) { - return (file != null && file.isFile()); + return file != null && file.isFile(); } /** @@ -435,10 +432,10 @@ public class SnapshotServiceFactoryBean extends AbstractFactoryBeanSupport protected static final File TEMPORARY_DIRECTORY = new File(System.getProperty("java.io.tmpdir")); - protected final Log log = createLog(); + protected final Logger logger = createLog(); - Log createLog() { - return LogFactory.getLog(getClass()); + Logger createLog() { + return LoggerFactory.getLogger(getClass()); } @Override @@ -527,16 +524,16 @@ public class SnapshotServiceFactoryBean extends AbstractFactoryBeanSupport closeable.close(); return true; } - catch (IOException ignore) { - logDebug(ignore, "Failed to close [%s]", closeable); + catch (IOException cause) { + logDebug(cause, "Failed to close [%s]", closeable); return false; } } protected void logDebug(Throwable cause, String message, Object... arguments) { - if (log.isDebugEnabled()) { - log.debug(String.format(message, arguments), cause); + if (logger.isDebugEnabled()) { + logger.debug(String.format(message, arguments), cause); } } diff --git a/src/main/java/org/springframework/data/gemfire/support/AbstractFactoryBeanSupport.java b/src/main/java/org/springframework/data/gemfire/support/AbstractFactoryBeanSupport.java index c0b6cb9b..45e100f5 100644 --- a/src/main/java/org/springframework/data/gemfire/support/AbstractFactoryBeanSupport.java +++ b/src/main/java/org/springframework/data/gemfire/support/AbstractFactoryBeanSupport.java @@ -19,8 +19,8 @@ package org.springframework.data.gemfire.support; import java.util.Optional; import java.util.function.Supplier; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanFactory; @@ -52,7 +52,7 @@ public abstract class AbstractFactoryBeanSupport private BeanFactory beanFactory; - private final Log log; + private final Logger log; private String beanName; @@ -66,14 +66,14 @@ public abstract class AbstractFactoryBeanSupport } /** - * Constructs a new instance of {@link Log} to log statements printed by Spring Data GemFire/Geode. + * Constructs a new instance of {@link Logger} to log statements printed by Spring Data GemFire/Geode. * - * @return a new instance of {@link Log}. + * @return a new instance of {@link Logger}. * @see org.apache.commons.logging.LogFactory#getLog(Class) * @see org.apache.commons.logging.Log */ - protected Log newLog() { - return LogFactory.getLog(getClass()); + protected Logger newLog() { + return LoggerFactory.getLogger(getClass()); } /** @@ -146,12 +146,12 @@ public abstract class AbstractFactoryBeanSupport } /** - * Returns a reference to the {@link Log} used by this {@link FactoryBean} to log {@link String messages}. + * Returns a reference to the {@link Logger} used by this {@link FactoryBean} to log {@link String messages}. * - * @return a reference to the {@link Log} used by this {@link FactoryBean} to log {@link String messages}. + * @return a reference to the {@link Logger} used by this {@link FactoryBean} to log {@link String messages}. * @see org.apache.commons.logging.Log */ - protected Log getLog() { + protected Logger getLog() { return this.log; } @@ -187,7 +187,7 @@ public abstract class AbstractFactoryBeanSupport */ protected void logDebug(Supplier message) { Optional.ofNullable(getLog()) - .filter(Log::isDebugEnabled) + .filter(Logger::isDebugEnabled) .ifPresent(log -> log.debug(message.get())); } @@ -212,7 +212,7 @@ public abstract class AbstractFactoryBeanSupport */ protected void logInfo(Supplier message) { Optional.ofNullable(getLog()) - .filter(Log::isInfoEnabled) + .filter(Logger::isInfoEnabled) .ifPresent(log -> log.info(message.get())); } @@ -237,7 +237,7 @@ public abstract class AbstractFactoryBeanSupport */ protected void logWarning(Supplier message) { Optional.ofNullable(getLog()) - .filter(Log::isWarnEnabled) + .filter(Logger::isWarnEnabled) .ifPresent(log -> log.warn(message.get())); } @@ -262,7 +262,7 @@ public abstract class AbstractFactoryBeanSupport */ protected void logError(Supplier message) { Optional.ofNullable(getLog()) - .filter(Log::isErrorEnabled) + .filter(Logger::isErrorEnabled) .ifPresent(log -> log.error(message.get())); } } diff --git a/src/main/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocator.java b/src/main/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocator.java index 4a5fe852..07a21e60 100644 --- a/src/main/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocator.java +++ b/src/main/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocator.java @@ -28,8 +28,8 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicReference; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.BeanNameAware; @@ -62,7 +62,7 @@ public class GemfireBeanFactoryLocator implements BeanFactoryAware, BeanNameAwar private BeanFactory beanFactory; - protected final Log logger = LogFactory.getLog(getClass()); + protected final Logger logger = LoggerFactory.getLogger(getClass()); private Set associatedBeanNameWithAliases = Collections.emptySet(); diff --git a/src/main/java/org/springframework/data/gemfire/support/SpringContextBootstrappingInitializer.java b/src/main/java/org/springframework/data/gemfire/support/SpringContextBootstrappingInitializer.java index 9dcc5444..dc23830d 100644 --- a/src/main/java/org/springframework/data/gemfire/support/SpringContextBootstrappingInitializer.java +++ b/src/main/java/org/springframework/data/gemfire/support/SpringContextBootstrappingInitializer.java @@ -22,10 +22,10 @@ import java.util.Properties; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicReference; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.geode.cache.Cache; import org.apache.geode.cache.Declarable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextException; import org.springframework.context.ApplicationListener; @@ -85,7 +85,7 @@ public class SpringContextBootstrappingInitializer implements Declarable, Applic private static final List> registeredAnnotatedClasses = new CopyOnWriteArrayList<>(); - protected final Log logger = initLogger(); + protected final Logger logger = initLogger(); /** * Gets a reference to the Spring ApplicationContext constructed, configured and initialized inside the GemFire @@ -225,8 +225,8 @@ public class SpringContextBootstrappingInitializer implements Declarable, Applic * @see org.apache.commons.logging.LogFactory#getLog(Class) * @see org.apache.commons.logging.Log */ - protected Log initLogger() { - return LogFactory.getLog(getClass()); + protected Logger initLogger() { + return LoggerFactory.getLogger(getClass()); } private boolean isConfigurable(Collection> annotatedClasses, String[] basePackages, diff --git a/src/main/java/org/springframework/data/gemfire/wan/AbstractWANComponentFactoryBean.java b/src/main/java/org/springframework/data/gemfire/wan/AbstractWANComponentFactoryBean.java index cb831607..f1268664 100644 --- a/src/main/java/org/springframework/data/gemfire/wan/AbstractWANComponentFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/wan/AbstractWANComponentFactoryBean.java @@ -16,9 +16,9 @@ package org.springframework.data.gemfire.wan; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.geode.cache.Cache; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.FactoryBean; @@ -42,7 +42,7 @@ public abstract class AbstractWANComponentFactoryBean protected final Cache cache; - protected final Log log = LogFactory.getLog(getClass()); + protected final Logger logger = LoggerFactory.getLogger(getClass()); protected Object factory; diff --git a/src/test/java/org/springframework/data/gemfire/IndexFactoryBeanTest.java b/src/test/java/org/springframework/data/gemfire/IndexFactoryBeanTest.java index 12121a04..4273285d 100644 --- a/src/test/java/org/springframework/data/gemfire/IndexFactoryBeanTest.java +++ b/src/test/java/org/springframework/data/gemfire/IndexFactoryBeanTest.java @@ -37,7 +37,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.concurrent.atomic.AtomicReference; -import org.apache.commons.logging.Log; import org.apache.geode.cache.Cache; import org.apache.geode.cache.client.ClientCache; import org.apache.geode.cache.query.Index; @@ -52,6 +51,7 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.slf4j.Logger; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.data.gemfire.config.xml.GemfireConstants; @@ -86,7 +86,7 @@ public class IndexFactoryBeanTest { private IndexFactoryBean indexFactoryBean; @Mock - private Log mockLog; + private Logger mockLogger; @Mock private QueryService mockQueryService; @@ -98,6 +98,7 @@ public class IndexFactoryBeanTest { @After public void tearDown() { + indexFactoryBean.setBeanFactory(null); indexFactoryBean.setCache(null); indexFactoryBean.setDefine(false); @@ -135,9 +136,10 @@ public class IndexFactoryBeanTest { private IndexFactoryBean newIndexFactoryBean() { IndexFactoryBean indexFactoryBean = spy(new IndexFactoryBean() { + @Override - protected Log newLog() { - return mockLog; + protected Logger newLog() { + return mockLogger; } }); @@ -732,7 +734,7 @@ public class IndexFactoryBeanTest { Index mockIndex = mockIndexWithDefinition("MockIndex", "id", "/Example", IndexType.PRIMARY_KEY); - when(mockLog.isWarnEnabled()).thenReturn(true); + when(mockLogger.isWarnEnabled()).thenReturn(true); when(mockQueryService.getIndexes()).thenReturn(Collections.singletonList(mockIndex)); @@ -755,7 +757,7 @@ public class IndexFactoryBeanTest { verify(indexFactoryBean, times(1)) .createKeyIndex(eq(mockQueryService), eq("TestIndex"), eq("id"), eq("/Example")); - verify(mockLog, times(1)).warn( + verify(mockLogger, times(1)).warn( eq(String.format("WARNING! You are choosing to ignore this Index [TestIndex] and return the existing Index" + " having the same basic definition [%s] but with a different name [MockIndex];" + " Make sure no OQL Query Hints refer to this Index by name [TestIndex]", @@ -773,7 +775,7 @@ public class IndexFactoryBeanTest { Index testIndex = mockIndexWithDefinition("TestIndex", "id", "/Example", IndexType.PRIMARY_KEY); - when(mockLog.isWarnEnabled()).thenReturn(true); + when(mockLogger.isWarnEnabled()).thenReturn(true); when(mockQueryService.getIndexes()).thenReturn(Collections.singletonList(mockIndex)); @@ -796,7 +798,7 @@ public class IndexFactoryBeanTest { verify(indexFactoryBean, times(2)) .createKeyIndex(eq(mockQueryService), eq("TestIndex"), eq("id"), eq("/Example")); - verify(mockLog, times(1)).warn( + verify(mockLogger, times(1)).warn( eq(String.format("WARNING! You are attempting to 'override' an existing Index [MockIndex]" + " having the same basic definition [%s] as the Index that will be created by this" + " IndexFactoryBean [TestIndex]; 'Override' effectively 'renames' the existing Index [MockIndex]" @@ -814,7 +816,7 @@ public class IndexFactoryBeanTest { Index mockIndex = mockIndexWithDefinition("MockIndex", "id", "/Example", IndexType.PRIMARY_KEY); - when(mockLog.isWarnEnabled()).thenReturn(true); + when(mockLogger.isWarnEnabled()).thenReturn(true); when(mockQueryService.getIndexes()).thenReturn(Collections.singletonList(mockIndex)) .thenReturn(Collections.emptyList()); @@ -858,7 +860,7 @@ public class IndexFactoryBeanTest { verify(indexFactoryBean, times(2)) .createKeyIndex(eq(mockQueryService), eq("TestIndex"), eq("id"), eq("/Example")); - verify(mockLog, times(1)).warn( + verify(mockLogger, times(1)).warn( eq(String.format("WARNING! You are attempting to 'override' an existing Index [MockIndex]" + " having the same basic definition [%s] as the Index that will be created by this" + " IndexFactoryBean [TestIndex]; 'Override' effectively 'renames' the existing Index [MockIndex]" @@ -918,7 +920,7 @@ public class IndexFactoryBeanTest { .createFunctionalIndex(eq(mockQueryService), eq("TestIndex"), eq("id"), eq("/Example"), eq(null)); - verifyZeroInteractions(mockLog); + verifyZeroInteractions(mockLogger); verify(mockQueryService, times(1)).getIndexes(); } @@ -966,7 +968,7 @@ public class IndexFactoryBeanTest { .createFunctionalIndex(eq(mockQueryService), eq("TestIndex"), eq("id"), eq("/Example"), eq(null)); - verifyZeroInteractions(mockLog); + verifyZeroInteractions(mockLogger); verify(mockQueryService, times(1)).getIndexes(); } @@ -1000,7 +1002,7 @@ public class IndexFactoryBeanTest { .createFunctionalIndex(eq(mockQueryService), eq("TestIndex"), eq("price"), eq("/Orders"), eq(null)); - verifyZeroInteractions(mockLog); + verifyZeroInteractions(mockLogger); verify(mockQueryService, times(1)).getIndexes(); } @@ -1011,7 +1013,7 @@ public class IndexFactoryBeanTest { Index mockIndex = mockIndexWithDefinition("TestIndex", "id", "/Orders", IndexType.PRIMARY_KEY); - when(mockLog.isWarnEnabled()).thenReturn(true); + when(mockLogger.isWarnEnabled()).thenReturn(true); when(mockQueryService.getIndexes()).thenReturn(Collections.singletonList(mockIndex)); @@ -1038,7 +1040,7 @@ public class IndexFactoryBeanTest { .createFunctionalIndex(eq(mockQueryService), eq("TestIndex"), eq("price"), eq("/Orders"), eq(null)); - verify(mockLog, times(1)).warn(String.format( + verify(mockLogger, times(1)).warn(String.format( "WARNING! Returning existing Index [TestIndex] having a definition [%1$s] that does not match" + " the Index defined [%2$s] by this IndexFactoryBean [TestIndex]", existingIndexDefinition, indexFactoryBean.toBasicIndexDefinition())); @@ -1082,7 +1084,7 @@ public class IndexFactoryBeanTest { verify(indexFactoryBean, times(1)) .createKeyIndex(eq(mockQueryService), eq("TestIndex"), eq("id"), eq("/Example")); - verifyZeroInteractions(mockLog); + verifyZeroInteractions(mockLogger); verify(mockQueryService, times(1)).getIndexes(); } @@ -1098,7 +1100,7 @@ public class IndexFactoryBeanTest { assertThat(mockIndex).isNotSameAs(testIndex); - when(mockLog.isWarnEnabled()).thenReturn(true); + when(mockLogger.isWarnEnabled()).thenReturn(true); when(mockQueryService.getIndexes()).thenReturn(Collections.singletonList(mockIndex)); @@ -1124,7 +1126,7 @@ public class IndexFactoryBeanTest { verify(indexFactoryBean, times(2)).createHashIndex(eq(mockQueryService), eq("TestIndex"), eq("purchaseDate"), eq("/Orders"), eq(null)); - verify(mockLog, times(1)).warn(eq(String.format( + verify(mockLogger, times(1)).warn(eq(String.format( "WARNING! Overriding existing Index [TestIndex] having a definition [%1$s] that does not match" + " the Index defined [%2$s] by this IndexFactoryBean [TestIndex]", existingIndexDefinition, indexFactoryBean.toBasicIndexDefinition()))); @@ -1139,7 +1141,7 @@ public class IndexFactoryBeanTest { mockIndexWithDefinition("MockIndex", "purchaseDate", "/Example", IndexType.HASH); - when(mockLog.isWarnEnabled()).thenReturn(true); + when(mockLogger.isWarnEnabled()).thenReturn(true); when(mockQueryService.getIndexes()).thenReturn(Collections.singletonList(mockIndex)) .thenReturn(Collections.emptyList()); @@ -1186,7 +1188,7 @@ public class IndexFactoryBeanTest { verify(indexFactoryBean, times(2)) .createKeyIndex(eq(mockQueryService), eq("MockIndex"), eq("id"), eq("/Example")); - verify(mockLog, times(1)).warn(eq(String.format( + verify(mockLogger, times(1)).warn(eq(String.format( "WARNING! Overriding existing Index [MockIndex] having a definition [%1$s] that does not match" + " the Index defined [%2$s] by this IndexFactoryBean [MockIndex]", existingIndexDefinition, indexFactoryBean.toBasicIndexDefinition()))); diff --git a/src/test/java/org/springframework/data/gemfire/config/support/DefinedIndexesApplicationListenerUnitTests.java b/src/test/java/org/springframework/data/gemfire/config/support/DefinedIndexesApplicationListenerUnitTests.java index 7df999c2..2a256c65 100644 --- a/src/test/java/org/springframework/data/gemfire/config/support/DefinedIndexesApplicationListenerUnitTests.java +++ b/src/test/java/org/springframework/data/gemfire/config/support/DefinedIndexesApplicationListenerUnitTests.java @@ -16,11 +16,11 @@ package org.springframework.data.gemfire.config.support; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Matchers.isA; -import static org.mockito.Matchers.startsWith; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isA; +import static org.mockito.ArgumentMatchers.startsWith; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; @@ -30,7 +30,6 @@ import static org.mockito.Mockito.when; import java.util.Collections; import java.util.HashMap; -import org.apache.commons.logging.Log; import org.apache.geode.cache.query.MultiIndexCreationException; import org.apache.geode.cache.query.QueryService; import org.junit.Before; @@ -38,6 +37,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import org.slf4j.Logger; import org.springframework.context.ApplicationContext; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.data.gemfire.config.xml.GemfireConstants; @@ -75,7 +75,7 @@ public class DefinedIndexesApplicationListenerUnitTests { } protected HashMap newHashMap(K key, V value) { - return new HashMap(Collections.singletonMap(key, value)); + return new HashMap<>(Collections.singletonMap(key, value)); } protected MultiIndexCreationException newMultiIndexCreationException(String key, Exception cause) { @@ -84,6 +84,7 @@ public class DefinedIndexesApplicationListenerUnitTests { @Test public void createDefinedIndexesCalledOnContextRefreshedEvent() throws Exception { + when(mockApplicationContext.containsBean(eq(QUERY_SERVICE_BEAN_NAME))).thenReturn(true); when(mockApplicationContext.getBean(eq(QUERY_SERVICE_BEAN_NAME), eq(QueryService.class))) .thenReturn(mockQueryService); @@ -98,6 +99,7 @@ public class DefinedIndexesApplicationListenerUnitTests { @Test public void createDefinedIndexesNotCalledOnContextRefreshedEvent() throws Exception { + when(mockApplicationContext.containsBean(eq(QUERY_SERVICE_BEAN_NAME))).thenReturn(false); listener.onApplicationEvent(mockEvent); @@ -110,16 +112,17 @@ public class DefinedIndexesApplicationListenerUnitTests { @Test public void createDefinedIndexesThrowingAnExceptionIsLogged() throws Exception { + when(mockApplicationContext.containsBean(eq(QUERY_SERVICE_BEAN_NAME))).thenReturn(true); when(mockApplicationContext.getBean(eq(QUERY_SERVICE_BEAN_NAME), eq(QueryService.class))) .thenReturn(mockQueryService); when(mockQueryService.createDefinedIndexes()) .thenThrow(newMultiIndexCreationException("TestKey", new RuntimeException("TEST"))); - final Log mockLog = mock(Log.class); + Logger mockLog = mock(Logger.class); DefinedIndexesApplicationListener listener = new DefinedIndexesApplicationListener() { - @Override Log initLogger() { + @Override Logger initLogger() { return mockLog; } }; diff --git a/src/test/java/org/springframework/data/gemfire/snapshot/SnapshotServiceFactoryBeanTest.java b/src/test/java/org/springframework/data/gemfire/snapshot/SnapshotServiceFactoryBeanTest.java index 90e7ee62..f992c0a9 100644 --- a/src/test/java/org/springframework/data/gemfire/snapshot/SnapshotServiceFactoryBeanTest.java +++ b/src/test/java/org/springframework/data/gemfire/snapshot/SnapshotServiceFactoryBeanTest.java @@ -27,9 +27,9 @@ import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.CoreMatchers.sameInstance; import static org.junit.Assert.assertThat; import static org.junit.Assume.assumeThat; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Matchers.isNull; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; @@ -49,7 +49,6 @@ import java.io.File; import java.io.IOException; import java.util.Arrays; -import org.apache.commons.logging.Log; import org.apache.geode.cache.Cache; import org.apache.geode.cache.Region; import org.apache.geode.cache.snapshot.CacheSnapshotService; @@ -62,6 +61,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.ArgumentMatchers; +import org.slf4j.Logger; import org.springframework.core.io.ClassPathResource; import org.springframework.data.gemfire.snapshot.event.ExportSnapshotApplicationEvent; import org.springframework.data.gemfire.snapshot.event.ImportSnapshotApplicationEvent; @@ -155,6 +155,7 @@ public class SnapshotServiceFactoryBeanTest { @After public void tearDown() { + factoryBean.setExports(null); factoryBean.setImports(null); factoryBean.setRegion(null); @@ -425,7 +426,7 @@ public class SnapshotServiceFactoryBeanTest { "MockSnapshotServiceAdapter"); SnapshotServiceFactoryBean factoryBean = new SnapshotServiceFactoryBean() { - @Override public SnapshotServiceAdapter getObject() throws Exception { + @Override public SnapshotServiceAdapter getObject() { return mockSnapshotService; } }; @@ -439,7 +440,7 @@ public class SnapshotServiceFactoryBeanTest { } @Test - public void onApplicationEventWhenMatchUsingEventSnapshotMetadataPerformsExport() throws Exception { + public void onApplicationEventWhenMatchUsingEventSnapshotMetadataPerformsExport() { Region mockRegion = mock(Region.class, "MockRegion"); @@ -456,7 +457,7 @@ public class SnapshotServiceFactoryBeanTest { when(mockSnapshotEvent.getSnapshotMetadata()).thenReturn(toArray(eventSnapshotMetadata)); SnapshotServiceFactoryBean factoryBean = new SnapshotServiceFactoryBean() { - @Override public SnapshotServiceAdapter getObject() throws Exception { + @Override public SnapshotServiceAdapter getObject() { return mockSnapshotService; } }; @@ -476,7 +477,7 @@ public class SnapshotServiceFactoryBeanTest { } @Test - public void onApplicationEventWhenMatchUsingFactorySnapshotMetadataPerformsImport() throws Exception { + public void onApplicationEventWhenMatchUsingFactorySnapshotMetadataPerformsImport() { SnapshotApplicationEvent mockSnapshotEvent = mock(ImportSnapshotApplicationEvent.class, "MockImportSnapshotApplicationEvent"); @@ -491,7 +492,7 @@ public class SnapshotServiceFactoryBeanTest { when(mockSnapshotEvent.getSnapshotMetadata()).thenReturn(null); SnapshotServiceFactoryBean factoryBean = new SnapshotServiceFactoryBean() { - @Override public SnapshotServiceAdapter getObject() throws Exception { + @Override public SnapshotServiceAdapter getObject() { return mockSnapshotService; } }; @@ -510,7 +511,7 @@ public class SnapshotServiceFactoryBeanTest { } @Test - public void onApplicationEventWhenNoMatchDoesNotPerformExport() throws Exception { + public void onApplicationEventWhenNoMatchDoesNotPerformExport() { SnapshotApplicationEvent mockSnapshotEvent = mock(ExportSnapshotApplicationEvent.class, "MockExportSnapshotApplicationEvent"); @@ -523,7 +524,7 @@ public class SnapshotServiceFactoryBeanTest { mock(SnapshotServiceAdapter.class, "MockSnapshotServiceAdapter"); SnapshotServiceFactoryBean factoryBean = new SnapshotServiceFactoryBean() { - @Override public SnapshotServiceAdapter getObject() throws Exception { + @Override public SnapshotServiceAdapter getObject() { return mockSnapshotService; } }; @@ -542,7 +543,7 @@ public class SnapshotServiceFactoryBeanTest { } @Test - public void onApplicationEventWhenNoMatchDoesNotPerformImport() throws Exception { + public void onApplicationEventWhenNoMatchDoesNotPerformImport() { Region mockRegion = mock(Region.class, "MockRegion"); @@ -557,7 +558,7 @@ public class SnapshotServiceFactoryBeanTest { when(mockSnapshotEvent.getSnapshotMetadata()).thenReturn(null); SnapshotServiceFactoryBean factoryBean = new SnapshotServiceFactoryBean() { - @Override public SnapshotServiceAdapter getObject() throws Exception { + @Override public SnapshotServiceAdapter getObject() { return mockSnapshotService; } }; @@ -1005,12 +1006,12 @@ public class SnapshotServiceFactoryBeanTest { @Test public void logDebugWhenDebugging() { - Log mockLog = mock(Log.class, "MockLog"); + Logger mockLog = mock(Logger.class, "MockLog"); when(mockLog.isDebugEnabled()).thenReturn(true); TestSnapshotServiceAdapter snapshotService = new TestSnapshotServiceAdapter() { - @Override Log createLog() { + @Override Logger createLog() { return mockLog; } }; @@ -1026,12 +1027,12 @@ public class SnapshotServiceFactoryBeanTest { @Test public void logDebugWhenNotDebugging() { - Log mockLog = mock(Log.class, "MockLog"); + Logger mockLog = mock(Logger.class, "MockLog"); when(mockLog.isDebugEnabled()).thenReturn(false); TestSnapshotServiceAdapter snapshotService = new TestSnapshotServiceAdapter() { - @Override Log createLog() { + @Override Logger createLog() { return mockLog; } }; @@ -1313,7 +1314,7 @@ public class SnapshotServiceFactoryBeanTest { } @Test - public void createSnapshotMetadataWithFileGemFireFormatAndNullFilter() throws Exception { + public void createSnapshotMetadataWithFileGemFireFormatAndNullFilter() { SnapshotMetadata snapshotMetadata = new SnapshotMetadata(snapshotDat, SnapshotFormat.GEMFIRE, null); diff --git a/src/test/java/org/springframework/data/gemfire/support/AbstractFactoryBeanSupportUnitTests.java b/src/test/java/org/springframework/data/gemfire/support/AbstractFactoryBeanSupportUnitTests.java index c0d30c86..ecdf90c4 100644 --- a/src/test/java/org/springframework/data/gemfire/support/AbstractFactoryBeanSupportUnitTests.java +++ b/src/test/java/org/springframework/data/gemfire/support/AbstractFactoryBeanSupportUnitTests.java @@ -25,13 +25,13 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import org.apache.commons.logging.Log; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.slf4j.Logger; import org.springframework.beans.factory.BeanFactory; /** @@ -49,7 +49,7 @@ import org.springframework.beans.factory.BeanFactory; public class AbstractFactoryBeanSupportUnitTests { @Mock - private Log mockLog; + private Logger mockLog; @Spy private TestFactoryBeanSupport factoryBeanSupport; @@ -61,6 +61,7 @@ public class AbstractFactoryBeanSupportUnitTests { @Test public void setAndGetBeanClassLoader() { + assertThat(factoryBeanSupport.getBeanClassLoader()).isNull(); ClassLoader mockClassLoader = mock(ClassLoader.class); @@ -82,6 +83,7 @@ public class AbstractFactoryBeanSupportUnitTests { @Test public void setAndGetBeanFactory() { + assertThat(factoryBeanSupport.getBeanFactory()).isNull(); BeanFactory mockBeanFactory = mock(BeanFactory.class); @@ -97,6 +99,7 @@ public class AbstractFactoryBeanSupportUnitTests { @Test public void setAndGetBeanName() { + assertThat(factoryBeanSupport.getBeanName()).isNullOrEmpty(); factoryBeanSupport.setBeanName("test"); @@ -115,6 +118,7 @@ public class AbstractFactoryBeanSupportUnitTests { @Test public void logsDebugWhenDebugIsEnabled() { + when(mockLog.isDebugEnabled()).thenReturn(true); factoryBeanSupport.logDebug("%s log test", "debug"); @@ -125,6 +129,7 @@ public class AbstractFactoryBeanSupportUnitTests { @Test public void logsInfoWhenInfoIsEnabled() { + when(mockLog.isInfoEnabled()).thenReturn(true); factoryBeanSupport.logInfo("%s log test", "info"); @@ -135,6 +140,7 @@ public class AbstractFactoryBeanSupportUnitTests { @Test public void logsWarningWhenWarnIsEnabled() { + when(mockLog.isWarnEnabled()).thenReturn(true); factoryBeanSupport.logWarning("%s log test", "warn"); @@ -145,6 +151,7 @@ public class AbstractFactoryBeanSupportUnitTests { @Test public void logsWarningWhenErrorIsEnabled() { + when(mockLog.isErrorEnabled()).thenReturn(true); factoryBeanSupport.logError("%s log test", "error"); @@ -155,6 +162,7 @@ public class AbstractFactoryBeanSupportUnitTests { @Test public void suppressesDebugLoggingWhenDebugIsDisabled() { + when(mockLog.isDebugEnabled()).thenReturn(false); factoryBeanSupport.logDebug(() -> "test"); @@ -165,6 +173,7 @@ public class AbstractFactoryBeanSupportUnitTests { @Test public void suppressesInfoLoggingWhenInfoIsDisabled() { + when(mockLog.isInfoEnabled()).thenReturn(false); factoryBeanSupport.logInfo(() -> "test"); @@ -175,6 +184,7 @@ public class AbstractFactoryBeanSupportUnitTests { @Test public void suppressesWarnLoggingWhenWarnIsDisabled() { + when(mockLog.isWarnEnabled()).thenReturn(false); factoryBeanSupport.logWarning(() -> "test"); @@ -185,6 +195,7 @@ public class AbstractFactoryBeanSupportUnitTests { @Test public void suppressesErrorLoggingWhenInfoIsDisabled() { + when(mockLog.isErrorEnabled()).thenReturn(false); factoryBeanSupport.logError(() -> "test"); @@ -196,7 +207,7 @@ public class AbstractFactoryBeanSupportUnitTests { private static class TestFactoryBeanSupport extends AbstractFactoryBeanSupport { @Override - public T getObject() throws Exception { + public T getObject() { return null; } diff --git a/src/test/java/org/springframework/data/gemfire/support/SpringContextBootstrappingInitializerTest.java b/src/test/java/org/springframework/data/gemfire/support/SpringContextBootstrappingInitializerTest.java index 6291c4e1..ec275eb6 100644 --- a/src/test/java/org/springframework/data/gemfire/support/SpringContextBootstrappingInitializerTest.java +++ b/src/test/java/org/springframework/data/gemfire/support/SpringContextBootstrappingInitializerTest.java @@ -45,10 +45,10 @@ import static org.mockito.Mockito.when; import java.util.Arrays; import java.util.Properties; -import org.apache.commons.logging.Log; import org.apache.geode.cache.Cache; import org.junit.After; import org.junit.Test; +import org.slf4j.Logger; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextException; import org.springframework.context.ApplicationListener; @@ -746,12 +746,12 @@ public class SpringContextBootstrappingInitializerTest { @Test(expected = IllegalStateException.class) public void testInitLogsErrors() throws Throwable { - Log mockLog = mock(Log.class, "testInitLogsErrors.MockLog"); + Logger mockLog = mock(Logger.class, "testInitLogsErrors.MockLog"); SpringContextBootstrappingInitializer initializer = new SpringContextBootstrappingInitializer() { @Override - protected Log initLogger() { + protected Logger initLogger() { return mockLog; } @@ -829,8 +829,9 @@ public class SpringContextBootstrappingInitializerTest { @Test public void onContextRefreshedApplicationEvent() { - TestApplicationListener testApplicationListener = new TestApplicationListener( - "testOnContextRefreshedApplicationEvent"); + + TestApplicationListener testApplicationListener = + new TestApplicationListener("testOnContextRefreshedApplicationEvent"); try { testApplicationListener = SpringContextBootstrappingInitializer.register(testApplicationListener); @@ -853,8 +854,9 @@ public class SpringContextBootstrappingInitializerTest { @Test public void onContextStartedApplicationEvent() { - TestApplicationListener testApplicationListener = new TestApplicationListener( - "testOnContextStartedApplicationEvent"); + + TestApplicationListener testApplicationListener = + new TestApplicationListener("testOnContextStartedApplicationEvent"); try { testApplicationListener = SpringContextBootstrappingInitializer.register(testApplicationListener); @@ -875,8 +877,9 @@ public class SpringContextBootstrappingInitializerTest { @Test public void onContextStoppedApplicationEvent() { - TestApplicationListener testApplicationListener = new TestApplicationListener( - "testOnContextStartedApplicationEvent"); + + TestApplicationListener testApplicationListener = + new TestApplicationListener("testOnContextStartedApplicationEvent"); try { testApplicationListener = SpringContextBootstrappingInitializer.register(testApplicationListener); @@ -904,6 +907,7 @@ public class SpringContextBootstrappingInitializerTest { @Test public void onApplicationEventWithMultipleRegisteredApplicationListeners() { + TestApplicationListener testApplicationListenerOne = new TestApplicationListener("TestApplicationListener.1"); TestApplicationListener testApplicationListenerTwo = new TestApplicationListener("TestApplicationListener.2"); @@ -940,6 +944,7 @@ public class SpringContextBootstrappingInitializerTest { @Test public void onApplicationEventWithNoRegisteredApplicationListener() { + TestApplicationListener testApplicationListener = new TestApplicationListener("TestApplicationListener"); try { @@ -960,6 +965,7 @@ public class SpringContextBootstrappingInitializerTest { @Test public void testNotifyOnExistingContextRefreshedEventBeforeApplicationContextExists() { + assertNull(SpringContextBootstrappingInitializer.contextRefreshedEvent); TestApplicationListener testApplicationListener = new TestApplicationListener( @@ -976,6 +982,7 @@ public class SpringContextBootstrappingInitializerTest { @Test public void testNotifyOnExistingContextRefreshedEventAfterContextRefreshed() { + ContextRefreshedEvent testContextRefreshedEvent = new ContextRefreshedEvent(mock(ApplicationContext.class)); new SpringContextBootstrappingInitializer().onApplicationEvent(testContextRefreshedEvent); @@ -994,6 +1001,7 @@ public class SpringContextBootstrappingInitializerTest { @Test public void testOnApplicationEventAndNotifyOnExistingContextRefreshedEvent() { + ConfigurableApplicationContext mockApplicationContext = mock(ConfigurableApplicationContext.class, "testOnApplicationEventAndNotifyOnExistingContextRefreshedEvent"); @@ -1065,12 +1073,10 @@ public class SpringContextBootstrappingInitializerTest { } @Configuration - protected static class TestAppConfigOne { - } + protected static class TestAppConfigOne { } @Configuration - protected static class TestAppConfigTwo { - } + protected static class TestAppConfigTwo { } // TODO add additional multi-threaded test cases once MultithreadedTC test framework is added to the SDP project // in order to properly test concurrency of notification and registration during Spring ApplicationContext creation. diff --git a/src/test/java/org/springframework/data/gemfire/test/GemfireTestApplicationContextInitializer.java b/src/test/java/org/springframework/data/gemfire/test/GemfireTestApplicationContextInitializer.java index 3a33c5a5..2ff5fc9e 100644 --- a/src/test/java/org/springframework/data/gemfire/test/GemfireTestApplicationContextInitializer.java +++ b/src/test/java/org/springframework/data/gemfire/test/GemfireTestApplicationContextInitializer.java @@ -13,8 +13,8 @@ package org.springframework.data.gemfire.test; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.util.StringUtils; @@ -33,18 +33,19 @@ public class GemfireTestApplicationContextInitializer implements ApplicationCont public static final String GEMFIRE_TEST_RUNNER_DISABLED = "org.springframework.data.gemfire.test.GemfireTestRunner.nomock"; - protected final Log log = LogFactory.getLog(getClass()); + protected final Logger logger = LoggerFactory.getLogger(getClass()); /** * {@inheritDoc} */ @Override public void initialize(ConfigurableApplicationContext applicationContext) { + String gemfireTestRunnerDisabled = System.getProperty(GEMFIRE_TEST_RUNNER_DISABLED, Boolean.FALSE.toString()); if (isGemFireTestRunnerDisabled(gemfireTestRunnerDisabled)) { - log.warn(String.format("WARNING - Mocks disabled; Using real GemFire components (%1$s = %2$s)", - GEMFIRE_TEST_RUNNER_DISABLED, gemfireTestRunnerDisabled)); + logger.warn("WARNING - Mocks disabled; Using real GemFire components [{} = {}]", + GEMFIRE_TEST_RUNNER_DISABLED, gemfireTestRunnerDisabled); } else { applicationContext.getBeanFactory().addBeanPostProcessor(new GemfireTestBeanPostProcessor()); diff --git a/src/test/java/org/springframework/data/gemfire/test/GemfireTestBeanPostProcessor.java b/src/test/java/org/springframework/data/gemfire/test/GemfireTestBeanPostProcessor.java index 685e74bf..0d83bf33 100644 --- a/src/test/java/org/springframework/data/gemfire/test/GemfireTestBeanPostProcessor.java +++ b/src/test/java/org/springframework/data/gemfire/test/GemfireTestBeanPostProcessor.java @@ -12,8 +12,8 @@ */ package org.springframework.data.gemfire.test; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.data.gemfire.CacheFactoryBean; @@ -26,7 +26,7 @@ import org.springframework.data.gemfire.server.CacheServerFactoryBean; */ public class GemfireTestBeanPostProcessor implements BeanPostProcessor { - private static Log logger = LogFactory.getLog(GemfireTestBeanPostProcessor.class); + private static Logger logger = LoggerFactory.getLogger(GemfireTestBeanPostProcessor.class); /* * (non-Javadoc) @@ -34,15 +34,17 @@ public class GemfireTestBeanPostProcessor implements BeanPostProcessor { */ @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { + if (bean instanceof CacheFactoryBean) { + String beanTypeName = bean.getClass().getName(); bean = (bean instanceof ClientCacheFactoryBean ? new MockClientCacheFactoryBean((ClientCacheFactoryBean) bean) : new MockCacheFactoryBean((CacheFactoryBean) bean)); - logger.info(String.format("Replacing the [%1$s] bean definition having type [%2$s] with mock [%3$s]...", - beanName, beanTypeName, bean.getClass().getName())); + logger.info("Replacing the [{}] bean definition having type [{}] with mock [{}]...", + beanName, beanTypeName, bean.getClass().getName()); } else if (bean instanceof CacheServerFactoryBean) { ((CacheServerFactoryBean) bean).setCache(new StubCache()); @@ -59,5 +61,4 @@ public class GemfireTestBeanPostProcessor implements BeanPostProcessor { public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { return bean; } - }