From 168c0329af1301cd6aefbb6cf60923fd277c88c7 Mon Sep 17 00:00:00 2001 From: John Blum Date: Tue, 24 Apr 2018 10:02:02 -0700 Subject: [PATCH] DATAGEODE-100 - Add Integration Test based on Accenture's UC reproducing the problem. --- pom.xml | 2 +- .../PoolAlreadyExistsIntegrationTests.java | 77 +++++++++++++++++++ ...lAlreadyExistsIntegrationTests-context.xml | 36 +++++++++ 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 src/test/java/org/springframework/data/gemfire/config/xml/support/PoolAlreadyExistsIntegrationTests.java create mode 100644 src/test/resources/org/springframework/data/gemfire/config/xml/support/PoolAlreadyExistsIntegrationTests-context.xml diff --git a/pom.xml b/pom.xml index d1788b32..1e7b251d 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.springframework.data spring-data-geode - 2.1.0.DATAGEODE-100-SNAPSHOT + 2.1.0.BUILD-SNAPSHOT Spring Data Geode diff --git a/src/test/java/org/springframework/data/gemfire/config/xml/support/PoolAlreadyExistsIntegrationTests.java b/src/test/java/org/springframework/data/gemfire/config/xml/support/PoolAlreadyExistsIntegrationTests.java new file mode 100644 index 00000000..77a19107 --- /dev/null +++ b/src/test/java/org/springframework/data/gemfire/config/xml/support/PoolAlreadyExistsIntegrationTests.java @@ -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 + * @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(); + + } +} diff --git a/src/test/resources/org/springframework/data/gemfire/config/xml/support/PoolAlreadyExistsIntegrationTests-context.xml b/src/test/resources/org/springframework/data/gemfire/config/xml/support/PoolAlreadyExistsIntegrationTests-context.xml new file mode 100644 index 00000000..3005a578 --- /dev/null +++ b/src/test/resources/org/springframework/data/gemfire/config/xml/support/PoolAlreadyExistsIntegrationTests-context.xml @@ -0,0 +1,36 @@ + + + + + + + ${gemfire.log-level:error} + + + + + + + + + + + + + + + + + + +