Refactor the CollocatedRegionsXmlConfigurationIntegrationTests class.

Rename the CollocatedRegionIntegrationTests class to CollocatedRegionsXmlConfigurationIntegrationTests.

Rename the associated XML context configuration file acccordingly.

Rename test case method.

Resolves gh-566.
This commit is contained in:
John Blum
2022-01-19 15:36:35 -08:00
parent fb339cee3d
commit 5fb8aa804e
2 changed files with 17 additions and 14 deletions

View File

@@ -20,6 +20,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.geode.cache.DataPolicy;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
@@ -29,47 +30,49 @@ import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* Integration Tests for JIRA issue SGF-195,concerning collocated cache {@link Region Regions}.
* Integration Tests for Apache Geode {@literal collocated} {@link DataPolicy#PARTITION} {@link Region Regions}
* using SDG XML configuration.
*
* @author John Blum
* @see org.junit.Test
* @see org.apache.geode.cache.Region
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer
* @see org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
* @link https://jira.springsource.org/browse/SGF-195
* @see <a href="https://jira.springsource.org/browse/SGF-195">SGF-195</a>
* @since 1.3.3
*/
@RunWith(SpringRunner.class)
@GemFireUnitTest
@SuppressWarnings("unused")
public class CollocatedRegionIntegrationTests extends IntegrationTestsSupport {
public class CollocatedRegionsXmlConfigurationIntegrationTests extends IntegrationTestsSupport {
@Autowired
@Qualifier("colocatedRegion")
@Qualifier("collocatedRegion")
private Region<?, ?> colocatedRegion;
@Autowired
@Qualifier("sourceRegion")
private Region<?, ?> sourceRegion;
protected static void assertRegionExists(String expectedRegionName, Region<?, ?> region) {
private void assertRegionExists(Region<?, ?> region, String expectedRegionName) {
assertThat(region).isNotNull();
assertThat(region.getName())
.describedAs("Expected Region with name %1$s; but was %2$s!", expectedRegionName, region.getName())
.describedAs("Expected Region with name [%1$s]; but was [%2$s]!", expectedRegionName, region.getName())
.isEqualTo(expectedRegionName);
}
@Test
public void testRegionsColocated() {
public void collocatedRegionsAreConfiguredCorrectly() {
assertRegionExists("Source", sourceRegion);
assertRegionExists("Colocated", colocatedRegion);
assertThat(colocatedRegion.getAttributes()).isNotNull();
assertThat(colocatedRegion.getAttributes().getPartitionAttributes()).isNotNull();
assertThat(colocatedRegion.getAttributes().getPartitionAttributes().getColocatedWith()).isEqualTo(sourceRegion.getName());
assertRegionExists(this.sourceRegion, "Source");
assertRegionExists(this.colocatedRegion, "Collocated");
assertThat(this.colocatedRegion.getAttributes()).isNotNull();
assertThat(this.colocatedRegion.getAttributes().getPartitionAttributes()).isNotNull();
assertThat(this.colocatedRegion.getAttributes().getPartitionAttributes().getColocatedWith())
.isEqualTo(this.sourceRegion.getName());
}
}

View File

@@ -17,7 +17,7 @@
<gfe:cache properties-ref="gemfireProperties"/>
<!-- NOTE the order of Region bean definitions is important in reproducing the issue in JIRA 195 -->
<gfe:partitioned-region id="colocatedRegion" name="Colocated" colocated-with="Source"/>
<gfe:partitioned-region id="collocatedRegion" name="Collocated" colocated-with="Source"/>
<gfe:partitioned-region id="sourceRegion" name="Source"/>
</beans>