SGF-416 - Remove deprecated code associated with syncing GemFire properties between the ClientCache and Pool.
(cherry picked from commit a0c5ecad62917ccb71e856dae8e3743641f7d76e) Signed-off-by: John Blum <jblum@pivotal.io>
This commit is contained in:
@@ -119,7 +119,7 @@ class CacheParser extends AbstractSingleBeanDefinitionParser {
|
||||
/* (non-Javadoc) */
|
||||
void registerGemFireBeanFactoryPostProcessors(BeanDefinitionRegistry registry) {
|
||||
BeanDefinitionReaderUtils.registerWithGeneratedName(BeanDefinitionBuilder.genericBeanDefinition(
|
||||
CustomEditorRegistrationBeanFactoryPostProcessor.class).getBeanDefinition(), registry);
|
||||
CustomEditorRegisteringBeanFactoryPostProcessor.class).getBeanDefinition(), registry);
|
||||
}
|
||||
|
||||
private void parsePdxDiskStore(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.PropertyValue;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.data.gemfire.client.ClientCacheFactoryBean;
|
||||
import org.springframework.data.gemfire.client.PoolFactoryBean;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* The ClientCachePoolGemfirePropertiesSyncingBeanFactoryPostProcessor class is a Spring {@link BeanFactoryPostProcessor}
|
||||
* implementation responsible for making sure the GemFire {@link java.util.Properties} between the GemFire ClientCache
|
||||
* and GemFire Pool are identical.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.config.BeanDefinition
|
||||
* @see org.springframework.beans.factory.config.BeanFactoryPostProcessor
|
||||
* @see org.springframework.beans.factory.config.ConfigurableListableBeanFactory
|
||||
* @see org.springframework.data.gemfire.client.ClientCacheFactoryBean
|
||||
* @see org.springframework.data.gemfire.client.PoolFactoryBean
|
||||
* @since 1.8.0
|
||||
*/
|
||||
@Deprecated
|
||||
class ClientCachePoolGemfirePropertiesSyncingBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
|
||||
|
||||
protected static final String PROPERTIES_PROPERTY_NAME = "properties";
|
||||
|
||||
/**
|
||||
* Post processes the given {@link ConfigurableListableBeanFactory} by syncing the gemfire.properties used
|
||||
* to configure the GemFire Distributed System constructed by the {@link PoolFactoryBean} during Pool creation
|
||||
* and resolved by the {@link ClientCacheFactoryBean} during ClientCache creation.
|
||||
*
|
||||
* @param beanFactory the {@link ConfigurableListableBeanFactory} to post process.
|
||||
* @throws BeansException if errors occur during post processing.
|
||||
* @see org.springframework.beans.factory.config.ConfigurableListableBeanFactory
|
||||
*/
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
BeanDefinition poolFactoryBeanDefinition = null;
|
||||
String gemfirePropertiesBeanName = null;
|
||||
|
||||
for (String beanName : beanFactory.getBeanDefinitionNames()) {
|
||||
BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName);
|
||||
|
||||
if (ClientCacheFactoryBean.class.getName().equals(beanDefinition.getBeanClassName())) {
|
||||
PropertyValue gemfirePropertiesPropertyValue = beanDefinition.getPropertyValues()
|
||||
.getPropertyValue(PROPERTIES_PROPERTY_NAME);
|
||||
|
||||
gemfirePropertiesBeanName = (gemfirePropertiesPropertyValue != null
|
||||
? ((RuntimeBeanReference) gemfirePropertiesPropertyValue.getValue()).getBeanName() : null);
|
||||
}
|
||||
else if (PoolFactoryBean.class.getName().equals(beanDefinition.getBeanClassName())) {
|
||||
poolFactoryBeanDefinition = beanDefinition;
|
||||
}
|
||||
}
|
||||
|
||||
if (poolFactoryBeanDefinition != null && StringUtils.hasText(gemfirePropertiesBeanName)) {
|
||||
poolFactoryBeanDefinition.getPropertyValues().add(PROPERTIES_PROPERTY_NAME,
|
||||
new RuntimeBeanReference(gemfirePropertiesBeanName));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -47,20 +47,23 @@ import com.gemstone.gemfire.cache.Scope;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
|
||||
/**
|
||||
* The CustomEditorRegistrationBeanFactoryPostProcessor class is a Spring BeanFactoryPostProcessor used to register
|
||||
* custom GemFire JavaBeans PropertyEditors and Spring Converters that are used to perform type conversions between
|
||||
* String-based configuration meta-data and actual GemFire or SDG defined enumerated types.
|
||||
* The CustomEditorRegisteringBeanFactoryPostProcessor class is a Spring {@link BeanFactoryPostProcessor} used
|
||||
* to register custom GemFire-specific JavaBeans {@link java.beans.PropertyEditor}s and Spring {@link Converter}s
|
||||
* that are used to perform type conversions between String-based configuration meta-data and actual GemFire
|
||||
* or Spring Data GemFire defined enumerated types.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.config.BeanFactoryPostProcessor
|
||||
* @see org.springframework.beans.factory.config.ConfigurableListableBeanFactory
|
||||
* @since 1.6.0
|
||||
*/
|
||||
@SuppressWarnings({ "deprecation", "unused" })
|
||||
public class CustomEditorRegistrationBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
|
||||
class CustomEditorRegisteringBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@Override
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
beanFactory.registerCustomEditor(ConnectionEndpoint[].class, ConnectionEndpointArrayToIterableConverter.class);
|
||||
//beanFactory.registerCustomEditor(ConnectionEndpoint[].class, ConnectionEndpointArrayToIterableConverter.class);
|
||||
beanFactory.registerCustomEditor(EvictionAction.class, EvictionActionConverter.class);
|
||||
beanFactory.registerCustomEditor(EvictionPolicyType.class, EvictionPolicyConverter.class);
|
||||
beanFactory.registerCustomEditor(ExpirationAction.class, ExpirationActionConverter.class);
|
||||
@@ -73,7 +76,8 @@ public class CustomEditorRegistrationBeanFactoryPostProcessor implements BeanFac
|
||||
beanFactory.registerCustomEditor(SubscriptionEvictionPolicy.class, SubscriptionEvictionPolicyConverter.class);
|
||||
}
|
||||
|
||||
static final class ConnectionEndpointArrayToIterableConverter extends PropertyEditorSupport
|
||||
/* (non-Javadoc) */
|
||||
public static class ConnectionEndpointArrayToIterableConverter extends PropertyEditorSupport
|
||||
implements Converter<ConnectionEndpoint[], Iterable> {
|
||||
|
||||
@Override
|
||||
@@ -35,6 +35,8 @@ import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.data.gemfire.GemfireQueryException;
|
||||
import org.springframework.data.gemfire.GemfireUtils;
|
||||
import org.springframework.data.gemfire.client.support.DefaultableDelegatingPoolAdapter;
|
||||
import org.springframework.data.gemfire.client.support.DelegatingPoolAdapter;
|
||||
import org.springframework.data.gemfire.config.GemfireConstants;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
@@ -108,6 +110,9 @@ public class ContinuousQueryListenerContainer implements BeanFactoryAware, BeanN
|
||||
initQueryService(eagerlyInitializePool(resolvePoolName()));
|
||||
initExecutor();
|
||||
initContinuousQueries(continuousQueryDefinitions);
|
||||
|
||||
Assert.state(queryService != null, "QueryService was not properly initialized");
|
||||
|
||||
initialized = true;
|
||||
|
||||
if (isAutoStartup()) {
|
||||
@@ -145,8 +150,9 @@ public class ContinuousQueryListenerContainer implements BeanFactoryAware, BeanN
|
||||
|
||||
/* (non-Javadoc) */
|
||||
QueryService initQueryService(String poolName) {
|
||||
if (queryService == null) {
|
||||
queryService = PoolManager.find(poolName).getQueryService();
|
||||
if (queryService == null || StringUtils.hasText(poolName)) {
|
||||
queryService = DefaultableDelegatingPoolAdapter.from(DelegatingPoolAdapter.from(
|
||||
PoolManager.find(poolName))).preferPool().getQueryService(queryService);
|
||||
}
|
||||
|
||||
return queryService;
|
||||
|
||||
@@ -1,159 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.data.gemfire.client.ClientCacheFactoryBean;
|
||||
import org.springframework.data.gemfire.client.PoolFactoryBean;
|
||||
|
||||
/**
|
||||
* The ClientCachePoolGemfirePropertiesSyncingBeanFactoryPostProcessorTest class is a test suite of test cases testing
|
||||
* the contract and functionality of the ClientCachePoolGemfirePropertiesSyncingBeanFactoryPostProcessor class.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.junit.runner.RunWith
|
||||
* @see org.mockito.Mock
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.mockito.runners.MockitoJUnitRunner
|
||||
* @see org.springframework.data.gemfire.config.ClientCachePoolGemfirePropertiesSyncingBeanFactoryPostProcessor
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ClientCachePoolGemfirePropertiesSyncingBeanFactoryPostProcessorTest {
|
||||
|
||||
protected static final String PROPERTIES_PROPERTY_NAME_SHORTCUT =
|
||||
ClientCachePoolGemfirePropertiesSyncingBeanFactoryPostProcessor.PROPERTIES_PROPERTY_NAME;
|
||||
|
||||
private ClientCachePoolGemfirePropertiesSyncingBeanFactoryPostProcessor beanFactoryPostProcessor =
|
||||
new ClientCachePoolGemfirePropertiesSyncingBeanFactoryPostProcessor();
|
||||
|
||||
@Mock
|
||||
private ConfigurableListableBeanFactory mockBeanFactory;
|
||||
|
||||
protected String getBeanReference(Object reference) {
|
||||
return (reference instanceof RuntimeBeanReference ? ((RuntimeBeanReference) reference).getBeanName() : null);
|
||||
}
|
||||
|
||||
protected BeanDefinition newBeanDefinition(Class<?> type) {
|
||||
return BeanDefinitionBuilder.genericBeanDefinition(type).getBeanDefinition();
|
||||
}
|
||||
|
||||
protected <T> T[] toArray(T... array) {
|
||||
return array;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postProcessSyncsGemfireProperties() {
|
||||
BeanDefinition objectBean = newBeanDefinition(Object.class);
|
||||
BeanDefinition clientCacheBean = newBeanDefinition(ClientCacheFactoryBean.class);
|
||||
|
||||
clientCacheBean.getPropertyValues().addPropertyValue(PROPERTIES_PROPERTY_NAME_SHORTCUT,
|
||||
new RuntimeBeanReference("gemfireProperties"));
|
||||
|
||||
BeanDefinition poolBean = newBeanDefinition(PoolFactoryBean.class);
|
||||
|
||||
when(mockBeanFactory.getBeanDefinitionNames()).thenReturn(toArray("objectBean", "clientCacheBean", "poolBean"));
|
||||
when(mockBeanFactory.getBeanDefinition(eq("objectBean"))).thenReturn(objectBean);
|
||||
when(mockBeanFactory.getBeanDefinition(eq("clientCacheBean"))).thenReturn(clientCacheBean);
|
||||
when(mockBeanFactory.getBeanDefinition(eq("poolBean"))).thenReturn(poolBean);
|
||||
|
||||
assertThat(poolBean.getPropertyValues().getPropertyValue(PROPERTIES_PROPERTY_NAME_SHORTCUT), is(nullValue()));
|
||||
|
||||
beanFactoryPostProcessor.postProcessBeanFactory(mockBeanFactory);
|
||||
|
||||
assertThat(getBeanReference(poolBean.getPropertyValues().getPropertyValue(PROPERTIES_PROPERTY_NAME_SHORTCUT).getValue()),
|
||||
is(equalTo("gemfireProperties")));
|
||||
|
||||
verify(mockBeanFactory, times(1)).getBeanDefinitionNames();
|
||||
verify(mockBeanFactory, times(1)).getBeanDefinition(eq("objectBean"));
|
||||
verify(mockBeanFactory, times(1)).getBeanDefinition(eq("clientCacheBean"));
|
||||
verify(mockBeanFactory, times(1)).getBeanDefinition(eq("poolBean"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postProcessDoesNotSyncGemfirePropertiesWhenNoClientCacheFactoryBeanIsDeclared() {
|
||||
BeanDefinition poolBean = newBeanDefinition(PoolFactoryBean.class);
|
||||
|
||||
when(mockBeanFactory.getBeanDefinitionNames()).thenReturn(toArray("poolBean"));
|
||||
when(mockBeanFactory.getBeanDefinition(eq("poolBean"))).thenReturn(poolBean);
|
||||
|
||||
assertThat(poolBean.getPropertyValues().getPropertyValue(PROPERTIES_PROPERTY_NAME_SHORTCUT), is(nullValue()));
|
||||
|
||||
beanFactoryPostProcessor.postProcessBeanFactory(mockBeanFactory);
|
||||
|
||||
assertThat(poolBean.getPropertyValues().getPropertyValue(PROPERTIES_PROPERTY_NAME_SHORTCUT), is(nullValue()));
|
||||
|
||||
verify(mockBeanFactory, times(1)).getBeanDefinitionNames();
|
||||
verify(mockBeanFactory, times(1)).getBeanDefinition(eq("poolBean"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postProcessDoesNotSyncGemfirePropertiesWhenNoPoolFactoryBeanIsDeclared() {
|
||||
BeanDefinition clientCacheBean = newBeanDefinition(ClientCacheFactoryBean.class);
|
||||
|
||||
clientCacheBean.getPropertyValues().addPropertyValue(PROPERTIES_PROPERTY_NAME_SHORTCUT,
|
||||
new RuntimeBeanReference("gemfireProperties"));
|
||||
|
||||
when(mockBeanFactory.getBeanDefinitionNames()).thenReturn(toArray("clientCacheBean"));
|
||||
when(mockBeanFactory.getBeanDefinition(eq("clientCacheBean"))).thenReturn(clientCacheBean);
|
||||
|
||||
beanFactoryPostProcessor.postProcessBeanFactory(mockBeanFactory);
|
||||
|
||||
verify(mockBeanFactory, times(1)).getBeanDefinitionNames();
|
||||
verify(mockBeanFactory, times(1)).getBeanDefinition(eq("clientCacheBean"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postProcessDoesNotSyncWhenGemfirePropertiesAreUnspecified() {
|
||||
BeanDefinition clientCacheBean = newBeanDefinition(ClientCacheFactoryBean.class);
|
||||
BeanDefinition poolBean = newBeanDefinition(PoolFactoryBean.class);
|
||||
|
||||
when(mockBeanFactory.getBeanDefinitionNames()).thenReturn(toArray("clientCacheBean", "poolBean"));
|
||||
when(mockBeanFactory.getBeanDefinition(eq("clientCacheBean"))).thenReturn(clientCacheBean);
|
||||
when(mockBeanFactory.getBeanDefinition(eq("poolBean"))).thenReturn(poolBean);
|
||||
|
||||
assertThat(poolBean.getPropertyValues().getPropertyValue(PROPERTIES_PROPERTY_NAME_SHORTCUT), is(nullValue()));
|
||||
|
||||
beanFactoryPostProcessor.postProcessBeanFactory(mockBeanFactory);
|
||||
|
||||
assertThat(poolBean.getPropertyValues().getPropertyValue(PROPERTIES_PROPERTY_NAME_SHORTCUT), is(nullValue()));
|
||||
|
||||
verify(mockBeanFactory, times(1)).getBeanDefinitionNames();
|
||||
verify(mockBeanFactory, times(1)).getBeanDefinition(eq("clientCacheBean"));
|
||||
verify(mockBeanFactory, times(1)).getBeanDefinition(eq("poolBean"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,24 +51,24 @@ import com.gemstone.gemfire.cache.Scope;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
|
||||
/**
|
||||
* The CustomEditorRegistrationBeanFactoryPostProcessorTest class...
|
||||
* The CustomEditorRegisteringBeanFactoryPostProcessorTest class...
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.config.CustomEditorRegistrationBeanFactoryPostProcessor
|
||||
* @see CustomEditorRegisteringBeanFactoryPostProcessor
|
||||
* @since 1.6.0
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class CustomEditorRegistrationBeanFactoryPostProcessorTest {
|
||||
public class CustomEditorRegisteringBeanFactoryPostProcessorTest {
|
||||
|
||||
@Test
|
||||
public void customEditorRegistration() {
|
||||
ConfigurableListableBeanFactory mockBeanFactory = mock(ConfigurableListableBeanFactory.class);
|
||||
|
||||
new CustomEditorRegistrationBeanFactoryPostProcessor().postProcessBeanFactory(mockBeanFactory);
|
||||
new CustomEditorRegisteringBeanFactoryPostProcessor().postProcessBeanFactory(mockBeanFactory);
|
||||
|
||||
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(ConnectionEndpoint[].class), eq(
|
||||
CustomEditorRegistrationBeanFactoryPostProcessor.ConnectionEndpointArrayToIterableConverter.class));
|
||||
//verify(mockBeanFactory, times(1)).registerCustomEditor(eq(ConnectionEndpoint[].class),
|
||||
// eq(CustomEditorRegisteringBeanFactoryPostProcessor.ConnectionEndpointArrayToIterableConverter.class));
|
||||
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(EvictionAction.class),
|
||||
eq(EvictionActionConverter.class));
|
||||
verify(mockBeanFactory, times(1)).registerCustomEditor(eq(EvictionPolicyType.class),
|
||||
@@ -103,7 +103,7 @@ public class CustomEditorRegistrationBeanFactoryPostProcessorTest {
|
||||
newConnectionEndpoint("localhost", 40404)
|
||||
};
|
||||
|
||||
Iterable<ConnectionEndpoint> iterable = new CustomEditorRegistrationBeanFactoryPostProcessor
|
||||
Iterable<ConnectionEndpoint> iterable = new CustomEditorRegisteringBeanFactoryPostProcessor
|
||||
.ConnectionEndpointArrayToIterableConverter().convert(array);
|
||||
|
||||
assertThat(iterable, is(notNullValue()));
|
||||
@@ -45,6 +45,7 @@ import org.springframework.data.gemfire.GemfireUtils;
|
||||
import org.springframework.data.gemfire.TestUtils;
|
||||
import org.springframework.data.gemfire.config.GemfireConstants;
|
||||
|
||||
import com.gemstone.gemfire.cache.RegionService;
|
||||
import com.gemstone.gemfire.cache.client.Pool;
|
||||
import com.gemstone.gemfire.cache.query.QueryService;
|
||||
import com.gemstone.gemfire.internal.cache.PoolManagerImpl;
|
||||
@@ -136,6 +137,23 @@ public class ContinuousQueryListenerContainerTest {
|
||||
verifyZeroInteractions(mockQueryService);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void afterPropertiesSetThrowsIllegalStateExceptionWhenQueryServicesIsUninitialized() {
|
||||
exception.expect(IllegalStateException.class);
|
||||
exception.expectCause(is(nullValue(Throwable.class)));
|
||||
exception.expectMessage("QueryService was not properly initialized");
|
||||
|
||||
try {
|
||||
listenerContainer.setPoolName("TestPool");
|
||||
listenerContainer.afterPropertiesSet();
|
||||
}
|
||||
finally {
|
||||
assertThat(listenerContainer.isActive(), is(false));
|
||||
assertThat(listenerContainer.isAutoStartup(), is(true));
|
||||
assertThat(listenerContainer.isRunning(), is(false));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolvesToProvidedPoolName() {
|
||||
listenerContainer.setPoolName("TestPool");
|
||||
@@ -222,7 +240,7 @@ public class ContinuousQueryListenerContainerTest {
|
||||
|
||||
try {
|
||||
exception.expect(IllegalArgumentException.class);
|
||||
exception.expectCause(nullValue(Throwable.class));
|
||||
exception.expectCause(is(nullValue(Throwable.class)));
|
||||
exception.expectMessage("No GemFire Pool with name [TestPool] was found");
|
||||
|
||||
listenerContainer.setBeanFactory(mockBeanFactory);
|
||||
@@ -245,6 +263,17 @@ public class ContinuousQueryListenerContainerTest {
|
||||
verifyZeroInteractions(mockQueryService);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initializesQueryServiceFromContainer() {
|
||||
QueryService mockQueryService = mock(QueryService.class);
|
||||
|
||||
listenerContainer.setQueryService(mockQueryService);
|
||||
|
||||
assertThat(listenerContainer.initQueryService("TestPool"), is(equalTo(mockQueryService)));
|
||||
|
||||
verifyZeroInteractions(mockQueryService);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initializesQueryServiceFromPool() {
|
||||
Pool mockPool = mock(Pool.class);
|
||||
@@ -255,6 +284,7 @@ public class ContinuousQueryListenerContainerTest {
|
||||
|
||||
try {
|
||||
PoolManagerImpl.getPMI().register(mockPool);
|
||||
listenerContainer.setQueryService(null);
|
||||
assertThat(listenerContainer.initQueryService("TestPool"), is(equalTo(mockQueryService)));
|
||||
}
|
||||
finally {
|
||||
@@ -265,6 +295,30 @@ public class ContinuousQueryListenerContainerTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initializesQueryServiceFromPoolInThePresenceOfAProvidedQueryService() {
|
||||
Pool mockPool = mock(Pool.class);
|
||||
|
||||
QueryService mockQueryServiceOne = mock(QueryService.class);
|
||||
QueryService mockQueryServiceTwo = mock(QueryService.class);
|
||||
|
||||
when(mockPool.getName()).thenReturn("TestPool");
|
||||
when(mockPool.getQueryService()).thenReturn(mockQueryServiceOne);
|
||||
|
||||
try {
|
||||
PoolManagerImpl.getPMI().register(mockPool);
|
||||
listenerContainer.setQueryService(mockQueryServiceTwo);
|
||||
assertThat(listenerContainer.initQueryService("TestPool"), is(equalTo(mockQueryServiceOne)));
|
||||
}
|
||||
finally {
|
||||
assertThat(PoolManagerImpl.getPMI().unregister(mockPool), is(true));
|
||||
verify(mockPool, times(2)).getName();
|
||||
verify(mockPool, times(1)).getQueryService();
|
||||
verifyZeroInteractions(mockQueryServiceOne);
|
||||
verifyZeroInteractions(mockQueryServiceTwo);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initExecutorReturnsProvidedExecutor() {
|
||||
Executor mockExecutor = mock(Executor.class);
|
||||
@@ -281,4 +335,32 @@ public class ContinuousQueryListenerContainerTest {
|
||||
assertThat(listenerContainer.initExecutor(), is(instanceOf(Executor.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setCacheSetsQueryService() {
|
||||
QueryService mockQueryService = mock(QueryService.class);
|
||||
RegionService mockRegionService = mock(RegionService.class);
|
||||
|
||||
when(mockRegionService.getQueryService()).thenReturn(mockQueryService);
|
||||
|
||||
listenerContainer.setCache(mockRegionService);
|
||||
|
||||
assertThat(listenerContainer.initQueryService(null), is(equalTo(mockQueryService)));
|
||||
|
||||
verify(mockRegionService, times(1)).getQueryService();
|
||||
verifyZeroInteractions(mockQueryService);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setAndGetAutoStartup() {
|
||||
assertThat(listenerContainer.isAutoStartup(), is(true));
|
||||
|
||||
listenerContainer.setAutoStartup(false);
|
||||
|
||||
assertThat(listenerContainer.isAutoStartup(), is(false));
|
||||
|
||||
listenerContainer.setAutoStartup(true);
|
||||
|
||||
assertThat(listenerContainer.isAutoStartup(), is(true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<prop key="log-level">warning</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:client-cache properties-ref="gemfireProperties" use-bean-factory-locator="false"/>
|
||||
<gfe:client-cache properties-ref="gemfireProperties"/>
|
||||
|
||||
<gfe:pool id="client" subscription-enabled="true">
|
||||
<gfe:server host="localhost" port="40404"/>
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
<task:executor id="testTaskExecutor"/>
|
||||
|
||||
<gfe:cq-listener-container id="testContainerId" cache="gemfireCache" pool-name="client">
|
||||
<gfe:cq-listener-container id="testContainerId" pool-name="client">
|
||||
<!-- default handle method -->
|
||||
<gfe:listener ref="testBean1" query="SELECT * from /test-cq"/>
|
||||
<gfe:listener ref="testBean1" query="SELECT * from /test-cq" name="test-bean-1" method="handleQuery"/>
|
||||
@@ -32,7 +32,6 @@
|
||||
|
||||
<bean id="testBean1" class="org.springframework.data.gemfire.listener.GemfireMDP"/>
|
||||
<bean id="testBean2" class="org.springframework.data.gemfire.listener.ThrowableEventListener"/>
|
||||
|
||||
<bean id="handler" class="org.springframework.data.gemfire.listener.StubErrorHandler"/>
|
||||
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user