Refactor the EnableClusterDefinedRegionsIntegrationTests to declare a client-only Region.

This commit is contained in:
John Blum
2022-06-27 09:35:52 -07:00
parent 9b671bd586
commit 25733e6e1f

View File

@@ -28,6 +28,7 @@ import org.apache.geode.cache.DataPolicy;
import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientCache;
import org.apache.geode.cache.client.ClientRegionShortcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -37,6 +38,7 @@ import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.data.gemfire.LocalRegionFactoryBean;
import org.springframework.data.gemfire.PartitionedRegionFactoryBean;
import org.springframework.data.gemfire.ReplicatedRegionFactoryBean;
import org.springframework.data.gemfire.client.ClientRegionFactoryBean;
import org.springframework.data.gemfire.support.ConnectionEndpoint;
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
import org.springframework.data.gemfire.util.CacheUtils;
@@ -72,6 +74,10 @@ public class EnableClusterDefinedRegionsIntegrationTests extends ForkingClientSe
@Autowired
private ClientCache cache;
@Autowired
@Qualifier("Example")
private Region<String, Object> exampleRegion;
@Autowired
@Qualifier("LocalRegion")
private Region<?, ?> localClientProxyRegion;
@@ -100,6 +106,16 @@ public class EnableClusterDefinedRegionsIntegrationTests extends ForkingClientSe
assertThat(CacheUtils.isClient(this.cache));
}
@Test
public void exampleRegionIsClientOnly() {
assertThat(this.exampleRegion).isNotNull();
assertThat(this.exampleRegion.getName()).isEqualTo("Example");
assertThat(this.exampleRegion.getFullPath()).isEqualTo(RegionUtils.toRegionPath("Example"));
assertThat(this.exampleRegion.getAttributes()).isNotNull();
assertThat(this.exampleRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.NORMAL);
}
@Test
public void clusterRegionsExistOnClient() {
@@ -125,6 +141,17 @@ public class EnableClusterDefinedRegionsIntegrationTests extends ForkingClientSe
Collections.singletonList(new ConnectionEndpoint("localhost", port)));
}
@Bean("Example")
ClientRegionFactoryBean<String, Object> exampleRegion(ClientCache clientCache) {
ClientRegionFactoryBean<String, Object> exampleRegion = new ClientRegionFactoryBean<>();
exampleRegion.setCache(clientCache);
exampleRegion.setShortcut(ClientRegionShortcut.LOCAL);
return exampleRegion;
}
@Bean("TestBean")
Object testBean(@Qualifier("LocalRegion") Region<?, ?> localRegion) {
return "TEST";