SGF-738 - Add Integration Test based on Accenture's UC reproducing the problem.

This commit is contained in:
John Blum
2018-04-24 10:02:02 -07:00
parent d3da36c733
commit c7df770a26
2 changed files with 113 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
/*
* Copyright 2018 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.xml.support;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.function.Function;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientCache;
import org.apache.geode.cache.client.Pool;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.gemfire.GemfireUtils;
import org.springframework.data.gemfire.function.annotation.OnRegion;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
/**
* Integration tests to test the configuration of the {@link ClientCache} {@literal DEFAULT} {@link Pool},
* client {@link Region Region's} using a configured {@link Pool} and a {@link Function} referring to
* a client {@link Region} requiring the configured {@link Pool}.
*
* @author John Blum
* @see org.junit.Test
* @see org.apache.geode.cache.Region
* @see org.apache.geode.cache.client.ClientCache
* @see org.apache.geode.cache.client.Pool
* @see <a href=""></a>
* @since 1.0.0
*/
@RunWith(SpringRunner.class)
@ContextConfiguration
@SuppressWarnings("unused")
public class PoolAlreadyExistsIntegrationTests {
@Autowired
private ClientCache clientCache;
private void assertRegion(Region<?, ?> region, String name) {
assertThat(region).isNotNull();
assertThat(region.getName()).isEqualTo(GemfireUtils.toRegionName(name));
assertThat(region.getFullPath()).isEqualTo(GemfireUtils.toRegionPath(name));
assertThat(region.getAttributes()).isNotNull();
assertThat(region.getAttributes().getPoolName()).isEqualTo("TestPool");
}
@Test
public void regionsConfiguredWithPool() {
assertRegion(this.clientCache.getRegion("RegionOne"), "RegionOne");
assertRegion(this.clientCache.getRegion("RegionTwo"), "RegionTwo");
}
@OnRegion(id = "TestFunction", region = "RegionTwo")
interface TestFunctionExecution {
void doSomething();
}
}

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
">
<context:property-placeholder/>
<util:properties id="gemfireProperties">
<prop key="log-level">${gemfire.log-level:error}</prop>
</util:properties>
<gfe:client-cache properties-ref="gemfireProperties" pool-name="TestPool"/>
<gfe:pool id="TestPool"/>
<gfe:client-region id="RegionOne" shortcut="PROXY" pool-name="TestPool"/>
<gfe:client-region id="RegionTwo" shortcut="PROXY" pool-name="TestPool"/>
<bean id="RegionTwoFunctionTemplate" class="org.springframework.data.gemfire.function.execution.GemfireOnRegionFunctionTemplate">
<constructor-arg index="0" ref="RegionTwo"/>
</bean>
<bean class="org.springframework.data.gemfire.function.execution.OnRegionFunctionProxyFactoryBean">
<constructor-arg index="0" value="org.springframework.data.gemfire.config.xml.support.PoolAlreadyExistsIntegrationTests$TestFunctionExecution"/>
<constructor-arg index="1" ref="RegionTwoFunctionTemplate"/>
</bean>
</beans>