From 285eac9cba0d2f47fb2b36e4f70866aa7297875c Mon Sep 17 00:00:00 2001 From: John Blum Date: Wed, 20 Mar 2019 17:59:58 -0700 Subject: [PATCH] Add integration tests testing the configuration of Spring Boot with Apache Geode / Pivotal GemFire using properties and @ConfigurationProperties classes. Resolves gh-14. --- .../GemFirePropertiesAutoConfiguration.java | 4 +- .../configuration/GemFireProperties.java | 11 +- .../support/CacheProperties.java | 11 +- .../support/SecurityProperties.java | 4 +- .../configuration/support/SslProperties.java | 96 ++-- .../GemFirePropertiesIntegrationTests.java | 491 ++++++++++++++++++ ...application-gemfire-config-test.properties | 138 +++++ 7 files changed, 708 insertions(+), 47 deletions(-) create mode 100644 spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/configuration/GemFirePropertiesIntegrationTests.java create mode 100644 spring-geode-autoconfigure/src/test/resources/application-gemfire-config-test.properties diff --git a/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/GemFirePropertiesAutoConfiguration.java b/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/GemFirePropertiesAutoConfiguration.java index e6b09803..c6d56168 100644 --- a/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/GemFirePropertiesAutoConfiguration.java +++ b/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/GemFirePropertiesAutoConfiguration.java @@ -45,8 +45,8 @@ import org.springframework.geode.boot.autoconfigure.configuration.GemFirePropert */ @Configuration @ConditionalOnBean(GemFireCache.class) -@ConditionalOnClass({ CacheFactoryBean.class, GemFireCache.class }) -@EnableConfigurationProperties(GemFireProperties.class) +@ConditionalOnClass({ GemFireCache.class, CacheFactoryBean.class }) +@EnableConfigurationProperties({ GemFireProperties.class }) @SuppressWarnings("unused") public class GemFirePropertiesAutoConfiguration { diff --git a/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/configuration/GemFireProperties.java b/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/configuration/GemFireProperties.java index 9dc33cc9..62ae11de 100644 --- a/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/configuration/GemFireProperties.java +++ b/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/configuration/GemFireProperties.java @@ -16,6 +16,8 @@ package org.springframework.geode.boot.autoconfigure.configuration; +import java.util.Properties; + import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; import org.springframework.geode.boot.autoconfigure.configuration.support.CacheProperties; @@ -32,9 +34,16 @@ import org.springframework.geode.boot.autoconfigure.configuration.support.Securi import org.springframework.geode.boot.autoconfigure.configuration.support.ServiceProperties; /** - * The GemFireProperties class... + * Spring Boot {@link ConfigurationProperties} for well-known, documented Spring Data for Apache Geode/Pivotal GemFire + * (SDG) {@link Properties}. + * + * This class assists the application developer in the auto-completion / content-assist of the well-known, documented + * SDG {@link Properties}. * * @author John Blum + * @see java.util.Properties + * @see org.springframework.boot.context.properties.ConfigurationProperties + * @see org.springframework.boot.context.properties.NestedConfigurationProperty * @since 1.0.0 */ @SuppressWarnings("unused") diff --git a/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/configuration/support/CacheProperties.java b/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/configuration/support/CacheProperties.java index be18541f..f599c148 100644 --- a/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/configuration/support/CacheProperties.java +++ b/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/configuration/support/CacheProperties.java @@ -16,13 +16,22 @@ package org.springframework.geode.boot.autoconfigure.configuration.support; +import java.util.Properties; + +import org.apache.geode.cache.Cache; import org.apache.geode.cache.control.ResourceManager; +import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; /** - * The CacheProperties class... + * Spring Boot {@link ConfigurationProperties} that apply to an Apache Geode / Pivotal GemFire peer {@link Cache} + * and correspond to Spring Data for Apache Geode/Pivotal GemFire's well-known, documented {@link Properties}. * * @author John Blum + * @see java.util.Properties + * @see org.apache.geode.cache.Cache + * @see org.springframework.boot.context.properties.ConfigurationProperties + * @see org.springframework.boot.context.properties.NestedConfigurationProperty * @since 1.0.0 */ @SuppressWarnings("unused") diff --git a/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/configuration/support/SecurityProperties.java b/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/configuration/support/SecurityProperties.java index 54ac9878..3e76688d 100644 --- a/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/configuration/support/SecurityProperties.java +++ b/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/configuration/support/SecurityProperties.java @@ -43,7 +43,7 @@ public class SecurityProperties { new SecurityPostProcessorProperties(); @NestedConfigurationProperty - private final SslProperties sslProperties = new SslProperties(); + private final SslProperties ssl = new SslProperties(); private String password; private String propertiesFile; @@ -90,7 +90,7 @@ public class SecurityProperties { } public SslProperties getSsl() { - return this.sslProperties; + return this.ssl; } public String getUsername() { diff --git a/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/configuration/support/SslProperties.java b/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/configuration/support/SslProperties.java index e08880ef..7d5db47b 100644 --- a/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/configuration/support/SslProperties.java +++ b/spring-geode-autoconfigure/src/main/java/org/springframework/geode/boot/autoconfigure/configuration/support/SslProperties.java @@ -16,6 +16,7 @@ package org.springframework.geode.boot.autoconfigure.configuration.support; +import org.springframework.boot.context.properties.NestedConfigurationProperty; import org.springframework.data.gemfire.config.annotation.EnableSsl; /** @@ -35,10 +36,14 @@ public class SslProperties { private EnableSsl.Component[] components; - private final KeyStoreProperties keystoreProperties = new KeyStoreProperties(); - private final KeyStoreProperties truststoreProperties = new KeyStoreProperties(); + @NestedConfigurationProperty + private final KeyStoreProperties keystoreConfig = new KeyStoreProperties(); - private final SslCertificateProperties sslCertificateProperties = new SslCertificateProperties(); + @NestedConfigurationProperty + private final KeyStoreProperties truststoreConfig = new KeyStoreProperties(); + + @NestedConfigurationProperty + private final SslCertificateProperties certificate = new SslCertificateProperties(); private String keystore; private String truststore; @@ -48,7 +53,7 @@ public class SslProperties { private String[] protocols; public SslCertificateProperties getCertificate() { - return this.sslCertificateProperties; + return this.certificate; } public String[] getCiphers() { @@ -75,6 +80,10 @@ public class SslProperties { this.keystore = keystore; } + public KeyStoreProperties getKeystoreConfig() { + return this.keystoreConfig; + } + public String[] getProtocols() { return this.protocols; } @@ -99,6 +108,10 @@ public class SslProperties { this.truststore = truststore; } + public KeyStoreProperties getTruststoreConfig() { + return this.truststoreConfig; + } + public boolean isWebRequireAuthentication() { return this.webRequireAuthentication; } @@ -131,38 +144,39 @@ public class SslProperties { public static class SslCertificateProperties { - private SslCertificateAliasProperties sslCertificateAliasProperties = new SslCertificateAliasProperties(); + @NestedConfigurationProperty + private SslCertificateAliasProperties alias = new SslCertificateAliasProperties(); public SslCertificateAliasProperties getAlias() { - return this.sslCertificateAliasProperties; + return this.alias; } } public static class SslCertificateAliasProperties { - private String allAlias; - private String clusterAlias; + private String all; + private String cluster; private String defaultAlias; - private String gatewayAlias; - private String jmxAlias; - private String locatorAlias; - private String serverAlias; - private String webAlias; + private String gateway; + private String jmx; + private String locator; + private String server; + private String web; - public String getAllAlias() { - return this.allAlias; + public String getAll() { + return this.all; } - public void setAllAlias(String allAlias) { - this.allAlias = allAlias; + public void setAll(String all) { + this.all = all; } - public String getClusterAlias() { - return this.clusterAlias; + public String getCluster() { + return this.cluster; } - public void setClusterAlias(String clusterAlias) { - this.clusterAlias = clusterAlias; + public void setCluster(String cluster) { + this.cluster = cluster; } public String getDefaultAlias() { @@ -173,44 +187,44 @@ public class SslProperties { this.defaultAlias = defaultAlias; } - public String getGatewayAlias() { - return this.gatewayAlias; + public String getGateway() { + return this.gateway; } - public void setGatewayAlias(String gatewayAlias) { - this.gatewayAlias = gatewayAlias; + public void setGateway(String gateway) { + this.gateway = gateway; } - public String getJmxAlias() { - return this.jmxAlias; + public String getJmx() { + return this.jmx; } - public void setJmxAlias(String jmxAlias) { - this.jmxAlias = jmxAlias; + public void setJmx(String jmx) { + this.jmx = jmx; } - public String getLocatorAlias() { - return this.locatorAlias; + public String getLocator() { + return this.locator; } - public void setLocatorAlias(String locatorAlias) { - this.locatorAlias = locatorAlias; + public void setLocator(String locator) { + this.locator = locator; } - public String getServerAlias() { - return this.serverAlias; + public String getServer() { + return this.server; } - public void setServerAlias(String serverAlias) { - this.serverAlias = serverAlias; + public void setServer(String server) { + this.server = server; } - public String getWebAlias() { - return this.webAlias; + public String getWeb() { + return this.web; } - public void setWebAlias(String webAlias) { - this.webAlias = webAlias; + public void setWeb(String web) { + this.web = web; } } } diff --git a/spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/configuration/GemFirePropertiesIntegrationTests.java b/spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/configuration/GemFirePropertiesIntegrationTests.java new file mode 100644 index 00000000..7050af4f --- /dev/null +++ b/spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/configuration/GemFirePropertiesIntegrationTests.java @@ -0,0 +1,491 @@ +/* + * Copyright 2019 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.geode.boot.autoconfigure.configuration; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.geode.cache.RegionShortcut; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.gemfire.config.annotation.EnableMemcachedServer; +import org.springframework.data.gemfire.config.annotation.EnableSsl; +import org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects; +import org.springframework.geode.boot.autoconfigure.ContinuousQueryAutoConfiguration; +import org.springframework.geode.boot.autoconfigure.configuration.support.CacheProperties; +import org.springframework.geode.boot.autoconfigure.configuration.support.CacheServerProperties; +import org.springframework.geode.boot.autoconfigure.configuration.support.ClientCacheProperties; +import org.springframework.geode.boot.autoconfigure.configuration.support.ClientSecurityProperties; +import org.springframework.geode.boot.autoconfigure.configuration.support.ClusterProperties; +import org.springframework.geode.boot.autoconfigure.configuration.support.DiskStoreProperties; +import org.springframework.geode.boot.autoconfigure.configuration.support.EntityProperties; +import org.springframework.geode.boot.autoconfigure.configuration.support.LocatorProperties; +import org.springframework.geode.boot.autoconfigure.configuration.support.LoggingProperties; +import org.springframework.geode.boot.autoconfigure.configuration.support.ManagementProperties; +import org.springframework.geode.boot.autoconfigure.configuration.support.ManagerProperties; +import org.springframework.geode.boot.autoconfigure.configuration.support.PdxProperties; +import org.springframework.geode.boot.autoconfigure.configuration.support.PeerCacheProperties; +import org.springframework.geode.boot.autoconfigure.configuration.support.PeerSecurityProperties; +import org.springframework.geode.boot.autoconfigure.configuration.support.PoolProperties; +import org.springframework.geode.boot.autoconfigure.configuration.support.SecurityProperties; +import org.springframework.geode.boot.autoconfigure.configuration.support.ServiceProperties; +import org.springframework.geode.boot.autoconfigure.configuration.support.SslProperties; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * Integration tests for {@link GemFireProperties}. + * + * @author John Blum + * @see org.junit.Test + * @see org.springframework.boot.autoconfigure.SpringBootApplication + * @see org.springframework.boot.test.context.SpringBootTest + * @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects + * @see org.springframework.geode.boot.autoconfigure.GemFirePropertiesAutoConfiguration + * @see org.springframework.geode.boot.autoconfigure.configuration.GemFireProperties + * @see org.springframework.test.context.junit4.SpringRunner + * @since 1.0.0 + */ +@RunWith(SpringRunner.class) +@ActiveProfiles("gemfire-config-test") +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) +@SuppressWarnings("unused") +public class GemFirePropertiesIntegrationTests { + + @Autowired + private GemFireProperties gemfireProperties; + + @Test + public void gemfireConfigurationIsCorrect() { + + assertThat(this.gemfireProperties).isNotNull(); + assertThat(this.gemfireProperties.getName()).isEqualTo(GemFirePropertiesIntegrationTests.class.getSimpleName()); + assertThat(this.gemfireProperties.getLocators()).containsExactly("localhost[11235]", "localhost[12480]"); + assertThat(this.gemfireProperties.isUseBeanFactoryLocator()).isTrue(); + } + + @Test + public void cacheConfigurationIsCorrect() { + + CacheProperties cacheProperties = this.gemfireProperties.getCache(); + + assertThat(cacheProperties).isNotNull(); + assertThat(cacheProperties.isCopyOnRead()).isTrue(); + assertThat(cacheProperties.getCriticalHeapPercentage()).isEqualTo(85.5f); + assertThat(cacheProperties.getCriticalOffHeapPercentage()).isEqualTo(95.0f); + assertThat(cacheProperties.isEnableAutoRegionLookup()).isFalse(); + assertThat(cacheProperties.getEvictionHeapPercentage()).isEqualTo(50.0f); + assertThat(cacheProperties.getEvictionOffHeapPercentage()).isEqualTo(75.5f); + assertThat(cacheProperties.getLogLevel()).isEqualTo("TRACE"); + assertThat(cacheProperties.getName()).isEqualTo("AnotherName"); + } + + @Test + public void cacheClientConfigurationIsCorrect() { + + ClientCacheProperties clientCacheProperties = this.gemfireProperties.getCache().getClient(); + + assertThat(clientCacheProperties).isNotNull(); + assertThat(clientCacheProperties.getDurableClientId()).isEqualTo("123"); + assertThat(clientCacheProperties.getDurableClientTimeout()).isEqualTo(60); + assertThat(clientCacheProperties.isKeepAlive()).isTrue(); + } + + @Test + public void cacheCompressionConfigurationIsCorrect() { + + CacheProperties.CompressionProperties compressionProperties = + this.gemfireProperties.getCache().getCompression(); + + assertThat(compressionProperties).isNotNull(); + assertThat(compressionProperties.getCompressorBeanName()).isEqualTo("TestCompressor"); + assertThat(compressionProperties.getRegionNames()).containsExactly("TestRegionOne", "TestRegionTwo"); + } + + @Test + public void cacheOffHeapConfigurationIsCorrect() { + + CacheProperties.OffHeapProperties offHeapProperties = this.gemfireProperties.getCache().getOffHeap(); + + assertThat(offHeapProperties).isNotNull(); + assertThat(offHeapProperties.getMemorySize()).isEqualTo("65535g"); + assertThat(offHeapProperties.getRegionNames()).containsExactly("TestRegionTwo", "TestRegionFour"); + } + + @Test + public void cachePeerConfigurationIsCorrect() { + + PeerCacheProperties peerCacheProperties = this.gemfireProperties.getCache().getPeer(); + + assertThat(peerCacheProperties).isNotNull(); + assertThat(peerCacheProperties.isEnableAutoReconnect()).isTrue(); + assertThat(peerCacheProperties.getLockLease()).isEqualTo(30); + assertThat(peerCacheProperties.getLockTimeout()).isEqualTo(5); + assertThat(peerCacheProperties.getMessageSyncInterval()).isEqualTo(2); + assertThat(peerCacheProperties.getSearchTimeout()).isEqualTo(120); + assertThat(peerCacheProperties.isUseClusterConfiguration()).isTrue(); + } + + @Test + public void cacheServerConfigurationIsCorrect() { + + CacheServerProperties cacheServerProperties = this.gemfireProperties.getCache().getServer(); + + assertThat(cacheServerProperties).isNotNull(); + assertThat(cacheServerProperties.isAutoStartup()).isFalse(); + assertThat(cacheServerProperties.getBindAddress()).isEqualTo("10.50.100.200"); + assertThat(cacheServerProperties.getHostnameForClients()).isEqualTo("skullbox"); + assertThat(cacheServerProperties.getLoadPollInterval()).isEqualTo(20000L); + assertThat(cacheServerProperties.getMaxConnections()).isEqualTo(256); + assertThat(cacheServerProperties.getMaxMessageCount()).isEqualTo(100000); + assertThat(cacheServerProperties.getMaxThreads()).isEqualTo(16); + assertThat(cacheServerProperties.getMaxTimeBetweenPings()).isEqualTo(15000); + assertThat(cacheServerProperties.getMessageTimeToLive()).isEqualTo(60); + assertThat(cacheServerProperties.getPort()).isEqualTo(12345); + assertThat(cacheServerProperties.getSocketBufferSize()).isEqualTo(8192); + assertThat(cacheServerProperties.getSubscriptionCapacity()).isEqualTo(2); + assertThat(cacheServerProperties.getSubscriptionDiskStoreName()).isEqualTo("TestSubscriptionDiskStore"); + assertThat(cacheServerProperties.isTcpNoDelay()).isFalse(); + } + + @Test + public void clusterConfigurationIsCorrect() { + + ClusterProperties clusterProperties = this.gemfireProperties.getCluster(); + + assertThat(clusterProperties).isNotNull(); + assertThat(clusterProperties.getRegion()).isNotNull(); + assertThat(clusterProperties.getRegion().getType()).isEqualTo(RegionShortcut.PARTITION_REDUNDANT_PERSISTENT); + } + + @Test + public void diskStoreConfigurationIsCorrect() { + + DiskStoreProperties diskStoreProperties = this.gemfireProperties.getDisk(); + + assertThat(diskStoreProperties).isNotNull(); + + DiskStoreProperties.StoreProperties storeProperties = diskStoreProperties.getStore(); + + assertThat(storeProperties).isNotNull(); + assertThat(storeProperties.isAllowForceCompaction()).isTrue(); + assertThat(storeProperties.isAutoCompact()).isFalse(); + assertThat(storeProperties.getCompactionThreshold()).isEqualTo(75); + assertThat(storeProperties.getDiskUsageCriticalPercentage()).isEqualTo(95.0f); + assertThat(storeProperties.getDiskUsageWarningPercentage()).isEqualTo(89.0f); + assertThat(storeProperties.getMaxOplogSize()).isEqualTo(4096L); + assertThat(storeProperties.getQueueSize()).isEqualTo(1000); + assertThat(storeProperties.getTimeInterval()).isEqualTo(2000L); + assertThat(storeProperties.getWriteBufferSize()).isEqualTo(65535); + } + + @Test + public void diskStoreDirectoryConfigurationIsCorrect() { + + DiskStoreProperties.DirectoryProperties[] directoryProperties = + this.gemfireProperties.getDisk().getStore().getDirectory(); + + assertThat(directoryProperties).isNotEmpty(); + assertThat(directoryProperties).hasSize(2); + assertThat(directoryProperties[0].getLocation()).isEqualTo("/path/to/no/where"); + assertThat(directoryProperties[0].getSize()).isEqualTo(8192); + assertThat(directoryProperties[1].getLocation()).isEqualTo("/path/to/some/where"); + assertThat(directoryProperties[1].getSize()).isEqualTo(2048); + } + + @Test + public void entityConfigurationIsCorrect() { + + EntityProperties entityProperties = this.gemfireProperties.getEntities(); + + assertThat(entityProperties).isNotNull(); + assertThat(entityProperties.getBasePackages()).isEqualTo("example.app.model"); + } + + @Test + public void locatorConfigurationIsCorrect() { + + LocatorProperties locatorProperties = this.gemfireProperties.getLocator(); + + assertThat(locatorProperties).isNotNull(); + assertThat(locatorProperties.getHost()).isEqualTo("mailbox"); + assertThat(locatorProperties.getPort()).isEqualTo(20668); + } + + @Test + public void loggingConfigurationIsCorrect() { + + LoggingProperties loggingProperties = this.gemfireProperties.getLogging(); + + assertThat(loggingProperties).isNotNull(); + assertThat(loggingProperties.getLevel()).isEqualTo("CONFIG"); + assertThat(loggingProperties.getLogDiskSpaceLimit()).isEqualTo(2048); + assertThat(loggingProperties.getLogFile()).isEqualTo("/path/to/geode.log"); + assertThat(loggingProperties.getLogFileSizeLimit()).isEqualTo(50); + } + + @Test + public void managementConfigurationIsCorrect() { + + ManagementProperties managementProperties = this.gemfireProperties.getManagement(); + + assertThat(managementProperties).isNotNull(); + assertThat(managementProperties.isUseHttp()).isTrue(); + assertThat(managementProperties.getHttp()).isNotNull(); + assertThat(managementProperties.getHttp().getHost()).isEqualTo("boombox"); + assertThat(managementProperties.getHttp().getPort()).isEqualTo(8181); + } + + @Test + public void managerConfigurationIsCorrect() { + + ManagerProperties managerProperties = this.gemfireProperties.getManager(); + + assertThat(managerProperties).isNotNull(); + assertThat(managerProperties.getAccessFile()).isEqualTo("/path/to/access/control/list.sys"); + assertThat(managerProperties.getBindAddress()).isEqualTo("10.100.50.255"); + assertThat(managerProperties.getHostnameForClients()).isEqualTo("bosshog"); + assertThat(managerProperties.getPasswordFile()).isEqualTo("/path/to/password.sys"); + assertThat(managerProperties.getPort()).isEqualTo(9090); + assertThat(managerProperties.isStart()).isTrue(); + assertThat(managerProperties.getUpdateRate()).isEqualTo(5000); + } + + @Test + public void pdxConfigurationIsCorrect() { + + PdxProperties pdxProperties = this.gemfireProperties.getPdx(); + + assertThat(pdxProperties).isNotNull(); + assertThat(pdxProperties.getDiskStoreName()).isEqualTo("TestPdxDiskStore"); + assertThat(pdxProperties.isIgnoreUnreadFields()).isTrue(); + assertThat(pdxProperties.isPersistent()).isTrue(); + assertThat(pdxProperties.isReadSerialized()).isTrue(); + assertThat(pdxProperties.getSerializerBeanName()).isEqualTo("TestPdxSerializer"); + } + + @Test + public void poolConfigurationIsCorrect() { + + PoolProperties poolProperties = this.gemfireProperties.getPool(); + + assertThat(poolProperties).isNotNull(); + assertThat(poolProperties.getFreeConnectionTimeout()).isEqualTo(15000); + assertThat(poolProperties.getIdleTimeout()).isEqualTo(30000L); + assertThat(poolProperties.getLoadConditioningInterval()).isEqualTo(120000); + assertThat(poolProperties.getLocators()).containsExactly("boombox[10334]", "mailbox[11235]", "skullbox[20668]"); + assertThat(poolProperties.getMaxConnections()).isEqualTo(100); + assertThat(poolProperties.getMinConnections()).isEqualTo(10); + assertThat(poolProperties.isMultiUserAuthentication()).isTrue(); + assertThat(poolProperties.getPingInterval()).isEqualTo(15000L); + assertThat(poolProperties.isPrSingleHopEnabled()).isFalse(); + assertThat(poolProperties.isReadyForEvents()).isTrue(); + assertThat(poolProperties.getReadTimeout()).isEqualTo(5000); + assertThat(poolProperties.getRetryAttempts()).isEqualTo(2); + assertThat(poolProperties.getServerGroup()).isEqualTo("TestServerGroup"); + assertThat(poolProperties.getServers()).containsExactly("cardboardbox[41414]"); + assertThat(poolProperties.getSocketBufferSize()).isEqualTo(65535); + assertThat(poolProperties.getStatisticInterval()).isEqualTo(500); + assertThat(poolProperties.getSubscriptionAckInterval()).isEqualTo(500); + assertThat(poolProperties.isSubscriptionEnabled()).isTrue(); + assertThat(poolProperties.getSubscriptionMessageTrackingTimeout()).isEqualTo(450000); + assertThat(poolProperties.getSubscriptionRedundancy()).isEqualTo(2); + assertThat(poolProperties.isThreadLocalConnections()).isTrue(); + } + + @Test + public void securityConfigurationIsCorrect() { + + SecurityProperties securityProperties = this.gemfireProperties.getSecurity(); + + assertThat(securityProperties).isNotNull(); + assertThat(securityProperties.getUsername()).isEqualTo("TestUser"); + assertThat(securityProperties.getPassword()).isEqualTo("TestPassword"); + assertThat(securityProperties.getPropertiesFile()).isEqualTo("/path/to/security.properties"); + } + + @Test + public void securityClientConfigurationIsCorrect() { + + ClientSecurityProperties clientSecurityProperties = this.gemfireProperties.getSecurity().getClient(); + + assertThat(clientSecurityProperties).isNotNull(); + assertThat(clientSecurityProperties.getAccessor()).isEqualTo("TestClientAccessor"); + assertThat(clientSecurityProperties.getAccessorPostProcessor()).isEqualTo("TestClientAccessorPostProcessor"); + assertThat(clientSecurityProperties.getAuthenticationInitializer()).isEqualTo("TestClientAuthenticationInitializer"); + assertThat(clientSecurityProperties.getAuthenticator()).isEqualTo("TestClientAuthenticator"); + assertThat(clientSecurityProperties.getDiffieHellmanAlgorithm()).isEqualTo("RSA"); + } + + @Test + public void securityLogConfigurationIsCorrect() { + + SecurityProperties.SecurityLogProperties securityLogProperties = this.gemfireProperties.getSecurity().getLog(); + + assertThat(securityLogProperties).isNotNull(); + assertThat(securityLogProperties.getFile()).isEqualTo("/path/to/security.log"); + assertThat(securityLogProperties.getLevel()).isEqualTo("info"); + } + + @Test + public void securityManagerConfigurationIsCorrect() { + + SecurityProperties.SecurityManagerProperties securityManagerProperties = + this.gemfireProperties.getSecurity().getManager(); + + assertThat(securityManagerProperties).isNotNull(); + assertThat(securityManagerProperties.getClassName()).isEqualTo("example.app.security.manager.TestSecurityManager"); + } + + @Test + public void securityPeerConfigurationIsCorrect() { + + PeerSecurityProperties peerSecurityProperties = this.gemfireProperties.getSecurity().getPeer(); + + assertThat(peerSecurityProperties).isNotNull(); + assertThat(peerSecurityProperties.getAuthenticationInitializer()).isEqualTo("TestPeerAuthenticationInitializer"); + assertThat(peerSecurityProperties.getAuthenticator()).isEqualTo("TestPeerAuthenticator"); + } + + @Test + public void securityPostProcessorConfigurationIsCorrect() { + + SecurityProperties.SecurityPostProcessorProperties securityPostProcessorProperties = + this.gemfireProperties.getSecurity().getPostProcessor(); + + assertThat(securityPostProcessorProperties).isNotNull(); + assertThat(securityPostProcessorProperties.getClassName()) + .isEqualTo("example.app.security.processor.TestSecurityPostProcessor"); + } + + @Test + public void securityShiroConfigurationIsCorrect() { + + SecurityProperties.ApacheShiroProperties shiroProperties = this.gemfireProperties.getSecurity().getShiro(); + + assertThat(shiroProperties).isNotNull(); + assertThat(shiroProperties.getIniResourcePath()).isEqualTo("/path/to/shiro.ini"); + } + + @Test + public void securitySslConfigurationIsCorrect() { + + SslProperties sslProperties = this.gemfireProperties.getSecurity().getSsl(); + + assertThat(sslProperties).isNotNull(); + assertThat(sslProperties.getCiphers()).containsExactly("AES", "DES"); + assertThat(sslProperties.getComponents()) + .containsExactly(EnableSsl.Component.GATEWAY, EnableSsl.Component.LOCATOR, EnableSsl.Component.SERVER); + assertThat(sslProperties.getKeystore()).isEqualTo("/path/to/keystore.jks"); + assertThat(sslProperties.getProtocols()).containsExactly("any"); + assertThat(sslProperties.getTruststore()).isEqualTo("/path/to/truststore.jks"); + } + + @Test + public void securitySslCertificateConfigurationIsCorrect() { + + SslProperties.SslCertificateProperties certificateProperties = + this.gemfireProperties.getSecurity().getSsl().getCertificate(); + + assertThat(certificateProperties).isNotNull(); + assertThat(certificateProperties.getAlias()).isNotNull(); + assertThat(certificateProperties.getAlias().getAll()).isEqualTo("Master"); + assertThat(certificateProperties.getAlias().getCluster()).isEqualTo("Custard"); + assertThat(certificateProperties.getAlias().getDefaultAlias()).isEqualTo("RogueOne"); + assertThat(certificateProperties.getAlias().getGateway()).isEqualTo("WAN"); + assertThat(certificateProperties.getAlias().getJmx()).isEqualTo("Manage"); + assertThat(certificateProperties.getAlias().getLocator()).isEqualTo("Local"); + assertThat(certificateProperties.getAlias().getServer()).isEqualTo("Servant"); + assertThat(certificateProperties.getAlias().getWeb()).isEqualTo("WWW"); + } + + @Test + public void securitySslKeystoreConfigurationIsCorrect() { + + SslProperties.KeyStoreProperties keystoreProperties = + this.gemfireProperties.getSecurity().getSsl().getKeystoreConfig(); + + assertThat(keystoreProperties).isNotNull(); + assertThat(keystoreProperties.getPassword()).isEqualTo("keypass"); + assertThat(keystoreProperties.getType()).isEqualTo("JKS"); + } + + @Test + public void securitySslTruststoreConfigurationIsCorrect() { + + SslProperties.KeyStoreProperties truststoreProperties = + this.gemfireProperties.getSecurity().getSsl().getTruststoreConfig(); + + assertThat(truststoreProperties).isNotNull(); + assertThat(truststoreProperties.getPassword()).isEqualTo("storepass"); + assertThat(truststoreProperties.getType()).isEqualTo("PKS11"); + } + + @Test + public void serviceConfigurationIsNotNull() { + assertThat(this.gemfireProperties.getService()).isNotNull(); + } + + @Test + public void serviceHttpConfigurationIsCorrect() { + + ServiceProperties.HttpServiceProperties httpProperties = this.gemfireProperties.getService().getHttp(); + + assertThat(httpProperties).isNotNull(); + assertThat(httpProperties.getBindAddress()).isEqualTo("10.51.151.255"); + assertThat(httpProperties.getPort()).isEqualTo(8181); + assertThat(httpProperties.isSslRequireAuthentication()).isTrue(); + } + + @Test + public void serviceHttpDeveloperRestApiConfigurationIsCorrect() { + + ServiceProperties.DeveloperRestApiProperties developerRestApiProperties = + this.gemfireProperties.getService().getHttp().getDevRestApi(); + + assertThat(developerRestApiProperties).isNotNull(); + assertThat(developerRestApiProperties.isStart()).isTrue(); + } + + @Test + public void serviceMemcachedConfigurationIsCorrect() { + + ServiceProperties.MemcachedServerProperties memcachedProperties = + this.gemfireProperties.getService().getMemcached(); + + assertThat(memcachedProperties).isNotNull(); + assertThat(memcachedProperties.getPort()).isEqualTo(22422); + assertThat(memcachedProperties.getProtocol()).isEqualTo(EnableMemcachedServer.MemcachedProtocol.BINARY); + } + + @Test + public void serviceRedisConfigurationIsCorrect() { + + ServiceProperties.RedisServerProperties redisProperties = this.gemfireProperties.getService().getRedis(); + + assertThat(redisProperties).isNotNull(); + assertThat(redisProperties.getBindAddress()).isEqualTo("10.21.121.242"); + assertThat(redisProperties.getPort()).isEqualTo(3697); + } + + @EnableGemFireMockObjects + @SpringBootApplication(exclude = ContinuousQueryAutoConfiguration.class) + static class TestConfiguration { } + +} diff --git a/spring-geode-autoconfigure/src/test/resources/application-gemfire-config-test.properties b/spring-geode-autoconfigure/src/test/resources/application-gemfire-config-test.properties new file mode 100644 index 00000000..3419e86e --- /dev/null +++ b/spring-geode-autoconfigure/src/test/resources/application-gemfire-config-test.properties @@ -0,0 +1,138 @@ +spring.data.gemfire.name=GemFirePropertiesIntegrationTests +spring.data.gemfire.locators=localhost[11235],localhost[12480] +spring.data.gemfire.use-bean-factory-locator=true +spring.data.gemfire.cache.copy-on-read=true +spring.data.gemfire.cache.critical-heap-percentage=85.5 +spring.data.gemfire.cache.critical-off-heap-percentage=95.0 +spring.data.gemfire.cache.enable-auto-region-lookup=false +spring.data.gemfire.cache.eviction-heap-percentage=50.0 +spring.data.gemfire.cache.eviction-off-heap-percentage=75.5 +spring.data.gemfire.cache.log-level=TRACE +spring.data.gemfire.cache.name=AnotherName +spring.data.gemfire.cache.client.durable-client-id=123 +spring.data.gemfire.cache.client.durable-client-timeout=60 +spring.data.gemfire.cache.client.keep-alive=true +spring.data.gemfire.cache.compression.compressor-bean-name=TestCompressor +spring.data.gemfire.cache.compression.region-names=TestRegionOne,TestRegionTwo +spring.data.gemfire.cache.off-heap.memory-size=65535g +spring.data.gemfire.cache.off-heap.region-names=TestRegionTwo,TestRegionFour +spring.data.gemfire.cache.peer.enable-auto-reconnect=true +spring.data.gemfire.cache.peer.lock-lease=30 +spring.data.gemfire.cache.peer.lock-timeout=5 +spring.data.gemfire.cache.peer.message-sync-interval=2 +spring.data.gemfire.cache.peer.search-timeout=120 +spring.data.gemfire.cache.peer.use-cluster-configuration=true +spring.data.gemfire.cache.server.auto-startup=false +spring.data.gemfire.cache.server.bind-address=10.50.100.200 +spring.data.gemfire.cache.server.hostname-for-clients=skullbox +spring.data.gemfire.cache.server.load-poll-interval=20000 +spring.data.gemfire.cache.server.max-connections=256 +spring.data.gemfire.cache.server.max-message-count=100000 +spring.data.gemfire.cache.server.max-threads=16 +spring.data.gemfire.cache.server.max-time-between-pings=15000 +spring.data.gemfire.cache.server.message-time-to-live=60 +spring.data.gemfire.cache.server.port=12345 +spring.data.gemfire.cache.server.socket-buffer-size=8192 +spring.data.gemfire.cache.server.subscription-capacity=2 +spring.data.gemfire.cache.server.subscription-disk-store-name=TestSubscriptionDiskStore +spring.data.gemfire.cache.server.tcp-no-delay=false +spring.data.gemfire.cluster.region.type=PARTITION_REDUNDANT_PERSISTENT +spring.data.gemfire.disk.store.allow-force-compaction=true +spring.data.gemfire.disk.store.auto-compact=false +spring.data.gemfire.disk.store.compaction-threshold=75 +spring.data.gemfire.disk.store.directory[0].location=/path/to/no/where +spring.data.gemfire.disk.store.directory[0].size=8192 +spring.data.gemfire.disk.store.directory[1].location=/path/to/some/where +spring.data.gemfire.disk.store.directory[1].size=2048 +spring.data.gemfire.disk.store.disk-usage-critical-percentage=95.0 +spring.data.gemfire.disk.store.disk-usage-warning-percentage=89.0 +spring.data.gemfire.disk.store.max-oplog-size=4096 +spring.data.gemfire.disk.store.queue-size=1000 +spring.data.gemfire.disk.store.time-interval=2000 +spring.data.gemfire.disk.store.write-buffer-size=65535 +spring.data.gemfire.entities.base-packages=example.app.model +spring.data.gemfire.locator.host=mailbox +spring.data.gemfire.locator.port=20668 +spring.data.gemfire.logging.level=CONFIG +spring.data.gemfire.logging.log-disk-space-limit=2048 +spring.data.gemfire.logging.log-file=/path/to/geode.log +spring.data.gemfire.logging.log-file-size-limit=50 +spring.data.gemfire.management.use-http=true +spring.data.gemfire.management.http.host=boombox +spring.data.gemfire.management.http.port=8181 +spring.data.gemfire.manager.access-file=/path/to/access/control/list.sys +spring.data.gemfire.manager.bind-address=10.100.50.255 +spring.data.gemfire.manager.hostname-for-clients=bosshog +spring.data.gemfire.manager.password-file=/path/to/password.sys +spring.data.gemfire.manager.port=9090 +spring.data.gemfire.manager.start=true +spring.data.gemfire.manager.update-rate=5000 +spring.data.gemfire.pdx.disk-store-name=TestPdxDiskStore +spring.data.gemfire.pdx.ignore-unread-fields=true +spring.data.gemfire.pdx.persistent=true +spring.data.gemfire.pdx.read-serialized=true +spring.data.gemfire.pdx.serializer-bean-name=TestPdxSerializer +spring.data.gemfire.pool.free-connection-timeout=15000 +spring.data.gemfire.pool.idle-timeout=30000 +spring.data.gemfire.pool.load-conditioning-interval=120000 +spring.data.gemfire.pool.locators=boombox[10334],mailbox[11235],skullbox[20668] +spring.data.gemfire.pool.max-connections=100 +spring.data.gemfire.pool.min-connections=10 +spring.data.gemfire.pool.multi-user-authentication=true +spring.data.gemfire.pool.ping-interval=15000 +spring.data.gemfire.pool.pr-single-hop-enabled=false +spring.data.gemfire.pool.ready-for-events=true +spring.data.gemfire.pool.read-timeout=5000 +spring.data.gemfire.pool.retry-attempts=2 +spring.data.gemfire.pool.server-group=TestServerGroup +spring.data.gemfire.pool.servers=cardboardbox[41414] +spring.data.gemfire.pool.socket-buffer-size=65535 +spring.data.gemfire.pool.statistic-interval=500 +spring.data.gemfire.pool.subscription-ack-interval=500 +spring.data.gemfire.pool.subscription-enabled=true +spring.data.gemfire.pool.subscription-message-tracking-timeout=450000 +spring.data.gemfire.pool.subscription-redundancy=2 +spring.data.gemfire.pool.thread-local-connections=true +spring.data.gemfire.security.username=TestUser +spring.data.gemfire.security.password=TestPassword +spring.data.gemfire.security.properties-file=/path/to/security.properties +spring.data.gemfire.security.client.accessor=TestClientAccessor +spring.data.gemfire.security.client.accessor-post-processor=TestClientAccessorPostProcessor +spring.data.gemfire.security.client.authentication-initializer=TestClientAuthenticationInitializer +spring.data.gemfire.security.client.authenticator=TestClientAuthenticator +spring.data.gemfire.security.client.diffie-hellman-algorithm=RSA +spring.data.gemfire.security.log.file=/path/to/security.log +spring.data.gemfire.security.log.level=info +spring.data.gemfire.security.manager.class-name=example.app.security.manager.TestSecurityManager +spring.data.gemfire.security.peer.authentication-initializer=TestPeerAuthenticationInitializer +spring.data.gemfire.security.peer.authenticator=TestPeerAuthenticator +spring.data.gemfire.security.peer.verify-member-timeout=5000 +spring.data.gemfire.security.post-processor.class-name=example.app.security.processor.TestSecurityPostProcessor +spring.data.gemfire.security.shiro.ini-resource-path=/path/to/shiro.ini +spring.data.gemfire.security.ssl.certificate.alias.all=Master +spring.data.gemfire.security.ssl.certificate.alias.cluster=Custard +spring.data.gemfire.security.ssl.certificate.alias.default-alias=RogueOne +spring.data.gemfire.security.ssl.certificate.alias.gateway=WAN +spring.data.gemfire.security.ssl.certificate.alias.jmx=Manage +spring.data.gemfire.security.ssl.certificate.alias.locator=Local +spring.data.gemfire.security.ssl.certificate.alias.server=Servant +spring.data.gemfire.security.ssl.certificate.alias.web=WWW +spring.data.gemfire.security.ssl.ciphers=AES,DES +spring.data.gemfire.security.ssl.components=gateway,locator,server +spring.data.gemfire.security.ssl.keystore=/path/to/keystore.jks +spring.data.gemfire.security.ssl.keystore-config.password=keypass +spring.data.gemfire.security.ssl.keystore-config.type=JKS +spring.data.gemfire.security.ssl.protocols=any +spring.data.gemfire.security.ssl.require-authentication=false +spring.data.gemfire.security.ssl.web-require-authentication=true +spring.data.gemfire.security.ssl.truststore=/path/to/truststore.jks +spring.data.gemfire.security.ssl.truststore-config.password=storepass +spring.data.gemfire.security.ssl.truststore-config.type=PKS11 +spring.data.gemfire.service.http.bind-address=10.51.151.255 +spring.data.gemfire.service.http.port=8181 +spring.data.gemfire.service.http.ssl-require-authentication=true +spring.data.gemfire.service.http.dev-rest-api.start=true +spring.data.gemfire.service.memcached.port=22422 +spring.data.gemfire.service.memcached.protocol=binary +spring.data.gemfire.service.redis.bind-address=10.21.121.242 +spring.data.gemfire.service.redis.port=3697