Refactor Spring Session Boot Sample to use Spring Data for Apache Geode Test.

Remove the sample.client.IntegrationTestConfiugration class.

Refactor sample.server.GemFireServer class to extend ClientServerIntegrationTestsConfiguration.

Refactor sample.client.Application.ClientCacheConfiguration class to import SubscriptionEnabledClientServerIntegrationTestsConfiguration class.

Refactor integrationTest.doFirst to set the 'spring.data.gemfire.cache.server.port' property.

Refactor integrationTest.onLast to call runGemFireServer.process?.destroy().

Add 'spring.data.gemfire.cache.server.port' property to the System properties when forking & launching the GemFire server in runGemFireServer.doLast.
This commit is contained in:
John Blum
2018-08-13 16:04:35 -07:00
parent 3c984bad1d
commit 6ad1813ddf
4 changed files with 21 additions and 209 deletions

View File

@@ -26,14 +26,13 @@ import java.util.Optional;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.context.annotation.Import;
import org.springframework.data.gemfire.config.annotation.ClientCacheApplication;
import org.springframework.data.gemfire.config.annotation.ClientCacheConfigurer;
import org.springframework.data.gemfire.tests.integration.config.SubscriptionEnabledClientServerIntegrationTestsConfiguration;
import org.springframework.data.gemfire.util.CollectionUtils;
import org.springframework.session.data.gemfire.config.annotation.web.http.EnableGemFireHttpSession;
import org.springframework.stereotype.Controller;
@@ -78,26 +77,11 @@ public class Application {
@ClientCacheApplication(name = "SpringSessionDataGeodeClientBootSample", logLevel = "error",
pingInterval = 5000L, readTimeout = 15000, retryAttempts = 1, subscriptionEnabled = true) // <3>
@EnableGemFireHttpSession(poolName = "DEFAULT") // <4>
static class ClientCacheConfiguration extends IntegrationTestConfiguration {
// Required to resolve property placeholders in Spring @Value annotations.
@Bean
static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
@Bean
ClientCacheConfigurer clientCacheServerPortConfigurer(
@Value("${spring.session.data.geode.cache.server.port:40404}") int port) { // <5>
return (beanName, clientCacheFactoryBean) ->
clientCacheFactoryBean.setServers(Collections.singletonList(
newConnectionEndpoint("localhost", port)));
}
}
@Import(SubscriptionEnabledClientServerIntegrationTestsConfiguration.class)
static class ClientCacheConfiguration { }
@Configuration
static class SpringWebMvcConfiguration { // <6>
static class SpringWebMvcConfiguration { // <5>
@Bean
public WebMvcConfigurer webMvcConfig() {