SGF-833 - Switch from Apache Commons Logging to SLF4J.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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<K> 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<K> 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<K> 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<K> 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<K> 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -98,7 +98,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
|
||||
@@ -192,14 +192,14 @@ public abstract class AbstractAnnotationConfigSupport
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance of {@link Log} to log statements printed by SDG.
|
||||
* 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());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -491,12 +491,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;
|
||||
}
|
||||
|
||||
@@ -521,7 +521,7 @@ public abstract class AbstractAnnotationConfigSupport
|
||||
*/
|
||||
protected void logDebug(Supplier<String> message) {
|
||||
Optional.ofNullable(getLog())
|
||||
.filter(Log::isDebugEnabled)
|
||||
.filter(Logger::isDebugEnabled)
|
||||
.ifPresent(log -> log.debug(message.get()));
|
||||
}
|
||||
|
||||
@@ -546,7 +546,7 @@ public abstract class AbstractAnnotationConfigSupport
|
||||
*/
|
||||
protected void logInfo(Supplier<String> message) {
|
||||
Optional.ofNullable(getLog())
|
||||
.filter(Log::isInfoEnabled)
|
||||
.filter(Logger::isInfoEnabled)
|
||||
.ifPresent(log -> log.info(message.get()));
|
||||
}
|
||||
|
||||
@@ -571,7 +571,7 @@ public abstract class AbstractAnnotationConfigSupport
|
||||
*/
|
||||
protected void logWarning(Supplier<String> message) {
|
||||
Optional.ofNullable(getLog())
|
||||
.filter(Log::isWarnEnabled)
|
||||
.filter(Logger::isWarnEnabled)
|
||||
.ifPresent(log -> log.info(message.get()));
|
||||
}
|
||||
|
||||
@@ -596,7 +596,7 @@ public abstract class AbstractAnnotationConfigSupport
|
||||
*/
|
||||
protected void logError(Supplier<String> message) {
|
||||
Optional.ofNullable(getLog())
|
||||
.filter(Log::isWarnEnabled)
|
||||
.filter(Logger::isWarnEnabled)
|
||||
.ifPresent(log -> log.info(message.get()));
|
||||
}
|
||||
|
||||
@@ -796,6 +796,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> T requireProperty(String propertyName, Class<T> type) {
|
||||
|
||||
return Optional.of(propertyName)
|
||||
|
||||
@@ -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<String> {
|
||||
private Set<TypeFilter> excludes = new HashSet<>();
|
||||
private Set<TypeFilter> includes = new HashSet<>();
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private final Set<String> basePackages;
|
||||
|
||||
@@ -210,7 +210,7 @@ public class GemFireComponentClassTypeScanner implements Iterable<String> {
|
||||
|
||||
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<String> {
|
||||
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<String> {
|
||||
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<TypeFilter> 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<TypeFilter> includes) {
|
||||
stream(nullSafeIterable(includes).spliterator(), false).forEach(this.includes::add);
|
||||
return this;
|
||||
|
||||
@@ -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<ContextRefreshedEvent> {
|
||||
|
||||
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<Co
|
||||
queryService.createDefinedIndexes();
|
||||
}
|
||||
catch (MultiIndexCreationException cause) {
|
||||
logger.warn(String.format("Failed to create pre-defined Indexes: %s", cause.getMessage()), cause);
|
||||
logger.warn("Failed to create pre-defined Indexes: {}", cause.getMessage(), cause);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
Log initLogger() {
|
||||
return LogFactory.getLog(getClass());
|
||||
Logger initLogger() {
|
||||
return LoggerFactory.getLogger(getClass());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private QueryService getQueryService(ContextRefreshedEvent event) {
|
||||
|
||||
ApplicationContext applicationContext = event.getApplicationContext();
|
||||
@@ -85,7 +83,6 @@ public class DefinedIndexesApplicationListener implements ApplicationListener<Co
|
||||
? applicationContext.getBean(queryServiceBeanName, QueryService.class) : null);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private String getQueryServiceBeanName() {
|
||||
return GemfireConstants.DEFAULT_GEMFIRE_INDEX_DEFINITION_QUERY_SERVICE;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.data.gemfire.config.support;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
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.DiskStoreFactoryBean.DiskDir;
|
||||
@@ -40,7 +40,7 @@ import org.springframework.util.ObjectUtils;
|
||||
@SuppressWarnings("unused")
|
||||
public class DiskStoreDirectoryBeanPostProcessor implements BeanPostProcessor {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -48,9 +48,9 @@ public class DiskStoreDirectoryBeanPostProcessor implements BeanPostProcessor {
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("Processing Bean [%1$s] of Type [%2$s] with Name [%3$s] before initialization%n",
|
||||
bean, ObjectUtils.nullSafeClassName(bean), beanName));
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Processing Bean [{}] of Type [{}] with Name [{}] before initialization%n",
|
||||
bean, ObjectUtils.nullSafeClassName(bean), beanName);
|
||||
}
|
||||
|
||||
if (bean instanceof DiskDir) {
|
||||
@@ -70,8 +70,8 @@ public class DiskStoreDirectoryBeanPostProcessor implements BeanPostProcessor {
|
||||
Assert.isTrue(diskDirectoryFile.isDirectory() || diskDirectoryFile.mkdirs(),
|
||||
String.format("Failed to create Disk Directory [%s]%n", location));
|
||||
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info(String.format("Disk Directory is @ Location [%s].%n", location));
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Disk Directory is @ Location [{}].%n", location);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
|
||||
import org.apache.geode.cache.wan.GatewaySender;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.PropertyValue;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
@@ -49,7 +49,7 @@ import org.w3c.dom.Element;
|
||||
*/
|
||||
abstract class AbstractRegionParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
||||
@@ -17,10 +17,10 @@ package org.springframework.data.gemfire.function;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -37,16 +37,17 @@ import org.springframework.util.CollectionUtils;
|
||||
*/
|
||||
public class FunctionServiceFactoryBean implements FactoryBean<FunctionService>, InitializingBean {
|
||||
|
||||
private static Log logger = LogFactory.getLog(FunctionServiceFactoryBean.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(FunctionServiceFactoryBean.class);
|
||||
|
||||
private List<Function> 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);
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<CqQuery> 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<QueryString, Predicates> {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(GemfireQueryCreator.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(GemfireQueryCreator.class);
|
||||
|
||||
private Iterator<Integer> indexes;
|
||||
|
||||
@@ -106,8 +106,8 @@ class GemfireQueryCreator extends AbstractQueryCreator<QueryString, Predicates>
|
||||
|
||||
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<QueryString, Predicates>
|
||||
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();
|
||||
|
||||
@@ -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<String> 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;
|
||||
|
||||
@@ -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<K, V> extends AbstractFactoryBeanSupport
|
||||
|
||||
private SnapshotServiceAdapter<K, V> snapshotServiceAdapter;
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@SuppressWarnings("unchecked")
|
||||
static <K, V> SnapshotMetadata<K, V>[] nullSafeArray(SnapshotMetadata<K, V>[] 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<K, V> 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<K, V> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<T>
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
private final Log log;
|
||||
private final Logger log;
|
||||
|
||||
private String beanName;
|
||||
|
||||
@@ -66,14 +66,14 @@ public abstract class AbstractFactoryBeanSupport<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance of {@link Log} to log statements printed by SDG.
|
||||
* 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<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<T>
|
||||
*/
|
||||
protected void logDebug(Supplier<String> message) {
|
||||
Optional.ofNullable(getLog())
|
||||
.filter(Log::isDebugEnabled)
|
||||
.filter(Logger::isDebugEnabled)
|
||||
.ifPresent(log -> log.debug(message.get()));
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ public abstract class AbstractFactoryBeanSupport<T>
|
||||
*/
|
||||
protected void logInfo(Supplier<String> message) {
|
||||
Optional.ofNullable(getLog())
|
||||
.filter(Log::isInfoEnabled)
|
||||
.filter(Logger::isInfoEnabled)
|
||||
.ifPresent(log -> log.info(message.get()));
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ public abstract class AbstractFactoryBeanSupport<T>
|
||||
*/
|
||||
protected void logWarning(Supplier<String> message) {
|
||||
Optional.ofNullable(getLog())
|
||||
.filter(Log::isWarnEnabled)
|
||||
.filter(Logger::isWarnEnabled)
|
||||
.ifPresent(log -> log.warn(message.get()));
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ public abstract class AbstractFactoryBeanSupport<T>
|
||||
*/
|
||||
protected void logError(Supplier<String> message) {
|
||||
Optional.ofNullable(getLog())
|
||||
.filter(Log::isErrorEnabled)
|
||||
.filter(Logger::isErrorEnabled)
|
||||
.ifPresent(log -> log.error(message.get()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String> associatedBeanNameWithAliases = Collections.emptySet();
|
||||
|
||||
|
||||
@@ -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<Class<?>> 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<Class<?>> annotatedClasses, String[] basePackages,
|
||||
|
||||
@@ -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<T>
|
||||
|
||||
protected final Cache cache;
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
protected Object factory;
|
||||
|
||||
|
||||
@@ -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())));
|
||||
|
||||
@@ -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 <K, V> HashMap<K, V> newHashMap(K key, V value) {
|
||||
return new HashMap<K, V>(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;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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<T> extends AbstractFactoryBeanSupport<T> {
|
||||
|
||||
@Override
|
||||
public T getObject() throws Exception {
|
||||
public T getObject() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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,7 +33,7 @@ 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}
|
||||
@@ -44,8 +44,8 @@ public class GemfireTestApplicationContextInitializer implements ApplicationCont
|
||||
String gemfireTestRunnerDisabled = System.getProperty(GEMFIRE_TEST_RUNNER_DISABLED, Boolean.FALSE.toString());
|
||||
|
||||
if (isGemFireTestRunnerDisabled(gemfireTestRunnerDisabled)) {
|
||||
log.warn(String.format("WARNING - Mocks disabled; Using real Pivotal GemFire objects [%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());
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user