diff --git a/gradle.properties b/gradle.properties index a9673de2..e95a5ae6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,30 +1,30 @@ +assertjVersion=2.5.0 bootstrapVersion=2.3.2 -commonsPoolVersion=2.4.2 -jacksonVersion=2.6.5 -jspApiVersion=2.0 -servletApiVersion=3.0.1 -jstlelVersion=1.2.5 -version=1.4.0.BUILD-SNAPSHOT -springDataRedisVersion=1.8.0.RC1 -html5ShivVersion=3.7.3 commonsLoggingVersion=1.2 +commonsPoolVersion=2.4.2 +gebVersion=0.13.1 +groovyVersion=2.4.4 +h2Version=1.4.192 +hazelcastVersion=3.6.5 +httpClientVersion=4.5.1 +html5ShivVersion=3.7.3 +jacksonVersion=2.6.5 +jedisVersion=2.9.0 +jspApiVersion=2.0 +jstlVersion=1.2.1 +jstlelVersion=1.2.5 junitVersion=4.12 lettuceVersion=4.3.0.Final -gebVersion=0.13.1 mockitoVersion=1.10.19 -hazelcastVersion=3.6.5 seleniumVersion=2.52.0 -springDataGeodeVersion=1.0.0.APACHE-GEODE-INCUBATING-M2 -springSecurityVersion=4.2.0.RELEASE +servletApiVersion=3.0.1 springVersion=4.3.4.RELEASE -httpClientVersion=4.5.1 -jedisVersion=2.9.0 -h2Version=1.4.192 +springDataGemFireVersion=1.9.3.RELEASE +springDataGeodeVersion=1.0.0.INCUBATING-RELEASE springDataMongoVersion=1.9.4.RELEASE +springDataRedisVersion=1.8.0.RC1 +springSecurityVersion=4.2.0.RELEASE springShellVersion=1.1.0.RELEASE -springDataGemFireVersion=1.8.5.RELEASE -assertjVersion=2.5.0 spockVersion=1.0-groovy-2.4 webjarsTaglibVersion=0.3 -jstlVersion=1.2.1 -groovyVersion=2.4.4 +version=1.4.0.BUILD-SNAPSHOT diff --git a/samples/javaconfig/gemfire-clientserver/src/main/java/sample/ClientConfig.java b/samples/javaconfig/gemfire-clientserver/src/main/java/sample/ClientConfig.java index b09f3dbe..b3c130ba 100644 --- a/samples/javaconfig/gemfire-clientserver/src/main/java/sample/ClientConfig.java +++ b/samples/javaconfig/gemfire-clientserver/src/main/java/sample/ClientConfig.java @@ -38,7 +38,7 @@ import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.context.annotation.Bean; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.data.gemfire.client.ClientCacheFactoryBean; -import org.springframework.data.gemfire.config.GemfireConstants; +import org.springframework.data.gemfire.config.xml.GemfireConstants; import org.springframework.data.gemfire.support.ConnectionEndpoint; import org.springframework.session.data.gemfire.config.annotation.web.http.EnableGemFireHttpSession; import org.springframework.session.data.gemfire.config.annotation.web.http.GemFireHttpSessionConfiguration; diff --git a/samples/xml/gemfire-clientserver/src/main/java/sample/GemFireClientServerReadyBeanPostProcessor.java b/samples/xml/gemfire-clientserver/src/main/java/sample/GemFireClientServerReadyBeanPostProcessor.java index 896d1b39..19430e20 100644 --- a/samples/xml/gemfire-clientserver/src/main/java/sample/GemFireClientServerReadyBeanPostProcessor.java +++ b/samples/xml/gemfire-clientserver/src/main/java/sample/GemFireClientServerReadyBeanPostProcessor.java @@ -32,7 +32,7 @@ import com.gemstone.gemfire.management.membership.ClientMembershipListenerAdapte import org.springframework.beans.BeansException; import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.data.gemfire.config.GemfireConstants; +import org.springframework.data.gemfire.config.xml.GemfireConstants; import org.springframework.session.data.gemfire.config.annotation.web.http.GemFireHttpSessionConfiguration; import org.springframework.util.Assert; diff --git a/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/AbstractGemFireIntegrationTests.java b/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/AbstractGemFireIntegrationTests.java index be063530..2daa5117 100644 --- a/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/AbstractGemFireIntegrationTests.java +++ b/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/AbstractGemFireIntegrationTests.java @@ -47,8 +47,8 @@ import org.springframework.session.events.AbstractSessionEvent; import static org.assertj.core.api.Assertions.assertThat; /** - * AbstractGemFireIntegrationTests is an abstract base class encapsulating common - * operations for writing Spring Session GemFire integration tests. + * {@link AbstractGemFireIntegrationTests} is an abstract base class encapsulating common + * operations for writing Spring Session Data GemFire integration tests. * * @author John Blum * @since 1.1.0 @@ -74,8 +74,7 @@ public abstract class AbstractGemFireIntegrationTests { protected static final long DEFAULT_WAIT_DURATION = TimeUnit.SECONDS.toMillis(20); protected static final long DEFAULT_WAIT_INTERVAL = 500L; - protected static final File WORKING_DIRECTORY = - new File(System.getProperty("user.dir")); + protected static final File WORKING_DIRECTORY = new File(System.getProperty("user.dir")); protected static final String DEFAULT_PROCESS_CONTROL_FILENAME = "process.ctl"; @@ -83,7 +82,7 @@ public abstract class AbstractGemFireIntegrationTests { System.getProperty("spring.session.data.gemfire.log-file", "server.log"); protected static final String GEMFIRE_LOG_LEVEL = - System.getProperty("spring.session.data.gemfire.log-level", "warning"); + System.getProperty("spring.session.data.gemfire.log-level", "error"); @Autowired protected Cache gemfireCache; @@ -258,7 +257,7 @@ public abstract class AbstractGemFireIntegrationTests { /* (non-Javadoc) */ protected static int waitForProcessToStop(Process process, File directory, long duration) { - final long timeout = (System.currentTimeMillis() + duration); + long timeout = (System.currentTimeMillis() + duration); try { while (process.isAlive() && System.currentTimeMillis() < timeout) { @@ -282,7 +281,7 @@ public abstract class AbstractGemFireIntegrationTests { /* (non-Javadoc) */ @SuppressWarnings("all") protected static boolean waitOnCondition(Condition condition, long duration) { - final long timeout = (System.currentTimeMillis() + duration); + long timeout = (System.currentTimeMillis() + duration); try { while (!condition.evaluate() && System.currentTimeMillis() < timeout) { @@ -335,6 +334,7 @@ public abstract class AbstractGemFireIntegrationTests { /* (non-Javadoc) */ protected void assertEntryIdleTimeout(ExpirationAttributes actualExpirationAttributes, ExpirationAction expectedAction, int expectedTimeout) { + assertThat(actualExpirationAttributes).isNotNull(); assertThat(actualExpirationAttributes.getAction()).isEqualTo(expectedAction); assertThat(actualExpirationAttributes.getTimeout()).isEqualTo(expectedTimeout); @@ -446,5 +446,4 @@ public abstract class AbstractGemFireIntegrationTests { protected interface Condition { boolean evaluate(); } - } diff --git a/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/ClientServerGemFireOperationsSessionRepositoryIntegrationTests.java b/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/ClientServerGemFireOperationsSessionRepositoryIntegrationTests.java index a05af13e..9762158d 100644 --- a/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/ClientServerGemFireOperationsSessionRepositoryIntegrationTests.java +++ b/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/ClientServerGemFireOperationsSessionRepositoryIntegrationTests.java @@ -31,6 +31,8 @@ import com.gemstone.gemfire.cache.DataPolicy; import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.RegionAttributes; import com.gemstone.gemfire.cache.client.ClientCache; +import com.gemstone.gemfire.cache.client.ClientRegionShortcut; + import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -58,7 +60,7 @@ import org.springframework.session.events.SessionDeletedEvent; import org.springframework.session.events.SessionExpiredEvent; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.util.FileSystemUtils; import org.springframework.util.SocketUtils; @@ -66,28 +68,29 @@ import org.springframework.util.SocketUtils; import static org.assertj.core.api.Assertions.assertThat; /** - * The ClientServerGemFireOperationsSessionRepositoryIntegrationTests class is a test - * suite of test cases testing the functionality of GemFire-backed Spring Sessions using a - * GemFire client-server topology. + * Integration tests to test the functionality of GemFire-backed Spring Sessions using + * the GemFire client-server topology. * * @author John Blum * @since 1.1.0 * @see org.junit.Test * @see org.junit.runner.RunWith + * @see org.springframework.context.ConfigurableApplicationContext + * @see org.springframework.session.ExpiringSession * @see org.springframework.session.data.gemfire.AbstractGemFireIntegrationTests * @see org.springframework.session.data.gemfire.config.annotation.web.http.EnableGemFireHttpSession * @see org.springframework.session.data.gemfire.config.annotation.web.http.GemFireHttpSessionConfiguration * @see org.springframework.test.annotation.DirtiesContext * @see org.springframework.test.context.ContextConfiguration - * @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner + * @see org.springframework.test.context.junit4.SpringRunner * @see org.springframework.test.context.web.WebAppConfiguration * @see com.gemstone.gemfire.cache.Cache + * @see com.gemstone.gemfire.cache.Region * @see com.gemstone.gemfire.cache.client.ClientCache - * @see com.gemstone.gemfire.cache.client.Pool - * @see com.gemstone.gemfire.cache.server.CacheServer */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = ClientServerGemFireOperationsSessionRepositoryIntegrationTests.SpringSessionGemFireClientConfiguration.class) +@RunWith(SpringRunner.class) +@ContextConfiguration(classes = + ClientServerGemFireOperationsSessionRepositoryIntegrationTests.SpringSessionDataGemFireClientConfiguration.class) @DirtiesContext @WebAppConfiguration public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests @@ -108,24 +111,25 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests @BeforeClass public static void startGemFireServer() throws IOException { - final long t0 = System.currentTimeMillis(); + long t0 = System.currentTimeMillis(); - final int port = SocketUtils.findAvailableTcpPort(); + int port = SocketUtils.findAvailableTcpPort(); - System.err.printf("Starting a GemFire Server on [%1$s] listening on port [%2$d]%n", - SpringSessionGemFireServerConfiguration.SERVER_HOSTNAME, port); + System.err.printf("Starting a GemFire Server running on host [%1$s] listening on port [%2$d]%n", + SpringSessionDataGemFireServerConfiguration.SERVER_HOSTNAME, port); System.setProperty("spring.session.data.gemfire.port", String.valueOf(port)); - String processWorkingDirectoryPathname = String.format("gemfire-client-server-tests-%1$s", - TIMESTAMP.format(new Date())); + String processWorkingDirectoryPathname = + String.format("gemfire-client-server-tests-%1$s", TIMESTAMP.format(new Date())); processWorkingDirectory = createDirectory(processWorkingDirectoryPathname); - gemfireServer = run(SpringSessionGemFireServerConfiguration.class, processWorkingDirectory, + gemfireServer = run(SpringSessionDataGemFireServerConfiguration.class, processWorkingDirectory, String.format("-Dspring.session.data.gemfire.port=%1$d", port)); - assertThat(waitForCacheServerToStart(SpringSessionGemFireServerConfiguration.SERVER_HOSTNAME, port)).isTrue(); + assertThat(waitForCacheServerToStart(SpringSessionDataGemFireServerConfiguration.SERVER_HOSTNAME, port)) + .isTrue(); System.err.printf("GemFire Server [startup time = %1$d ms]%n", System.currentTimeMillis() - t0); } @@ -133,7 +137,7 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests @AfterClass public static void stopGemFireServerAndDeleteArtifacts() { if (gemfireServer != null) { - gemfireServer.destroyForcibly(); + gemfireServer.destroy(); System.err.printf("GemFire Server [exit code = %1$d]%n", waitForProcessToStop(gemfireServer, processWorkingDirectory)); } @@ -158,7 +162,7 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests springSessionGemFireRegion.getAttributes(); assertThat(springSessionGemFireRegionAttributes).isNotNull(); - assertThat(springSessionGemFireRegionAttributes.getDataPolicy()).isEqualTo(DataPolicy.EMPTY); + assertThat(springSessionGemFireRegionAttributes.getDataPolicy()).isEqualTo(DataPolicy.NORMAL); } @After @@ -168,7 +172,7 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests @Test public void createSessionFiresSessionCreatedEvent() { - final long beforeOrAtCreationTime = System.currentTimeMillis(); + long beforeOrAtCreationTime = System.currentTimeMillis(); ExpiringSession expectedSession = save(createSession()); @@ -178,12 +182,19 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests ExpiringSession createdSession = sessionEvent.getSession(); - assertThat(createdSession).isEqualTo(expectedSession); - assertThat(createdSession.getId()).isNotNull(); + assertThat(createdSession.getId()).isEqualTo(expectedSession.getId()); assertThat(createdSession.getCreationTime()).isGreaterThanOrEqualTo(beforeOrAtCreationTime); assertThat(createdSession.getLastAccessedTime()).isEqualTo(createdSession.getCreationTime()); assertThat(createdSession.getMaxInactiveIntervalInSeconds()).isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS); + createdSession.setAttribute("attrOne", 1); + + assertThat(save(touch(createdSession)).getAttribute("attrOne")).isEqualTo(1); + + sessionEvent = this.sessionEventListener.waitForSessionEvent(500); + + assertThat(sessionEvent).isNull(); + this.gemfireSessionRepository.delete(expectedSession.getId()); } @@ -194,19 +205,13 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests AbstractSessionEvent sessionEvent = this.sessionEventListener.waitForSessionEvent(500); assertThat(sessionEvent).isInstanceOf(SessionCreatedEvent.class); - assertThat(sessionEvent.getSession()).isEqualTo(expectedSession); + assertThat(sessionEvent.getSession()).isEqualTo(expectedSession); assertThat(this.sessionEventListener.getSessionEvent()).isNull(); ExpiringSession savedSession = this.gemfireSessionRepository.getSession(expectedSession.getId()); assertThat(savedSession).isEqualTo(expectedSession); - // NOTE for some reason or another, performing a GemFire (Client)Cache - // Region.get(key) - // causes a Region CREATE event... o.O - // calling sessionEventListener.getSessionEvent() here to clear the event - this.sessionEventListener.getSessionEvent(); - sessionEvent = this.sessionEventListener.waitForSessionEvent( TimeUnit.SECONDS.toMillis(MAX_INACTIVE_INTERVAL_IN_SECONDS + 1)); @@ -240,11 +245,12 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests } @EnableGemFireHttpSession(regionName = SPRING_SESSION_GEMFIRE_REGION_NAME, - maxInactiveIntervalInSeconds = MAX_INACTIVE_INTERVAL_IN_SECONDS) - static class SpringSessionGemFireClientConfiguration { + clientRegionShortcut = ClientRegionShortcut.CACHING_PROXY, + maxInactiveIntervalInSeconds = MAX_INACTIVE_INTERVAL_IN_SECONDS) + static class SpringSessionDataGemFireClientConfiguration { @Bean - static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() { + static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { return new PropertySourcesPlaceholderConfigurer(); } @@ -270,17 +276,14 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests PoolFactoryBean poolFactory = new PoolFactoryBean(); - poolFactory.setFreeConnectionTimeout(5000); // 5 seconds poolFactory.setKeepAlive(false); - poolFactory.setMaxConnections(SpringSessionGemFireServerConfiguration.MAX_CONNECTIONS); poolFactory.setPingInterval(TimeUnit.SECONDS.toMillis(5)); poolFactory.setReadTimeout(2000); // 2 seconds poolFactory.setRetryAttempts(1); poolFactory.setSubscriptionEnabled(true); - poolFactory.setThreadLocalConnections(false); poolFactory.setServers(Collections.singletonList(new ConnectionEndpoint( - SpringSessionGemFireServerConfiguration.SERVER_HOSTNAME, port))); + SpringSessionDataGemFireServerConfiguration.SERVER_HOSTNAME, port))); return poolFactory; } @@ -292,9 +295,9 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests // used for debugging purposes @SuppressWarnings("resource") - public static void main(final String[] args) { + public static void main(String[] args) { ConfigurableApplicationContext applicationContext = new AnnotationConfigApplicationContext( - SpringSessionGemFireClientConfiguration.class); + SpringSessionDataGemFireClientConfiguration.class); applicationContext.registerShutdownHook(); @@ -309,30 +312,27 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests @EnableGemFireHttpSession(regionName = SPRING_SESSION_GEMFIRE_REGION_NAME, maxInactiveIntervalInSeconds = MAX_INACTIVE_INTERVAL_IN_SECONDS) - static class SpringSessionGemFireServerConfiguration { + static class SpringSessionDataGemFireServerConfiguration { - static final int MAX_CONNECTIONS = 50; static final String SERVER_HOSTNAME = "localhost"; @Bean - PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { + static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { return new PropertySourcesPlaceholderConfigurer(); } - @Bean Properties gemfireProperties() { Properties gemfireProperties = new Properties(); gemfireProperties.setProperty("name", name()); gemfireProperties.setProperty("mcast-port", "0"); - gemfireProperties.setProperty("log-file", "server.log"); gemfireProperties.setProperty("log-level", GEMFIRE_LOG_LEVEL); return gemfireProperties; } String name() { - return SpringSessionGemFireServerConfiguration.class.getName(); + return SpringSessionDataGemFireServerConfiguration.class.getName(); } @Bean @@ -351,22 +351,22 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests CacheServerFactoryBean cacheServerFactory = new CacheServerFactoryBean(); + cacheServerFactory.setCache(gemfireCache); cacheServerFactory.setAutoStartup(true); cacheServerFactory.setBindAddress(SERVER_HOSTNAME); - cacheServerFactory.setCache(gemfireCache); - cacheServerFactory.setMaxConnections(MAX_CONNECTIONS); cacheServerFactory.setPort(port); return cacheServerFactory; } @SuppressWarnings("resource") - public static void main(final String[] args) throws IOException { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( - SpringSessionGemFireServerConfiguration.class); + public static void main(String[] args) throws IOException { + AnnotationConfigApplicationContext context = + new AnnotationConfigApplicationContext(SpringSessionDataGemFireServerConfiguration.class); + context.registerShutdownHook(); + writeProcessControlFile(WORKING_DIRECTORY); } } - } diff --git a/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/ClientServerHttpSessionAttributesDeltaIntegrationTests.java b/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/ClientServerHttpSessionAttributesDeltaIntegrationTests.java new file mode 100644 index 00000000..101cf747 --- /dev/null +++ b/spring-session/src/integration-test/java/org/springframework/session/data/gemfire/ClientServerHttpSessionAttributesDeltaIntegrationTests.java @@ -0,0 +1,285 @@ +/* + * Copyright 2014-2016 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.session.data.gemfire; + +import java.io.File; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Collections; +import java.util.Date; +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.client.ClientCache; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; +import org.springframework.data.gemfire.CacheFactoryBean; +import org.springframework.data.gemfire.client.ClientCacheFactoryBean; +import org.springframework.data.gemfire.client.PoolFactoryBean; +import org.springframework.data.gemfire.server.CacheServerFactoryBean; +import org.springframework.data.gemfire.support.ConnectionEndpoint; +import org.springframework.session.ExpiringSession; +import org.springframework.session.data.gemfire.config.annotation.web.http.EnableGemFireHttpSession; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.util.FileSystemUtils; +import org.springframework.util.SocketUtils; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Integration tests testing the addition/removal of HTTP Session Attributes + * and the proper persistence of the HTTP Session state in a GemFire cache + * across a client/server topology. + * + * @author John Blum + * @see org.junit.Test + * @see org.junit.runner.RunWith + * @see org.springframework.context.ConfigurableApplicationContext + * @see org.springframework.session.ExpiringSession + * @see org.springframework.session.data.gemfire.AbstractGemFireIntegrationTests + * @see org.springframework.session.data.gemfire.config.annotation.web.http.EnableGemFireHttpSession + * @see org.springframework.session.data.gemfire.config.annotation.web.http.GemFireHttpSessionConfiguration + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner + * @see com.gemstone.gemfire.cache.Cache + * @see com.gemstone.gemfire.cache.Region + * @see com.gemstone.gemfire.cache.client.ClientCache + * @since 1.3.1 + */ +@RunWith(SpringRunner.class) +@ContextConfiguration(classes = + ClientServerHttpSessionAttributesDeltaIntegrationTests.SpringSessionDataGemFireClientConfiguration.class) +public class ClientServerHttpSessionAttributesDeltaIntegrationTests extends AbstractGemFireIntegrationTests { + + private static final int MAX_INACTIVE_INTERVAL_IN_SECONDS = 1; + + private static final DateFormat TIMESTAMP = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); + + private static File processWorkingDirectory; + + private static Process gemfireServer; + + @BeforeClass + public static void startGemFireServer() throws IOException { + long t0 = System.currentTimeMillis(); + + int port = SocketUtils.findAvailableTcpPort(); + + System.err.printf("Starting a GemFire Server running on host [%1$s] listening on port [%2$d]%n", + SpringSessionDataGemFireServerConfiguration.SERVER_HOSTNAME, port); + + System.setProperty("spring.session.data.gemfire.port", String.valueOf(port)); + + String processWorkingDirectoryPathname = + String.format("gemfire-client-server-tests-%1$s", TIMESTAMP.format(new Date())); + + processWorkingDirectory = createDirectory(processWorkingDirectoryPathname); + + gemfireServer = run(SpringSessionDataGemFireServerConfiguration.class, processWorkingDirectory, + String.format("-Dspring.session.data.gemfire.port=%1$d", port)); + + assertThat(waitForCacheServerToStart(SpringSessionDataGemFireServerConfiguration.SERVER_HOSTNAME, port)) + .isTrue(); + + System.err.printf("GemFire Server [startup time = %1$d ms]%n", System.currentTimeMillis() - t0); + } + + @AfterClass + public static void stopGemFireServerAndDeleteArtifacts() { + if (gemfireServer != null) { + gemfireServer.destroy(); + System.err.printf("GemFire Server [exit code = %1$d]%n", + waitForProcessToStop(gemfireServer, processWorkingDirectory)); + } + + if (Boolean.valueOf(System.getProperty("spring.session.data.gemfire.fork.clean", Boolean.TRUE.toString()))) { + FileSystemUtils.deleteRecursively(processWorkingDirectory); + } + + assertThat(waitForClientCacheToClose(DEFAULT_WAIT_DURATION)).isTrue(); + } + + @Test + public void sessionCreationAndAccessIsSuccessful() { + ExpiringSession session = save(touch(createSession())); + + assertThat(session).isNotNull(); + assertThat(session.isExpired()).isFalse(); + + session.setAttribute("attrOne", 1); + session.setAttribute("attrTwo", 2); + + save(touch(session)); + + ExpiringSession loadedSession = get(session.getId()); + + assertThat(loadedSession).isNotNull(); + assertThat(loadedSession.isExpired()).isFalse(); + assertThat(loadedSession).isNotSameAs(session); + assertThat(loadedSession.getId()).isEqualTo(session.getId()); + assertThat(loadedSession.getAttribute("attrOne")).isEqualTo(1); + assertThat(loadedSession.getAttribute("attrTwo")).isEqualTo(2); + + loadedSession.removeAttribute("attrTwo"); + + assertThat(loadedSession.getAttributeNames()).doesNotContain("attrTwo"); + assertThat(loadedSession.getAttributeNames()).hasSize(1); + + save(touch(loadedSession)); + + ExpiringSession reloadedSession = get(loadedSession.getId()); + + assertThat(reloadedSession).isNotNull(); + assertThat(reloadedSession.isExpired()).isFalse(); + assertThat(reloadedSession).isNotSameAs(loadedSession); + assertThat(reloadedSession.getId()).isEqualTo(loadedSession.getId()); + assertThat(reloadedSession.getAttributeNames()).hasSize(1); + assertThat(reloadedSession.getAttributeNames()).doesNotContain("attrTwo"); + assertThat(reloadedSession.getAttribute("attrOne")).isEqualTo(1); + } + + @EnableGemFireHttpSession(maxInactiveIntervalInSeconds = MAX_INACTIVE_INTERVAL_IN_SECONDS) + static class SpringSessionDataGemFireClientConfiguration { + + @Bean + static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { + return new PropertySourcesPlaceholderConfigurer(); + } + + 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); + clientCacheFactory.setProperties(gemfireProperties()); + + return clientCacheFactory; + } + + @Bean + PoolFactoryBean gemfirePool(@Value("${spring.session.data.gemfire.port:" + + DEFAULT_GEMFIRE_SERVER_PORT + "}") int port) { + + PoolFactoryBean poolFactory = new PoolFactoryBean(); + + poolFactory.setKeepAlive(false); + poolFactory.setPingInterval(TimeUnit.SECONDS.toMillis(5)); + poolFactory.setReadTimeout(2000); // 2 seconds + poolFactory.setRetryAttempts(1); + poolFactory.setSubscriptionEnabled(true); + + poolFactory.setServers(Collections.singletonList(new ConnectionEndpoint( + SpringSessionDataGemFireServerConfiguration.SERVER_HOSTNAME, port))); + + return poolFactory; + } + + // used for debugging purposes + @SuppressWarnings("resource") + public static void main(String[] args) { + ConfigurableApplicationContext applicationContext = + new AnnotationConfigApplicationContext(SpringSessionDataGemFireClientConfiguration.class); + + applicationContext.registerShutdownHook(); + + ClientCache clientCache = applicationContext.getBean(ClientCache.class); + + for (InetSocketAddress server : clientCache.getCurrentServers()) { + System.err.printf("GemFire Server [host: %1$s, port: %2$d]%n", + server.getHostName(), server.getPort()); + } + } + } + + @EnableGemFireHttpSession(maxInactiveIntervalInSeconds = MAX_INACTIVE_INTERVAL_IN_SECONDS) + static class SpringSessionDataGemFireServerConfiguration { + + static final String SERVER_HOSTNAME = "localhost"; + + @Bean + static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { + return new PropertySourcesPlaceholderConfigurer(); + } + + Properties gemfireProperties() { + Properties gemfireProperties = new Properties(); + + gemfireProperties.setProperty("name", name()); + gemfireProperties.setProperty("mcast-port", "0"); + gemfireProperties.setProperty("log-level", GEMFIRE_LOG_LEVEL); + + return gemfireProperties; + } + + String name() { + return SpringSessionDataGemFireServerConfiguration.class.getName(); + } + + @Bean + CacheFactoryBean gemfireCache() { + CacheFactoryBean gemfireCache = new CacheFactoryBean(); + + gemfireCache.setClose(true); + gemfireCache.setProperties(gemfireProperties()); + + return gemfireCache; + } + + @Bean + CacheServerFactoryBean gemfireCacheServer(Cache gemfireCache, + @Value("${spring.session.data.gemfire.port:" + DEFAULT_GEMFIRE_SERVER_PORT + "}") int port) { + + CacheServerFactoryBean cacheServerFactory = new CacheServerFactoryBean(); + + cacheServerFactory.setCache(gemfireCache); + cacheServerFactory.setAutoStartup(true); + cacheServerFactory.setBindAddress(SERVER_HOSTNAME); + cacheServerFactory.setPort(port); + + return cacheServerFactory; + } + + @SuppressWarnings("resource") + public static void main(String[] args) throws IOException { + AnnotationConfigApplicationContext context = + new AnnotationConfigApplicationContext(SpringSessionDataGemFireServerConfiguration.class); + + context.registerShutdownHook(); + + writeProcessControlFile(WORKING_DIRECTORY); + } + } +} diff --git a/spring-session/src/main/java/org/springframework/session/data/gemfire/AbstractGemFireOperationsSessionRepository.java b/spring-session/src/main/java/org/springframework/session/data/gemfire/AbstractGemFireOperationsSessionRepository.java index 8155e7de..566c75e6 100644 --- a/spring-session/src/main/java/org/springframework/session/data/gemfire/AbstractGemFireOperationsSessionRepository.java +++ b/spring-session/src/main/java/org/springframework/session/data/gemfire/AbstractGemFireOperationsSessionRepository.java @@ -41,6 +41,7 @@ import com.gemstone.gemfire.InvalidDeltaException; import com.gemstone.gemfire.cache.EntryEvent; import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.util.CacheListenerAdapter; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -266,6 +267,19 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi handleExpired(event.getKey().toString(), toExpiringSession(event.getOldValue())); } + /** + * Deletes the given {@link Session} from GemFire. + * + * @param session {@link Session} to delete. + * @return {@literal null}. + * @see org.springframework.session.Session + * @see #delete(String) + */ + protected ExpiringSession delete(Session session) { + delete(session.getId()); + return null; + } + /** * Causes Session created events to be published to the Spring application context. * @@ -334,10 +348,23 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi getApplicationEventPublisher().publishEvent(event); } catch (Throwable t) { - this.logger.error(String.format("error occurred publishing event (%1$s)", event), t); + this.logger.error(String.format("Error occurred publishing event [%s]", event), t); } } + /** + * Updates the {@link ExpiringSession#setLastAccessedTime(long)} property of the {@link ExpiringSession}. + * + * @param {@link Class} sub-type of the {@link ExpiringSession}. + * @param expiringSession {@link ExpiringSession} to touch. + * @return the {@link ExpiringSession}. + * @see org.springframework.session.ExpiringSession#setLastAccessedTime(long) + */ + protected T touch(T expiringSession) { + expiringSession.setLastAccessedTime(System.currentTimeMillis()); + return expiringSession; + } + /** * GemFireSession is a GemFire representation model of a Spring {@link ExpiringSession} * that stores and manages Session state information in GemFire. This class implements @@ -362,8 +389,8 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi private long creationTime; private long lastAccessedTime; - private transient final GemFireSessionAttributes sessionAttributes = new GemFireSessionAttributes( - this); + private transient final GemFireSessionAttributes sessionAttributes = + new GemFireSessionAttributes(this); private transient final SpelExpressionParser parser = new SpelExpressionParser(); @@ -399,11 +426,13 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi return session; } + public static GemFireSession copy(ExpiringSession session) { + return new GemFireSession(session); + } + /* (non-Javadoc) */ - public static GemFireSession from(ExpiringSession expiringSession) { - GemFireSession session = new GemFireSession(expiringSession); - session.setLastAccessedTime(System.currentTimeMillis()); - return session; + public static GemFireSession from(ExpiringSession session) { + return (session instanceof GemFireSession ? (GemFireSession) session : copy(session)); } /* (non-Javadoc) */ diff --git a/spring-session/src/main/java/org/springframework/session/data/gemfire/GemFireOperationsSessionRepository.java b/spring-session/src/main/java/org/springframework/session/data/gemfire/GemFireOperationsSessionRepository.java index 179ec88a..d958d3ea 100644 --- a/spring-session/src/main/java/org/springframework/session/data/gemfire/GemFireOperationsSessionRepository.java +++ b/spring-session/src/main/java/org/springframework/session/data/gemfire/GemFireOperationsSessionRepository.java @@ -119,15 +119,12 @@ public class GemFireOperationsSessionRepository extends AbstractGemFireOperation ExpiringSession storedSession = getTemplate().get(sessionId); if (storedSession != null) { - if (storedSession.isExpired()) { - delete(storedSession.getId()); - } - else { - return GemFireSession.from(storedSession); - } + storedSession = storedSession.isExpired() + ? delete(storedSession) + : touch(GemFireSession.from(storedSession)); } - return null; + return storedSession; } /** @@ -138,7 +135,7 @@ public class GemFireOperationsSessionRepository extends AbstractGemFireOperation * @see org.springframework.session.ExpiringSession */ public void save(ExpiringSession session) { - getTemplate().put(session.getId(), new GemFireSession(session)); + getTemplate().put(session.getId(), GemFireSession.from(session)); } /** @@ -152,5 +149,4 @@ public class GemFireOperationsSessionRepository extends AbstractGemFireOperation public void delete(String sessionId) { handleDeleted(sessionId, getTemplate().remove(sessionId)); } - } diff --git a/spring-session/src/main/java/org/springframework/session/data/gemfire/config/annotation/web/http/EnableGemFireHttpSession.java b/spring-session/src/main/java/org/springframework/session/data/gemfire/config/annotation/web/http/EnableGemFireHttpSession.java index d2904499..14cf7bdc 100644 --- a/spring-session/src/main/java/org/springframework/session/data/gemfire/config/annotation/web/http/EnableGemFireHttpSession.java +++ b/spring-session/src/main/java/org/springframework/session/data/gemfire/config/annotation/web/http/EnableGemFireHttpSession.java @@ -101,7 +101,7 @@ import org.springframework.context.annotation.Import; * * @author John Blum * @see org.springframework.session.config.annotation.web.http.EnableSpringHttpSession - * @see GemFireHttpSessionConfiguration + * @see org.springframework.session.data.gemfire.config.annotation.web.http.GemFireHttpSessionConfiguration * @since 1.1.0 */ @Documented @@ -145,7 +145,7 @@ public @interface EnableGemFireHttpSession { * * @return the name of the GemFire {@link com.gemstone.gemfire.cache.client.Pool} to be used * by the client Region used to manage (HTTP) Sessions. - * @see org.springframework.data.gemfire.config.GemfireConstants#DEFAULT_GEMFIRE_POOL_NAME + * @see org.springframework.data.gemfire.config.xml.GemfireConstants#DEFAULT_GEMFIRE_POOL_NAME */ String poolName() default GemFireHttpSessionConfiguration.DEFAULT_GEMFIRE_POOL_NAME; diff --git a/spring-session/src/main/java/org/springframework/session/data/gemfire/config/annotation/web/http/GemFireHttpSessionConfiguration.java b/spring-session/src/main/java/org/springframework/session/data/gemfire/config/annotation/web/http/GemFireHttpSessionConfiguration.java index bcccb725..f194d05f 100644 --- a/spring-session/src/main/java/org/springframework/session/data/gemfire/config/annotation/web/http/GemFireHttpSessionConfiguration.java +++ b/spring-session/src/main/java/org/springframework/session/data/gemfire/config/annotation/web/http/GemFireHttpSessionConfiguration.java @@ -40,7 +40,7 @@ import org.springframework.data.gemfire.GemfireTemplate; import org.springframework.data.gemfire.IndexFactoryBean; import org.springframework.data.gemfire.IndexType; import org.springframework.data.gemfire.RegionAttributesFactoryBean; -import org.springframework.data.gemfire.config.GemfireConstants; +import org.springframework.data.gemfire.config.xml.GemfireConstants; import org.springframework.session.ExpiringSession; import org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration; import org.springframework.session.data.gemfire.AbstractGemFireOperationsSessionRepository.GemFireSession; diff --git a/spring-session/src/test/java/org/springframework/session/data/gemfire/AbstractGemFireOperationsSessionRepositoryTest.java b/spring-session/src/test/java/org/springframework/session/data/gemfire/AbstractGemFireOperationsSessionRepositoryTest.java index 62681d24..b9d440cb 100644 --- a/spring-session/src/test/java/org/springframework/session/data/gemfire/AbstractGemFireOperationsSessionRepositoryTest.java +++ b/spring-session/src/test/java/org/springframework/session/data/gemfire/AbstractGemFireOperationsSessionRepositoryTest.java @@ -33,13 +33,13 @@ import java.util.concurrent.TimeUnit; import com.gemstone.gemfire.cache.AttributesMutator; import com.gemstone.gemfire.cache.EntryEvent; import com.gemstone.gemfire.cache.Region; + import edu.umd.cs.mtc.MultithreadedTestCase; import edu.umd.cs.mtc.TestFramework; + import org.apache.commons.logging.Log; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; @@ -66,35 +66,36 @@ import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.willAnswer; import static org.mockito.BDDMockito.willThrow; import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Matchers.isA; import static org.mockito.Matchers.same; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; /** - * The AbstractGemFireOperationsSessionRepositoryTest class is a test suite of test cases - * testing the contract and functionality of the - * AbstractGemFireOperationsSessionRepository class. + * Unit tests for {@link AbstractGemFireOperationsSessionRepository}. * * @author John Blum * @since 1.1.0 * @see org.junit.Rule * @see org.junit.Test - * @see org.junit.rules.ExpectedException * @see org.junit.runner.RunWith * @see org.mockito.Mock * @see org.mockito.Mockito + * @see org.mockito.Spy * @see org.mockito.runners.MockitoJUnitRunner * @see org.springframework.data.gemfire.GemfireOperations * @see org.springframework.session.ExpiringSession * @see org.springframework.session.Session - * @see org.springframework.session.data.gemfire. - * AbstractGemFireOperationsSessionRepository + * @see org.springframework.session.data.gemfire.AbstractGemFireOperationsSessionRepository + * @see org.springframework.session.data.gemfire.config.annotation.web.http.GemFireHttpSessionConfiguration * @see edu.umd.cs.mtc.MultithreadedTestCase * @see edu.umd.cs.mtc.TestFramework */ @@ -103,8 +104,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest { protected static final int MAX_INACTIVE_INTERVAL_IN_SECONDS = 600; - @Rule - public ExpectedException expectedException = ExpectedException.none(); + private AbstractGemFireOperationsSessionRepository sessionRepository; @Mock private GemfireOperations mockGemfireOperations; @@ -112,17 +112,14 @@ public class AbstractGemFireOperationsSessionRepositoryTest { @Mock private Log mockLog; - private AbstractGemFireOperationsSessionRepository sessionRepository; - @Before public void setup() { - this.sessionRepository = new TestGemFireOperationsSessionRepository( - this.mockGemfireOperations) { + this.sessionRepository = spy(new TestGemFireOperationsSessionRepository(this.mockGemfireOperations) { @Override Log newLogger() { return AbstractGemFireOperationsSessionRepositoryTest.this.mockLog; } - }; + }); } protected static Set asSet(E... elements) { @@ -134,39 +131,41 @@ public class AbstractGemFireOperationsSessionRepositoryTest { protected ExpiringSession mockSession(String sessionId, long creationAndLastAccessedTime, int maxInactiveIntervalInSeconds) { - return mockSession(sessionId, creationAndLastAccessedTime, - creationAndLastAccessedTime, maxInactiveIntervalInSeconds); + return mockSession(sessionId, creationAndLastAccessedTime, creationAndLastAccessedTime, + maxInactiveIntervalInSeconds); } - protected ExpiringSession mockSession(String sessionId, long creationTime, - long lastAccessedTime, int maxInactiveIntervalInSeconds) { + protected ExpiringSession mockSession(String sessionId, long creationTime, long lastAccessedTime, + int maxInactiveIntervalInSeconds) { ExpiringSession mockSession = mock(ExpiringSession.class, sessionId); given(mockSession.getId()).willReturn(sessionId); given(mockSession.getCreationTime()).willReturn(creationTime); given(mockSession.getLastAccessedTime()).willReturn(lastAccessedTime); - given(mockSession.getMaxInactiveIntervalInSeconds()) - .willReturn(maxInactiveIntervalInSeconds); + given(mockSession.getMaxInactiveIntervalInSeconds()).willReturn(maxInactiveIntervalInSeconds); return mockSession; } - @Test + @Test(expected = IllegalArgumentException.class) public void constructGemFireOperationsSessionRepositoryWithNullTemplate() { - this.expectedException.expect(IllegalArgumentException.class); - this.expectedException.expectMessage("GemfireOperations must not be null"); - new TestGemFireOperationsSessionRepository(null); + try { + new TestGemFireOperationsSessionRepository(null); + } + catch (IllegalArgumentException expected) { + assertThat(expected).hasMessage("GemfireOperations must not be null"); + assertThat(expected).hasNoCause(); + + throw expected; + } } @Test @SuppressWarnings("unchecked") - public void gemfireOperationsSessionRepositoryIsProperlyConstructedAndInitialized() - throws Exception { - ApplicationEventPublisher mockApplicationEventPublisher = mock( - ApplicationEventPublisher.class); - AttributesMutator mockAttributesMutator = mock( - AttributesMutator.class); + public void gemfireOperationsSessionRepositoryIsProperlyConstructedAndInitialized() throws Exception { + ApplicationEventPublisher mockApplicationEventPublisher = mock(ApplicationEventPublisher.class); + AttributesMutator mockAttributesMutator = mock(AttributesMutator.class); Region mockRegion = mock(Region.class); given(mockRegion.getFullPath()).willReturn("/Example"); @@ -174,24 +173,22 @@ public class AbstractGemFireOperationsSessionRepositoryTest { GemfireTemplate template = new GemfireTemplate(mockRegion); - AbstractGemFireOperationsSessionRepository sessionRepository = new TestGemFireOperationsSessionRepository( - template); + AbstractGemFireOperationsSessionRepository sessionRepository = + new TestGemFireOperationsSessionRepository(template); - ApplicationEventPublisher applicationEventPublisher = sessionRepository - .getApplicationEventPublisher(); + ApplicationEventPublisher applicationEventPublisher = sessionRepository.getApplicationEventPublisher(); assertThat(applicationEventPublisher).isNotNull(); assertThat(sessionRepository.getFullyQualifiedRegionName()).isNull(); - assertThat(sessionRepository.getMaxInactiveIntervalInSeconds()).isEqualTo( - GemFireHttpSessionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL_IN_SECONDS); + assertThat(sessionRepository.getMaxInactiveIntervalInSeconds()) + .isEqualTo(GemFireHttpSessionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL_IN_SECONDS); assertThat(sessionRepository.getTemplate()).isSameAs(template); sessionRepository.setApplicationEventPublisher(mockApplicationEventPublisher); sessionRepository.setMaxInactiveIntervalInSeconds(300); sessionRepository.afterPropertiesSet(); - assertThat(sessionRepository.getApplicationEventPublisher()) - .isSameAs(mockApplicationEventPublisher); + assertThat(sessionRepository.getApplicationEventPublisher()).isSameAs(mockApplicationEventPublisher); assertThat(sessionRepository.getFullyQualifiedRegionName()).isEqualTo("/Example"); assertThat(sessionRepository.getMaxInactiveIntervalInSeconds()).isEqualTo(300); assertThat(sessionRepository.getTemplate()).isSameAs(template); @@ -203,28 +200,24 @@ public class AbstractGemFireOperationsSessionRepositoryTest { @Test public void maxInactiveIntervalInSecondsAllowsNegativeValuesAndExtremelyLargeValues() { - assertThat(this.sessionRepository.getMaxInactiveIntervalInSeconds()).isEqualTo( - GemFireHttpSessionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL_IN_SECONDS); + assertThat(this.sessionRepository.getMaxInactiveIntervalInSeconds()) + .isEqualTo(GemFireHttpSessionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL_IN_SECONDS); this.sessionRepository.setMaxInactiveIntervalInSeconds(-1); - assertThat(this.sessionRepository.getMaxInactiveIntervalInSeconds()) - .isEqualTo(-1); + assertThat(this.sessionRepository.getMaxInactiveIntervalInSeconds()).isEqualTo(-1); this.sessionRepository.setMaxInactiveIntervalInSeconds(Integer.MIN_VALUE); - assertThat(this.sessionRepository.getMaxInactiveIntervalInSeconds()) - .isEqualTo(Integer.MIN_VALUE); + assertThat(this.sessionRepository.getMaxInactiveIntervalInSeconds()).isEqualTo(Integer.MIN_VALUE); - this.sessionRepository.setMaxInactiveIntervalInSeconds(3600); + this.sessionRepository.setMaxInactiveIntervalInSeconds(1024000); - assertThat(this.sessionRepository.getMaxInactiveIntervalInSeconds()) - .isEqualTo(3600); + assertThat(this.sessionRepository.getMaxInactiveIntervalInSeconds()).isEqualTo(1024000); this.sessionRepository.setMaxInactiveIntervalInSeconds(Integer.MAX_VALUE); - assertThat(this.sessionRepository.getMaxInactiveIntervalInSeconds()) - .isEqualTo(Integer.MAX_VALUE); + assertThat(this.sessionRepository.getMaxInactiveIntervalInSeconds()).isEqualTo(Integer.MAX_VALUE); } @Test @@ -235,20 +228,18 @@ public class AbstractGemFireOperationsSessionRepositoryTest { given(mockSession.getId()).willReturn(sessionId); - ApplicationEventPublisher mockApplicationEventPublisher = mock( - ApplicationEventPublisher.class); + ApplicationEventPublisher mockApplicationEventPublisher = mock(ApplicationEventPublisher.class); willAnswer(new Answer() { public Void answer(InvocationOnMock invocation) throws Throwable { - ApplicationEvent applicationEvent = invocation.getArgumentAt(0, - ApplicationEvent.class); + ApplicationEvent applicationEvent = invocation.getArgumentAt(0, ApplicationEvent.class); assertThat(applicationEvent).isInstanceOf(SessionCreatedEvent.class); AbstractSessionEvent sessionEvent = (AbstractSessionEvent) applicationEvent; - assertThat(sessionEvent.getSource()).isEqualTo( - AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); + assertThat(sessionEvent.getSource()) + .isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); assertThat(sessionEvent.getSession()).isEqualTo(mockSession); assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId); @@ -261,8 +252,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest { given(mockEntryEvent.getKey()).willReturn(sessionId); given(mockEntryEvent.getNewValue()).willReturn(mockSession); - this.sessionRepository - .setApplicationEventPublisher(mockApplicationEventPublisher); + this.sessionRepository.setApplicationEventPublisher(mockApplicationEventPublisher); this.sessionRepository.afterCreate(mockEntryEvent); assertThat(this.sessionRepository.getApplicationEventPublisher()) @@ -273,7 +263,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest { verify(mockEntryEvent, never()).getOldValue(); verify(mockSession, times(1)).getId(); verify(mockApplicationEventPublisher, times(1)) - .publishEvent(isA(SessionCreatedEvent.class)); + .publishEvent(isA(SessionCreatedEvent.class)); } @Test @@ -281,20 +271,18 @@ public class AbstractGemFireOperationsSessionRepositoryTest { public void afterCreateWithSessionIdPublishesSessionCreatedEvent() { final String sessionId = "abc123"; - ApplicationEventPublisher mockApplicationEventPublisher = mock( - ApplicationEventPublisher.class); + ApplicationEventPublisher mockApplicationEventPublisher = mock(ApplicationEventPublisher.class); willAnswer(new Answer() { public Void answer(InvocationOnMock invocation) throws Throwable { - ApplicationEvent applicationEvent = invocation.getArgumentAt(0, - ApplicationEvent.class); + ApplicationEvent applicationEvent = invocation.getArgumentAt(0, ApplicationEvent.class); assertThat(applicationEvent).isInstanceOf(SessionCreatedEvent.class); AbstractSessionEvent sessionEvent = (AbstractSessionEvent) applicationEvent; - assertThat(sessionEvent.getSource()).isEqualTo( - AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); + assertThat(sessionEvent.getSource()) + .isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); assertThat(sessionEvent.getSession()).isNull(); assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId); @@ -307,29 +295,27 @@ public class AbstractGemFireOperationsSessionRepositoryTest { given(mockEntryEvent.getKey()).willReturn(sessionId); given(mockEntryEvent.getNewValue()).willReturn(null); - this.sessionRepository - .setApplicationEventPublisher(mockApplicationEventPublisher); + this.sessionRepository.setApplicationEventPublisher(mockApplicationEventPublisher); this.sessionRepository.afterCreate(mockEntryEvent); - assertThat(this.sessionRepository.getApplicationEventPublisher()) - .isSameAs(mockApplicationEventPublisher); + assertThat(this.sessionRepository.getApplicationEventPublisher()).isSameAs(mockApplicationEventPublisher); verify(mockEntryEvent, times(1)).getKey(); verify(mockEntryEvent, times(2)).getNewValue(); verify(mockEntryEvent, never()).getOldValue(); verify(mockApplicationEventPublisher, times(1)) - .publishEvent(isA(SessionCreatedEvent.class)); + .publishEvent(isA(SessionCreatedEvent.class)); } @Test @SuppressWarnings({ "unchecked", "rawtypes" }) public void afterCreatedWithNonSessionTypeDoesNotPublishSessionCreatedEvent() { - TestGemFireOperationsSessionRepository sessionRepository = new TestGemFireOperationsSessionRepository( - this.mockGemfireOperations) { - @Override - protected void handleCreated(String sessionId, ExpiringSession session) { - fail("handleCreated(..) should not have been called"); - } + TestGemFireOperationsSessionRepository sessionRepository = + new TestGemFireOperationsSessionRepository(this.mockGemfireOperations) { + @Override + protected void handleCreated(String sessionId, ExpiringSession session) { + fail("handleCreated(..) should not have been called"); + } }; EntryEvent mockEntryEvent = mock(EntryEvent.class); @@ -337,8 +323,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest { given(mockEntryEvent.getKey()).willReturn("abc123"); given(mockEntryEvent.getNewValue()).willReturn(new Tombstone()); - sessionRepository - .afterCreate((EntryEvent) mockEntryEvent); + sessionRepository.afterCreate((EntryEvent) mockEntryEvent); verify(mockEntryEvent, never()).getKey(); verify(mockEntryEvent, times(1)).getNewValue(); @@ -353,20 +338,18 @@ public class AbstractGemFireOperationsSessionRepositoryTest { given(mockSession.getId()).willReturn(sessionId); - ApplicationEventPublisher mockApplicationEventPublisher = mock( - ApplicationEventPublisher.class); + ApplicationEventPublisher mockApplicationEventPublisher = mock(ApplicationEventPublisher.class); willAnswer(new Answer() { public Void answer(InvocationOnMock invocation) throws Throwable { - ApplicationEvent applicationEvent = invocation.getArgumentAt(0, - ApplicationEvent.class); + ApplicationEvent applicationEvent = invocation.getArgumentAt(0, ApplicationEvent.class); assertThat(applicationEvent).isInstanceOf(SessionDestroyedEvent.class); AbstractSessionEvent sessionEvent = (AbstractSessionEvent) applicationEvent; - assertThat(sessionEvent.getSource()).isEqualTo( - AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); + assertThat(sessionEvent.getSource()) + .isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); assertThat(sessionEvent.getSession()).isEqualTo(mockSession); assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId); @@ -391,7 +374,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest { verify(mockEntryEvent, times(1)).getOldValue(); verify(mockSession, times(1)).getId(); verify(mockApplicationEventPublisher, times(1)) - .publishEvent(isA(SessionDestroyedEvent.class)); + .publishEvent(isA(SessionDestroyedEvent.class)); } @Test @@ -399,20 +382,18 @@ public class AbstractGemFireOperationsSessionRepositoryTest { public void afterDestroyWithSessionIdPublishesSessionDestroyedEvent() { final String sessionId = "def456"; - ApplicationEventPublisher mockApplicationEventPublisher = mock( - ApplicationEventPublisher.class); + ApplicationEventPublisher mockApplicationEventPublisher = mock(ApplicationEventPublisher.class); willAnswer(new Answer() { public Void answer(InvocationOnMock invocation) throws Throwable { - ApplicationEvent applicationEvent = invocation.getArgumentAt(0, - ApplicationEvent.class); + ApplicationEvent applicationEvent = invocation.getArgumentAt(0, ApplicationEvent.class); assertThat(applicationEvent).isInstanceOf(SessionDestroyedEvent.class); AbstractSessionEvent sessionEvent = (AbstractSessionEvent) applicationEvent; - assertThat(sessionEvent.getSource()).isEqualTo( - AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); + assertThat(sessionEvent.getSource()) + .isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); assertThat(sessionEvent.getSession()).isNull(); assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId); @@ -425,18 +406,16 @@ public class AbstractGemFireOperationsSessionRepositoryTest { given(mockEntryEvent.getKey()).willReturn(sessionId); given(mockEntryEvent.getOldValue()).willReturn(null); - this.sessionRepository - .setApplicationEventPublisher(mockApplicationEventPublisher); + this.sessionRepository.setApplicationEventPublisher(mockApplicationEventPublisher); this.sessionRepository.afterDestroy(mockEntryEvent); - assertThat(this.sessionRepository.getApplicationEventPublisher()) - .isSameAs(mockApplicationEventPublisher); + assertThat(this.sessionRepository.getApplicationEventPublisher()).isSameAs(mockApplicationEventPublisher); verify(mockEntryEvent, times(1)).getKey(); verify(mockEntryEvent, never()).getNewValue(); verify(mockEntryEvent, times(1)).getOldValue(); verify(mockApplicationEventPublisher, times(1)) - .publishEvent(isA(SessionDestroyedEvent.class)); + .publishEvent(isA(SessionDestroyedEvent.class)); } @Test @@ -444,20 +423,18 @@ public class AbstractGemFireOperationsSessionRepositoryTest { public void afterDestroyWithNonSessionTypePublishesSessionDestroyedEventWithSessionId() { final String sessionId = "def456"; - ApplicationEventPublisher mockApplicationEventPublisher = mock( - ApplicationEventPublisher.class); + ApplicationEventPublisher mockApplicationEventPublisher = mock(ApplicationEventPublisher.class); willAnswer(new Answer() { public Void answer(InvocationOnMock invocation) throws Throwable { - ApplicationEvent applicationEvent = invocation.getArgumentAt(0, - ApplicationEvent.class); + ApplicationEvent applicationEvent = invocation.getArgumentAt(0, ApplicationEvent.class); assertThat(applicationEvent).isInstanceOf(SessionDestroyedEvent.class); AbstractSessionEvent sessionEvent = (AbstractSessionEvent) applicationEvent; - assertThat(sessionEvent.getSource()).isEqualTo( - AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); + assertThat(sessionEvent.getSource()) + .isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); assertThat(sessionEvent.getSession()).isNull(); assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId); @@ -470,19 +447,16 @@ public class AbstractGemFireOperationsSessionRepositoryTest { given(mockEntryEvent.getKey()).willReturn(sessionId); given(mockEntryEvent.getOldValue()).willReturn(new Tombstone()); - this.sessionRepository - .setApplicationEventPublisher(mockApplicationEventPublisher); - this.sessionRepository - .afterDestroy((EntryEvent) mockEntryEvent); + this.sessionRepository.setApplicationEventPublisher(mockApplicationEventPublisher); + this.sessionRepository.afterDestroy((EntryEvent) mockEntryEvent); - assertThat(this.sessionRepository.getApplicationEventPublisher()) - .isSameAs(mockApplicationEventPublisher); + assertThat(this.sessionRepository.getApplicationEventPublisher()).isSameAs(mockApplicationEventPublisher); verify(mockEntryEvent, times(1)).getKey(); verify(mockEntryEvent, never()).getNewValue(); verify(mockEntryEvent, times(1)).getOldValue(); verify(mockApplicationEventPublisher, times(1)) - .publishEvent(isA(SessionDestroyedEvent.class)); + .publishEvent(isA(SessionDestroyedEvent.class)); } @Test @@ -493,20 +467,18 @@ public class AbstractGemFireOperationsSessionRepositoryTest { given(mockSession.getId()).willReturn(sessionId); - ApplicationEventPublisher mockApplicationEventPublisher = mock( - ApplicationEventPublisher.class); + ApplicationEventPublisher mockApplicationEventPublisher = mock(ApplicationEventPublisher.class); willAnswer(new Answer() { public Void answer(InvocationOnMock invocation) throws Throwable { - ApplicationEvent applicationEvent = invocation.getArgumentAt(0, - ApplicationEvent.class); + ApplicationEvent applicationEvent = invocation.getArgumentAt(0, ApplicationEvent.class); assertThat(applicationEvent).isInstanceOf(SessionExpiredEvent.class); AbstractSessionEvent sessionEvent = (AbstractSessionEvent) applicationEvent; - assertThat(sessionEvent.getSource()).isEqualTo( - AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); + assertThat(sessionEvent.getSource()) + .isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); assertThat(sessionEvent.getSession()).isEqualTo(mockSession); assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId); @@ -539,20 +511,18 @@ public class AbstractGemFireOperationsSessionRepositoryTest { public void afterInvalidateWithSessionIdPublishesSessionExpiredEvent() { final String sessionId = "ghi789"; - ApplicationEventPublisher mockApplicationEventPublisher = mock( - ApplicationEventPublisher.class); + ApplicationEventPublisher mockApplicationEventPublisher = mock(ApplicationEventPublisher.class); willAnswer(new Answer() { public Void answer(InvocationOnMock invocation) throws Throwable { - ApplicationEvent applicationEvent = invocation.getArgumentAt(0, - ApplicationEvent.class); + ApplicationEvent applicationEvent = invocation.getArgumentAt(0, ApplicationEvent.class); assertThat(applicationEvent).isInstanceOf(SessionExpiredEvent.class); AbstractSessionEvent sessionEvent = (AbstractSessionEvent) applicationEvent; - assertThat(sessionEvent.getSource()).isEqualTo( - AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); + assertThat(sessionEvent.getSource()) + .isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); assertThat(sessionEvent.getSession()).isNull(); assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId); @@ -565,8 +535,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest { given(mockEntryEvent.getKey()).willReturn(sessionId); given(mockEntryEvent.getOldValue()).willReturn(null); - this.sessionRepository - .setApplicationEventPublisher(mockApplicationEventPublisher); + this.sessionRepository.setApplicationEventPublisher(mockApplicationEventPublisher); this.sessionRepository.afterInvalidate(mockEntryEvent); assertThat(this.sessionRepository.getApplicationEventPublisher()) @@ -576,7 +545,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest { verify(mockEntryEvent, never()).getNewValue(); verify(mockEntryEvent, times(1)).getOldValue(); verify(mockApplicationEventPublisher, times(1)) - .publishEvent(isA(SessionExpiredEvent.class)); + .publishEvent(isA(SessionExpiredEvent.class)); } @Test @@ -584,20 +553,18 @@ public class AbstractGemFireOperationsSessionRepositoryTest { public void afterInvalidateWithNonSessionTypePublishesSessionExpiredEventWithSessionId() { final String sessionId = "ghi789"; - ApplicationEventPublisher mockApplicationEventPublisher = mock( - ApplicationEventPublisher.class); + ApplicationEventPublisher mockApplicationEventPublisher = mock(ApplicationEventPublisher.class); willAnswer(new Answer() { public Void answer(InvocationOnMock invocation) throws Throwable { - ApplicationEvent applicationEvent = invocation.getArgumentAt(0, - ApplicationEvent.class); + ApplicationEvent applicationEvent = invocation.getArgumentAt(0, ApplicationEvent.class); assertThat(applicationEvent).isInstanceOf(SessionExpiredEvent.class); AbstractSessionEvent sessionEvent = (AbstractSessionEvent) applicationEvent; - assertThat(sessionEvent.getSource()).isEqualTo( - AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); + assertThat(sessionEvent.getSource()) + .isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); assertThat(sessionEvent.getSession()).isNull(); assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId); @@ -610,19 +577,28 @@ public class AbstractGemFireOperationsSessionRepositoryTest { given(mockEntryEvent.getKey()).willReturn(sessionId); given(mockEntryEvent.getOldValue()).willReturn(new Tombstone()); - this.sessionRepository - .setApplicationEventPublisher(mockApplicationEventPublisher); - this.sessionRepository - .afterInvalidate((EntryEvent) mockEntryEvent); + this.sessionRepository.setApplicationEventPublisher(mockApplicationEventPublisher); + this.sessionRepository.afterInvalidate((EntryEvent) mockEntryEvent); - assertThat(this.sessionRepository.getApplicationEventPublisher()) - .isSameAs(mockApplicationEventPublisher); + assertThat(this.sessionRepository.getApplicationEventPublisher()).isSameAs(mockApplicationEventPublisher); verify(mockEntryEvent, times(1)).getKey(); verify(mockEntryEvent, never()).getNewValue(); verify(mockEntryEvent, times(1)).getOldValue(); verify(mockApplicationEventPublisher, times(1)) - .publishEvent(isA(SessionExpiredEvent.class)); + .publishEvent(isA(SessionExpiredEvent.class)); + } + + @Test + public void deleteSessionCallsDeleteSessionId() { + Session mockSession = mock(Session.class); + + doNothing().when(this.sessionRepository).delete(anyString()); + given(mockSession.getId()).willReturn("2"); + + assertThat(this.sessionRepository.delete(mockSession)).isNull(); + + verify(this.sessionRepository, times(1)).delete(eq("2")); } @Test @@ -632,20 +608,18 @@ public class AbstractGemFireOperationsSessionRepositoryTest { given(mockSession.getId()).willReturn(sessionId); - ApplicationEventPublisher mockApplicationEventPublisher = mock( - ApplicationEventPublisher.class); + ApplicationEventPublisher mockApplicationEventPublisher = mock(ApplicationEventPublisher.class); willAnswer(new Answer() { public Void answer(InvocationOnMock invocation) throws Throwable { - ApplicationEvent applicationEvent = invocation.getArgumentAt(0, - ApplicationEvent.class); + ApplicationEvent applicationEvent = invocation.getArgumentAt(0, ApplicationEvent.class); assertThat(applicationEvent).isInstanceOf(SessionDeletedEvent.class); AbstractSessionEvent sessionEvent = (AbstractSessionEvent) applicationEvent; - assertThat(sessionEvent.getSource()).isEqualTo( - AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); + assertThat(sessionEvent.getSource()) + .isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); assertThat(sessionEvent.getSession()).isEqualTo(mockSession); assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId); @@ -653,36 +627,32 @@ public class AbstractGemFireOperationsSessionRepositoryTest { } }).given(mockApplicationEventPublisher).publishEvent(isA(ApplicationEvent.class)); - this.sessionRepository - .setApplicationEventPublisher(mockApplicationEventPublisher); + this.sessionRepository.setApplicationEventPublisher(mockApplicationEventPublisher); this.sessionRepository.handleDeleted(sessionId, mockSession); - assertThat(this.sessionRepository.getApplicationEventPublisher()) - .isSameAs(mockApplicationEventPublisher); + assertThat(this.sessionRepository.getApplicationEventPublisher()).isSameAs(mockApplicationEventPublisher); verify(mockSession, times(1)).getId(); verify(mockApplicationEventPublisher, times(1)) - .publishEvent(isA(SessionDeletedEvent.class)); + .publishEvent(isA(SessionDeletedEvent.class)); } @Test public void handleDeletedWithSessionIdPublishesSessionDeletedEvent() { final String sessionId = "abc123"; - ApplicationEventPublisher mockApplicationEventPublisher = mock( - ApplicationEventPublisher.class); + ApplicationEventPublisher mockApplicationEventPublisher = mock(ApplicationEventPublisher.class); willAnswer(new Answer() { public Void answer(InvocationOnMock invocation) throws Throwable { - ApplicationEvent applicationEvent = invocation.getArgumentAt(0, - ApplicationEvent.class); + ApplicationEvent applicationEvent = invocation.getArgumentAt(0, ApplicationEvent.class); assertThat(applicationEvent).isInstanceOf(SessionDeletedEvent.class); AbstractSessionEvent sessionEvent = (AbstractSessionEvent) applicationEvent; - assertThat(sessionEvent.getSource()).isEqualTo( - AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); + assertThat(sessionEvent.getSource()) + .isEqualTo(AbstractGemFireOperationsSessionRepositoryTest.this.sessionRepository); assertThat(sessionEvent.getSession()).isNull(); assertThat(sessionEvent.getSessionId()).isEqualTo(sessionId); @@ -690,81 +660,93 @@ public class AbstractGemFireOperationsSessionRepositoryTest { } }).given(mockApplicationEventPublisher).publishEvent(isA(ApplicationEvent.class)); - this.sessionRepository - .setApplicationEventPublisher(mockApplicationEventPublisher); + this.sessionRepository.setApplicationEventPublisher(mockApplicationEventPublisher); this.sessionRepository.handleDeleted(sessionId, null); - assertThat(this.sessionRepository.getApplicationEventPublisher()) - .isSameAs(mockApplicationEventPublisher); + assertThat(this.sessionRepository.getApplicationEventPublisher()).isSameAs(mockApplicationEventPublisher); verify(mockApplicationEventPublisher, times(1)) - .publishEvent(isA(SessionDeletedEvent.class)); + .publishEvent(isA(SessionDeletedEvent.class)); } @Test public void publishEventHandlesThrowable() { ApplicationEvent mockApplicationEvent = mock(ApplicationEvent.class); - ApplicationEventPublisher mockApplicationEventPublisher = mock( - ApplicationEventPublisher.class); + ApplicationEventPublisher mockApplicationEventPublisher = mock(ApplicationEventPublisher.class); willThrow(new IllegalStateException("test")).given(mockApplicationEventPublisher) - .publishEvent(any(ApplicationEvent.class)); + .publishEvent(any(ApplicationEvent.class)); - this.sessionRepository - .setApplicationEventPublisher(mockApplicationEventPublisher); + this.sessionRepository.setApplicationEventPublisher(mockApplicationEventPublisher); this.sessionRepository.publishEvent(mockApplicationEvent); - assertThat(this.sessionRepository.getApplicationEventPublisher()) - .isSameAs(mockApplicationEventPublisher); + assertThat(this.sessionRepository.getApplicationEventPublisher()).isSameAs(mockApplicationEventPublisher); - verify(mockApplicationEventPublisher, times(1)) - .publishEvent(eq(mockApplicationEvent)); - verify(this.mockLog, times(1)).error(eq(String - .format("error occurred publishing event (%1$s)", mockApplicationEvent)), + verify(mockApplicationEventPublisher, times(1)).publishEvent(eq(mockApplicationEvent)); + verify(this.mockLog, times(1)) + .error(eq(String.format("Error occurred publishing event [%s]", mockApplicationEvent)), isA(IllegalStateException.class)); } + @Test + public void touchSetsLastAccessedTime() { + ExpiringSession mockSession = mock(ExpiringSession.class); + + assertThat(this.sessionRepository.touch(mockSession)).isSameAs(mockSession); + + verify(mockSession, times(1)).setLastAccessedTime(anyInt()); + } + @Test public void constructGemFireSessionWithDefaultInitialization() { - final long beforeOrAtCreationTime = System.currentTimeMillis(); + long beforeOrAtCreationTime = System.currentTimeMillis(); AbstractGemFireOperationsSessionRepository.GemFireSession session = new AbstractGemFireOperationsSessionRepository.GemFireSession(); assertThat(session.getId()).isNotNull(); - assertThat(session.getCreationTime()) - .isGreaterThanOrEqualTo(beforeOrAtCreationTime); - assertThat(session.getLastAccessedTime()) - .isGreaterThanOrEqualTo(beforeOrAtCreationTime); + assertThat(session.getCreationTime()).isGreaterThanOrEqualTo(beforeOrAtCreationTime); + assertThat(session.getLastAccessedTime()).isGreaterThanOrEqualTo(beforeOrAtCreationTime); assertThat(session.getMaxInactiveIntervalInSeconds()).isEqualTo(0); assertThat(session.getAttributeNames()).isNotNull(); - assertThat(session.getAttributeNames().isEmpty()).isTrue(); + assertThat(session.getAttributeNames()).isEmpty(); } @Test public void constructGemFireSessionWithId() { - final long beforeOrAtCreationTime = System.currentTimeMillis(); + long beforeOrAtCreationTime = System.currentTimeMillis(); - AbstractGemFireOperationsSessionRepository.GemFireSession session = new AbstractGemFireOperationsSessionRepository.GemFireSession( - "1"); + AbstractGemFireOperationsSessionRepository.GemFireSession session = + new AbstractGemFireOperationsSessionRepository.GemFireSession("1"); assertThat(session.getId()).isEqualTo("1"); - assertThat(session.getCreationTime()) - .isGreaterThanOrEqualTo(beforeOrAtCreationTime); - assertThat(session.getLastAccessedTime()) - .isGreaterThanOrEqualTo(beforeOrAtCreationTime); + assertThat(session.getCreationTime()).isGreaterThanOrEqualTo(beforeOrAtCreationTime); + assertThat(session.getLastAccessedTime()).isGreaterThanOrEqualTo(beforeOrAtCreationTime); assertThat(session.getMaxInactiveIntervalInSeconds()).isEqualTo(0); assertThat(session.getAttributeNames()).isNotNull(); - assertThat(session.getAttributeNames().isEmpty()).isTrue(); + assertThat(session.getAttributeNames()).isEmpty(); + } + + @Test(expected = IllegalArgumentException.class) + public void constructGemFireSessionWithUnspecifiedId() { + try { + new AbstractGemFireOperationsSessionRepository.GemFireSession(" "); + } + catch (IllegalArgumentException expected) { + assertThat(expected).hasMessage("ID must be specified"); + assertThat(expected).hasNoCause(); + + throw expected; + } } @Test public void constructGemFireSessionWithSession() { - final long expectedCreationTime = 1L; - final long expectedLastAccessTime = 2L; + long expectedCreationTime = 1L; + long expectedLastAccessTime = 2L; - ExpiringSession mockSession = mockSession("2", expectedCreationTime, - expectedLastAccessTime, MAX_INACTIVE_INTERVAL_IN_SECONDS); + ExpiringSession mockSession = + mockSession("2", expectedCreationTime, expectedLastAccessTime, MAX_INACTIVE_INTERVAL_IN_SECONDS); Set expectedAttributedNames = asSet("attrOne", "attrTwo"); @@ -772,20 +754,16 @@ public class AbstractGemFireOperationsSessionRepositoryTest { given(mockSession.getAttribute(eq("attrOne"))).willReturn("testOne"); given(mockSession.getAttribute(eq("attrTwo"))).willReturn("testTwo"); - AbstractGemFireOperationsSessionRepository.GemFireSession gemfireSession = new AbstractGemFireOperationsSessionRepository.GemFireSession( - mockSession); + AbstractGemFireOperationsSessionRepository.GemFireSession gemfireSession = + new AbstractGemFireOperationsSessionRepository.GemFireSession(mockSession); assertThat(gemfireSession.getId()).isEqualTo("2"); assertThat(gemfireSession.getCreationTime()).isEqualTo(expectedCreationTime); - assertThat(gemfireSession.getLastAccessedTime()) - .isEqualTo(expectedLastAccessTime); - assertThat(gemfireSession.getMaxInactiveIntervalInSeconds()) - .isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS); + assertThat(gemfireSession.getLastAccessedTime()).isEqualTo(expectedLastAccessTime); + assertThat(gemfireSession.getMaxInactiveIntervalInSeconds()).isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS); assertThat(gemfireSession.getAttributeNames()).isEqualTo(expectedAttributedNames); - assertThat(String.valueOf(gemfireSession.getAttribute("attrOne"))) - .isEqualTo("testOne"); - assertThat(String.valueOf(gemfireSession.getAttribute("attrTwo"))) - .isEqualTo("testTwo"); + assertThat(String.valueOf(gemfireSession.getAttribute("attrOne"))).isEqualTo("testOne"); + assertThat(String.valueOf(gemfireSession.getAttribute("attrTwo"))).isEqualTo("testTwo"); verify(mockSession, times(1)).getId(); verify(mockSession, times(1)).getCreationTime(); @@ -796,33 +774,29 @@ public class AbstractGemFireOperationsSessionRepositoryTest { verify(mockSession, times(1)).getAttribute(eq("attrTwo")); } - @Test + @Test(expected = IllegalArgumentException.class) public void constructGemFireSessionWithNullSession() { - this.expectedException.expect(IllegalArgumentException.class); - this.expectedException - .expectMessage("The ExpiringSession to copy cannot be null"); - new AbstractGemFireOperationsSessionRepository.GemFireSession( - (ExpiringSession) null); - } + try { + new AbstractGemFireOperationsSessionRepository.GemFireSession((ExpiringSession) null); + } + catch (IllegalArgumentException expected) { + assertThat(expected).hasMessage("The ExpiringSession to copy cannot be null"); + assertThat(expected).hasNoCause(); - @Test - public void constructGemFireSessionWithUnspecifiedId() { - this.expectedException.expect(IllegalArgumentException.class); - this.expectedException.expectMessage("ID must be specified"); - new AbstractGemFireOperationsSessionRepository.GemFireSession(" "); + throw expected; + } } @Test public void createNewGemFireSession() { - final long beforeOrAtCreationTime = System.currentTimeMillis(); + long beforeOrAtCreationTime = System.currentTimeMillis(); - AbstractGemFireOperationsSessionRepository.GemFireSession session = AbstractGemFireOperationsSessionRepository.GemFireSession - .create(120); + AbstractGemFireOperationsSessionRepository.GemFireSession session = + AbstractGemFireOperationsSessionRepository.GemFireSession.create(120); assertThat(session).isNotNull(); assertThat(session.getId()).isNotNull(); - assertThat(session.getCreationTime()) - .isGreaterThanOrEqualTo(beforeOrAtCreationTime); + assertThat(session.getCreationTime()).isGreaterThanOrEqualTo(beforeOrAtCreationTime); assertThat(session.getLastAccessedTime()).isEqualTo(session.getCreationTime()); assertThat(session.getMaxInactiveIntervalInSeconds()).isEqualTo(120); assertThat(session.getAttributeNames()).isNotNull(); @@ -831,28 +805,22 @@ public class AbstractGemFireOperationsSessionRepositoryTest { @Test public void fromExistingSession() { - final long expectedCreationTime = 1L; - final long expectedLastAccessedTime = 2L; + long expectedCreationTime = 1L; + long expectedLastAccessedTime = 2L; - ExpiringSession mockSession = mockSession("4", expectedCreationTime, - expectedLastAccessedTime, MAX_INACTIVE_INTERVAL_IN_SECONDS); + ExpiringSession mockSession = mockSession("4", expectedCreationTime, expectedLastAccessedTime, + MAX_INACTIVE_INTERVAL_IN_SECONDS); given(mockSession.getAttributeNames()).willReturn(Collections.emptySet()); - AbstractGemFireOperationsSessionRepository.GemFireSession gemfireSession = AbstractGemFireOperationsSessionRepository.GemFireSession - .from(mockSession); + AbstractGemFireOperationsSessionRepository.GemFireSession gemfireSession = + AbstractGemFireOperationsSessionRepository.GemFireSession.from(mockSession); assertThat(gemfireSession).isNotNull(); assertThat(gemfireSession.getId()).isEqualTo("4"); assertThat(gemfireSession.getCreationTime()).isEqualTo(expectedCreationTime); - assertThat(gemfireSession.getLastAccessedTime()) - .isNotEqualTo(expectedLastAccessedTime); - assertThat(gemfireSession.getLastAccessedTime()) - .isGreaterThanOrEqualTo(expectedCreationTime); - assertThat(gemfireSession.getLastAccessedTime()) - .isLessThanOrEqualTo(System.currentTimeMillis()); - assertThat(gemfireSession.getMaxInactiveIntervalInSeconds()) - .isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS); + assertThat(gemfireSession.getLastAccessedTime()).isEqualTo(expectedLastAccessedTime); + assertThat(gemfireSession.getMaxInactiveIntervalInSeconds()).isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS); assertThat(gemfireSession.getAttributeNames()).isNotNull(); assertThat(gemfireSession.getAttributeNames().isEmpty()).isTrue(); @@ -864,10 +832,21 @@ public class AbstractGemFireOperationsSessionRepositoryTest { verify(mockSession, never()).getAttribute(anyString()); } + @Test + public void fromExistingGemFireSessionIsGemFireSession() { + AbstractGemFireOperationsSessionRepository.GemFireSession gemfireSession = + AbstractGemFireOperationsSessionRepository.GemFireSession.create(300); + + AbstractGemFireOperationsSessionRepository.GemFireSession fromGemFireSession = + AbstractGemFireOperationsSessionRepository.GemFireSession.from(gemfireSession); + + assertThat(fromGemFireSession).isSameAs(gemfireSession); + } + @Test public void setGetAndRemoveAttribute() { - AbstractGemFireOperationsSessionRepository.GemFireSession session = AbstractGemFireOperationsSessionRepository.GemFireSession - .create(60); + AbstractGemFireOperationsSessionRepository.GemFireSession session = + AbstractGemFireOperationsSessionRepository.GemFireSession.create(60); assertThat(session).isNotNull(); assertThat(session.getMaxInactiveIntervalInSeconds()).isEqualTo(60); @@ -902,26 +881,23 @@ public class AbstractGemFireOperationsSessionRepositoryTest { public void isExpiredIsFalseWhenMaxInactiveIntervalIsNegative() { final int expectedMaxInactiveIntervalInSeconds = -1; - AbstractGemFireOperationsSessionRepository.GemFireSession session = AbstractGemFireOperationsSessionRepository.GemFireSession - .create(expectedMaxInactiveIntervalInSeconds); + AbstractGemFireOperationsSessionRepository.GemFireSession session = + AbstractGemFireOperationsSessionRepository.GemFireSession.create(expectedMaxInactiveIntervalInSeconds); assertThat(session).isNotNull(); - assertThat(session.getMaxInactiveIntervalInSeconds()) - .isEqualTo(expectedMaxInactiveIntervalInSeconds); + assertThat(session.getMaxInactiveIntervalInSeconds()).isEqualTo(expectedMaxInactiveIntervalInSeconds); assertThat(session.isExpired()).isFalse(); } @Test public void isExpiredIsFalseWhenSessionIsActive() { - final int expectedMaxInactiveIntervalInSeconds = (int) TimeUnit.HOURS - .toSeconds(2); + final int expectedMaxInactiveIntervalInSeconds = (int) TimeUnit.HOURS.toSeconds(2); - AbstractGemFireOperationsSessionRepository.GemFireSession session = AbstractGemFireOperationsSessionRepository.GemFireSession - .create(expectedMaxInactiveIntervalInSeconds); + AbstractGemFireOperationsSessionRepository.GemFireSession session = + AbstractGemFireOperationsSessionRepository.GemFireSession.create(expectedMaxInactiveIntervalInSeconds); assertThat(session).isNotNull(); - assertThat(session.getMaxInactiveIntervalInSeconds()) - .isEqualTo(expectedMaxInactiveIntervalInSeconds); + assertThat(session.getMaxInactiveIntervalInSeconds()).isEqualTo(expectedMaxInactiveIntervalInSeconds); final long now = System.currentTimeMillis(); @@ -935,15 +911,14 @@ public class AbstractGemFireOperationsSessionRepositoryTest { public void isExpiredIsTrueWhenSessionIsInactive() { final int expectedMaxInactiveIntervalInSeconds = 60; - AbstractGemFireOperationsSessionRepository.GemFireSession session = AbstractGemFireOperationsSessionRepository.GemFireSession - .create(expectedMaxInactiveIntervalInSeconds); + AbstractGemFireOperationsSessionRepository.GemFireSession session = + AbstractGemFireOperationsSessionRepository.GemFireSession.create(expectedMaxInactiveIntervalInSeconds); assertThat(session).isNotNull(); assertThat(session.getMaxInactiveIntervalInSeconds()) .isEqualTo(expectedMaxInactiveIntervalInSeconds); - final long twoHoursAgo = (System.currentTimeMillis() - - TimeUnit.HOURS.toMillis(2)); + final long twoHoursAgo = (System.currentTimeMillis() - TimeUnit.HOURS.toMillis(2)); session.setLastAccessedTime(twoHoursAgo); @@ -953,8 +928,8 @@ public class AbstractGemFireOperationsSessionRepositoryTest { @Test public void setAndGetPrincipalName() { - AbstractGemFireOperationsSessionRepository.GemFireSession session = AbstractGemFireOperationsSessionRepository.GemFireSession - .create(0); + AbstractGemFireOperationsSessionRepository.GemFireSession session = + AbstractGemFireOperationsSessionRepository.GemFireSession.create(0); assertThat(session).isNotNull(); assertThat(session.getPrincipalName()).isNull(); @@ -962,24 +937,20 @@ public class AbstractGemFireOperationsSessionRepositoryTest { session.setPrincipalName("jblum"); assertThat(session.getPrincipalName()).isEqualTo("jblum"); - assertThat(session.getAttributeNames()).isEqualTo( - asSet(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME)); - assertThat(String.valueOf(session.getAttribute( - FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME))) - .isEqualTo("jblum"); + assertThat(session.getAttributeNames()) + .isEqualTo(asSet(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME)); + assertThat(String.valueOf(session.getAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME))) + .isEqualTo("jblum"); - session.setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, - "rwinch"); + session.setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, "rwinch"); - assertThat(session.getAttributeNames()).isEqualTo( - asSet(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME)); - assertThat(String.valueOf(session.getAttribute( - FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME))) - .isEqualTo("rwinch"); + assertThat(session.getAttributeNames()) + .isEqualTo(asSet(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME)); + assertThat(String.valueOf(session.getAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME))) + .isEqualTo("rwinch"); assertThat(session.getPrincipalName()).isEqualTo("rwinch"); - session.removeAttribute( - FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME); + session.removeAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME); assertThat(session.getPrincipalName()).isNull(); } @@ -987,14 +958,14 @@ public class AbstractGemFireOperationsSessionRepositoryTest { @Test public void sessionToData() throws Exception { @SuppressWarnings("serial") - AbstractGemFireOperationsSessionRepository.GemFireSession session = new AbstractGemFireOperationsSessionRepository.GemFireSession( - "1") { - @Override - void writeObject(Object obj, DataOutput out) throws IOException { - assertThat(obj).isInstanceOf( - AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes.class); - assertThat(out).isNotNull(); - } + AbstractGemFireOperationsSessionRepository.GemFireSession session = + new AbstractGemFireOperationsSessionRepository.GemFireSession("1") { + @Override + void writeObject(Object obj, DataOutput out) throws IOException { + assertThat(obj) + .isInstanceOf(AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes.class); + assertThat(out).isNotNull(); + } }; session.setLastAccessedTime(123L); @@ -1009,64 +980,60 @@ public class AbstractGemFireOperationsSessionRepositoryTest { verify(mockDataOutput, times(1)).writeLong(eq(session.getCreationTime())); verify(mockDataOutput, times(1)).writeLong(eq(session.getLastAccessedTime())); verify(mockDataOutput, times(1)) - .writeInt(eq(session.getMaxInactiveIntervalInSeconds())); + .writeInt(eq(session.getMaxInactiveIntervalInSeconds())); verify(mockDataOutput, times(1)).writeInt(eq("jblum".length())); verify(mockDataOutput, times(1)).writeUTF(eq(session.getPrincipalName())); } @Test public void sessionFromData() throws Exception { - final long expectedCreationTime = 1L; - final long expectedLastAccessedTime = 2L; + long expectedCreationTime = 1L; + long expectedLastAccessedTime = 2L; - final int expectedMaxInactiveIntervalInSeconds = (int) TimeUnit.HOURS - .toSeconds(6); + int expectedMaxInactiveIntervalInSeconds = (int) TimeUnit.HOURS.toSeconds(6); final String expectedPrincipalName = "jblum"; DataInput mockDataInput = mock(DataInput.class); given(mockDataInput.readUTF()).willReturn("2").willReturn(expectedPrincipalName); - given(mockDataInput.readLong()).willReturn(expectedCreationTime) - .willReturn(expectedLastAccessedTime); + given(mockDataInput.readLong()).willReturn(expectedCreationTime).willReturn(expectedLastAccessedTime); given(mockDataInput.readInt()).willReturn(expectedMaxInactiveIntervalInSeconds); @SuppressWarnings("serial") - AbstractGemFireOperationsSessionRepository.GemFireSession session = new AbstractGemFireOperationsSessionRepository.GemFireSession( - "1") { - @Override - @SuppressWarnings("unchecked") - T readObject(DataInput in) throws ClassNotFoundException, IOException { - assertThat(in).isNotNull(); + AbstractGemFireOperationsSessionRepository.GemFireSession session = + new AbstractGemFireOperationsSessionRepository.GemFireSession("1") { + @Override + @SuppressWarnings("unchecked") + T readObject(DataInput in) throws ClassNotFoundException, IOException { + assertThat(in).isNotNull(); - AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes sessionAttributes = new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes(); + AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes sessionAttributes = + new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes(); - sessionAttributes.setAttribute("attrOne", "testOne"); - sessionAttributes.setAttribute("attrTwo", "testTwo"); + sessionAttributes.setAttribute("attrOne", "testOne"); + sessionAttributes.setAttribute("attrTwo", "testTwo"); - return (T) sessionAttributes; - } + return (T) sessionAttributes; + } }; session.fromData(mockDataInput); - Set expectedAttributeNames = asSet("attrOne", "attrTwo", - FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME); + Set expectedAttributeNames = + asSet("attrOne", "attrTwo", FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME); assertThat(session.getId()).isEqualTo("2"); assertThat(session.getCreationTime()).isEqualTo(expectedCreationTime); assertThat(session.getLastAccessedTime()).isEqualTo(expectedLastAccessedTime); - assertThat(session.getMaxInactiveIntervalInSeconds()) - .isEqualTo(expectedMaxInactiveIntervalInSeconds); + assertThat(session.getMaxInactiveIntervalInSeconds()).isEqualTo(expectedMaxInactiveIntervalInSeconds); assertThat(session.getPrincipalName()).isEqualTo(expectedPrincipalName); assertThat(session.getAttributeNames().size()).isEqualTo(3); - assertThat(session.getAttributeNames().containsAll(expectedAttributeNames)) - .isTrue(); + assertThat(session.getAttributeNames().containsAll(expectedAttributeNames)).isTrue(); assertThat(String.valueOf(session.getAttribute("attrOne"))).isEqualTo("testOne"); assertThat(String.valueOf(session.getAttribute("attrTwo"))).isEqualTo("testTwo"); - assertThat(String.valueOf(session.getAttribute( - FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME))) - .isEqualTo(expectedPrincipalName); + assertThat(String.valueOf(session.getAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME))) + .isEqualTo(expectedPrincipalName); verify(mockDataInput, times(2)).readUTF(); verify(mockDataInput, times(2)).readLong(); @@ -1080,21 +1047,19 @@ public class AbstractGemFireOperationsSessionRepositoryTest { final long beforeOrAtCreationTime = System.currentTimeMillis(); @SuppressWarnings("serial") - AbstractGemFireOperationsSessionRepository.GemFireSession expectedSession = new AbstractGemFireOperationsSessionRepository.GemFireSession( - "123") { - @Override - void writeObject(Object obj, DataOutput out) throws IOException { - assertThat(obj).isInstanceOf( - AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes.class); - assertThat(out).isNotNull(); - } + AbstractGemFireOperationsSessionRepository.GemFireSession expectedSession = + new AbstractGemFireOperationsSessionRepository.GemFireSession("123") { + @Override + void writeObject(Object obj, DataOutput out) throws IOException { + assertThat(obj) + .isInstanceOf(AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes.class); + assertThat(out).isNotNull(); + } }; assertThat(expectedSession.getId()).isEqualTo("123"); - assertThat(expectedSession.getCreationTime()) - .isGreaterThanOrEqualTo(beforeOrAtCreationTime); - assertThat(expectedSession.getLastAccessedTime()) - .isGreaterThanOrEqualTo(expectedSession.getCreationTime()); + assertThat(expectedSession.getCreationTime()).isGreaterThanOrEqualTo(beforeOrAtCreationTime); + assertThat(expectedSession.getLastAccessedTime()).isGreaterThanOrEqualTo(expectedSession.getCreationTime()); assertThat(expectedSession.getMaxInactiveIntervalInSeconds()).isEqualTo(0); assertThat(expectedSession.getPrincipalName()).isNull(); @@ -1103,37 +1068,34 @@ public class AbstractGemFireOperationsSessionRepositoryTest { expectedSession.toData(new DataOutputStream(outBytes)); @SuppressWarnings("serial") - AbstractGemFireOperationsSessionRepository.GemFireSession deserializedSession = new AbstractGemFireOperationsSessionRepository.GemFireSession( - "0") { - @Override - @SuppressWarnings("unchecked") - T readObject(DataInput in) throws ClassNotFoundException, IOException { - return (T) new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes(); - } + AbstractGemFireOperationsSessionRepository.GemFireSession deserializedSession = + new AbstractGemFireOperationsSessionRepository.GemFireSession("0") { + @Override + @SuppressWarnings("unchecked") + T readObject(DataInput in) throws ClassNotFoundException, IOException { + return (T) new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes(); + } }; - deserializedSession.fromData( - new DataInputStream(new ByteArrayInputStream(outBytes.toByteArray()))); + deserializedSession.fromData(new DataInputStream(new ByteArrayInputStream(outBytes.toByteArray()))); assertThat(deserializedSession).isEqualTo(expectedSession); - assertThat(deserializedSession.getCreationTime()) - .isEqualTo(expectedSession.getCreationTime()); - assertThat(deserializedSession.getLastAccessedTime()) - .isEqualTo(expectedSession.getLastAccessedTime()); + assertThat(deserializedSession.getCreationTime()).isEqualTo(expectedSession.getCreationTime()); + assertThat(deserializedSession.getLastAccessedTime()).isEqualTo(expectedSession.getLastAccessedTime()); assertThat(deserializedSession.getMaxInactiveIntervalInSeconds()) - .isEqualTo(expectedSession.getMaxInactiveIntervalInSeconds()); + .isEqualTo(expectedSession.getMaxInactiveIntervalInSeconds()); assertThat(deserializedSession.getPrincipalName()).isNull(); } @Test public void hasDeltaWhenNoSessionChangesIsFalse() { - assertThat(new AbstractGemFireOperationsSessionRepository.GemFireSession() - .hasDelta()).isFalse(); + assertThat(new AbstractGemFireOperationsSessionRepository.GemFireSession().hasDelta()).isFalse(); } @Test public void hasDeltaWhenSessionAttributesChangeIsTrue() { - AbstractGemFireOperationsSessionRepository.GemFireSession session = new AbstractGemFireOperationsSessionRepository.GemFireSession(); + AbstractGemFireOperationsSessionRepository.GemFireSession session = + new AbstractGemFireOperationsSessionRepository.GemFireSession(); assertThat(session.hasDelta()).isFalse(); @@ -1144,9 +1106,10 @@ public class AbstractGemFireOperationsSessionRepositoryTest { @Test public void hasDeltaWhenSessionLastAccessedTimeIsUpdatedIsTrue() { - final long expectedLastAccessTime = 1L; + long expectedLastAccessTime = 1L; - AbstractGemFireOperationsSessionRepository.GemFireSession session = new AbstractGemFireOperationsSessionRepository.GemFireSession(); + AbstractGemFireOperationsSessionRepository.GemFireSession session = + new AbstractGemFireOperationsSessionRepository.GemFireSession(); assertThat(session.getLastAccessedTime()).isNotEqualTo(expectedLastAccessTime); assertThat(session.hasDelta()).isFalse(); @@ -1164,24 +1127,22 @@ public class AbstractGemFireOperationsSessionRepositoryTest { @Test public void hasDeltaWhenSessionMaxInactiveIntervalInSecondsIsUpdatedIsTrue() { - final int expectedMaxInactiveIntervalInSeconds = 300; + int expectedMaxInactiveIntervalInSeconds = 300; - AbstractGemFireOperationsSessionRepository.GemFireSession session = new AbstractGemFireOperationsSessionRepository.GemFireSession(); + AbstractGemFireOperationsSessionRepository.GemFireSession session = + new AbstractGemFireOperationsSessionRepository.GemFireSession(); - assertThat(session.getMaxInactiveIntervalInSeconds()) - .isNotEqualTo(expectedMaxInactiveIntervalInSeconds); + assertThat(session.getMaxInactiveIntervalInSeconds()).isNotEqualTo(expectedMaxInactiveIntervalInSeconds); assertThat(session.hasDelta()).isFalse(); session.setMaxInactiveIntervalInSeconds(expectedMaxInactiveIntervalInSeconds); - assertThat(session.getMaxInactiveIntervalInSeconds()) - .isEqualTo(expectedMaxInactiveIntervalInSeconds); + assertThat(session.getMaxInactiveIntervalInSeconds()).isEqualTo(expectedMaxInactiveIntervalInSeconds); assertThat(session.hasDelta()).isTrue(); session.setMaxInactiveIntervalInSeconds(expectedMaxInactiveIntervalInSeconds); - assertThat(session.getMaxInactiveIntervalInSeconds()) - .isEqualTo(expectedMaxInactiveIntervalInSeconds); + assertThat(session.getMaxInactiveIntervalInSeconds()).isEqualTo(expectedMaxInactiveIntervalInSeconds); assertThat(session.hasDelta()).isTrue(); } @@ -1190,12 +1151,13 @@ public class AbstractGemFireOperationsSessionRepositoryTest { final DataOutput mockDataOutput = mock(DataOutput.class); @SuppressWarnings("serial") - AbstractGemFireOperationsSessionRepository.GemFireSession session = new AbstractGemFireOperationsSessionRepository.GemFireSession() { - @Override - void writeObject(Object obj, DataOutput out) throws IOException { - assertThat(String.valueOf(obj)).isEqualTo("test"); - assertThat(out).isSameAs(mockDataOutput); - } + AbstractGemFireOperationsSessionRepository.GemFireSession session = + new AbstractGemFireOperationsSessionRepository.GemFireSession() { + @Override + void writeObject(Object obj, DataOutput out) throws IOException { + assertThat(String.valueOf(obj)).isEqualTo("test"); + assertThat(out).isSameAs(mockDataOutput); + } }; session.setLastAccessedTime(1L); @@ -1222,13 +1184,14 @@ public class AbstractGemFireOperationsSessionRepositoryTest { given(mockDataInput.readInt()).willReturn(600).willReturn(0); @SuppressWarnings("serial") - AbstractGemFireOperationsSessionRepository.GemFireSession session = new AbstractGemFireOperationsSessionRepository.GemFireSession() { - @Override - @SuppressWarnings("unchecked") - T readObject(DataInput in) throws ClassNotFoundException, IOException { - assertThat(in).isSameAs(mockDataInput); - return (T) "test"; - } + AbstractGemFireOperationsSessionRepository.GemFireSession session = + new AbstractGemFireOperationsSessionRepository.GemFireSession() { + @Override + @SuppressWarnings("unchecked") + T readObject(DataInput in) throws ClassNotFoundException, IOException { + assertThat(in).isSameAs(mockDataInput); + return (T) "test"; + } }; session.fromDelta(mockDataInput); @@ -1245,13 +1208,14 @@ public class AbstractGemFireOperationsSessionRepositoryTest { @Test public void sessionComparisons() { - final long twoHoursAgo = (System.currentTimeMillis() - - TimeUnit.HOURS.toMillis(2)); + long twoHoursAgo = (System.currentTimeMillis() - TimeUnit.HOURS.toMillis(2)); - AbstractGemFireOperationsSessionRepository.GemFireSession sessionOne = new AbstractGemFireOperationsSessionRepository.GemFireSession( + AbstractGemFireOperationsSessionRepository.GemFireSession sessionOne = + new AbstractGemFireOperationsSessionRepository.GemFireSession( mockSession("1", twoHoursAgo, MAX_INACTIVE_INTERVAL_IN_SECONDS)); - AbstractGemFireOperationsSessionRepository.GemFireSession sessionTwo = new AbstractGemFireOperationsSessionRepository.GemFireSession( - "2"); + + AbstractGemFireOperationsSessionRepository.GemFireSession sessionTwo = + new AbstractGemFireOperationsSessionRepository.GemFireSession("2"); assertThat(sessionOne.getCreationTime()).isEqualTo(twoHoursAgo); assertThat(sessionTwo.getCreationTime()).isGreaterThan(twoHoursAgo); @@ -1262,27 +1226,25 @@ public class AbstractGemFireOperationsSessionRepositoryTest { @Test public void sessionEqualsDifferentSessionBasedOnId() { - AbstractGemFireOperationsSessionRepository.GemFireSession sessionOne = new AbstractGemFireOperationsSessionRepository.GemFireSession( - "1"); + AbstractGemFireOperationsSessionRepository.GemFireSession sessionOne = + new AbstractGemFireOperationsSessionRepository.GemFireSession("1"); sessionOne.setLastAccessedTime(12345L); sessionOne.setMaxInactiveIntervalInSeconds(120); sessionOne.setPrincipalName("jblum"); - AbstractGemFireOperationsSessionRepository.GemFireSession sessionTwo = new AbstractGemFireOperationsSessionRepository.GemFireSession( - "1"); + AbstractGemFireOperationsSessionRepository.GemFireSession sessionTwo = + new AbstractGemFireOperationsSessionRepository.GemFireSession("1"); sessionTwo.setLastAccessedTime(67890L); sessionTwo.setMaxInactiveIntervalInSeconds(300); sessionTwo.setPrincipalName("rwinch"); assertThat(sessionOne.getId().equals(sessionTwo.getId())).isTrue(); - assertThat(sessionOne.getLastAccessedTime() == sessionTwo.getLastAccessedTime()) - .isFalse(); - assertThat(sessionOne.getMaxInactiveIntervalInSeconds() == sessionTwo - .getMaxInactiveIntervalInSeconds()).isFalse(); - assertThat(sessionOne.getPrincipalName().equals(sessionTwo.getPrincipalName())) - .isFalse(); + assertThat(sessionOne.getLastAccessedTime() == sessionTwo.getLastAccessedTime()).isFalse(); + assertThat(sessionOne.getMaxInactiveIntervalInSeconds() == sessionTwo.getMaxInactiveIntervalInSeconds()) + .isFalse(); + assertThat(sessionOne.getPrincipalName().equals(sessionTwo.getPrincipalName())).isFalse(); assertThat(sessionOne.equals(sessionTwo)).isTrue(); } @@ -1310,12 +1272,9 @@ public class AbstractGemFireOperationsSessionRepositoryTest { sessionAttributes.from(mockSession); assertThat(sessionAttributes.getAttributeNames().size()).isEqualTo(2); - assertThat(sessionAttributes.getAttributeNames() - .containsAll(asSet("attrOne", "attrTwo"))).isTrue(); - assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))) - .isEqualTo("testOne"); - assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))) - .isEqualTo("testTwo"); + assertThat(sessionAttributes.getAttributeNames().containsAll(asSet("attrOne", "attrTwo"))).isTrue(); + assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))).isEqualTo("testOne"); + assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))).isEqualTo("testTwo"); verify(mockSession, times(1)).getAttributeNames(); verify(mockSession, times(1)).getAttribute(eq("attrOne")); @@ -1336,8 +1295,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest { target.from(source); assertThat(target.getAttributeNames().size()).isEqualTo(2); - assertThat(target.getAttributeNames().containsAll(asSet("attrOne", "attrTwo"))) - .isTrue(); + assertThat(target.getAttributeNames().containsAll(asSet("attrOne", "attrTwo"))).isTrue(); assertThat(String.valueOf(target.getAttribute("attrOne"))).isEqualTo("testOne"); assertThat(String.valueOf(target.getAttribute("attrTwo"))).isEqualTo("testTwo"); } @@ -1347,15 +1305,15 @@ public class AbstractGemFireOperationsSessionRepositoryTest { final DataOutput mockDataOutput = mock(DataOutput.class); @SuppressWarnings("serial") - AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes sessionAttributes = new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes() { - private int count = 0; + AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes sessionAttributes = + new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes() { + private int count = 0; - @Override - void writeObject(Object obj, DataOutput out) throws IOException { - assertThat(Arrays.asList("testOne", "testTwo").get(count++)) - .isEqualTo(String.valueOf(obj)); - assertThat(out).isSameAs(mockDataOutput); - } + @Override + void writeObject(Object obj, DataOutput out) throws IOException { + assertThat(Arrays.asList("testOne", "testTwo").get(count++)).isEqualTo(String.valueOf(obj)); + assertThat(out).isSameAs(mockDataOutput); + } }; sessionAttributes.setAttribute("attrOne", "testOne"); @@ -1376,15 +1334,16 @@ public class AbstractGemFireOperationsSessionRepositoryTest { given(mockDataInput.readUTF()).willReturn("attrOne").willReturn("attrTwo"); @SuppressWarnings("serial") - AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes sessionAttributes = new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes() { - private int count = 0; + AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes sessionAttributes = + new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes() { + private int count = 0; - @Override - @SuppressWarnings("unchecked") - T readObject(DataInput in) throws ClassNotFoundException, IOException { - assertThat(in).isSameAs(mockDataInput); - return (T) Arrays.asList("testOne", "testTwo").get(count++); - } + @Override + @SuppressWarnings("unchecked") + T readObject(DataInput in) throws ClassNotFoundException, IOException { + assertThat(in).isSameAs(mockDataInput); + return (T) Arrays.asList("testOne", "testTwo").get(count++); + } }; assertThat(sessionAttributes.getAttributeNames().isEmpty()).isTrue(); @@ -1392,12 +1351,9 @@ public class AbstractGemFireOperationsSessionRepositoryTest { sessionAttributes.fromData(mockDataInput); assertThat(sessionAttributes.getAttributeNames().size()).isEqualTo(2); - assertThat(sessionAttributes.getAttributeNames() - .containsAll(asSet("attrOne", "attrTwo"))).isTrue(); - assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))) - .isEqualTo("testOne"); - assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))) - .isEqualTo("testTwo"); + assertThat(sessionAttributes.getAttributeNames().containsAll(asSet("attrOne", "attrTwo"))).isTrue(); + assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))).isEqualTo("testOne"); + assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))).isEqualTo("testTwo"); verify(mockDataInput, times(1)).readInt(); verify(mockDataInput, times(2)).readUTF(); @@ -1405,21 +1361,19 @@ public class AbstractGemFireOperationsSessionRepositoryTest { @Test public void sessionAttributesHasDeltaIsFalse() { - assertThat( - new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes() - .hasDelta()).isFalse(); + assertThat(new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes().hasDelta()).isFalse(); } @Test public void sessionAttributesHasDeltaIsTrue() { - AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes sessionAttributes = new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes(); + AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes sessionAttributes = + new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes(); assertThat(sessionAttributes.hasDelta()).isFalse(); sessionAttributes.setAttribute("attrOne", "testOne"); - assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))) - .isEqualTo("testOne"); + assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))).isEqualTo("testOne"); assertThat(sessionAttributes.hasDelta()).isTrue(); } @@ -1428,15 +1382,16 @@ public class AbstractGemFireOperationsSessionRepositoryTest { final DataOutput mockDataOutput = mock(DataOutput.class); @SuppressWarnings("serial") - AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes sessionAttributes = new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes() { - private int count = 0; + AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes sessionAttributes = + new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes() { + private int count = 0; - @Override - void writeObject(Object obj, DataOutput out) throws IOException { - assertThat(Arrays.asList("testOne", "testTwo", "testThree").get(count++)) + @Override + void writeObject(Object obj, DataOutput out) throws IOException { + assertThat(Arrays.asList("testOne", "testTwo", "testThree").get(count++)) .isEqualTo(String.valueOf(obj)); - assertThat(out).isSameAs(mockDataOutput); - } + assertThat(out).isSameAs(mockDataOutput); + } }; sessionAttributes.setAttribute("attrOne", "testOne"); @@ -1481,38 +1436,33 @@ public class AbstractGemFireOperationsSessionRepositoryTest { given(mockDataInput.readUTF()).willReturn("attrOne").willReturn("attrTwo"); @SuppressWarnings("serial") - AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes sessionAttributes = new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes() { - private int count = 0; + AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes sessionAttributes = + new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes() { + private int count = 0; - @Override - @SuppressWarnings("unchecked") - T readObject(DataInput in) throws ClassNotFoundException, IOException { - assertThat(in).isSameAs(mockDataInput); - return (T) Arrays.asList("testOne", "testTwo", "testThree").get(count++); - } + @Override + @SuppressWarnings("unchecked") + T readObject(DataInput in) throws ClassNotFoundException, IOException { + assertThat(in).isSameAs(mockDataInput); + return (T) Arrays.asList("testOne", "testTwo", "testThree").get(count++); + } }; sessionAttributes.setAttribute("attrOne", "one"); sessionAttributes.setAttribute("attrTwo", "two"); assertThat(sessionAttributes.getAttributeNames().size()).isEqualTo(2); - assertThat(sessionAttributes.getAttributeNames() - .containsAll(asSet("attrOne", "attrTwo"))).isTrue(); - assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))) - .isEqualTo("one"); - assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))) - .isEqualTo("two"); + assertThat(sessionAttributes.getAttributeNames().containsAll(asSet("attrOne", "attrTwo"))).isTrue(); + assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))).isEqualTo("one"); + assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))).isEqualTo("two"); assertThat(sessionAttributes.hasDelta()).isTrue(); sessionAttributes.fromDelta(mockDataInput); assertThat(sessionAttributes.getAttributeNames().size()).isEqualTo(2); - assertThat(sessionAttributes.getAttributeNames() - .containsAll(asSet("attrOne", "attrTwo"))).isTrue(); - assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))) - .isEqualTo("testOne"); - assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))) - .isEqualTo("testTwo"); + assertThat(sessionAttributes.getAttributeNames().containsAll(asSet("attrOne", "attrTwo"))).isTrue(); + assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))).isEqualTo("testOne"); + assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))).isEqualTo("testTwo"); assertThat(sessionAttributes.hasDelta()).isFalse(); verify(mockDataInput, times(1)).readInt(); @@ -1526,23 +1476,17 @@ public class AbstractGemFireOperationsSessionRepositoryTest { sessionAttributes.setAttribute("attrTwo", "two"); assertThat(sessionAttributes.getAttributeNames().size()).isEqualTo(2); - assertThat(sessionAttributes.getAttributeNames() - .containsAll(asSet("attrOne", "attrTwo"))).isTrue(); - assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))) - .isEqualTo("one"); - assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))) - .isEqualTo("two"); + assertThat(sessionAttributes.getAttributeNames().containsAll(asSet("attrOne", "attrTwo"))).isTrue(); + assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))).isEqualTo("one"); + assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))).isEqualTo("two"); assertThat(sessionAttributes.hasDelta()).isTrue(); sessionAttributes.fromDelta(mockDataInput); assertThat(sessionAttributes.getAttributeNames().size()).isEqualTo(2); - assertThat(sessionAttributes.getAttributeNames() - .containsAll(asSet("attrOne", "attrTwo"))).isTrue(); - assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))) - .isEqualTo("one"); - assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))) - .isEqualTo("testThree"); + assertThat(sessionAttributes.getAttributeNames().containsAll(asSet("attrOne", "attrTwo"))).isTrue(); + assertThat(String.valueOf(sessionAttributes.getAttribute("attrOne"))).isEqualTo("one"); + assertThat(String.valueOf(sessionAttributes.getAttribute("attrTwo"))).isEqualTo("testThree"); assertThat(sessionAttributes.hasDelta()).isTrue(); verify(mockDataInput, times(1)).readInt(); @@ -1551,13 +1495,13 @@ public class AbstractGemFireOperationsSessionRepositoryTest { @Test public void sessionAttributesEntrySetIteratesAttributeNameValues() { - AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes sessionAttributes = new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes(); + AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes sessionAttributes = + new AbstractGemFireOperationsSessionRepository.GemFireSessionAttributes(); sessionAttributes.setAttribute("keyOne", "valueOne"); sessionAttributes.setAttribute("keyTwo", "valueTwo"); - Set> sessionAttributeEntries = sessionAttributes - .entrySet(); + Set> sessionAttributeEntries = sessionAttributes.entrySet(); assertThat(sessionAttributeEntries).isNotNull(); assertThat(sessionAttributeEntries.size()).isEqualTo(2); @@ -1619,10 +1563,8 @@ public class AbstractGemFireOperationsSessionRepositoryTest { assertThat(this.session).isNotNull(); assertThat(this.session.getId()).isEqualTo("1"); - assertThat(this.session.getCreationTime()) - .isGreaterThanOrEqualTo(this.beforeOrAtCreationTime); - assertThat(this.session.getLastAccessedTime()) - .isEqualTo(this.session.getCreationTime()); + assertThat(this.session.getCreationTime()).isGreaterThanOrEqualTo(this.beforeOrAtCreationTime); + assertThat(this.session.getLastAccessedTime()).isEqualTo(this.session.getCreationTime()); assertThat(this.session.getMaxInactiveIntervalInSeconds()).isEqualTo(0); assertThat(this.session.getPrincipalName()).isNull(); assertThat(this.session.getAttributeNames().isEmpty()).isTrue(); @@ -1641,15 +1583,14 @@ public class AbstractGemFireOperationsSessionRepositoryTest { assertThat(this.session).isNotNull(); assertThat(this.session.getId()).isEqualTo("1"); - assertThat(this.session.getCreationTime()) - .isEqualTo(this.expectedCreationTime); + assertThat(this.session.getCreationTime()).isEqualTo(this.expectedCreationTime); assertThat(this.session.getLastAccessedTime()).isEqualTo(0L); assertThat(this.session.getMaxInactiveIntervalInSeconds()).isEqualTo(60); assertThat(this.session.getPrincipalName()).isEqualTo("jblum"); assertThat(this.session.getAttributeNames().size()).isEqualTo(1); - assertThat(String.valueOf(this.session.getAttribute( - FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME))) - .isEqualTo("jblum"); + assertThat(String.valueOf( + this.session.getAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME))) + .isEqualTo("jblum"); this.session.setAttribute("tennis", "ping"); this.session.setAttribute("junk", "test"); @@ -1661,20 +1602,16 @@ public class AbstractGemFireOperationsSessionRepositoryTest { assertThat(this.session).isNotNull(); assertThat(this.session.getId()).isEqualTo("1"); - assertThat(this.session.getCreationTime()) - .isEqualTo(this.expectedCreationTime); + assertThat(this.session.getCreationTime()).isEqualTo(this.expectedCreationTime); assertThat(this.session.getLastAccessedTime()).isEqualTo(2L); assertThat(this.session.getMaxInactiveIntervalInSeconds()).isEqualTo(180); assertThat(this.session.getPrincipalName()).isEqualTo("ogierke"); assertThat(this.session.getAttributeNames().size()).isEqualTo(3); - assertThat(this.session.getAttributeNames() - .containsAll(asSet("tennis", "greeting"))).isTrue(); + assertThat(this.session.getAttributeNames().containsAll(asSet("tennis", "greeting"))).isTrue(); assertThat(this.session.getAttributeNames().contains("junk")).isFalse(); assertThat(this.session.getAttribute("junk")).isNull(); - assertThat(String.valueOf(this.session.getAttribute("tennis"))) - .isEqualTo("pong"); - assertThat(String.valueOf(this.session.getAttribute("greeting"))) - .isEqualTo("hello"); + assertThat(String.valueOf(this.session.getAttribute("tennis"))).isEqualTo("pong"); + assertThat(String.valueOf(this.session.getAttribute("greeting"))).isEqualTo("hello"); } public void thread2() { @@ -1687,19 +1624,14 @@ public class AbstractGemFireOperationsSessionRepositoryTest { assertThat(this.session).isNotNull(); assertThat(this.session.getId()).isEqualTo("1"); - assertThat(this.session.getCreationTime()) - .isEqualTo(this.expectedCreationTime); + assertThat(this.session.getCreationTime()).isEqualTo(this.expectedCreationTime); assertThat(this.session.getLastAccessedTime()).isEqualTo(1L); assertThat(this.session.getMaxInactiveIntervalInSeconds()).isEqualTo(120); assertThat(this.session.getPrincipalName()).isEqualTo("rwinch"); assertThat(this.session.getAttributeNames().size()).isEqualTo(3); - assertThat( - this.session.getAttributeNames().containsAll(asSet("tennis", "junk"))) - .isTrue(); - assertThat(String.valueOf(this.session.getAttribute("junk"))) - .isEqualTo("test"); - assertThat(String.valueOf(this.session.getAttribute("tennis"))) - .isEqualTo("ping"); + assertThat(this.session.getAttributeNames().containsAll(asSet("tennis", "junk"))).isTrue(); + assertThat(String.valueOf(this.session.getAttribute("junk"))).isEqualTo("test"); + assertThat(String.valueOf(this.session.getAttribute("tennis"))).isEqualTo("ping"); this.session.setAttribute("tennis", "pong"); this.session.setAttribute("greeting", "hello"); @@ -1718,34 +1650,35 @@ public class AbstractGemFireOperationsSessionRepositoryTest { static class Tombstone { } - protected static class TestGemFireOperationsSessionRepository - extends AbstractGemFireOperationsSessionRepository { + protected static class TestGemFireOperationsSessionRepository extends AbstractGemFireOperationsSessionRepository { - protected TestGemFireOperationsSessionRepository( - GemfireOperations gemfireOperations) { + protected TestGemFireOperationsSessionRepository(GemfireOperations gemfireOperations) { super(gemfireOperations); } - public Map findByIndexNameAndIndexValue(String indexName, - String indexValue) { - throw new UnsupportedOperationException("not implemented"); - } - + @Override public ExpiringSession createSession() { - throw new UnsupportedOperationException("not implemented"); + throw new UnsupportedOperationException("Not Implemented"); } + @Override + public Map findByIndexNameAndIndexValue(String indexName, String indexValue) { + throw new UnsupportedOperationException("Not Implemented"); + } + + @Override public ExpiringSession getSession(String id) { - throw new UnsupportedOperationException("not implemented"); + throw new UnsupportedOperationException("Not Implemented"); } + @Override public void save(ExpiringSession session) { - throw new UnsupportedOperationException("not implemented"); + throw new UnsupportedOperationException("Not Implemented"); } + @Override public void delete(String id) { - throw new UnsupportedOperationException("not implemented"); + throw new UnsupportedOperationException("Not Implemented"); } } - } diff --git a/spring-session/src/test/java/org/springframework/session/data/gemfire/GemFireOperationsSessionRepositoryTest.java b/spring-session/src/test/java/org/springframework/session/data/gemfire/GemFireOperationsSessionRepositoryTest.java index c2af135a..1d1b7534 100644 --- a/spring-session/src/test/java/org/springframework/session/data/gemfire/GemFireOperationsSessionRepositoryTest.java +++ b/spring-session/src/test/java/org/springframework/session/data/gemfire/GemFireOperationsSessionRepositoryTest.java @@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit; import com.gemstone.gemfire.cache.AttributesMutator; import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.query.SelectResults; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -89,32 +90,23 @@ public class GemFireOperationsSessionRepositoryTest { @Before public void setup() throws Exception { - given(this.mockRegion.getAttributesMutator()) - .willReturn(this.mockAttributesMutator); + given(this.mockRegion.getAttributesMutator()).willReturn(this.mockAttributesMutator); given(this.mockRegion.getFullPath()).willReturn("/Example"); - given(this.mockTemplate.getRegion()) - .willReturn(this.mockRegion); + given(this.mockTemplate.getRegion()).willReturn(this.mockRegion); - this.sessionRepository = new GemFireOperationsSessionRepository( - this.mockTemplate); - this.sessionRepository - .setApplicationEventPublisher(this.mockApplicationEventPublisher); - this.sessionRepository - .setMaxInactiveIntervalInSeconds(MAX_INACTIVE_INTERVAL_IN_SECONDS); + this.sessionRepository = new GemFireOperationsSessionRepository(this.mockTemplate); + this.sessionRepository.setApplicationEventPublisher(this.mockApplicationEventPublisher); + this.sessionRepository.setMaxInactiveIntervalInSeconds(MAX_INACTIVE_INTERVAL_IN_SECONDS); this.sessionRepository.afterPropertiesSet(); - assertThat(this.sessionRepository.getApplicationEventPublisher()) - .isSameAs(this.mockApplicationEventPublisher); - assertThat(this.sessionRepository.getFullyQualifiedRegionName()) - .isEqualTo("/Example"); - assertThat(this.sessionRepository.getMaxInactiveIntervalInSeconds()) - .isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS); + assertThat(this.sessionRepository.getApplicationEventPublisher()).isSameAs(this.mockApplicationEventPublisher); + assertThat(this.sessionRepository.getFullyQualifiedRegionName()).isEqualTo("/Example"); + assertThat(this.sessionRepository.getMaxInactiveIntervalInSeconds()).isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS); } @After public void tearDown() { - verify(this.mockAttributesMutator, times(1)) - .addCacheListener(same(this.sessionRepository)); + verify(this.mockAttributesMutator, times(1)).addCacheListener(same(this.sessionRepository)); verify(this.mockRegion, times(1)).getFullPath(); verify(this.mockTemplate, times(1)).getRegion(); } @@ -128,21 +120,18 @@ public class GemFireOperationsSessionRepositoryTest { SelectResults mockSelectResults = mock(SelectResults.class); - given(mockSelectResults.asList()) - .willReturn(Collections.singletonList(mockSession)); + given(mockSelectResults.asList()).willReturn(Collections.singletonList(mockSession)); String indexName = "vip"; String indexValue = "rwinch"; - String expectedQql = String.format( - GemFireOperationsSessionRepository.FIND_SESSIONS_BY_INDEX_NAME_VALUE_QUERY, - this.sessionRepository.getFullyQualifiedRegionName(), indexName); + String expectedQql = String.format(GemFireOperationsSessionRepository.FIND_SESSIONS_BY_INDEX_NAME_VALUE_QUERY, + this.sessionRepository.getFullyQualifiedRegionName(), indexName); - given(this.mockTemplate.find(eq(expectedQql), eq(indexValue))) - .willReturn(mockSelectResults); + given(this.mockTemplate.find(eq(expectedQql), eq(indexValue))).willReturn(mockSelectResults); - Map sessions = this.sessionRepository - .findByIndexNameAndIndexValue(indexName, indexValue); + Map sessions = + this.sessionRepository.findByIndexNameAndIndexValue(indexName, indexValue); assertThat(sessions).isNotNull(); assertThat(sessions.size()).isEqualTo(1); @@ -158,8 +147,7 @@ public class GemFireOperationsSessionRepositoryTest { public void findByPrincipalNameFindsMatchingSessions() throws Exception { ExpiringSession mockSessionOne = mock(ExpiringSession.class, "MockSessionOne"); ExpiringSession mockSessionTwo = mock(ExpiringSession.class, "MockSessionTwo"); - ExpiringSession mockSessionThree = mock(ExpiringSession.class, - "MockSessionThree"); + ExpiringSession mockSessionThree = mock(ExpiringSession.class, "MockSessionThree"); given(mockSessionOne.getId()).willReturn("1"); given(mockSessionTwo.getId()).willReturn("2"); @@ -167,22 +155,18 @@ public class GemFireOperationsSessionRepositoryTest { SelectResults mockSelectResults = mock(SelectResults.class); - given(mockSelectResults.asList()).willReturn( - Arrays.asList(mockSessionOne, mockSessionTwo, mockSessionThree)); + given(mockSelectResults.asList()) + .willReturn(Arrays.asList(mockSessionOne, mockSessionTwo, mockSessionThree)); String principalName = "jblum"; - String expectedOql = String.format( - GemFireOperationsSessionRepository.FIND_SESSIONS_BY_PRINCIPAL_NAME_QUERY, - this.sessionRepository.getFullyQualifiedRegionName()); + String expectedOql = String.format(GemFireOperationsSessionRepository.FIND_SESSIONS_BY_PRINCIPAL_NAME_QUERY, + this.sessionRepository.getFullyQualifiedRegionName()); - given(this.mockTemplate.find(eq(expectedOql), eq(principalName))) - .willReturn(mockSelectResults); + given(this.mockTemplate.find(eq(expectedOql), eq(principalName))).willReturn(mockSelectResults); - Map sessions = this.sessionRepository - .findByIndexNameAndIndexValue( - FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, - principalName); + Map sessions = this.sessionRepository.findByIndexNameAndIndexValue( + FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, principalName); assertThat(sessions).isNotNull(); assertThat(sessions.size()).isEqualTo(3); @@ -206,17 +190,13 @@ public class GemFireOperationsSessionRepositoryTest { String principalName = "jblum"; - String expectedOql = String.format( - GemFireOperationsSessionRepository.FIND_SESSIONS_BY_PRINCIPAL_NAME_QUERY, - this.sessionRepository.getFullyQualifiedRegionName()); + String expectedOql = String.format(GemFireOperationsSessionRepository.FIND_SESSIONS_BY_PRINCIPAL_NAME_QUERY, + this.sessionRepository.getFullyQualifiedRegionName()); - given(this.mockTemplate.find(eq(expectedOql), eq(principalName))) - .willReturn(mockSelectResults); + given(this.mockTemplate.find(eq(expectedOql), eq(principalName))).willReturn(mockSelectResults); - Map sessions = this.sessionRepository - .findByIndexNameAndIndexValue( - FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, - principalName); + Map sessions = this.sessionRepository.findByIndexNameAndIndexValue( + FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, principalName); assertThat(sessions).isNotNull(); assertThat(sessions.isEmpty()).isTrue(); @@ -227,11 +207,11 @@ public class GemFireOperationsSessionRepositoryTest { @Test public void prepareQueryReturnsPrincipalNameOql() { - String actualQql = this.sessionRepository - .prepareQuery(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME); - String expectedOql = String.format( - GemFireOperationsSessionRepository.FIND_SESSIONS_BY_PRINCIPAL_NAME_QUERY, - this.sessionRepository.getFullyQualifiedRegionName()); + String actualQql = + this.sessionRepository.prepareQuery(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME); + + String expectedOql = String.format(GemFireOperationsSessionRepository.FIND_SESSIONS_BY_PRINCIPAL_NAME_QUERY, + this.sessionRepository.getFullyQualifiedRegionName()); assertThat(actualQql).isEqualTo(expectedOql); } @@ -240,29 +220,24 @@ public class GemFireOperationsSessionRepositoryTest { public void prepareQueryReturnsIndexNameValueOql() { String attributeName = "testAttributeName"; String actualOql = this.sessionRepository.prepareQuery(attributeName); - String expectedOql = String.format( - GemFireOperationsSessionRepository.FIND_SESSIONS_BY_INDEX_NAME_VALUE_QUERY, - this.sessionRepository.getFullyQualifiedRegionName(), attributeName); + String expectedOql = String.format(GemFireOperationsSessionRepository.FIND_SESSIONS_BY_INDEX_NAME_VALUE_QUERY, + this.sessionRepository.getFullyQualifiedRegionName(), attributeName); assertThat(actualOql).isEqualTo(expectedOql); } @Test public void createProperlyInitializedSession() { - final long beforeOrAtCreationTime = System.currentTimeMillis(); + long beforeOrAtCreationTime = System.currentTimeMillis(); ExpiringSession session = this.sessionRepository.createSession(); - assertThat(session).isInstanceOf( - AbstractGemFireOperationsSessionRepository.GemFireSession.class); + assertThat(session).isInstanceOf(AbstractGemFireOperationsSessionRepository.GemFireSession.class); assertThat(session.getId()).isNotNull(); assertThat(session.getAttributeNames().isEmpty()).isTrue(); - assertThat(session.getCreationTime()) - .isGreaterThanOrEqualTo(beforeOrAtCreationTime); - assertThat(session.getLastAccessedTime()) - .isGreaterThanOrEqualTo(beforeOrAtCreationTime); - assertThat(session.getMaxInactiveIntervalInSeconds()) - .isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS); + assertThat(session.getCreationTime()).isGreaterThanOrEqualTo(beforeOrAtCreationTime); + assertThat(session.getLastAccessedTime()).isGreaterThanOrEqualTo(beforeOrAtCreationTime); + assertThat(session.getMaxInactiveIntervalInSeconds()).isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS); } @Test @@ -277,23 +252,21 @@ public class GemFireOperationsSessionRepositoryTest { given(this.mockTemplate.remove(eq(expectedSessionId))).willReturn(mockSession); willAnswer(new Answer() { - public Void answer(final InvocationOnMock invocation) throws Throwable { - ApplicationEvent applicationEvent = invocation.getArgumentAt(0, - ApplicationEvent.class); + public Void answer(InvocationOnMock invocation) throws Throwable { + ApplicationEvent applicationEvent = invocation.getArgumentAt(0, ApplicationEvent.class); assertThat(applicationEvent).isInstanceOf(SessionDeletedEvent.class); AbstractSessionEvent sessionEvent = (AbstractSessionEvent) applicationEvent; - assertThat(sessionEvent.getSource()).isSameAs( - GemFireOperationsSessionRepositoryTest.this.sessionRepository); + assertThat(sessionEvent.getSource()) + .isSameAs(GemFireOperationsSessionRepositoryTest.this.sessionRepository); assertThat(sessionEvent.getSession()).isSameAs(mockSession); assertThat(sessionEvent.getSessionId()).isEqualTo(expectedSessionId); return null; } - }).given(this.mockApplicationEventPublisher) - .publishEvent(any(ApplicationEvent.class)); + }).given(this.mockApplicationEventPublisher).publishEvent(any(ApplicationEvent.class)); assertThat(this.sessionRepository.getSession(expectedSessionId)).isNull(); @@ -302,16 +275,15 @@ public class GemFireOperationsSessionRepositoryTest { verify(mockSession, times(1)).isExpired(); verify(mockSession, times(2)).getId(); verify(this.mockApplicationEventPublisher, times(1)) - .publishEvent(isA(SessionDeletedEvent.class)); + .publishEvent(isA(SessionDeletedEvent.class)); } @Test public void getSessionFindsMatchingNonExpiredSessionById() { - final String expectedId = "1"; + String expectedId = "1"; - final long expectedCreationTime = System.currentTimeMillis(); - final long currentLastAccessedTime = (expectedCreationTime - + TimeUnit.MINUTES.toMillis(5)); + long expectedCreationTime = System.currentTimeMillis(); + long currentLastAccessedTime = (expectedCreationTime + TimeUnit.MINUTES.toMillis(5)); ExpiringSession mockSession = mock(ExpiringSession.class); @@ -319,8 +291,7 @@ public class GemFireOperationsSessionRepositoryTest { given(mockSession.getId()).willReturn(expectedId); given(mockSession.getCreationTime()).willReturn(expectedCreationTime); given(mockSession.getLastAccessedTime()).willReturn(currentLastAccessedTime); - given(mockSession.getAttributeNames()) - .willReturn(Collections.singleton("attrOne")); + given(mockSession.getAttributeNames()).willReturn(Collections.singleton("attrOne")); given(mockSession.getAttribute(eq("attrOne"))).willReturn("test"); given(this.mockTemplate.get(eq(expectedId))).willReturn(mockSession); @@ -329,14 +300,10 @@ public class GemFireOperationsSessionRepositoryTest { assertThat(actualSession).isNotSameAs(mockSession); assertThat(actualSession.getId()).isEqualTo(expectedId); assertThat(actualSession.getCreationTime()).isEqualTo(expectedCreationTime); - assertThat(actualSession.getLastAccessedTime()) - .isNotEqualTo(currentLastAccessedTime); - assertThat(actualSession.getLastAccessedTime()) - .isGreaterThanOrEqualTo(expectedCreationTime); - assertThat(actualSession.getAttributeNames()) - .isEqualTo(Collections.singleton("attrOne")); - assertThat(String.valueOf(actualSession.getAttribute("attrOne"))) - .isEqualTo("test"); + assertThat(actualSession.getLastAccessedTime()).isNotEqualTo(currentLastAccessedTime); + assertThat(actualSession.getLastAccessedTime()).isGreaterThanOrEqualTo(expectedCreationTime); + assertThat(actualSession.getAttributeNames()).isEqualTo(Collections.singleton("attrOne")); + assertThat(String.valueOf(actualSession.getAttribute("attrOne"))).isEqualTo("test"); verify(this.mockTemplate, times(1)).get(eq(expectedId)); verify(mockSession, times(1)).isExpired(); @@ -358,8 +325,7 @@ public class GemFireOperationsSessionRepositoryTest { final String expectedSessionId = "1"; final long expectedCreationTime = System.currentTimeMillis(); - final long expectedLastAccessTime = (expectedCreationTime - + TimeUnit.MINUTES.toMillis(5)); + final long expectedLastAccessTime = (expectedCreationTime + TimeUnit.MINUTES.toMillis(5)); ExpiringSession mockSession = mock(ExpiringSession.class); @@ -371,27 +337,22 @@ public class GemFireOperationsSessionRepositoryTest { given(mockSession.getAttributeNames()).willReturn(Collections.emptySet()); given(this.mockTemplate.put(eq(expectedSessionId), - isA(AbstractGemFireOperationsSessionRepository.GemFireSession.class))) - .willAnswer(new Answer() { - public ExpiringSession answer( - final InvocationOnMock invocation) throws Throwable { - ExpiringSession session = invocation.getArgumentAt(1, - ExpiringSession.class); + isA(AbstractGemFireOperationsSessionRepository.GemFireSession.class))) + .willAnswer(new Answer() { + public ExpiringSession answer(InvocationOnMock invocation) throws Throwable { + ExpiringSession session = invocation.getArgumentAt(1, ExpiringSession.class); - assertThat(session).isNotNull(); - assertThat(session.getId()).isEqualTo(expectedSessionId); - assertThat(session.getCreationTime()) - .isEqualTo(expectedCreationTime); - assertThat(session.getLastAccessedTime()) - .isEqualTo(expectedLastAccessTime); - assertThat(session.getMaxInactiveIntervalInSeconds()) - .isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS); - assertThat(session.getAttributeNames().isEmpty()) - .isTrue(); + assertThat(session).isNotNull(); + assertThat(session.getId()).isEqualTo(expectedSessionId); + assertThat(session.getCreationTime()).isEqualTo(expectedCreationTime); + assertThat(session.getLastAccessedTime()).isEqualTo(expectedLastAccessTime); + assertThat(session.getMaxInactiveIntervalInSeconds()) + .isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS); + assertThat(session.getAttributeNames().isEmpty()).isTrue(); - return null; - } - }); + return null; + } + }); this.sessionRepository.save(mockSession); @@ -401,7 +362,7 @@ public class GemFireOperationsSessionRepositoryTest { verify(mockSession, times(1)).getMaxInactiveIntervalInSeconds(); verify(mockSession, times(1)).getAttributeNames(); verify(this.mockTemplate, times(1)).put(eq(expectedSessionId), - isA(AbstractGemFireOperationsSessionRepository.GemFireSession.class)); + isA(AbstractGemFireOperationsSessionRepository.GemFireSession.class)); } @Test @@ -415,29 +376,27 @@ public class GemFireOperationsSessionRepositoryTest { willAnswer(new Answer() { public Void answer(final InvocationOnMock invocation) throws Throwable { - ApplicationEvent applicationEvent = invocation.getArgumentAt(0, - ApplicationEvent.class); + ApplicationEvent applicationEvent = invocation.getArgumentAt(0, ApplicationEvent.class); assertThat(applicationEvent).isInstanceOf(SessionDeletedEvent.class); AbstractSessionEvent sessionEvent = (AbstractSessionEvent) applicationEvent; - assertThat(sessionEvent.getSource()).isSameAs( - GemFireOperationsSessionRepositoryTest.this.sessionRepository); + assertThat(sessionEvent.getSource()) + .isSameAs(GemFireOperationsSessionRepositoryTest.this.sessionRepository); assertThat(sessionEvent.getSession()).isSameAs(mockSession); assertThat(sessionEvent.getSessionId()).isEqualTo(expectedSessionId); return null; } - }).given(this.mockApplicationEventPublisher) - .publishEvent(isA(SessionDeletedEvent.class)); + }).given(this.mockApplicationEventPublisher).publishEvent(isA(SessionDeletedEvent.class)); this.sessionRepository.delete(expectedSessionId); verify(mockSession, times(1)).getId(); verify(this.mockTemplate, times(1)).remove(eq(expectedSessionId)); verify(this.mockApplicationEventPublisher, times(1)) - .publishEvent(isA(SessionDeletedEvent.class)); + .publishEvent(isA(SessionDeletedEvent.class)); } @Test @@ -448,32 +407,29 @@ public class GemFireOperationsSessionRepositoryTest { willAnswer(new Answer() { public Void answer(final InvocationOnMock invocation) throws Throwable { - ApplicationEvent applicationEvent = invocation.getArgumentAt(0, - ApplicationEvent.class); + ApplicationEvent applicationEvent = invocation.getArgumentAt(0, ApplicationEvent.class); assertThat(applicationEvent).isInstanceOf(SessionDeletedEvent.class); AbstractSessionEvent sessionEvent = (AbstractSessionEvent) applicationEvent; - assertThat(sessionEvent.getSource()).isSameAs( - GemFireOperationsSessionRepositoryTest.this.sessionRepository); + assertThat(sessionEvent.getSource()). + isSameAs(GemFireOperationsSessionRepositoryTest.this.sessionRepository); assertThat(sessionEvent.getSession()).isNull(); assertThat(sessionEvent.getSessionId()).isEqualTo(expectedSessionId); return null; } - }).given(this.mockApplicationEventPublisher) - .publishEvent(isA(SessionDeletedEvent.class)); + }).given(this.mockApplicationEventPublisher).publishEvent(isA(SessionDeletedEvent.class)); this.sessionRepository.delete(expectedSessionId); verify(this.mockTemplate, times(1)).remove(eq(expectedSessionId)); verify(this.mockApplicationEventPublisher, times(1)) - .publishEvent(isA(SessionDeletedEvent.class)); + .publishEvent(isA(SessionDeletedEvent.class)); } protected abstract class GemfireOperationsAccessor extends GemfireAccessor implements GemfireOperations { } - }