Adapt to API in Spring Data Kay.
This commit is contained in:
@@ -19,7 +19,6 @@ package org.springframework.data.gemfire.tests.integration.config;
|
||||
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeMap;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@@ -40,12 +39,7 @@ import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Condition;
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
import org.springframework.data.gemfire.client.ClientCacheFactoryBean;
|
||||
import org.springframework.data.gemfire.client.ClientRegionFactoryBean;
|
||||
import org.springframework.data.gemfire.client.ClientRegionShortcutWrapper;
|
||||
import org.springframework.data.gemfire.client.PoolFactoryBean;
|
||||
@@ -53,7 +47,6 @@ import org.springframework.data.gemfire.config.xml.GemfireConstants;
|
||||
import org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer;
|
||||
import org.springframework.data.gemfire.tests.integration.ClientServerIntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.util.ObjectUtils;
|
||||
import org.springframework.data.gemfire.util.ArrayUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -137,29 +130,6 @@ public class SubscriptionEnabledClientServerIntegrationTestsConfiguration
|
||||
return Math.max(timeout != null ? timeout : DEFAULT_TIMEOUT, 0);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Conditional(ClientCacheFactoryBeanSetSocketConnectTimeoutPresentCondition.class)
|
||||
BeanPostProcessor clientCachePoolSocketConnectTimeoutBeanPostProcessor() {
|
||||
|
||||
return new BeanPostProcessor() {
|
||||
|
||||
@Nullable @Override @SuppressWarnings("all")
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
|
||||
if (bean instanceof ClientCacheFactoryBean) {
|
||||
((ClientCacheFactoryBean) bean).setSocketConnectTimeout(
|
||||
Long.valueOf(resolveSocketConnectTimeout()).intValue());
|
||||
}
|
||||
else if (bean instanceof PoolFactoryBean) {
|
||||
((PoolFactoryBean) bean).setSocketConnectTimeout(
|
||||
Long.valueOf(resolveSocketConnectTimeout()).intValue());
|
||||
}
|
||||
|
||||
return bean;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
BeanPostProcessor clientServerReadyBeanPostProcessor(ListableBeanFactory beanFactory,
|
||||
@Value("${" + GEMFIRE_CACHE_SERVER_PORT_PROPERTY + ":40404}") int port) {
|
||||
@@ -304,15 +274,4 @@ public class SubscriptionEnabledClientServerIntegrationTestsConfiguration
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static class ClientCacheFactoryBeanSetSocketConnectTimeoutPresentCondition implements Condition {
|
||||
|
||||
@Override @SuppressWarnings("all")
|
||||
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
|
||||
|
||||
return Arrays.stream(ArrayUtils.nullSafeArray(ClientCacheFactoryBean.class.getMethods(), Method.class))
|
||||
.map(Method::getName)
|
||||
.anyMatch("setSocketConnectTimeout"::equals);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,6 @@ import org.apache.geode.cache.lucene.LuceneIndexFactory;
|
||||
import org.apache.geode.cache.lucene.LuceneQuery;
|
||||
import org.apache.geode.cache.lucene.LuceneQueryFactory;
|
||||
import org.apache.geode.cache.lucene.LuceneQueryProvider;
|
||||
import org.apache.geode.cache.lucene.LuceneSerializer;
|
||||
import org.apache.geode.cache.lucene.LuceneService;
|
||||
import org.apache.geode.cache.query.CqAttributes;
|
||||
import org.apache.geode.cache.query.CqQuery;
|
||||
@@ -180,7 +179,6 @@ import org.springframework.util.StringUtils;
|
||||
* @see org.apache.geode.cache.lucene.LuceneQuery
|
||||
* @see org.apache.geode.cache.lucene.LuceneQueryFactory
|
||||
* @see org.apache.geode.cache.lucene.LuceneQueryProvider
|
||||
* @see org.apache.geode.cache.lucene.LuceneSerializer
|
||||
* @see org.apache.geode.cache.lucene.LuceneService
|
||||
* @see org.apache.geode.cache.query.CqAttributes
|
||||
* @see org.apache.geode.cache.query.CqQuery
|
||||
@@ -1921,8 +1919,6 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
|
||||
|
||||
LuceneIndexFactory mockLuceneIndexFactory = mock(LuceneIndexFactory.class);
|
||||
|
||||
AtomicReference<LuceneSerializer> luceneSerializerReference = new AtomicReference<>(null);
|
||||
|
||||
Map<String, Analyzer> fieldAnalyzers = new ConcurrentHashMap<>();
|
||||
|
||||
Set<String> fields = new CopyOnWriteArraySet<>();
|
||||
@@ -1970,21 +1966,6 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
|
||||
return mockLuceneIndexFactory;
|
||||
});
|
||||
|
||||
when(mockLuceneIndexFactory.setLuceneSerializer(any(LuceneSerializer.class))).thenAnswer(invocation -> {
|
||||
|
||||
Optional.ofNullable(invocation.<LuceneSerializer>getArgument(0))
|
||||
.map(luceneSerializer -> {
|
||||
luceneSerializerReference.set(luceneSerializer);
|
||||
return luceneSerializer;
|
||||
})
|
||||
.orElseGet(() -> {
|
||||
luceneSerializerReference.set(null);
|
||||
return null;
|
||||
});
|
||||
|
||||
return mockLuceneIndexFactory;
|
||||
});
|
||||
|
||||
doAnswer(invocation -> {
|
||||
|
||||
String indexName = invocation.getArgument(0);
|
||||
@@ -1996,7 +1977,6 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
|
||||
|
||||
when(mockLuceneIndex.getFieldAnalyzers()).thenReturn(Collections.unmodifiableMap(fieldAnalyzers));
|
||||
when(mockLuceneIndex.getFieldNames()).thenAnswer(in -> fields.toArray(new String[fields.size()]));
|
||||
when(mockLuceneIndex.getLuceneSerializer()).thenAnswer(in -> luceneSerializerReference.get());
|
||||
when(mockLuceneIndex.getName()).thenReturn(indexName);
|
||||
when(mockLuceneIndex.getRegionPath()).thenReturn(regionPath);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user