Refactor all samples to use the Spring Test for Apache Geode project.

Add appropriate synchronization/coordination between the client and server.
This commit is contained in:
John Blum
2018-08-15 01:03:39 -07:00
parent fbf5044930
commit 1454a81ade
15 changed files with 59 additions and 332 deletions

View File

@@ -26,13 +26,14 @@ 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.annotation.Import;
import org.springframework.data.gemfire.config.annotation.ClientCacheApplication;
import org.springframework.data.gemfire.tests.integration.config.SubscriptionEnabledClientServerIntegrationTestsConfiguration;
import org.springframework.data.gemfire.config.annotation.ClientCacheConfigurer;
import org.springframework.data.gemfire.tests.integration.ClientServerIntegrationTestsSupport;
import org.springframework.data.gemfire.util.CollectionUtils;
import org.springframework.session.data.gemfire.config.annotation.web.http.EnableGemFireHttpSession;
import org.springframework.stereotype.Controller;
@@ -74,14 +75,21 @@ public class Application {
SpringApplication.run(Application.class, args);
}
@ClientCacheApplication(name = "SpringSessionDataGeodeClientBootSample", logLevel = "error",
pingInterval = 5000L, readTimeout = 15000, retryAttempts = 1, subscriptionEnabled = true) // <3>
@ClientCacheApplication(name = "SpringSessionDataGeodeBootSampleClient", logLevel = "error",
readTimeout = 15000, retryAttempts = 1, subscriptionEnabled = true) // <3>
@EnableGemFireHttpSession(poolName = "DEFAULT") // <4>
@Import(SubscriptionEnabledClientServerIntegrationTestsConfiguration.class)
static class ClientCacheConfiguration { }
static class ClientCacheConfiguration extends ClientServerIntegrationTestsSupport {
@Bean
ClientCacheConfigurer gemfireServerReadyConfigurer( // <5>
@Value("${spring.data.gemfire.cache.server.port:40404}") int cacheServerPort) {
return (beanName, clientCacheFactoryBean) -> waitForServerToStart("localhost", cacheServerPort);
}
}
@Configuration
static class SpringWebMvcConfiguration { // <5>
static class SpringWebMvcConfiguration { // <6>
@Bean
public WebMvcConfigurer webMvcConfig() {

View File

@@ -20,7 +20,6 @@ import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.data.gemfire.config.annotation.CacheServerApplication;
import org.springframework.data.gemfire.tests.integration.config.ClientServerIntegrationTestsConfiguration;
import org.springframework.session.data.gemfire.config.annotation.web.http.EnableGemFireHttpSession;
/**
@@ -34,12 +33,11 @@ import org.springframework.session.data.gemfire.config.annotation.web.http.Enabl
* @see org.apache.geode.cache.Cache
* @since 1.2.1
*/
@SuppressWarnings("unused")
// tag::class[]
@SpringBootApplication // <1>
@CacheServerApplication(name = "SpringSessionDataGeodeServerBootSample", logLevel = "error") // <2>
@CacheServerApplication(name = "SpringSessionDataGeodeBootSampleServer", logLevel = "config") // <2>
@EnableGemFireHttpSession(maxInactiveIntervalInSeconds = 20) // <3>
public class GemFireServer extends ClientServerIntegrationTestsConfiguration {
public class GemFireServer {
public static void main(String[] args) {