Adapt to API changes in Spring Data Geode Kay.

This commit is contained in:
John Blum
2017-07-20 13:45:37 -07:00
parent f501df2315
commit 7517ba375d
10 changed files with 118 additions and 29 deletions

View File

@@ -22,6 +22,7 @@ import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
@@ -101,7 +102,7 @@ public class GemFireServer {
}
@Bean
CacheServerFactoryBean gemfireCacheServer(Cache gemfireCache,
CacheServerFactoryBean gemfireCacheServer(GemFireCache gemfireCache,
@Value("${spring-session-data-gemfire.cache.server.bind-address:localhost}") String bindAddress,
@Value("${spring-session-data-gemfire.cache.server.hostname-for-clients:localhost}") String hostnameForClients,
@Value("${spring-session-data-gemfire.cache.server.port:40404}") int port) { // <4>
@@ -110,7 +111,7 @@ public class GemFireServer {
gemfireCacheServer.setAutoStartup(true);
gemfireCacheServer.setBindAddress(bindAddress);
gemfireCacheServer.setCache(gemfireCache);
gemfireCacheServer.setCache((Cache) gemfireCache);
gemfireCacheServer.setHostNameForClients(hostnameForClients);
gemfireCacheServer.setMaxTimeBetweenPings(Long.valueOf(TimeUnit.SECONDS.toMillis(60)).intValue());
gemfireCacheServer.setPort(port);
@@ -120,7 +121,7 @@ public class GemFireServer {
@Bean(name = "Example")
@Profile("debug")
ReplicatedRegionFactoryBean<String, Object> exampleRegion(Cache gemfireCache) {
ReplicatedRegionFactoryBean<String, Object> exampleRegion(GemFireCache gemfireCache) {
ReplicatedRegionFactoryBean<String, Object> exampleRegionFactory = new ReplicatedRegionFactoryBean<>();
@@ -131,7 +132,7 @@ public class GemFireServer {
}
@Autowired
private Cache gemfireCache;
private GemFireCache gemfireCache;
@Bean
@Profile("debug")
@@ -140,6 +141,7 @@ public class GemFireServer {
return args -> {
Region<String, Object> example = this.gemfireCache.getRegion("/Example");
String key = "time";
example.put(key, LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:ss a")));

View File

@@ -21,6 +21,7 @@ import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.GemFireCache;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -50,6 +51,7 @@ public class ServerConfig {
}
Properties gemfireProperties() { // <2>
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name", applicationName());
@@ -72,6 +74,7 @@ public class ServerConfig {
@Bean
CacheFactoryBean gemfireCache() { // <3>
CacheFactoryBean gemfireCache = new CacheFactoryBean();
gemfireCache.setClose(true);
@@ -81,14 +84,14 @@ public class ServerConfig {
}
@Bean
CacheServerFactoryBean gemfireCacheServer(Cache gemfireCache,
CacheServerFactoryBean gemfireCacheServer(GemFireCache gemfireCache,
@Value("${spring.session.data.gemfire.port:" + SERVER_PORT + "}") int port) { // <4>
CacheServerFactoryBean gemfireCacheServer = new CacheServerFactoryBean();
gemfireCacheServer.setAutoStartup(true);
gemfireCacheServer.setBindAddress(SERVER_HOST);
gemfireCacheServer.setCache(gemfireCache);
gemfireCacheServer.setCache((Cache) gemfireCache);
gemfireCacheServer.setHostNameForClients(SERVER_HOST);
gemfireCacheServer.setMaxTimeBetweenPings(Long.valueOf(TimeUnit.SECONDS.toMillis(60)).intValue());
gemfireCacheServer.setPort(port);

View File

@@ -37,6 +37,7 @@ import org.junit.runner.RunWith;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.DataPolicy;
import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionAttributes;
import org.apache.geode.cache.client.ClientCache;
@@ -113,6 +114,7 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
@BeforeClass
public static void startGemFireServer() throws IOException {
long t0 = System.currentTimeMillis();
int port = SocketUtils.findAvailableTcpPort();
@@ -138,6 +140,7 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
@AfterClass
public static void stopGemFireServer() {
if (gemfireServer != null) {
gemfireServer.destroy();
System.err.printf("GemFire Server [exit code = %1$d]%n",
@@ -153,6 +156,7 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
@Before
public void setup() {
assertThat(GemFireUtils.isClient(gemfireCache)).isTrue();
Region<Object, ExpiringSession> springSessionGemFireRegion =
@@ -174,6 +178,7 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
@Test
public void createSessionFiresSessionCreatedEvent() {
long beforeOrAtCreationTime = System.currentTimeMillis();
ExpiringSession expectedSession = save(createSession());
@@ -202,6 +207,7 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
@Test
public void getExistingNonExpiredSessionBeforeAndAfterExpiration() {
ExpiringSession expectedSession = save(touch(createSession()));
AbstractSessionEvent sessionEvent = this.sessionEventListener.waitForSessionEvent(500);
@@ -227,6 +233,7 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
@Test
public void deleteExistingNonExpiredSessionFiresSessionDeletedEventAndReturnsNullOnGet() {
ExpiringSession expectedSession = save(touch(createSession()));
AbstractSessionEvent sessionEvent = this.sessionEventListener.waitForSessionEvent(500);
@@ -324,6 +331,7 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
}
Properties gemfireProperties() {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name", name());
@@ -339,6 +347,7 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
@Bean
CacheFactoryBean gemfireCache() {
CacheFactoryBean gemfireCache = new CacheFactoryBean();
gemfireCache.setClose(true);
@@ -348,12 +357,12 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
}
@Bean
CacheServerFactoryBean gemfireCacheServer(Cache gemfireCache,
CacheServerFactoryBean gemfireCacheServer(GemFireCache gemfireCache,
@Value("${spring.session.data.gemfire.port:" + DEFAULT_GEMFIRE_SERVER_PORT + "}") int port) {
CacheServerFactoryBean cacheServerFactory = new CacheServerFactoryBean();
cacheServerFactory.setCache(gemfireCache);
cacheServerFactory.setCache((Cache) gemfireCache);
cacheServerFactory.setAutoStartup(true);
cacheServerFactory.setBindAddress(SERVER_HOSTNAME);
cacheServerFactory.setPort(port);
@@ -363,6 +372,7 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
@SuppressWarnings("resource")
public static void main(String[] args) throws IOException {
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(SpringSessionDataGemFireServerConfiguration.class);

View File

@@ -34,6 +34,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.client.ClientCache;
import org.springframework.beans.factory.annotation.Value;
@@ -88,6 +89,7 @@ public class ClientServerHttpSessionAttributesDeltaIntegrationTests extends Abst
@BeforeClass
public static void startGemFireServer() throws IOException {
long t0 = System.currentTimeMillis();
int port = SocketUtils.findAvailableTcpPort();
@@ -113,6 +115,7 @@ public class ClientServerHttpSessionAttributesDeltaIntegrationTests extends Abst
@AfterClass
public static void stopGemFireServer() {
if (gemfireServer != null) {
gemfireServer.destroy();
System.err.printf("GemFire Server [exit code = %1$d]%n",
@@ -128,6 +131,7 @@ public class ClientServerHttpSessionAttributesDeltaIntegrationTests extends Abst
@Test
public void sessionCreationAndAccessIsSuccessful() {
ExpiringSession session = save(touch(createSession()));
assertThat(session).isNotNull();
@@ -174,13 +178,17 @@ public class ClientServerHttpSessionAttributesDeltaIntegrationTests extends Abst
}
Properties gemfireProperties() {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("log-level", GEMFIRE_LOG_LEVEL);
return gemfireProperties;
}
@Bean
ClientCacheFactoryBean gemfireCache() {
ClientCacheFactoryBean clientCacheFactory = new ClientCacheFactoryBean();
clientCacheFactory.setClose(true);
@@ -210,6 +218,7 @@ public class ClientServerHttpSessionAttributesDeltaIntegrationTests extends Abst
// used for debugging purposes
@SuppressWarnings("resource")
public static void main(String[] args) {
ConfigurableApplicationContext applicationContext =
new AnnotationConfigApplicationContext(SpringSessionDataGemFireClientConfiguration.class);
@@ -235,6 +244,7 @@ public class ClientServerHttpSessionAttributesDeltaIntegrationTests extends Abst
}
Properties gemfireProperties() {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name", name());
@@ -250,6 +260,7 @@ public class ClientServerHttpSessionAttributesDeltaIntegrationTests extends Abst
@Bean
CacheFactoryBean gemfireCache() {
CacheFactoryBean gemfireCache = new CacheFactoryBean();
gemfireCache.setClose(true);
@@ -259,12 +270,12 @@ public class ClientServerHttpSessionAttributesDeltaIntegrationTests extends Abst
}
@Bean
CacheServerFactoryBean gemfireCacheServer(Cache gemfireCache,
@Value("${spring.session.data.gemfire.port:" + DEFAULT_GEMFIRE_SERVER_PORT + "}") int port) {
CacheServerFactoryBean gemfireCacheServer(GemFireCache gemfireCache,
@Value("${spring.session.data.gemfire.port:" + DEFAULT_GEMFIRE_SERVER_PORT + "}") int port) {
CacheServerFactoryBean cacheServerFactory = new CacheServerFactoryBean();
cacheServerFactory.setCache(gemfireCache);
cacheServerFactory.setCache((Cache) gemfireCache);
cacheServerFactory.setAutoStartup(true);
cacheServerFactory.setBindAddress(SERVER_HOSTNAME);
cacheServerFactory.setPort(port);
@@ -274,6 +285,7 @@ public class ClientServerHttpSessionAttributesDeltaIntegrationTests extends Abst
@SuppressWarnings("resource")
public static void main(String[] args) throws IOException {
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(SpringSessionDataGemFireServerConfiguration.class);

View File

@@ -34,6 +34,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.client.ClientCache;
import org.springframework.beans.factory.annotation.Autowired;
@@ -82,6 +83,7 @@ public class ClientServerProxyRegionSessionOperationsIntegrationTests extends Ab
@BeforeClass
public static void startGemFireServer() throws IOException {
long t0 = System.currentTimeMillis();
int port = SocketUtils.findAvailableTcpPort();
@@ -107,6 +109,7 @@ public class ClientServerProxyRegionSessionOperationsIntegrationTests extends Ab
@AfterClass
public static void stopGemFireServer() {
if (gemfireServer != null) {
gemfireServer.destroy();
System.err.printf("GemFire Server [exit code = %1$d]%n",
@@ -122,6 +125,7 @@ public class ClientServerProxyRegionSessionOperationsIntegrationTests extends Ab
@Test
public void createReadUpdateExpireRecreateDeleteRecreateSessionResultsCorrectSessionCreatedEvents() {
ExpiringSession session = save(touch(createSession()));
assertValidSession(session);
@@ -194,13 +198,17 @@ public class ClientServerProxyRegionSessionOperationsIntegrationTests extends Ab
}
Properties gemfireProperties() {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("log-level", GEMFIRE_LOG_LEVEL);
return gemfireProperties;
}
@Bean
ClientCacheFactoryBean gemfireCache() {
ClientCacheFactoryBean clientCacheFactory = new ClientCacheFactoryBean();
clientCacheFactory.setClose(true);
@@ -235,6 +243,7 @@ public class ClientServerProxyRegionSessionOperationsIntegrationTests extends Ab
// used for debugging purposes
@SuppressWarnings("resource")
public static void main(String[] args) {
ConfigurableApplicationContext applicationContext =
new AnnotationConfigApplicationContext(SpringSessionDataGemFireClientConfiguration.class);
@@ -260,6 +269,7 @@ public class ClientServerProxyRegionSessionOperationsIntegrationTests extends Ab
}
Properties gemfireProperties() {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name", name());
@@ -275,6 +285,7 @@ public class ClientServerProxyRegionSessionOperationsIntegrationTests extends Ab
@Bean
CacheFactoryBean gemfireCache() {
CacheFactoryBean gemfireCache = new CacheFactoryBean();
gemfireCache.setClose(true);
@@ -284,12 +295,12 @@ public class ClientServerProxyRegionSessionOperationsIntegrationTests extends Ab
}
@Bean
CacheServerFactoryBean gemfireCacheServer(Cache gemfireCache,
CacheServerFactoryBean gemfireCacheServer(GemFireCache gemfireCache,
@Value("${spring.session.data.gemfire.port:" + DEFAULT_GEMFIRE_SERVER_PORT + "}") int port) {
CacheServerFactoryBean cacheServerFactory = new CacheServerFactoryBean();
cacheServerFactory.setCache(gemfireCache);
cacheServerFactory.setCache((Cache) gemfireCache);
cacheServerFactory.setAutoStartup(true);
cacheServerFactory.setBindAddress(SERVER_HOSTNAME);
cacheServerFactory.setPort(port);
@@ -299,6 +310,7 @@ public class ClientServerProxyRegionSessionOperationsIntegrationTests extends Ab
@SuppressWarnings("resource")
public static void main(String[] args) throws IOException {
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(SpringSessionDataGemFireServerConfiguration.class);

View File

@@ -90,12 +90,15 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
@Before
public void setup() {
this.context = SecurityContextHolder.createEmptyContext();
this.context.setAuthentication(
new UsernamePasswordAuthenticationToken("username-" + UUID.randomUUID(),
"na", AuthorityUtils.createAuthorityList("ROLE_USER")));
this.changedContext = SecurityContextHolder.createEmptyContext();
this.changedContext.setAuthentication(new UsernamePasswordAuthenticationToken(
"changedContext-" + UUID.randomUUID(), "na",
AuthorityUtils.createAuthorityList("ROLE_USER")));
@@ -103,7 +106,7 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
assertThat(this.gemfireCache).isNotNull();
assertThat(this.gemfireSessionRepository).isNotNull();
assertThat(this.gemfireSessionRepository.getMaxInactiveIntervalInSeconds())
.isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
.isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
Region<Object, ExpiringSession> sessionRegion = this.gemfireCache.getRegion(SPRING_SESSION_GEMFIRE_REGION_NAME);
@@ -119,13 +122,13 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
}
protected Map<String, ExpiringSession> doFindByPrincipalName(String principalName) {
return doFindByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME,
principalName);
return doFindByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, principalName);
}
@SuppressWarnings({ "unchecked" })
protected Map<String, ExpiringSession> doFindByPrincipalName(String regionName,
String principalName) {
try {
Region<String, ExpiringSession> region = this.gemfireCache.getRegion(regionName);
@@ -169,6 +172,7 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
@Test
public void findSessionsByIndexedSessionAttributeNameValues() {
ExpiringSession johnBlumSession = save(touch(setAttribute(
createSession("johnBlum"), "vip", "yes")));
ExpiringSession robWinchSession = save(touch(setAttribute(
@@ -220,6 +224,7 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
@Test
public void findSessionsByPrincipalName() {
ExpiringSession sessionOne = save(touch(createSession("robWinch")));
ExpiringSession sessionTwo = save(touch(createSession("johnBlum")));
ExpiringSession sessionThree = save(touch(createSession("robWinch")));
@@ -255,6 +260,7 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
@Test
public void findSessionsBySecurityPrincipalName() {
ExpiringSession toSave = this.gemfireSessionRepository.createSession();
toSave.setAttribute(SPRING_SECURITY_CONTEXT, this.context);
@@ -269,6 +275,7 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
@Test
public void findSessionsByChangedSecurityPrincipalName() {
ExpiringSession toSave = this.gemfireSessionRepository.createSession();
toSave.setAttribute(SPRING_SECURITY_CONTEXT, this.context);
@@ -290,8 +297,8 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
@Test
public void findsNoSessionsByNonExistingPrincipal() {
Map<String, ExpiringSession> nonExistingPrincipalSessions =
doFindByPrincipalName("nonExistingPrincipalName");
Map<String, ExpiringSession> nonExistingPrincipalSessions = doFindByPrincipalName("nonExistingPrincipalName");
assertThat(nonExistingPrincipalSessions).isNotNull();
assertThat(nonExistingPrincipalSessions.isEmpty()).isTrue();
@@ -299,7 +306,9 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
@Test
public void findsNoSessionsAfterPrincipalIsRemoved() {
String username = "doesNotFindAfterPrincipalRemoved";
ExpiringSession session = save(touch(createSession(username)));
session.setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, null);
@@ -314,6 +323,7 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
@Test
public void saveAndReadSessionWithAttributes() {
ExpiringSession expectedSession = this.gemfireSessionRepository.createSession();
assertThat(expectedSession).isInstanceOf(AbstractGemFireOperationsSessionRepository.GemFireSession.class);
@@ -361,6 +371,7 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
static class SpringSessionGemFireConfiguration {
Properties gemfireProperties() {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name", GemFireOperationsSessionRepositoryIntegrationTests.class.getName());
@@ -371,6 +382,7 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
@Bean
CacheFactoryBean gemfireCache() {
CacheFactoryBean gemfireCache = new CacheFactoryBean();
gemfireCache.setClose(true);
@@ -422,14 +434,16 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
@SuppressWarnings("all")
public int compareTo(final Person person) {
int compareValue = getLastName().compareTo(person.getLastName());
return (compareValue != 0 ? compareValue
: getFirstName().compareTo(person.getFirstName()));
return (compareValue != 0 ? compareValue : getFirstName().compareTo(person.getFirstName()));
}
@Override
public boolean equals(final Object obj) {
if (obj == this) {
if (this == obj) {
return true;
}
@@ -440,14 +454,17 @@ public class GemFireOperationsSessionRepositoryIntegrationTests extends Abstract
Person that = (Person) obj;
return ObjectUtils.nullSafeEquals(this.getFirstName(), that.getFirstName())
&& ObjectUtils.nullSafeEquals(this.getLastName(), that.getLastName());
&& ObjectUtils.nullSafeEquals(this.getLastName(), that.getLastName());
}
@Override
public int hashCode() {
int hashValue = 17;
hashValue = 37 * hashValue + ObjectUtils.nullSafeHashCode(getFirstName());
hashValue = 37 * hashValue + ObjectUtils.nullSafeHashCode(getLastName());
return hashValue;
}

View File

@@ -35,6 +35,7 @@ import org.junit.runner.RunWith;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.DataPolicy;
import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionAttributes;
import org.apache.geode.cache.client.ClientCache;
@@ -107,6 +108,7 @@ public class MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationT
@BeforeClass
public static void startGemFireServer() throws IOException {
final long t0 = System.currentTimeMillis();
final int port = SocketUtils.findAvailableTcpPort();
@@ -131,6 +133,7 @@ public class MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationT
@AfterClass
public static void stopGemFireServerAndDeleteArtifacts() {
if (gemfireServer != null) {
gemfireServer.destroyForcibly();
System.err.printf("GemFire Server [exit code = %1$d]%n",
@@ -146,6 +149,7 @@ public class MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationT
@Before
public void setup() {
assertThat(GemFireUtils.isClient(gemfireCache)).isTrue();
Region<Object, ExpiringSession> springSessionGemFireRegion =
@@ -166,6 +170,7 @@ public class MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationT
@Test
public void getExistingNonExpiredSessionBeforeAndAfterExpiration() {
ExpiringSession expectedSession = save(touch(createSession()));
AbstractSessionEvent sessionEvent = this.sessionEventListener.waitForSessionEvent(500);
@@ -202,9 +207,12 @@ public class MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationT
@Bean
Properties gemfireProperties() {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name", name());
gemfireProperties.setProperty("log-level", GEMFIRE_LOG_LEVEL);
return gemfireProperties;
}
@@ -214,6 +222,7 @@ public class MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationT
@Bean
ClientCacheFactoryBean gemfireCache() {
ClientCacheFactoryBean gemfireCache = new ClientCacheFactoryBean();
gemfireCache.setClose(true);
@@ -225,6 +234,7 @@ public class MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationT
@Bean
PoolFactoryBean gemfirePool() {
PoolFactoryBean poolFactory = new PoolFactoryBean();
poolFactory.setFreeConnectionTimeout(5000); // 5 seconds
@@ -240,7 +250,7 @@ public class MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationT
@Bean
PoolFactoryBean serverPool(@Value("${spring.session.data.gemfire.port:"
+ DEFAULT_GEMFIRE_SERVER_PORT + "}") int port) {
+ DEFAULT_GEMFIRE_SERVER_PORT + "}") int port) {
PoolFactoryBean poolFactory = new PoolFactoryBean();
@@ -267,6 +277,7 @@ public class MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationT
// used for debugging purposes
@SuppressWarnings("resource")
public static void main(final String[] args) {
ConfigurableApplicationContext applicationContext = new AnnotationConfigApplicationContext(
SpringSessionGemFireClientConfiguration.class);
@@ -294,6 +305,7 @@ public class MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationT
@Bean
Properties gemfireProperties() {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name", name());
@@ -310,6 +322,7 @@ public class MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationT
@Bean
CacheFactoryBean gemfireCache() {
CacheFactoryBean gemfireCache = new CacheFactoryBean();
gemfireCache.setClose(true);
@@ -319,14 +332,14 @@ public class MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationT
}
@Bean
CacheServerFactoryBean gemfireCacheServer(Cache gemfireCache,
CacheServerFactoryBean gemfireCacheServer(GemFireCache gemfireCache,
@Value("${spring.session.data.gemfire.port:" + DEFAULT_GEMFIRE_SERVER_PORT + "}") int port) {
CacheServerFactoryBean cacheServerFactory = new CacheServerFactoryBean();
cacheServerFactory.setAutoStartup(true);
cacheServerFactory.setBindAddress(SERVER_HOSTNAME);
cacheServerFactory.setCache(gemfireCache);
cacheServerFactory.setCache((Cache) gemfireCache);
cacheServerFactory.setMaxConnections(MAX_CONNECTIONS);
cacheServerFactory.setPort(port);
@@ -335,9 +348,12 @@ public class MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationT
@SuppressWarnings("resource")
public static void main(final String[] args) throws IOException {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
SpringSessionGemFireServerConfiguration.class);
context.registerShutdownHook();
writeProcessControlFile(WORKING_DIRECTORY);
}
}

View File

@@ -84,10 +84,10 @@ public class EnableGemFireHttpSessionEventsIntegrationTests extends AbstractGemF
@Before
public void setup() {
assertThat(GemFireUtils.isPeer(this.gemfireCache)).isTrue();
assertThat(this.gemfireSessionRepository).isNotNull();
assertThat(this.gemfireSessionRepository.getMaxInactiveIntervalInSeconds())
.isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
assertThat(this.gemfireSessionRepository.getMaxInactiveIntervalInSeconds()).isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
assertThat(this.sessionEventListener).isNotNull();
Region<Object, ExpiringSession> sessionRegion = this.gemfireCache.getRegion(SPRING_SESSION_GEMFIRE_REGION_NAME);
@@ -103,6 +103,7 @@ public class EnableGemFireHttpSessionEventsIntegrationTests extends AbstractGemF
@Test
public void sessionCreatedEvent() {
final long beforeOrAtCreationTime = System.currentTimeMillis();
ExpiringSession expectedSession = save(createSession());
@@ -123,6 +124,7 @@ public class EnableGemFireHttpSessionEventsIntegrationTests extends AbstractGemF
@Test
public void getExistingNonExpiredSession() {
ExpiringSession expectedSession = save(touch(createSession()));
assertThat(expectedSession.isExpired()).isFalse();
@@ -135,6 +137,7 @@ public class EnableGemFireHttpSessionEventsIntegrationTests extends AbstractGemF
@Test
public void getExistingExpiredSession() {
ExpiringSession expectedSession = save(expire(createSession()));
AbstractSessionEvent sessionEvent = this.sessionEventListener.getSessionEvent();
@@ -155,6 +158,7 @@ public class EnableGemFireHttpSessionEventsIntegrationTests extends AbstractGemF
@Test
public void deleteExistingNonExpiredSession() {
ExpiringSession expectedSession = save(touch(createSession()));
ExpiringSession savedSession = this.gemfireSessionRepository.getSession(expectedSession.getId());
@@ -176,6 +180,7 @@ public class EnableGemFireHttpSessionEventsIntegrationTests extends AbstractGemF
@Test
public void deleteExistingExpiredSession() {
ExpiringSession expectedSession = save(createSession());
AbstractSessionEvent sessionEvent = this.sessionEventListener.getSessionEvent();
@@ -208,6 +213,7 @@ public class EnableGemFireHttpSessionEventsIntegrationTests extends AbstractGemF
@Test
public void deleteNonExistingSession() {
String expectedSessionId = UUID.randomUUID().toString();
assertThat(this.gemfireSessionRepository.<ExpiringSession>getSession(expectedSessionId)).isNull();
@@ -226,10 +232,10 @@ public class EnableGemFireHttpSessionEventsIntegrationTests extends AbstractGemF
@Bean
Properties gemfireProperties() {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name",
EnableGemFireHttpSessionEventsIntegrationTests.class.getName());
gemfireProperties.setProperty("name", EnableGemFireHttpSessionEventsIntegrationTests.class.getName());
gemfireProperties.setProperty("mcast-port", "0");
gemfireProperties.setProperty("log-level", GEMFIRE_LOG_LEVEL);
@@ -238,6 +244,7 @@ public class EnableGemFireHttpSessionEventsIntegrationTests extends AbstractGemF
@Bean
CacheFactoryBean gemfireCache() {
CacheFactoryBean gemfireCache = new CacheFactoryBean();
gemfireCache.setClose(true);

View File

@@ -81,6 +81,7 @@ public class GemFireHttpSessionJavaConfigurationTests extends AbstractGemFireInt
@Test
public void gemfireCacheConfigurationIsValid() {
Region<Object, ExpiringSession> example =
assertCacheAndRegion(this.gemfireCache, "JavaExample", DataPolicy.REPLICATE);
@@ -89,6 +90,7 @@ public class GemFireHttpSessionJavaConfigurationTests extends AbstractGemFireInt
@Test
public void verifyGemFireExampleCacheRegionPrincipalNameIndexWasCreatedSuccessfully() {
Region<Object, ExpiringSession> example =
assertCacheAndRegion(this.gemfireCache, "JavaExample", DataPolicy.REPLICATE);
@@ -103,6 +105,7 @@ public class GemFireHttpSessionJavaConfigurationTests extends AbstractGemFireInt
@Test
public void verifyGemFireExampleCacheRegionSessionAttributesIndexWasNotCreated() {
Region<Object, ExpiringSession> example =
assertCacheAndRegion(this.gemfireCache, "JavaExample", DataPolicy.REPLICATE);
@@ -120,10 +123,13 @@ public class GemFireHttpSessionJavaConfigurationTests extends AbstractGemFireInt
public static class GemFireConfiguration {
Properties gemfireProperties() {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name", applicationName());
gemfireProperties.setProperty("mcast-port", "0");
gemfireProperties.setProperty("log-level", logLevel());
return gemfireProperties;
}
@@ -137,6 +143,7 @@ public class GemFireHttpSessionJavaConfigurationTests extends AbstractGemFireInt
@Bean
CacheFactoryBean gemfireCache() {
CacheFactoryBean cacheFactory = new CacheFactoryBean();
cacheFactory.setClose(true);

View File

@@ -76,6 +76,7 @@ public class GemFireHttpSessionXmlConfigurationTests extends AbstractGemFireInte
@Test
public void gemfireCacheConfigurationIsValid() {
Region<Object, ExpiringSession> example =
assertCacheAndRegion(this.gemfireCache, "XmlExample", DataPolicy.NORMAL);
@@ -84,6 +85,7 @@ public class GemFireHttpSessionXmlConfigurationTests extends AbstractGemFireInte
@Test
public void verifyGemFireExampleCacheRegionPrincipalNameIndexWasCreatedSuccessfully() {
Region<Object, ExpiringSession> example =
assertCacheAndRegion(this.gemfireCache, "XmlExample", DataPolicy.NORMAL);
@@ -98,6 +100,7 @@ public class GemFireHttpSessionXmlConfigurationTests extends AbstractGemFireInte
@Test
public void verifyGemFireExampleCacheRegionSessionAttributesIndexWasCreatedSuccessfully() {
Region<Object, ExpiringSession> example =
assertCacheAndRegion(this.gemfireCache, "XmlExample", DataPolicy.NORMAL);