Upgrade to Spring Data Kay
Dependency updates supporting Kay: Upgrade Spring Framework to 5.0.0.M3 Upgrade Spring Boot to 1.5.0.RC1 Upgrade Jackson to 2.7.6 Upgrade Jedis to 2.9.0 Upgrade Lettuce to 5.0.0.Beta1 Upgrade Mockito to 2.5.4 Fixes #gh-677
This commit is contained in:
@@ -19,7 +19,11 @@ plugins {
|
||||
|
||||
group = 'org.springframework.session'
|
||||
|
||||
ext.springBootVersion = '1.5.0.BUILD-SNAPSHOT'
|
||||
ext.springBootVersion = '1.5.0.RC1'
|
||||
ext.springDataGemFireVersion = "${springDataVersion}"
|
||||
ext.springDataMongoVersion = "${springDataVersion}"
|
||||
ext.springDataRedisVersion = "${springDataVersion}"
|
||||
|
||||
ext.IDE_GRADLE = "$rootDir/gradle/ide.gradle"
|
||||
ext.JAVA_GRADLE = "$rootDir/gradle/java.gradle"
|
||||
ext.SPRING3_GRADLE = "$rootDir/gradle/spring3.gradle"
|
||||
|
||||
@@ -27,25 +27,24 @@ asciidoctorj {
|
||||
tasks.findByPath("artifactoryPublish")?.enabled = false
|
||||
|
||||
dependencies {
|
||||
testCompile project(':spring-session'),
|
||||
project(':spring-session-data-mongo'),
|
||||
"org.springframework.data:spring-data-gemfire:$springDataGemFireVersion",
|
||||
"org.springframework.data:spring-data-redis:$springDataRedisVersion",
|
||||
"org.springframework.data:spring-data-gemfire:$springDataGemFireVersion",
|
||||
"org.springframework:spring-webmvc:${springVersion}",
|
||||
"org.springframework:spring-websocket:${springVersion}",
|
||||
"org.springframework:spring-messaging:${springVersion}",
|
||||
"org.springframework:spring-jdbc:${springVersion}",
|
||||
"org.springframework.security:spring-security-config:${springSecurityVersion}",
|
||||
"org.springframework.security:spring-security-web:${springSecurityVersion}",
|
||||
"org.springframework.security:spring-security-test:${springSecurityVersion}",
|
||||
"junit:junit:$junitVersion",
|
||||
"org.mockito:mockito-core:$mockitoVersion",
|
||||
"org.springframework:spring-test:$springVersion",
|
||||
"org.assertj:assertj-core:$assertjVersion",
|
||||
"com.hazelcast:hazelcast:$hazelcastVersion",
|
||||
"biz.paluch.redis:lettuce:$lettuceVersion",
|
||||
"javax.servlet:javax.servlet-api:$servletApiVersion"
|
||||
testCompile project(':spring-session'),
|
||||
project(':spring-session-data-gemfire'),
|
||||
project(':spring-session-data-mongo'),
|
||||
project(':spring-session-data-redis'),
|
||||
"org.springframework:spring-jdbc:${springVersion}",
|
||||
"org.springframework:spring-messaging:${springVersion}",
|
||||
"org.springframework:spring-webmvc:${springVersion}",
|
||||
"org.springframework:spring-websocket:${springVersion}",
|
||||
"org.springframework.security:spring-security-config:${springSecurityVersion}",
|
||||
"org.springframework.security:spring-security-web:${springSecurityVersion}",
|
||||
"org.springframework.security:spring-security-test:${springSecurityVersion}",
|
||||
"junit:junit:$junitVersion",
|
||||
"org.mockito:mockito-core:$mockitoVersion",
|
||||
"org.springframework:spring-test:$springVersion",
|
||||
"org.assertj:assertj-core:$assertjVersion",
|
||||
"com.hazelcast:hazelcast:$hazelcastVersion",
|
||||
"biz.paluch.redis:lettuce:$lettuceVersion",
|
||||
"javax.servlet:javax.servlet-api:$servletApiVersion"
|
||||
}
|
||||
|
||||
asciidoctor {
|
||||
|
||||
@@ -25,17 +25,18 @@ import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.CacheClosedException;
|
||||
import com.gemstone.gemfire.cache.DataPolicy;
|
||||
import com.gemstone.gemfire.cache.ExpirationAction;
|
||||
import com.gemstone.gemfire.cache.ExpirationAttributes;
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.client.ClientCache;
|
||||
import com.gemstone.gemfire.cache.client.ClientCacheFactory;
|
||||
import com.gemstone.gemfire.cache.query.Index;
|
||||
import com.gemstone.gemfire.cache.server.CacheServer;
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.CacheClosedException;
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.ExpirationAction;
|
||||
import org.apache.geode.cache.ExpirationAttributes;
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
import org.apache.geode.cache.client.ClientCacheFactory;
|
||||
import org.apache.geode.cache.query.Index;
|
||||
import org.apache.geode.cache.server.CacheServer;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -55,34 +56,31 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @since 1.1.0
|
||||
* @see org.springframework.session.ExpiringSession
|
||||
* @see org.springframework.session.events.AbstractSessionEvent
|
||||
* @see com.gemstone.gemfire.cache.Cache
|
||||
* @see com.gemstone.gemfire.cache.DataPolicy
|
||||
* @see com.gemstone.gemfire.cache.ExpirationAttributes
|
||||
* @see com.gemstone.gemfire.cache.GemFireCache
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @see com.gemstone.gemfire.cache.client.ClientCache
|
||||
* @see com.gemstone.gemfire.cache.server.CacheServer
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.DataPolicy
|
||||
* @see org.apache.geode.cache.ExpirationAttributes
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
* @see org.apache.geode.cache.server.CacheServer
|
||||
*/
|
||||
public class AbstractGemFireIntegrationTests {
|
||||
public static final String GEMFIRE_LOG_LEVEL = System
|
||||
.getProperty("spring.session.data.gemfire.log-level", "warning");
|
||||
|
||||
public static final String GEMFIRE_LOG_LEVEL =
|
||||
System.getProperty("spring.session.data.gemfire.log-level", "warning");
|
||||
|
||||
protected static final boolean DEFAULT_ENABLE_QUERY_DEBUGGING = false;
|
||||
protected static final boolean GEMFIRE_QUERY_DEBUG = Boolean
|
||||
.getBoolean("spring.session.data.gemfire.query.debug");
|
||||
|
||||
protected static final int DEFAULT_GEMFIRE_SERVER_PORT = CacheServer.DEFAULT_PORT;
|
||||
protected static final boolean GEMFIRE_QUERY_DEBUG = Boolean.getBoolean("spring.session.data.gemfire.query.debug");
|
||||
|
||||
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";
|
||||
|
||||
protected static final String GEMFIRE_LOG_FILE_NAME = System
|
||||
.getProperty("spring.session.data.gemfire.log-file", "server.log");
|
||||
protected static final String GEMFIRE_LOG_FILE_NAME =
|
||||
System.getProperty("spring.session.data.gemfire.log-file", "gemfire-server.log");
|
||||
|
||||
@Autowired
|
||||
protected Cache gemfireCache;
|
||||
@@ -93,7 +91,7 @@ public class AbstractGemFireIntegrationTests {
|
||||
@Before
|
||||
public void setup() {
|
||||
System.setProperty("gemfire.Query.VERBOSE",
|
||||
String.valueOf(isQueryDebuggingEnabled()));
|
||||
String.valueOf(isQueryDebuggingEnabled()));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@@ -101,8 +99,7 @@ public class AbstractGemFireIntegrationTests {
|
||||
File directory = new File(WORKING_DIRECTORY, pathname);
|
||||
|
||||
assertThat(directory.isDirectory() || directory.mkdirs())
|
||||
.as(String.format("Failed to create directory (%1$s)", directory))
|
||||
.isTrue();
|
||||
.as(String.format("Failed to create directory (%1$s)", directory)).isTrue();
|
||||
|
||||
directory.deleteOnExit();
|
||||
|
||||
@@ -110,8 +107,7 @@ public class AbstractGemFireIntegrationTests {
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static List<String> createJavaProcessCommandLine(Class<?> type,
|
||||
String... args) {
|
||||
protected static List<String> createJavaProcessCommandLine(Class<?> type, String... args) {
|
||||
List<String> commandLine = new ArrayList<String>();
|
||||
|
||||
String javaHome = System.getProperty("java.home");
|
||||
@@ -122,8 +118,7 @@ public class AbstractGemFireIntegrationTests {
|
||||
commandLine.add("-ea");
|
||||
commandLine.add(String.format("-Dgemfire.log-file=%1$s", GEMFIRE_LOG_FILE_NAME));
|
||||
commandLine.add(String.format("-Dgemfire.log-level=%1$s", GEMFIRE_LOG_LEVEL));
|
||||
commandLine
|
||||
.add(String.format("-Dgemfire.Query.VERBOSE=%1$s", GEMFIRE_QUERY_DEBUG));
|
||||
commandLine.add(String.format("-Dgemfire.Query.VERBOSE=%1$s", GEMFIRE_QUERY_DEBUG));
|
||||
commandLine.addAll(extractJvmArguments(args));
|
||||
commandLine.add("-classpath");
|
||||
commandLine.add(System.getProperty("java.class.path"));
|
||||
@@ -136,7 +131,7 @@ public class AbstractGemFireIntegrationTests {
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static List<String> extractJvmArguments(final String... args) {
|
||||
protected static List<String> extractJvmArguments(String... args) {
|
||||
List<String> jvmArgs = new ArrayList<String>(args.length);
|
||||
|
||||
for (String arg : args) {
|
||||
@@ -149,7 +144,7 @@ public class AbstractGemFireIntegrationTests {
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static List<String> extractProgramArguments(final String... args) {
|
||||
protected static List<String> extractProgramArguments(String... args) {
|
||||
List<String> jvmArgs = new ArrayList<String>(args.length);
|
||||
|
||||
for (String arg : args) {
|
||||
@@ -162,10 +157,8 @@ public class AbstractGemFireIntegrationTests {
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static Process run(Class<?> type, File directory, String... args)
|
||||
throws IOException {
|
||||
return new ProcessBuilder().command(createJavaProcessCommandLine(type, args))
|
||||
.directory(directory).start();
|
||||
protected static Process run(Class<?> type, File directory, String... args) throws IOException {
|
||||
return new ProcessBuilder().command(createJavaProcessCommandLine(type, args)).directory(directory).start();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@@ -174,10 +167,8 @@ public class AbstractGemFireIntegrationTests {
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitForCacheServerToStart(CacheServer cacheServer,
|
||||
long duration) {
|
||||
return waitForCacheServerToStart(cacheServer.getBindAddress(),
|
||||
cacheServer.getPort(), duration);
|
||||
protected static boolean waitForCacheServerToStart(CacheServer cacheServer, long duration) {
|
||||
return waitForCacheServerToStart(cacheServer.getBindAddress(), cacheServer.getPort(), duration);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@@ -186,8 +177,7 @@ public class AbstractGemFireIntegrationTests {
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitForCacheServerToStart(final String host, final int port,
|
||||
long duration) {
|
||||
protected static boolean waitForCacheServerToStart(final String host, final int port, long duration) {
|
||||
return waitOnCondition(new Condition() {
|
||||
AtomicBoolean connected = new AtomicBoolean(false);
|
||||
|
||||
@@ -247,8 +237,7 @@ public class AbstractGemFireIntegrationTests {
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@SuppressWarnings("all")
|
||||
protected static boolean waitForProcessToStart(Process process, File directory,
|
||||
long duration) {
|
||||
protected static boolean waitForProcessToStart(Process process, File directory, long duration) {
|
||||
final File processControl = new File(directory, DEFAULT_PROCESS_CONTROL_FILENAME);
|
||||
|
||||
waitOnCondition(new Condition() {
|
||||
@@ -266,8 +255,7 @@ public class AbstractGemFireIntegrationTests {
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static int waitForProcessToStop(Process process, File directory,
|
||||
long duration) {
|
||||
protected static int waitForProcessToStop(Process process, File directory, long duration) {
|
||||
final long timeout = (System.currentTimeMillis() + duration);
|
||||
|
||||
try {
|
||||
@@ -322,35 +310,31 @@ public class AbstractGemFireIntegrationTests {
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected void assertRegion(Region<?, ?> actualRegion, String expectedName,
|
||||
DataPolicy expectedDataPolicy) {
|
||||
protected void assertRegion(Region<?, ?> actualRegion, String expectedName, DataPolicy expectedDataPolicy) {
|
||||
assertThat(actualRegion).isNotNull();
|
||||
assertThat(actualRegion.getName()).isEqualTo(expectedName);
|
||||
assertThat(actualRegion.getFullPath())
|
||||
.isEqualTo(GemFireUtils.toRegionPath(expectedName));
|
||||
assertThat(actualRegion.getFullPath()).isEqualTo(GemFireUtils.toRegionPath(expectedName));
|
||||
assertThat(actualRegion.getAttributes()).isNotNull();
|
||||
assertThat(actualRegion.getAttributes().getDataPolicy())
|
||||
.isEqualTo(expectedDataPolicy);
|
||||
.isEqualTo(expectedDataPolicy);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected void assertIndex(Index index, String expectedExpression,
|
||||
String expectedFromClause) {
|
||||
protected void assertIndex(Index index, String expectedExpression, String expectedFromClause) {
|
||||
assertThat(index).isNotNull();
|
||||
assertThat(index.getIndexedExpression()).isEqualTo(expectedExpression);
|
||||
assertThat(index.getFromClause()).isEqualTo(expectedFromClause);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected void assertEntryIdleTimeout(Region<?, ?> region,
|
||||
ExpirationAction expectedAction, int expectedTimeout) {
|
||||
assertEntryIdleTimeout(region.getAttributes().getEntryIdleTimeout(),
|
||||
expectedAction, expectedTimeout);
|
||||
protected void assertEntryIdleTimeout(Region<?, ?> region, ExpirationAction expectedAction, int expectedTimeout) {
|
||||
assertEntryIdleTimeout(region.getAttributes().getEntryIdleTimeout(), expectedAction, expectedTimeout);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected void assertEntryIdleTimeout(ExpirationAttributes actualExpirationAttributes,
|
||||
ExpirationAction expectedAction, int expectedTimeout) {
|
||||
ExpirationAction expectedAction, int expectedTimeout) {
|
||||
|
||||
assertThat(actualExpirationAttributes).isNotNull();
|
||||
assertThat(actualExpirationAttributes.getAction()).isEqualTo(expectedAction);
|
||||
assertThat(actualExpirationAttributes.getTimeout()).isEqualTo(expectedTimeout);
|
||||
@@ -426,8 +410,7 @@ public class AbstractGemFireIntegrationTests {
|
||||
* @see org.springframework.context.ApplicationListener
|
||||
* @see org.springframework.session.events.AbstractSessionEvent
|
||||
*/
|
||||
public static class SessionEventListener
|
||||
implements ApplicationListener<AbstractSessionEvent> {
|
||||
public static class SessionEventListener implements ApplicationListener<AbstractSessionEvent> {
|
||||
|
||||
private volatile AbstractSessionEvent sessionEvent;
|
||||
|
||||
@@ -463,5 +446,4 @@ public class AbstractGemFireIntegrationTests {
|
||||
protected interface Condition {
|
||||
boolean evaluate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
bootstrapVersion=2.3.2
|
||||
commonsPoolVersion=2.4.2
|
||||
jacksonVersion=2.6.5
|
||||
jspApiVersion=2.0
|
||||
servletApiVersion=3.0.1
|
||||
jstlelVersion=1.2.5
|
||||
version=2.0.0.BUILD-SNAPSHOT
|
||||
springDataRedisVersion=1.7.1.RELEASE
|
||||
html5ShivVersion=3.7.3
|
||||
commonsLoggingVersion=1.2
|
||||
junitVersion=4.12
|
||||
lettuceVersion=3.5.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
|
||||
springVersion=4.3.4.RELEASE
|
||||
httpClientVersion=4.5.1
|
||||
jedisVersion=2.8.1
|
||||
h2Version=1.4.192
|
||||
springDataMongoVersion=1.9.4.RELEASE
|
||||
springShellVersion=1.1.0.RELEASE
|
||||
springDataGemFireVersion=1.8.5.RELEASE
|
||||
assertjVersion=2.5.0
|
||||
spockVersion=1.0-groovy-2.4
|
||||
webjarsTaglibVersion=0.3
|
||||
bootstrapVersion=2.3.2
|
||||
commonsLoggingVersion=1.2
|
||||
commonsPoolVersion=2.4.2
|
||||
h2Version=1.4.192
|
||||
hazelcastVersion=3.6.5
|
||||
html5ShivVersion=3.7.3
|
||||
httpClientVersion=4.5.1
|
||||
jacksonVersion=2.7.6
|
||||
jedisVersion=2.9.0
|
||||
jspApiVersion=2.0
|
||||
jstlVersion=1.2.1
|
||||
groovyVersion=2.4.4
|
||||
jstlelVersion=1.2.5
|
||||
junitVersion=4.12
|
||||
lettuceVersion=5.0.0.Beta1
|
||||
lombokVersion=1.16.10
|
||||
mockitoVersion=2.5.4
|
||||
reactorVersion=3.0.3.RELEASE
|
||||
seleniumVersion=2.52.0
|
||||
servletApiVersion=3.0.1
|
||||
springVersion=5.0.0.M3
|
||||
springDataVersion=2.0.0.M1
|
||||
springDataReleaseTrainVersion=Kay-M1
|
||||
springSecurityVersion=4.2.1.RELEASE
|
||||
springShellVersion=1.1.0.RELEASE
|
||||
webjarsTaglibVersion=0.3
|
||||
version=2.0.0.BUILD-SNAPSHOT
|
||||
|
||||
@@ -16,18 +16,6 @@ targetCompatibility = 1.5
|
||||
|
||||
ext.springIoVersion = project.hasProperty('platformVersion') ? platformVersion : 'Cairo-BUILD-SNAPSHOT'
|
||||
|
||||
ext.spockDependencies = [
|
||||
dependencies.create("org.spockframework:spock-core:$spockVersion") {
|
||||
exclude group: 'junit', module: 'junit-dep'
|
||||
}
|
||||
]
|
||||
|
||||
ext.gebDependencies = spockDependencies + [
|
||||
"org.seleniumhq.selenium:selenium-htmlunit-driver:$seleniumVersion",
|
||||
"org.gebish:geb-spock:$gebVersion",
|
||||
"org.codehaus.groovy:groovy:$groovyVersion"
|
||||
]
|
||||
|
||||
ext.seleniumDependencies = [
|
||||
"org.seleniumhq.selenium:selenium-htmlunit-driver:$seleniumVersion",
|
||||
"org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
|
||||
|
||||
@@ -7,7 +7,24 @@ configurations.spring3TestRuntime {
|
||||
if (details.requested.group == 'org.springframework'
|
||||
&& details.requested.name != 'spring-websocket'
|
||||
&& details.requested.name != 'spring-messaging') {
|
||||
details.useVersion '3.2.14.RELEASE'
|
||||
details.useVersion '3.2.18.RELEASE'
|
||||
}
|
||||
if (details.requested.group == 'org.springframework.data') {
|
||||
if (details.requested.name == 'spring-data-commons') {
|
||||
details.useVersion '1.12.1.RELEASE'
|
||||
}
|
||||
if (details.requested.name == 'spring-data-gemfire') {
|
||||
details.useVersion '1.8.1.RELEASE'
|
||||
}
|
||||
if (details.requested.name == 'spring-data-keyvalue') {
|
||||
details.useVersion '1.1.1.RELEASE'
|
||||
}
|
||||
if (details.requested.name == 'spring-data-mongodb') {
|
||||
details.useVersion '1.9.1.RELEASE'
|
||||
}
|
||||
if (details.requested.name == 'spring-data-redis') {
|
||||
details.useVersion '1.7.1.RELEASE'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,4 +38,5 @@ task spring3Test(type: Test) {
|
||||
junitXml.destination = project.file("$buildDir/reports/spring3-tests/")
|
||||
}
|
||||
}
|
||||
check.dependsOn spring3Test
|
||||
|
||||
check.dependsOn spring3Test
|
||||
|
||||
@@ -19,19 +19,22 @@ sonarqube {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':spring-session-data-gemfire'),
|
||||
compile "org.springframework.data:spring-data-gemfire:$springDataGemFireVersion",
|
||||
project(":spring-session"),
|
||||
// project(':spring-session-data-gemfire'),
|
||||
"org.springframework.boot:spring-boot-starter-thymeleaf",
|
||||
"org.springframework.boot:spring-boot-starter-web",
|
||||
"org.webjars:bootstrap:$bootstrapVersion",
|
||||
"org.webjars:webjars-locator"
|
||||
|
||||
runtime "org.springframework.shell:spring-shell:1.0.0.RELEASE"
|
||||
runtime "org.springframework.shell:spring-shell:1.1.0.RELEASE"
|
||||
|
||||
testCompile "org.springframework.boot:spring-boot-starter-test"
|
||||
testCompile "org.springframework.boot:spring-boot-starter-test",
|
||||
"org.projectlombok:lombok:$lombokVersion"
|
||||
|
||||
integrationTestCompile seleniumDependencies
|
||||
|
||||
integrationTestRuntime "org.springframework.shell:spring-shell:1.0.0.RELEASE"
|
||||
integrationTestRuntime "org.springframework.shell:spring-shell:1.1.0.RELEASE"
|
||||
}
|
||||
|
||||
run {
|
||||
@@ -53,7 +56,8 @@ task runGemFireServer() << {
|
||||
|
||||
String[] commandLine = ['java', '-server', '-ea', '-classpath', classpath,
|
||||
"-Dgemfire.cache.server.port=$port",
|
||||
"-Dgemfire.log-level=" + System.getProperty('gemfire.log.level', 'warning'),
|
||||
//"-Dgemfire.log-file=gemfire-server.log",
|
||||
"-Dgemfire.log-level=" + System.getProperty('gemfire.log.level', 'config'),
|
||||
'sample.server.GemFireServer']
|
||||
|
||||
//println commandLine
|
||||
|
||||
@@ -26,10 +26,8 @@ import sample.pages.HomePage;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootContextLoader;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.htmlunit.webdriver.MockMvcHtmlUnitDriverBuilder;
|
||||
@@ -40,9 +38,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Eddú Meléndez
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.MOCK)
|
||||
@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.MOCK)
|
||||
@AutoConfigureMockMvc
|
||||
@ContextConfiguration(classes = Application.class, loader = SpringBootContextLoader.class)
|
||||
public class AttributeTests {
|
||||
|
||||
@Autowired
|
||||
@@ -52,9 +49,7 @@ public class AttributeTests {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.driver = MockMvcHtmlUnitDriverBuilder
|
||||
.mockMvcSetup(this.mockMvc)
|
||||
.build();
|
||||
this.driver = MockMvcHtmlUnitDriverBuilder.mockMvcSetup(this.mockMvc).build();
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -78,5 +73,4 @@ public class AttributeTests {
|
||||
assertThat(home.row(1).getAttributeName()).isEqualTo("a");
|
||||
assertThat(home.row(1).getAttributeValue()).isEqualTo("b");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.gemstone.gemfire.cache.client.Pool;
|
||||
import com.gemstone.gemfire.management.membership.ClientMembership;
|
||||
import com.gemstone.gemfire.management.membership.ClientMembershipEvent;
|
||||
import com.gemstone.gemfire.management.membership.ClientMembershipListenerAdapter;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.management.membership.ClientMembership;
|
||||
import org.apache.geode.management.membership.ClientMembershipEvent;
|
||||
import org.apache.geode.management.membership.ClientMembershipListenerAdapter;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -40,10 +40,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.data.gemfire.client.ClientCacheFactoryBean;
|
||||
import org.springframework.data.gemfire.client.PoolFactoryBean;
|
||||
import org.springframework.data.gemfire.support.ConnectionEndpoint;
|
||||
import org.springframework.data.gemfire.util.CollectionUtils;
|
||||
import org.springframework.session.data.gemfire.config.annotation.web.http.EnableGemFireHttpSession;
|
||||
import org.springframework.session.data.gemfire.config.annotation.web.http.GemFireHttpSessionConfiguration;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -63,20 +63,21 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
* @see org.springframework.context.annotation.Bean
|
||||
* @see org.springframework.session.data.gemfire.config.annotation.web.http.EnableGemFireHttpSession
|
||||
* @see org.springframework.stereotype.Controller
|
||||
* @see com.gemstone.gemfire.cache.client.ClientCache
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
* @see org.apache.geode.cache.client.Pool
|
||||
* @since 1.2.1
|
||||
*/
|
||||
// tag::class[]
|
||||
@SpringBootApplication
|
||||
@EnableGemFireHttpSession // <1>
|
||||
@EnableGemFireHttpSession(poolName = "DEFAULT")// <1>
|
||||
@Controller
|
||||
public class Application {
|
||||
|
||||
static final long DEFAULT_WAIT_DURATION = TimeUnit.SECONDS.toMillis(60);
|
||||
static final long DEFAULT_TIMEOUT = TimeUnit.SECONDS.toMillis(60);
|
||||
|
||||
static final CountDownLatch latch = new CountDownLatch(1);
|
||||
static final CountDownLatch LATCH = new CountDownLatch(1);
|
||||
|
||||
static final String DEFAULT_GEMFIRE_LOG_LEVEL = "warning";
|
||||
static final String DEFAULT_GEMFIRE_LOG_LEVEL = "config";
|
||||
static final String INDEX_TEMPLATE_VIEW_NAME = "index";
|
||||
static final String PING_RESPONSE = "PONG";
|
||||
static final String REQUEST_COUNT_ATTRIBUTE_NAME = "requestCount";
|
||||
@@ -94,14 +95,14 @@ public class Application {
|
||||
Properties gemfireProperties = new Properties();
|
||||
|
||||
gemfireProperties.setProperty("name", applicationName());
|
||||
//gemfireProperties.setProperty("log-file", "gemfire-client.log");
|
||||
gemfireProperties.setProperty("log-level", logLevel());
|
||||
|
||||
return gemfireProperties;
|
||||
}
|
||||
|
||||
String applicationName() {
|
||||
return "samples:httpsession-gemfire-boot:"
|
||||
.concat(getClass().getSimpleName());
|
||||
return "samples:httpsession-gemfire-boot:".concat(getClass().getSimpleName());
|
||||
}
|
||||
|
||||
String logLevel() {
|
||||
@@ -109,37 +110,46 @@ public class Application {
|
||||
}
|
||||
|
||||
@Bean
|
||||
ClientCacheFactoryBean gemfireCache() { // <3>
|
||||
ClientCacheFactoryBean gemfireCache(
|
||||
@Value("${gemfire.cache.server.host:localhost}") String host,
|
||||
@Value("${gemfire.cache.server.port:12480}") int port) { // <3>
|
||||
|
||||
ClientCacheFactoryBean gemfireCache = new ClientCacheFactoryBean();
|
||||
|
||||
gemfireCache.setClose(true);
|
||||
gemfireCache.setProperties(gemfireProperties());
|
||||
|
||||
// GemFire Pool settings <4>
|
||||
gemfireCache.setKeepAlive(false);
|
||||
gemfireCache.setPingInterval(TimeUnit.SECONDS.toMillis(5));
|
||||
gemfireCache.setReadTimeout(intValue(TimeUnit.SECONDS.toMillis(15)));
|
||||
gemfireCache.setRetryAttempts(1);
|
||||
gemfireCache.setSubscriptionEnabled(true);
|
||||
gemfireCache.setThreadLocalConnections(false);
|
||||
gemfireCache.setServers(Collections.singletonList(newConnectionEndpoint(host, port)));
|
||||
|
||||
registerClientMembershipListener(); // <5>
|
||||
|
||||
return gemfireCache;
|
||||
}
|
||||
|
||||
@Bean
|
||||
PoolFactoryBean gemfirePool(
|
||||
@Value("${gemfire.cache.server.host:localhost}") String host,
|
||||
@Value("${gemfire.cache.server.port:12480}") int port) { // <4>
|
||||
|
||||
PoolFactoryBean gemfirePool = new PoolFactoryBean();
|
||||
|
||||
gemfirePool.setKeepAlive(false);
|
||||
gemfirePool.setPingInterval(TimeUnit.SECONDS.toMillis(5));
|
||||
gemfirePool.setReadTimeout(Long.valueOf(TimeUnit.SECONDS.toMillis(15)).intValue());
|
||||
gemfirePool.setRetryAttempts(1);
|
||||
gemfirePool.setSubscriptionEnabled(true);
|
||||
gemfirePool.setThreadLocalConnections(false);
|
||||
gemfirePool.setServers(Collections.singleton(newConnectionEndpoint(host, port)));
|
||||
|
||||
return gemfirePool;
|
||||
int intValue(Number number) {
|
||||
return number.intValue();
|
||||
}
|
||||
|
||||
ConnectionEndpoint newConnectionEndpoint(String host, int port) {
|
||||
return new ConnectionEndpoint(host, port);
|
||||
}
|
||||
|
||||
void registerClientMembershipListener() {
|
||||
ClientMembership.registerClientMembershipListener(new ClientMembershipListenerAdapter() {
|
||||
@Override
|
||||
public void memberJoined(ClientMembershipEvent event) {
|
||||
LATCH.countDown();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Bean
|
||||
BeanPostProcessor gemfireCacheServerReadyBeanPostProcessor(
|
||||
@Value("${gemfire.cache.server.host:localhost}") final String host,
|
||||
@@ -147,30 +157,15 @@ public class Application {
|
||||
|
||||
return new BeanPostProcessor() {
|
||||
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName)
|
||||
throws BeansException {
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (GemFireHttpSessionConfiguration.DEFAULT_SPRING_SESSION_GEMFIRE_REGION_NAME.equals(beanName)
|
||||
|| bean instanceof Region) {
|
||||
|
||||
if ("gemfirePool".equals(beanName)) {
|
||||
ClientMembership.registerClientMembershipListener(
|
||||
new ClientMembershipListenerAdapter() {
|
||||
@Override
|
||||
public void memberJoined(ClientMembershipEvent event) {
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName)
|
||||
throws BeansException {
|
||||
|
||||
if (bean instanceof Pool && "gemfirePool".equals(beanName)) {
|
||||
try {
|
||||
Assert.state(latch.await(DEFAULT_WAIT_DURATION, TimeUnit.MILLISECONDS),
|
||||
String.format("GemFire Cache Server failed to start on host [%1$s] and port [%2$d]",
|
||||
host, port));
|
||||
boolean didNotTimeout = LATCH.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
|
||||
|
||||
Assert.state(didNotTimeout, String.format(
|
||||
"GemFire Cache Server failed to start on host [%s] and port [%d]", host, port));
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
@@ -179,6 +174,10 @@ public class Application {
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -198,8 +197,7 @@ public class Application {
|
||||
@RequestParam(name = "attributeName", required = false) String name,
|
||||
@RequestParam(name = "attributeValue", required = false) String value) { // <8>
|
||||
|
||||
modelMap.addAttribute("sessionAttributes",
|
||||
attributes(setAttribute(updateRequestCount(session), name, value)));
|
||||
modelMap.addAttribute("sessionAttributes", attributes(setAttribute(updateRequestCount(session), name, value)));
|
||||
|
||||
return INDEX_TEMPLATE_VIEW_NAME;
|
||||
}
|
||||
@@ -250,8 +248,7 @@ public class Application {
|
||||
Map<String, String> sessionAttributes = new HashMap<String, String>();
|
||||
|
||||
for (String attributeName : toIterable(session.getAttributeNames())) {
|
||||
sessionAttributes.put(attributeName,
|
||||
String.valueOf(session.getAttribute(attributeName)));
|
||||
sessionAttributes.put(attributeName, String.valueOf(session.getAttribute(attributeName)));
|
||||
}
|
||||
|
||||
return sessionAttributes;
|
||||
|
||||
@@ -19,7 +19,7 @@ package sample.server;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import org.apache.geode.cache.Cache;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@@ -37,9 +37,8 @@ import org.springframework.session.data.gemfire.config.annotation.web.http.Enabl
|
||||
* @see org.springframework.boot.SpringApplication
|
||||
* @see org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
* @see org.springframework.context.annotation.Bean
|
||||
* @see org.springframework.session.data.gemfire.config.annotation.web.http.
|
||||
* EnableGemFireHttpSession
|
||||
* @see com.gemstone.gemfire.cache.Cache
|
||||
* @see org.springframework.session.data.gemfire.config.annotation.web.http.EnableGemFireHttpSession
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @since 1.2.1
|
||||
*/
|
||||
// tag::class[]
|
||||
@@ -47,7 +46,7 @@ import org.springframework.session.data.gemfire.config.annotation.web.http.Enabl
|
||||
@EnableGemFireHttpSession(maxInactiveIntervalInSeconds = 20) // <1>
|
||||
public class GemFireServer {
|
||||
|
||||
static final String DEFAULT_GEMFIRE_LOG_LEVEL = "warning";
|
||||
static final String DEFAULT_GEMFIRE_LOG_LEVEL = "config";
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication springApplication = new SpringApplication(GemFireServer.class);
|
||||
@@ -65,6 +64,7 @@ public class GemFireServer {
|
||||
|
||||
gemfireProperties.setProperty("name", applicationName());
|
||||
gemfireProperties.setProperty("mcast-port", "0");
|
||||
//gemfireProperties.setProperty("log-file", "gemfire-server.log");
|
||||
gemfireProperties.setProperty("log-level", logLevel());
|
||||
//gemfireProperties.setProperty("jmx-manager", "true");
|
||||
//gemfireProperties.setProperty("jmx-manager-start", "true");
|
||||
@@ -102,8 +102,7 @@ public class GemFireServer {
|
||||
gemfireCacheServer.setBindAddress(bindAddress);
|
||||
gemfireCacheServer.setCache(gemfireCache);
|
||||
gemfireCacheServer.setHostNameForClients(hostnameForClients);
|
||||
gemfireCacheServer.setMaxTimeBetweenPings(
|
||||
Long.valueOf(TimeUnit.SECONDS.toMillis(60)).intValue());
|
||||
gemfireCacheServer.setMaxTimeBetweenPings(Long.valueOf(TimeUnit.SECONDS.toMillis(60)).intValue());
|
||||
gemfireCacheServer.setPort(port);
|
||||
|
||||
return gemfireCacheServer;
|
||||
|
||||
@@ -17,14 +17,15 @@ dependencies {
|
||||
|
||||
providedCompile "javax.servlet:javax.servlet-api:$servletApiVersion"
|
||||
|
||||
runtime "org.springframework.shell:spring-shell:1.0.0.RELEASE"
|
||||
runtime "org.springframework.shell:spring-shell:1.1.0.RELEASE"
|
||||
|
||||
testCompile "junit:junit:$junitVersion",
|
||||
"org.assertj:assertj-core:$assertjVersion"
|
||||
"org.assertj:assertj-core:$assertjVersion",
|
||||
"org.projectlombok:lombok:$lombokVersion"
|
||||
|
||||
integrationTestCompile seleniumDependencies
|
||||
|
||||
integrationTestRuntime "org.springframework.shell:spring-shell:1.0.0.RELEASE"
|
||||
integrationTestRuntime "org.springframework.shell:spring-shell:1.1.0.RELEASE"
|
||||
}
|
||||
|
||||
mainClassName = 'sample.Application'
|
||||
|
||||
@@ -19,10 +19,10 @@ package sample;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.gemstone.gemfire.cache.client.Pool;
|
||||
import com.gemstone.gemfire.management.membership.ClientMembership;
|
||||
import com.gemstone.gemfire.management.membership.ClientMembershipEvent;
|
||||
import com.gemstone.gemfire.management.membership.ClientMembershipListenerAdapter;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.management.membership.ClientMembership;
|
||||
import org.apache.geode.management.membership.ClientMembershipEvent;
|
||||
import org.apache.geode.management.membership.ClientMembershipListenerAdapter;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -31,9 +31,9 @@ import org.springframework.util.Assert;
|
||||
|
||||
public class GemFireCacheServerReadyBeanPostProcessor implements BeanPostProcessor {
|
||||
|
||||
static final long DEFAULT_WAIT_DURATION = TimeUnit.SECONDS.toMillis(20);
|
||||
static final long DEFAULT_TIMEOUT = TimeUnit.SECONDS.toMillis(60);
|
||||
|
||||
static final CountDownLatch latch = new CountDownLatch(1);
|
||||
static final CountDownLatch LATCH = new CountDownLatch(1);
|
||||
|
||||
@Value("${spring.session.data.gemfire.port:${application.gemfire.client-server.port}}")
|
||||
int port;
|
||||
@@ -42,27 +42,21 @@ public class GemFireCacheServerReadyBeanPostProcessor implements BeanPostProcess
|
||||
String host;
|
||||
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if ("gemfirePool".equals(beanName)) {
|
||||
if ("gemfireCache".equals(beanName)) {
|
||||
ClientMembership.registerClientMembershipListener(
|
||||
new ClientMembershipListenerAdapter() {
|
||||
@Override
|
||||
public void memberJoined(ClientMembershipEvent event) {
|
||||
latch.countDown();
|
||||
LATCH.countDown();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName)
|
||||
throws BeansException {
|
||||
|
||||
if (bean instanceof Pool && "gemfirePool".equals(beanName)) {
|
||||
else if (bean instanceof Region) {
|
||||
try {
|
||||
Assert.state(latch.await(DEFAULT_WAIT_DURATION, TimeUnit.MILLISECONDS),
|
||||
String.format("GemFire Cache Server failed to start on host [%1$s] and port [%2$d]",
|
||||
this.host, this.port));
|
||||
boolean didNotTimeout = LATCH.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
|
||||
|
||||
Assert.state(didNotTimeout, String.format(
|
||||
"GemFire Cache Server failed to start on host [%s] and port [%d]", this.host, this.port));
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
@@ -71,5 +65,9 @@ public class GemFireCacheServerReadyBeanPostProcessor implements BeanPostProcess
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
// tag::end[]
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<!--6-->
|
||||
<gfe:pool keep-alive="false"
|
||||
ping-interval="5000"
|
||||
read-timeout="5000"
|
||||
read-timeout="15000"
|
||||
retry-attempts="1"
|
||||
subscription-enabled="true"
|
||||
thread-local-connections="false">
|
||||
|
||||
@@ -12,14 +12,15 @@ dependencies {
|
||||
|
||||
providedCompile "javax.servlet:javax.servlet-api:$servletApiVersion"
|
||||
|
||||
runtime "org.springframework.shell:spring-shell:1.0.0.RELEASE"
|
||||
runtime "org.springframework.shell:spring-shell:1.1.0.RELEASE"
|
||||
|
||||
testCompile "junit:junit:$junitVersion",
|
||||
"org.assertj:assertj-core:$assertjVersion"
|
||||
"org.assertj:assertj-core:$assertjVersion",
|
||||
"org.projectlombok:lombok:$lombokVersion"
|
||||
|
||||
integrationTestCompile seleniumDependencies
|
||||
|
||||
integrationTestRuntime "org.springframework.shell:spring-shell:1.0.0.RELEASE"
|
||||
integrationTestRuntime "org.springframework.shell:spring-shell:1.1.0.RELEASE"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@ import java.util.Properties;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.gemstone.gemfire.cache.client.Pool;
|
||||
import com.gemstone.gemfire.management.membership.ClientMembership;
|
||||
import com.gemstone.gemfire.management.membership.ClientMembershipEvent;
|
||||
import com.gemstone.gemfire.management.membership.ClientMembershipListenerAdapter;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.management.membership.ClientMembership;
|
||||
import org.apache.geode.management.membership.ClientMembershipEvent;
|
||||
import org.apache.geode.management.membership.ClientMembershipListenerAdapter;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -40,14 +40,14 @@ import org.springframework.util.Assert;
|
||||
@EnableGemFireHttpSession(maxInactiveIntervalInSeconds = 30, poolName = "DEFAULT") // <1>
|
||||
public class ClientConfig {
|
||||
|
||||
static final long DEFAULT_WAIT_DURATION = TimeUnit.SECONDS.toMillis(20);
|
||||
static final long DEFAULT_TIMEOUT = TimeUnit.SECONDS.toMillis(60);
|
||||
|
||||
static final CountDownLatch latch = new CountDownLatch(1);
|
||||
static final CountDownLatch LATCH = new CountDownLatch(1);
|
||||
|
||||
static final String DEFAULT_GEMFIRE_LOG_LEVEL = "warning";
|
||||
|
||||
@Bean
|
||||
static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
|
||||
static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
|
||||
return new PropertySourcesPlaceholderConfigurer();
|
||||
}
|
||||
|
||||
@@ -59,17 +59,16 @@ public class ClientConfig {
|
||||
}
|
||||
|
||||
String applicationName() {
|
||||
return "samples:httpsession-gemfire-clientserver:"
|
||||
.concat(getClass().getSimpleName());
|
||||
return "samples:httpsession-gemfire-clientserver:".concat(getClass().getSimpleName());
|
||||
}
|
||||
|
||||
String logLevel() {
|
||||
return System.getProperty("sample.httpsession.gemfire.log-level",
|
||||
DEFAULT_GEMFIRE_LOG_LEVEL);
|
||||
return System.getProperty("sample.httpsession.gemfire.log-level", DEFAULT_GEMFIRE_LOG_LEVEL);
|
||||
}
|
||||
|
||||
@Bean
|
||||
ClientCacheFactoryBean gemfireCache(
|
||||
@Value("${spring.session.data.gemfire.host:" + ServerConfig.SERVER_HOST + "}") String host,
|
||||
@Value("${spring.session.data.gemfire.port:" + ServerConfig.SERVER_PORT + "}") int port) { // <3>
|
||||
|
||||
ClientCacheFactoryBean clientCacheFactory = new ClientCacheFactoryBean();
|
||||
@@ -80,49 +79,49 @@ public class ClientConfig {
|
||||
// GemFire Pool settings <4>
|
||||
clientCacheFactory.setKeepAlive(false);
|
||||
clientCacheFactory.setPingInterval(TimeUnit.SECONDS.toMillis(5));
|
||||
clientCacheFactory.setReadTimeout(2000); // 2 seconds
|
||||
clientCacheFactory.setReadTimeout(intValue(TimeUnit.SECONDS.toMillis(15)));
|
||||
clientCacheFactory.setRetryAttempts(1);
|
||||
clientCacheFactory.setSubscriptionEnabled(true);
|
||||
clientCacheFactory.setThreadLocalConnections(false);
|
||||
clientCacheFactory.setServers(Collections.singletonList(newConnectionEndpoint(host, port)));
|
||||
|
||||
clientCacheFactory.setServers(Collections.singletonList(
|
||||
newConnectionEndpoint(ServerConfig.SERVER_HOST, port)));
|
||||
registerClientMembershipListener(); // <5>
|
||||
|
||||
return clientCacheFactory;
|
||||
}
|
||||
|
||||
int intValue(Number number) {
|
||||
return number.intValue();
|
||||
}
|
||||
|
||||
ConnectionEndpoint newConnectionEndpoint(String host, int port) {
|
||||
return new ConnectionEndpoint(host, port);
|
||||
}
|
||||
|
||||
void registerClientMembershipListener() {
|
||||
ClientMembership.registerClientMembershipListener(
|
||||
new ClientMembershipListenerAdapter() {
|
||||
@Override
|
||||
public void memberJoined(ClientMembershipEvent event) {
|
||||
LATCH.countDown();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Bean
|
||||
BeanPostProcessor gemfireCacheServerReadyBeanPostProcessor() { // <5>
|
||||
BeanPostProcessor gemfireCacheServerReadyBeanPostProcessor(
|
||||
@Value("${spring.session.data.gemfire.host:" + ServerConfig.SERVER_HOST + "}") final String host,
|
||||
@Value("${spring.session.data.gemfire.port:" + ServerConfig.SERVER_PORT + "}") final int port) { // <5>
|
||||
|
||||
return new BeanPostProcessor() {
|
||||
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName)
|
||||
throws BeansException {
|
||||
|
||||
if ("gemfirePool".equals(beanName)) {
|
||||
ClientMembership.registerClientMembershipListener(
|
||||
new ClientMembershipListenerAdapter() {
|
||||
@Override
|
||||
public void memberJoined(ClientMembershipEvent event) {
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName)
|
||||
throws BeansException {
|
||||
|
||||
if (bean instanceof Pool && "gemfirePool".equals(beanName)) {
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof Region) {
|
||||
try {
|
||||
Assert.state(latch.await(DEFAULT_WAIT_DURATION, TimeUnit.MILLISECONDS),
|
||||
String.format("GemFire Cache Server failed to start on host [%1$s] and port [%2$d]",
|
||||
ServerConfig.SERVER_HOST, ServerConfig.SERVER_PORT));
|
||||
boolean didNotTimeout = LATCH.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
|
||||
|
||||
Assert.state(didNotTimeout, String.format(
|
||||
"GemFire Cache Server failed to start on host [%s] and port [%d]", host, port));
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
@@ -131,6 +130,10 @@ public class ClientConfig {
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
};
|
||||
}
|
||||
// end::class[]
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import org.apache.geode.cache.Cache;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
@@ -14,7 +14,8 @@ dependencies {
|
||||
testCompile "junit:junit:$junitVersion"
|
||||
|
||||
integrationTestCompile seleniumDependencies,
|
||||
"org.assertj:assertj-core:$assertjVersion"
|
||||
"org.assertj:assertj-core:$assertjVersion",
|
||||
"org.projectlombok:lombok:$lombokVersion"
|
||||
|
||||
integrationTestRuntime "org.springframework.shell:spring-shell:1.0.0.RELEASE"
|
||||
integrationTestRuntime "org.springframework.shell:spring-shell:1.1.0.RELEASE"
|
||||
}
|
||||
|
||||
@@ -11,10 +11,11 @@ dependencies {
|
||||
|
||||
providedCompile "javax.servlet:javax.servlet-api:$servletApiVersion"
|
||||
|
||||
testCompile "junit:junit:$junitVersion"
|
||||
testCompile "junit:junit:$junitVersion",
|
||||
"org.projectlombok:lombok:$lombokVersion"
|
||||
|
||||
integrationTestCompile seleniumDependencies,
|
||||
"org.assertj:assertj-core:$assertjVersion"
|
||||
"org.assertj:assertj-core:$assertjVersion"
|
||||
|
||||
integrationTestRuntime "org.springframework.shell:spring-shell:1.0.0.RELEASE"
|
||||
integrationTestRuntime "org.springframework.shell:spring-shell:1.1.0.RELEASE"
|
||||
}
|
||||
|
||||
@@ -20,16 +20,17 @@ ext {
|
||||
assertjVersion = "2.4.0"
|
||||
}
|
||||
|
||||
ext['reactor.version'] = reactorVersion
|
||||
ext['spring-security.version'] = springSecurityVersion
|
||||
|
||||
dependencies {
|
||||
compile project(':spring-session'),
|
||||
"org.springframework.boot:spring-boot-starter-data-redis",
|
||||
"org.springframework.data:spring-data-redis:$springDataRedisVersion",
|
||||
"biz.paluch.redis:lettuce:$lettuceVersion",
|
||||
"org.springframework.boot:spring-boot-starter-web",
|
||||
"org.springframework.boot:spring-boot-starter-thymeleaf",
|
||||
"org.springframework.boot:spring-boot-starter-security",
|
||||
"nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect",
|
||||
"biz.paluch.redis:lettuce:$lettuceVersion",
|
||||
"org.apache.httpcomponents:httpclient"
|
||||
|
||||
testCompile "org.springframework.boot:spring-boot-starter-test",
|
||||
@@ -62,4 +63,4 @@ def reservePort() {
|
||||
def result = socket.localPort
|
||||
socket.close()
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author jitendra on 8/3/16.
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class RedisSerializerTest {
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ group = 'samples'
|
||||
|
||||
dependencies {
|
||||
compile project(':spring-session'),
|
||||
"org.springframework.boot:spring-boot-starter-data-mongodb",
|
||||
"org.springframework.data:spring-data-mongodb:$springDataMongoVersion",
|
||||
"org.springframework.boot:spring-boot-starter-web",
|
||||
"org.springframework.boot:spring-boot-starter-security",
|
||||
"org.springframework.boot:spring-boot-starter-thymeleaf",
|
||||
|
||||
@@ -16,16 +16,17 @@ apply from: SAMPLE_GRADLE
|
||||
|
||||
group = 'samples'
|
||||
|
||||
ext['reactor.version'] = reactorVersion
|
||||
|
||||
dependencies {
|
||||
compile(project(':spring-session-data-redis')) {
|
||||
exclude module: 'jedis'
|
||||
}
|
||||
compile "org.springframework.boot:spring-boot-starter-web",
|
||||
"org.springframework.boot:spring-boot-starter-data-jpa",
|
||||
compile "org.springframework.boot:spring-boot-starter-data-jpa",
|
||||
"org.springframework.boot:spring-boot-starter-thymeleaf",
|
||||
"org.springframework.boot:spring-boot-starter-web",
|
||||
"org.springframework.boot:spring-boot-starter-websocket",
|
||||
"org.springframework:spring-websocket:${springVersion}",
|
||||
"org.springframework.data:spring-data-jpa",
|
||||
"nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect",
|
||||
"org.thymeleaf.extras:thymeleaf-extras-conditionalcomments",
|
||||
"biz.paluch.redis:lettuce:$lettuceVersion",
|
||||
|
||||
@@ -27,9 +27,8 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
import org.springframework.web.socket.TextMessage;
|
||||
import org.springframework.web.socket.WebSocketHandler;
|
||||
@@ -43,9 +42,8 @@ import org.springframework.web.socket.sockjs.client.WebSocketTransport;
|
||||
/**
|
||||
* @author Rob Winch
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(Application.class)
|
||||
@WebIntegrationTest(randomPort = true)
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
public class ApplicationTests {
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@@ -16,27 +16,30 @@ configurations {
|
||||
|
||||
dependencies {
|
||||
compile "commons-logging:commons-logging:$commonsLoggingVersion"
|
||||
optional "org.springframework.data:spring-data-redis:$springDataRedisVersion",
|
||||
"com.hazelcast:hazelcast:$hazelcastVersion",
|
||||
"org.springframework.data:spring-data-gemfire:$springDataGemFireVersion",
|
||||
|
||||
optional "org.springframework:spring-context:$springVersion",
|
||||
"org.springframework:spring-jdbc:$springVersion",
|
||||
"org.springframework.data:spring-data-mongodb:$springDataMongoVersion",
|
||||
"org.springframework:spring-context:$springVersion",
|
||||
"org.springframework:spring-web:$springVersion",
|
||||
"org.springframework:spring-messaging:$springVersion",
|
||||
"org.springframework:spring-web:$springVersion",
|
||||
"org.springframework:spring-websocket:$springVersion",
|
||||
"org.springframework.data:spring-data-gemfire",
|
||||
"org.springframework.data:spring-data-mongodb",
|
||||
"org.springframework.data:spring-data-redis",
|
||||
"org.springframework.security:spring-security-core:$springSecurityVersion",
|
||||
"org.springframework.security:spring-security-web:$springSecurityVersion"
|
||||
"org.springframework.security:spring-security-web:$springSecurityVersion",
|
||||
"com.hazelcast:hazelcast:$hazelcastVersion"
|
||||
|
||||
provided "javax.servlet:javax.servlet-api:$servletApiVersion"
|
||||
|
||||
integrationTestCompile "redis.clients:jedis:$jedisVersion",
|
||||
"org.apache.commons:commons-pool2:2.2",
|
||||
"com.hazelcast:hazelcast-client:$hazelcastVersion",
|
||||
"com.h2database:h2:$h2Version",
|
||||
"org.hsqldb:hsqldb:2.3.3",
|
||||
"org.apache.derby:derby:10.12.1.1",
|
||||
"com.h2database:h2:$h2Version",
|
||||
"com.hazelcast:hazelcast-client:$hazelcastVersion",
|
||||
"org.hsqldb:hsqldb:2.3.3",
|
||||
"de.flapdoodle.embed:de.flapdoodle.embed.mongo:1.50.2"
|
||||
|
||||
integrationTestRuntime "org.springframework.shell:spring-shell:1.0.0.RELEASE"
|
||||
integrationTestRuntime "org.springframework.shell:spring-shell:1.1.0.RELEASE"
|
||||
|
||||
testCompile "junit:junit:$junitVersion",
|
||||
"org.mockito:mockito-core:$mockitoVersion",
|
||||
@@ -50,6 +53,9 @@ dependencies {
|
||||
}
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "org.springframework.data:spring-data-releasetrain:$springDataReleaseTrainVersion"
|
||||
}
|
||||
springIoTestRuntime {
|
||||
imports {
|
||||
mavenBom "io.spring.platform:platform-bom:${springIoVersion}"
|
||||
|
||||
@@ -25,17 +25,18 @@ import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.CacheClosedException;
|
||||
import com.gemstone.gemfire.cache.DataPolicy;
|
||||
import com.gemstone.gemfire.cache.ExpirationAction;
|
||||
import com.gemstone.gemfire.cache.ExpirationAttributes;
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.client.ClientCache;
|
||||
import com.gemstone.gemfire.cache.client.ClientCacheFactory;
|
||||
import com.gemstone.gemfire.cache.query.Index;
|
||||
import com.gemstone.gemfire.cache.server.CacheServer;
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.CacheClosedException;
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.ExpirationAction;
|
||||
import org.apache.geode.cache.ExpirationAttributes;
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
import org.apache.geode.cache.client.ClientCacheFactory;
|
||||
import org.apache.geode.cache.query.Index;
|
||||
import org.apache.geode.cache.server.CacheServer;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -47,35 +48,31 @@ 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 functionality
|
||||
* for writing Spring Session GemFire integration tests.
|
||||
*
|
||||
* @author John Blum
|
||||
* @since 1.1.0
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
* @see org.apache.geode.cache.query.Index
|
||||
* @see org.apache.geode.cache.server.CacheServer
|
||||
* @see org.springframework.session.ExpiringSession
|
||||
* @see org.springframework.session.events.AbstractSessionEvent
|
||||
* @see com.gemstone.gemfire.cache.Cache
|
||||
* @see com.gemstone.gemfire.cache.DataPolicy
|
||||
* @see com.gemstone.gemfire.cache.ExpirationAttributes
|
||||
* @see com.gemstone.gemfire.cache.GemFireCache
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @see com.gemstone.gemfire.cache.client.ClientCache
|
||||
* @see com.gemstone.gemfire.cache.server.CacheServer
|
||||
*/
|
||||
public abstract class AbstractGemFireIntegrationTests {
|
||||
|
||||
protected static final boolean DEFAULT_ENABLE_QUERY_DEBUGGING = false;
|
||||
|
||||
protected static final boolean GEMFIRE_QUERY_DEBUG =
|
||||
Boolean.getBoolean("spring.session.data.gemfire.query.debug");
|
||||
protected static final boolean GEMFIRE_QUERY_DEBUG = Boolean.getBoolean("spring.session.data.gemfire.query.debug");
|
||||
|
||||
protected static final int DEFAULT_GEMFIRE_SERVER_PORT = CacheServer.DEFAULT_PORT;
|
||||
|
||||
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";
|
||||
|
||||
@@ -100,8 +97,8 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
protected static File createDirectory(String pathname) {
|
||||
File directory = new File(WORKING_DIRECTORY, pathname);
|
||||
|
||||
assertThat(directory.isDirectory() || directory.mkdirs()).as(
|
||||
String.format("Failed to create directory (%1$s)", directory)).isTrue();
|
||||
assertThat(directory.isDirectory() || directory.mkdirs())
|
||||
.as(String.format("Failed to create directory (%1$s)", directory)).isTrue();
|
||||
|
||||
directory.deleteOnExit();
|
||||
|
||||
@@ -335,6 +332,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 +444,4 @@ public abstract class AbstractGemFireIntegrationTests {
|
||||
protected interface Condition {
|
||||
boolean evaluate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,11 +26,12 @@ import java.util.Date;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
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 org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.RegionAttributes;
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
@@ -81,10 +82,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see org.springframework.test.context.web.WebAppConfiguration
|
||||
* @see com.gemstone.gemfire.cache.Cache
|
||||
* @see com.gemstone.gemfire.cache.client.ClientCache
|
||||
* @see com.gemstone.gemfire.cache.client.Pool
|
||||
* @see com.gemstone.gemfire.cache.server.CacheServer
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
* @see org.apache.geode.cache.client.Pool
|
||||
* @see org.apache.geode.cache.server.CacheServer
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = ClientServerGemFireOperationsSessionRepositoryIntegrationTests.SpringSessionGemFireClientConfiguration.class)
|
||||
@@ -244,11 +245,10 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
|
||||
static class SpringSessionGemFireClientConfiguration {
|
||||
|
||||
@Bean
|
||||
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
|
||||
static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
|
||||
return new PropertySourcesPlaceholderConfigurer();
|
||||
}
|
||||
|
||||
@Bean
|
||||
Properties gemfireProperties() {
|
||||
Properties gemfireProperties = new Properties();
|
||||
gemfireProperties.setProperty("log-level", GEMFIRE_LOG_LEVEL);
|
||||
@@ -266,8 +266,8 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
|
||||
}
|
||||
|
||||
@Bean
|
||||
PoolFactoryBean gemfirePool(@Value("${spring.session.data.gemfire.port:"
|
||||
+ DEFAULT_GEMFIRE_SERVER_PORT + "}") int port) {
|
||||
PoolFactoryBean gemfirePool(
|
||||
@Value("${spring.session.data.gemfire.port:" + DEFAULT_GEMFIRE_SERVER_PORT + "}") int port) {
|
||||
|
||||
PoolFactoryBean poolFactory = new PoolFactoryBean();
|
||||
|
||||
@@ -294,8 +294,8 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
|
||||
// used for debugging purposes
|
||||
@SuppressWarnings("resource")
|
||||
public static void main(final String[] args) {
|
||||
ConfigurableApplicationContext applicationContext = new AnnotationConfigApplicationContext(
|
||||
SpringSessionGemFireClientConfiguration.class);
|
||||
ConfigurableApplicationContext applicationContext =
|
||||
new AnnotationConfigApplicationContext(SpringSessionGemFireClientConfiguration.class);
|
||||
|
||||
applicationContext.registerShutdownHook();
|
||||
|
||||
@@ -308,7 +308,8 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
|
||||
}
|
||||
}
|
||||
|
||||
@EnableGemFireHttpSession(regionName = SPRING_SESSION_GEMFIRE_REGION_NAME, maxInactiveIntervalInSeconds = MAX_INACTIVE_INTERVAL_IN_SECONDS)
|
||||
@EnableGemFireHttpSession(regionName = SPRING_SESSION_GEMFIRE_REGION_NAME,
|
||||
maxInactiveIntervalInSeconds = MAX_INACTIVE_INTERVAL_IN_SECONDS)
|
||||
static class SpringSessionGemFireServerConfiguration {
|
||||
|
||||
static final int MAX_CONNECTIONS = 50;
|
||||
@@ -362,11 +363,10 @@ public class ClientServerGemFireOperationsSessionRepositoryIntegrationTests
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public static void main(final String[] args) throws IOException {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
SpringSessionGemFireServerConfiguration.class);
|
||||
AnnotationConfigApplicationContext context =
|
||||
new AnnotationConfigApplicationContext(SpringSessionGemFireServerConfiguration.class);
|
||||
context.registerShutdownHook();
|
||||
writeProcessControlFile(WORKING_DIRECTORY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,15 +23,16 @@ import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.gemstone.gemfire.cache.DataPolicy;
|
||||
import com.gemstone.gemfire.cache.ExpirationAction;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.query.Query;
|
||||
import com.gemstone.gemfire.cache.query.QueryService;
|
||||
import com.gemstone.gemfire.cache.query.SelectResults;
|
||||
import com.gemstone.gemfire.pdx.PdxReader;
|
||||
import com.gemstone.gemfire.pdx.PdxSerializable;
|
||||
import com.gemstone.gemfire.pdx.PdxWriter;
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.ExpirationAction;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.query.Query;
|
||||
import org.apache.geode.cache.query.QueryService;
|
||||
import org.apache.geode.cache.query.SelectResults;
|
||||
import org.apache.geode.pdx.PdxReader;
|
||||
import org.apache.geode.pdx.PdxSerializable;
|
||||
import org.apache.geode.pdx.PdxWriter;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -55,9 +56,8 @@ import org.springframework.util.ObjectUtils;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* The GemFireOperationsSessionRepositoryIntegrationTests class is a test suite of test
|
||||
* cases testing the findByPrincipalName query method on the
|
||||
* GemFireOpeationsSessionRepository class.
|
||||
* Integration test to test the {@code findByPrincipalName} query method
|
||||
* on {@link GemFireOperationsSessionRepository}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @since 1.1.0
|
||||
@@ -69,15 +69,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see org.springframework.test.context.web.WebAppConfiguration
|
||||
* @see com.gemstone.gemfire.cache.Cache
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.Region
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@DirtiesContext
|
||||
@WebAppConfiguration
|
||||
public class GemFireOperationsSessionRepositoryIntegrationTests
|
||||
extends AbstractGemFireIntegrationTests {
|
||||
public class GemFireOperationsSessionRepositoryIntegrationTests extends AbstractGemFireIntegrationTests {
|
||||
|
||||
private static final int MAX_INACTIVE_INTERVAL_IN_SECONDS = 300;
|
||||
|
||||
@@ -474,5 +473,4 @@ public class GemFireOperationsSessionRepositoryIntegrationTests
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ import java.util.Date;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
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 org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.RegionAttributes;
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
@@ -64,10 +64,9 @@ import org.springframework.util.SocketUtils;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* The MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationTests class is a test suite of test cases
|
||||
* testing the functionality of a GemFire cache client in a Spring Session application using a specifically named
|
||||
* GemFire {@link com.gemstone.gemfire.cache.client.Pool} as configured with the 'poolName' attribute on the
|
||||
* Spring Session Data GemFire {@link EnableGemFireHttpSession} annotation.
|
||||
* Integration test to test the functionality of a GemFire cache client in a Spring Session application
|
||||
* using a specifically named GemFire {@link org.apache.geode.cache.client.Pool} configured with
|
||||
* the 'poolName' attribute in the Spring Session Data GemFire {@link EnableGemFireHttpSession} annotation.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
@@ -79,10 +78,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see org.springframework.test.context.web.WebAppConfiguration
|
||||
* @see com.gemstone.gemfire.cache.Cache
|
||||
* @see com.gemstone.gemfire.cache.client.ClientCache
|
||||
* @see com.gemstone.gemfire.cache.client.Pool
|
||||
* @see com.gemstone.gemfire.cache.server.CacheServer
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
* @see org.apache.geode.cache.client.Pool
|
||||
* @see org.apache.geode.cache.server.CacheServer
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@@ -342,5 +341,4 @@ public class MultiPoolClientServerGemFireOperationsSessionRepositoryIntegrationT
|
||||
writeProcessControlFile(WORKING_DIRECTORY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,10 +20,11 @@ import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.gemstone.gemfire.cache.DataPolicy;
|
||||
import com.gemstone.gemfire.cache.ExpirationAction;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.RegionShortcut;
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.ExpirationAction;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.RegionShortcut;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -65,14 +66,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see org.springframework.test.context.web.WebAppConfiguration
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @see org.apache.geode.cache.Region
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@DirtiesContext
|
||||
@WebAppConfiguration
|
||||
public class EnableGemFireHttpSessionEventsIntegrationTests
|
||||
extends AbstractGemFireIntegrationTests {
|
||||
public class EnableGemFireHttpSessionEventsIntegrationTests extends AbstractGemFireIntegrationTests {
|
||||
|
||||
private static final int MAX_INACTIVE_INTERVAL_IN_SECONDS = 1;
|
||||
|
||||
@@ -264,5 +264,4 @@ public class EnableGemFireHttpSessionEventsIntegrationTests
|
||||
return new SessionEventListener();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,13 +18,14 @@ package org.springframework.session.data.gemfire.config.annotation.web.http;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.DataPolicy;
|
||||
import com.gemstone.gemfire.cache.ExpirationAction;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.RegionShortcut;
|
||||
import com.gemstone.gemfire.cache.query.Index;
|
||||
import com.gemstone.gemfire.cache.query.QueryService;
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.ExpirationAction;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.RegionShortcut;
|
||||
import org.apache.geode.cache.query.Index;
|
||||
import org.apache.geode.cache.query.QueryService;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -42,7 +43,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Test suite of test cases testing the configuration of Spring Session backed by GemFire
|
||||
* Integration test to test the configuration of Spring Session backed by GemFire
|
||||
* using Java-based configuration meta-data.
|
||||
*
|
||||
* @author John Blum
|
||||
@@ -54,8 +55,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see org.springframework.test.context.web.WebAppConfiguration
|
||||
* @see com.gemstone.gemfire.cache.Cache
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.Region
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
|
||||
@@ -16,12 +16,13 @@
|
||||
|
||||
package org.springframework.session.data.gemfire.config.annotation.web.http;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.DataPolicy;
|
||||
import com.gemstone.gemfire.cache.ExpirationAction;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.query.Index;
|
||||
import com.gemstone.gemfire.cache.query.QueryService;
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.ExpirationAction;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.query.Index;
|
||||
import org.apache.geode.cache.query.QueryService;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -49,8 +50,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see org.springframework.test.context.web.WebAppConfiguration
|
||||
* @see com.gemstone.gemfire.cache.Cache
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.Region
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
|
||||
@@ -33,16 +33,16 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.gemstone.gemfire.DataSerializable;
|
||||
import com.gemstone.gemfire.DataSerializer;
|
||||
import com.gemstone.gemfire.Delta;
|
||||
import com.gemstone.gemfire.Instantiator;
|
||||
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;
|
||||
import org.apache.geode.DataSerializable;
|
||||
import org.apache.geode.DataSerializer;
|
||||
import org.apache.geode.Delta;
|
||||
import org.apache.geode.Instantiator;
|
||||
import org.apache.geode.InvalidDeltaException;
|
||||
import org.apache.geode.cache.EntryEvent;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.util.CacheListenerAdapter;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
@@ -65,20 +65,30 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* AbstractGemFireOperationsSessionRepository is an abstract base class encapsulating functionality
|
||||
* {@link AbstractGemFireOperationsSessionRepository} is an abstract base class encapsulating functionality
|
||||
* common to all implementations that support {@link SessionRepository} operations backed by GemFire.
|
||||
*
|
||||
* @author John Blum
|
||||
* @since 1.1.0
|
||||
* @see org.apache.geode.DataSerializable
|
||||
* @see org.apache.geode.DataSerializer
|
||||
* @see org.apache.geode.Delta
|
||||
* @see org.apache.geode.Instantiator
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.util.CacheListenerAdapter
|
||||
* @see org.springframework.beans.factory.InitializingBean
|
||||
* @see org.springframework.context.ApplicationEventPublisher
|
||||
* @see org.springframework.context.ApplicationEventPublisherAware
|
||||
* @see org.springframework.data.gemfire.GemfireOperations
|
||||
* @see org.springframework.session.ExpiringSession
|
||||
* @see org.springframework.session.Session
|
||||
* @see org.springframework.session.SessionRepository
|
||||
* @see org.springframework.session.FindByIndexNameSessionRepository
|
||||
* @see org.springframework.session.data.gemfire.config.annotation.web.http.GemFireHttpSessionConfiguration
|
||||
* @see org.springframework.session.data.gemfire.config.annotation.web.http.EnableGemFireHttpSession
|
||||
* @see com.gemstone.gemfire.cache.util.CacheListenerAdapter
|
||||
*/
|
||||
public abstract class AbstractGemFireOperationsSessionRepository extends CacheListenerAdapter<Object, ExpiringSession>
|
||||
implements InitializingBean, FindByIndexNameSessionRepository<ExpiringSession>, ApplicationEventPublisherAware {
|
||||
implements ApplicationEventPublisherAware, FindByIndexNameSessionRepository<ExpiringSession>, InitializingBean {
|
||||
|
||||
private int maxInactiveIntervalInSeconds = GemFireHttpSessionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL_IN_SECONDS;
|
||||
|
||||
@@ -192,7 +202,7 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
/**
|
||||
* Callback method during Spring bean initialization that will capture the fully-qualified name
|
||||
* of the GemFire cache {@link Region} used to manage Session state and register this SessionRepository
|
||||
* as a GemFire {@link com.gemstone.gemfire.cache.CacheListener}.
|
||||
* as a GemFire {@link org.apache.geode.cache.CacheListener}.
|
||||
*
|
||||
* Additionally, this method registers GemFire {@link Instantiator}s for the {@link GemFireSession}
|
||||
* and {@link GemFireSessionAttributes} types to optimize GemFire's instantiation logic on deserialization
|
||||
@@ -230,7 +240,7 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
* {@link Region}.
|
||||
*
|
||||
* @param event an EntryEvent containing the details of the cache operation.
|
||||
* @see com.gemstone.gemfire.cache.EntryEvent
|
||||
* @see org.apache.geode.cache.EntryEvent
|
||||
* @see #handleCreated(String, ExpiringSession)
|
||||
*/
|
||||
@Override
|
||||
@@ -245,7 +255,7 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
* {@link Region}.
|
||||
*
|
||||
* @param event an EntryEvent containing the details of the cache operation.
|
||||
* @see com.gemstone.gemfire.cache.EntryEvent
|
||||
* @see org.apache.geode.cache.EntryEvent
|
||||
* @see #handleDestroyed(String, ExpiringSession)
|
||||
*/
|
||||
@Override
|
||||
@@ -258,7 +268,7 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
* {@link Region}.
|
||||
*
|
||||
* @param event an EntryEvent containing the details of the cache operation.
|
||||
* @see com.gemstone.gemfire.cache.EntryEvent
|
||||
* @see org.apache.geode.cache.EntryEvent
|
||||
* @see #handleExpired(String, ExpiringSession)
|
||||
*/
|
||||
@Override
|
||||
@@ -350,8 +360,7 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
|
||||
protected static final boolean DEFAULT_ALLOW_JAVA_SERIALIZATION = true;
|
||||
|
||||
protected static final DateFormat TO_STRING_DATE_FORMAT = new SimpleDateFormat(
|
||||
"YYYY-MM-dd-HH-mm-ss");
|
||||
protected static final DateFormat TO_STRING_DATE_FORMAT = new SimpleDateFormat("YYYY-MM-dd-HH-mm-ss");
|
||||
|
||||
protected static final String SPRING_SECURITY_CONTEXT = "SPRING_SECURITY_CONTEXT";
|
||||
|
||||
@@ -362,8 +371,7 @@ 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();
|
||||
|
||||
@@ -654,9 +662,9 @@ public abstract class AbstractGemFireOperationsSessionRepository extends CacheLi
|
||||
* are effectively a name to value mapping.
|
||||
*
|
||||
* @see java.util.AbstractMap
|
||||
* @see com.gemstone.gemfire.DataSerializable
|
||||
* @see com.gemstone.gemfire.DataSerializer
|
||||
* @see com.gemstone.gemfire.Delta
|
||||
* @see org.apache.geode.DataSerializable
|
||||
* @see org.apache.geode.DataSerializer
|
||||
* @see org.apache.geode.Delta
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public static class GemFireSessionAttributes extends AbstractMap<String, Object>
|
||||
|
||||
@@ -19,18 +19,21 @@ package org.springframework.session.data.gemfire;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.gemstone.gemfire.cache.query.SelectResults;
|
||||
import org.apache.geode.cache.query.SelectResults;
|
||||
|
||||
import org.springframework.data.gemfire.GemfireOperations;
|
||||
import org.springframework.session.ExpiringSession;
|
||||
import org.springframework.session.SessionRepository;
|
||||
|
||||
/**
|
||||
* The GemFireOperationsSessionRepository class is a Spring SessionRepository
|
||||
* implementation that interfaces with and uses GemFire to back and store Spring Sessions.
|
||||
* The {@link GemFireOperationsSessionRepository} class is a Spring {@link SessionRepository} implementation
|
||||
* that interfaces with and uses GemFire to back and store Spring Sessions.
|
||||
*
|
||||
* @author John Blum
|
||||
* @since 1.1.0
|
||||
* @see AbstractGemFireOperationsSessionRepository
|
||||
* @see org.springframework.data.gemfire.GemfireOperations
|
||||
* @see org.springframework.session.ExpiringSession
|
||||
* @see org.springframework.session.data.gemfire.AbstractGemFireOperationsSessionRepository
|
||||
*/
|
||||
public class GemFireOperationsSessionRepository extends AbstractGemFireOperationsSessionRepository {
|
||||
|
||||
@@ -152,5 +155,4 @@ public class GemFireOperationsSessionRepository extends AbstractGemFireOperation
|
||||
public void delete(String sessionId) {
|
||||
handleDeleted(sessionId, getTemplate().<Object, ExpiringSession>remove(sessionId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import com.gemstone.gemfire.cache.RegionShortcut;
|
||||
import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
|
||||
import org.apache.geode.cache.RegionShortcut;
|
||||
import org.apache.geode.cache.client.ClientRegionShortcut;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
@@ -33,8 +33,8 @@ import org.springframework.context.annotation.Import;
|
||||
* as a bean named "springSessionRepositoryFilter" and backed by Pivotal GemFire or Apache Geode.
|
||||
*
|
||||
* In order to leverage the annotation, a single Pivotal GemFire/Apache Geode
|
||||
* {@link com.gemstone.gemfire.cache.Cache}
|
||||
* or {@link com.gemstone.gemfire.cache.client.ClientCache} instance must be provided.
|
||||
* {@link org.apache.geode.cache.Cache}
|
||||
* or {@link org.apache.geode.cache.client.ClientCache} instance must be provided.
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
@@ -63,7 +63,7 @@ import org.springframework.context.annotation.Import;
|
||||
* </code> </pre>
|
||||
*
|
||||
* Alternatively, Spring Session can be configured to use Pivotal GemFire (Apache Geode) as a client
|
||||
* using a dedicated GemFire Server cluster and a {@link com.gemstone.gemfire.cache.client.ClientCache}.
|
||||
* using a dedicated GemFire Server cluster and a {@link org.apache.geode.cache.client.ClientCache}.
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
@@ -116,7 +116,7 @@ public @interface EnableGemFireHttpSession {
|
||||
*
|
||||
* @return a ClientRegionShortcut used to specify and configure the ClientCache Region
|
||||
* DataPolicy.
|
||||
* @see com.gemstone.gemfire.cache.client.ClientRegionShortcut
|
||||
* @see org.apache.geode.cache.client.ClientRegionShortcut
|
||||
*/
|
||||
ClientRegionShortcut clientRegionShortcut() default ClientRegionShortcut.PROXY;
|
||||
|
||||
@@ -139,13 +139,13 @@ public @interface EnableGemFireHttpSession {
|
||||
int maxInactiveIntervalInSeconds() default 1800;
|
||||
|
||||
/**
|
||||
* Specifies the name of the specific GemFire {@link com.gemstone.gemfire.cache.client.Pool} used
|
||||
* Specifies the name of the specific GemFire {@link org.apache.geode.cache.client.Pool} used
|
||||
* by the Spring Session Data GemFire client Region ('ClusteredSpringSessions') when performing
|
||||
* cache operations. This is attribute is only used in the client/server topology.
|
||||
*
|
||||
* @return the name of the GemFire {@link com.gemstone.gemfire.cache.client.Pool} to be used
|
||||
* @return the name of the GemFire {@link org.apache.geode.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;
|
||||
|
||||
@@ -154,7 +154,7 @@ public @interface EnableGemFireHttpSession {
|
||||
*
|
||||
* @return a String specifying the name of the GemFire (Client)Cache Region used to
|
||||
* store Sessions.
|
||||
* @see com.gemstone.gemfire.cache.Region#getName()
|
||||
* @see org.apache.geode.cache.Region#getName()
|
||||
*/
|
||||
String regionName() default "ClusteredSpringSessions";
|
||||
|
||||
@@ -163,7 +163,7 @@ public @interface EnableGemFireHttpSession {
|
||||
*
|
||||
* @return a RegionShortcut used to specify and configure the Peer Cache Region
|
||||
* DataPolicy.
|
||||
* @see com.gemstone.gemfire.cache.RegionShortcut
|
||||
* @see org.apache.geode.cache.RegionShortcut
|
||||
*/
|
||||
RegionShortcut serverRegionShortcut() default RegionShortcut.PARTITION;
|
||||
|
||||
|
||||
@@ -18,14 +18,14 @@ package org.springframework.session.data.gemfire.config.annotation.web.http;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.gemstone.gemfire.cache.ExpirationAction;
|
||||
import com.gemstone.gemfire.cache.ExpirationAttributes;
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.RegionAttributes;
|
||||
import com.gemstone.gemfire.cache.RegionShortcut;
|
||||
import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
|
||||
import com.gemstone.gemfire.cache.client.Pool;
|
||||
import org.apache.geode.cache.ExpirationAction;
|
||||
import org.apache.geode.cache.ExpirationAttributes;
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.RegionAttributes;
|
||||
import org.apache.geode.cache.RegionShortcut;
|
||||
import org.apache.geode.cache.client.ClientRegionShortcut;
|
||||
import org.apache.geode.cache.client.Pool;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@@ -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;
|
||||
@@ -51,20 +51,24 @@ import org.springframework.session.data.gemfire.support.GemFireUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* The GemFireHttpSessionConfiguration class is a Spring @Configuration class used to
|
||||
* configure and initialize Pivotal GemFire (or Apache Geode) as a clustered, replicated
|
||||
* HttpSession provider implementation in Spring Session.
|
||||
* The {@link GemFireHttpSessionConfiguration} class is a Spring {@link Configuration @Configuration} class
|
||||
* used to configure and initialize Pivotal GemFire (or Apache Geode) as a clustered, replicated
|
||||
* {@link javax.servlet.http.HttpSession} provider implementation in Spring {@link ExpiringSession}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.client.Pool
|
||||
* @see org.springframework.beans.factory.BeanClassLoaderAware
|
||||
* @see org.springframework.context.annotation.Bean
|
||||
* @see org.springframework.context.annotation.Configuration
|
||||
* @see org.springframework.context.annotation.ImportAware
|
||||
* @see org.springframework.data.gemfire.GemfireOperations
|
||||
* @see org.springframework.data.gemfire.GemfireTemplate
|
||||
* @see org.springframework.session.ExpiringSession
|
||||
* @see org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration
|
||||
* @see org.springframework.session.data.gemfire.GemFireOperationsSessionRepository
|
||||
* @see org.springframework.session.data.gemfire.config.annotation.web.http.EnableGemFireHttpSession
|
||||
* @see com.gemstone.gemfire.cache.GemFireCache
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Configuration
|
||||
@@ -151,7 +155,7 @@ public class GemFireHttpSessionConfiguration extends SpringHttpSessionConfigurat
|
||||
*
|
||||
* @param shortcut the ClientRegionShortcut used to configure the GemFire ClientCache
|
||||
* Region.
|
||||
* @see com.gemstone.gemfire.cache.client.ClientRegionShortcut
|
||||
* @see org.apache.geode.cache.client.ClientRegionShortcut
|
||||
*/
|
||||
public void setClientRegionShortcut(ClientRegionShortcut shortcut) {
|
||||
this.clientRegionShortcut = shortcut;
|
||||
@@ -163,7 +167,7 @@ public class GemFireHttpSessionConfiguration extends SpringHttpSessionConfigurat
|
||||
* {@link ClientRegionShortcut#PROXY}.
|
||||
*
|
||||
* @return the ClientRegionShortcut used to configure the GemFire ClientCache Region.
|
||||
* @see com.gemstone.gemfire.cache.client.ClientRegionShortcut
|
||||
* @see org.apache.geode.cache.client.ClientRegionShortcut
|
||||
* @see EnableGemFireHttpSession#clientRegionShortcut()
|
||||
*/
|
||||
protected ClientRegionShortcut getClientRegionShortcut() {
|
||||
@@ -244,7 +248,7 @@ public class GemFireHttpSessionConfiguration extends SpringHttpSessionConfigurat
|
||||
* will store Spring Sessions.
|
||||
*
|
||||
* @param shortcut the RegionShortcut used to configure the GemFire Cache Region.
|
||||
* @see com.gemstone.gemfire.cache.RegionShortcut
|
||||
* @see org.apache.geode.cache.RegionShortcut
|
||||
*/
|
||||
public void setServerRegionShortcut(RegionShortcut shortcut) {
|
||||
this.serverRegionShortcut = shortcut;
|
||||
@@ -255,7 +259,7 @@ public class GemFireHttpSessionConfiguration extends SpringHttpSessionConfigurat
|
||||
* will store Spring Sessions. Defaults to {@link RegionShortcut#PARTITION}.
|
||||
*
|
||||
* @return the RegionShortcut used to configure the GemFire Cache Region.
|
||||
* @see com.gemstone.gemfire.cache.RegionShortcut
|
||||
* @see org.apache.geode.cache.RegionShortcut
|
||||
* @see EnableGemFireHttpSession#serverRegionShortcut()
|
||||
*/
|
||||
protected RegionShortcut getServerRegionShortcut() {
|
||||
@@ -278,7 +282,7 @@ public class GemFireHttpSessionConfiguration extends SpringHttpSessionConfigurat
|
||||
*
|
||||
* @return a String specifying the name of the GemFire (Client)Cache Region used to
|
||||
* store the Session.
|
||||
* @see com.gemstone.gemfire.cache.Region#getName()
|
||||
* @see org.apache.geode.cache.Region#getName()
|
||||
* @see EnableGemFireHttpSession#regionName()
|
||||
*/
|
||||
protected String getSpringSessionGemFireRegionName() {
|
||||
@@ -298,22 +302,22 @@ public class GemFireHttpSessionConfiguration extends SpringHttpSessionConfigurat
|
||||
AnnotationAttributes.fromMap(importMetadata.getAnnotationAttributes(
|
||||
EnableGemFireHttpSession.class.getName()));
|
||||
|
||||
setClientRegionShortcut(ClientRegionShortcut.class.cast(
|
||||
enableGemFireHttpSessionAnnotationAttributes.getEnum("clientRegionShortcut")));
|
||||
setClientRegionShortcut(ClientRegionShortcut.class.cast(enableGemFireHttpSessionAnnotationAttributes
|
||||
.getEnum("clientRegionShortcut")));
|
||||
|
||||
setIndexableSessionAttributes(enableGemFireHttpSessionAnnotationAttributes.getStringArray(
|
||||
"indexableSessionAttributes"));
|
||||
setIndexableSessionAttributes(enableGemFireHttpSessionAnnotationAttributes
|
||||
.getStringArray("indexableSessionAttributes"));
|
||||
|
||||
setMaxInactiveIntervalInSeconds(enableGemFireHttpSessionAnnotationAttributes.getNumber(
|
||||
"maxInactiveIntervalInSeconds").intValue());
|
||||
setMaxInactiveIntervalInSeconds(enableGemFireHttpSessionAnnotationAttributes
|
||||
.getNumber("maxInactiveIntervalInSeconds").intValue());
|
||||
|
||||
setPoolName(enableGemFireHttpSessionAnnotationAttributes.getString("poolName"));
|
||||
|
||||
setServerRegionShortcut(RegionShortcut.class.cast(enableGemFireHttpSessionAnnotationAttributes.getEnum(
|
||||
"serverRegionShortcut")));
|
||||
setServerRegionShortcut(RegionShortcut.class.cast(enableGemFireHttpSessionAnnotationAttributes
|
||||
.getEnum("serverRegionShortcut")));
|
||||
|
||||
setSpringSessionGemFireRegionName(enableGemFireHttpSessionAnnotationAttributes.getString(
|
||||
"regionName"));
|
||||
setSpringSessionGemFireRegionName(enableGemFireHttpSessionAnnotationAttributes
|
||||
.getString("regionName"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,7 +350,7 @@ public class GemFireHttpSessionConfiguration extends SpringHttpSessionConfigurat
|
||||
* @return a {@link GemfireTemplate} used to interact with GemFire's (Client)Cache
|
||||
* {@link Region} storing Sessions.
|
||||
* @see org.springframework.data.gemfire.GemfireTemplate
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @see org.apache.geode.cache.Region
|
||||
*/
|
||||
@Bean
|
||||
@DependsOn(DEFAULT_SPRING_SESSION_GEMFIRE_REGION_NAME)
|
||||
@@ -355,12 +359,12 @@ public class GemFireHttpSessionConfiguration extends SpringHttpSessionConfigurat
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a Spring GemFire {@link com.gemstone.gemfire.cache.Cache} {@link Region}
|
||||
* Defines a Spring GemFire {@link org.apache.geode.cache.Cache} {@link Region}
|
||||
* bean used to store and manage Sessions using either a client-server or peer-to-peer
|
||||
* (p2p) topology.
|
||||
*
|
||||
* @param gemfireCache a reference to the GemFire
|
||||
* {@link com.gemstone.gemfire.cache.Cache}.
|
||||
* {@link org.apache.geode.cache.Cache}.
|
||||
* @param sessionRegionAttributes the GemFire {@link RegionAttributes} used to
|
||||
* configure the {@link Region}.
|
||||
* @return a {@link GemFireCacheTypeAwareRegionFactoryBean} used to configure and
|
||||
@@ -396,8 +400,8 @@ public class GemFireHttpSessionConfiguration extends SpringHttpSessionConfigurat
|
||||
* @return an instance of {@link RegionAttributes} used to configure and initialize
|
||||
* the GemFire cache {@link Region} for storing and managing Sessions.
|
||||
* @see org.springframework.data.gemfire.RegionAttributesFactoryBean
|
||||
* @see com.gemstone.gemfire.cache.GemFireCache
|
||||
* @see com.gemstone.gemfire.cache.PartitionAttributes
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.PartitionAttributes
|
||||
* @see #isExpirationAllowed(GemFireCache)
|
||||
*/
|
||||
@Bean
|
||||
@@ -410,8 +414,8 @@ public class GemFireHttpSessionConfiguration extends SpringHttpSessionConfigurat
|
||||
|
||||
if (isExpirationAllowed(gemfireCache)) {
|
||||
regionAttributes.setStatisticsEnabled(true);
|
||||
regionAttributes.setEntryIdleTimeout(new ExpirationAttributes(
|
||||
Math.max(getMaxInactiveIntervalInSeconds(), 0), ExpirationAction.INVALIDATE));
|
||||
regionAttributes.setEntryIdleTimeout(
|
||||
new ExpirationAttributes(Math.max(getMaxInactiveIntervalInSeconds(), 0), ExpirationAction.INVALIDATE));
|
||||
}
|
||||
|
||||
return regionAttributes;
|
||||
@@ -441,7 +445,7 @@ public class GemFireHttpSessionConfiguration extends SpringHttpSessionConfigurat
|
||||
* @return a {@link IndexFactoryBean} to create an GemFire Index on the 'principalName' property
|
||||
* for Sessions stored in the GemFire cache {@link Region}.
|
||||
* @see org.springframework.data.gemfire.IndexFactoryBean
|
||||
* @see com.gemstone.gemfire.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
*/
|
||||
@Bean
|
||||
@DependsOn(DEFAULT_SPRING_SESSION_GEMFIRE_REGION_NAME)
|
||||
@@ -467,7 +471,7 @@ public class GemFireHttpSessionConfiguration extends SpringHttpSessionConfigurat
|
||||
* @return a {@link IndexFactoryBean} to create an GemFire Index on attributes of Sessions
|
||||
* stored in the GemFire cache {@link Region}.
|
||||
* @see org.springframework.data.gemfire.IndexFactoryBean
|
||||
* @see com.gemstone.gemfire.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
*/
|
||||
@Bean
|
||||
@DependsOn(DEFAULT_SPRING_SESSION_GEMFIRE_REGION_NAME)
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
package org.springframework.session.data.gemfire.config.annotation.web.http.support;
|
||||
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.InterestResultPolicy;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.RegionAttributes;
|
||||
import com.gemstone.gemfire.cache.RegionShortcut;
|
||||
import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
|
||||
import com.gemstone.gemfire.cache.client.Pool;
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.InterestResultPolicy;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.RegionAttributes;
|
||||
import org.apache.geode.cache.RegionShortcut;
|
||||
import org.apache.geode.cache.client.ClientRegionShortcut;
|
||||
import org.apache.geode.cache.client.Pool;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
@@ -37,9 +37,9 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* The GemFireCacheTypeAwareRegionFactoryBean class is a Spring {@link FactoryBean} used
|
||||
* to construct, configure and initialize the GemFire cache {@link Region} used to store
|
||||
* and manage Session state.
|
||||
* The {@link GemFireCacheTypeAwareRegionFactoryBean} class is a Spring {@link FactoryBean}
|
||||
* used to construct, configure and initialize the GemFire cache {@link Region} used to
|
||||
* store and manage Session state.
|
||||
*
|
||||
* @param <K> the type of keys
|
||||
* @param <V> the type of values
|
||||
@@ -105,14 +105,14 @@ public class GemFireCacheTypeAwareRegionFactoryBean<K, V>
|
||||
* from a GemFire cache client.
|
||||
*
|
||||
* @param gemfireCache a reference to the GemFire
|
||||
* {@link com.gemstone.gemfire.cache.Cache}.
|
||||
* {@link org.apache.geode.cache.Cache}.
|
||||
* @return a peer-to-peer-based GemFire cache {@link Region} to store and manage
|
||||
* Session state.
|
||||
* @throws Exception if the instantiation, configuration and initialization of the
|
||||
* GemFire cache {@link Region} fails.
|
||||
* @see org.springframework.data.gemfire.GenericRegionFactoryBean
|
||||
* @see com.gemstone.gemfire.cache.GemFireCache
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see #getRegionAttributes()
|
||||
* @see #getRegionName()
|
||||
* @see #getServerRegionShortcut()
|
||||
@@ -135,14 +135,14 @@ public class GemFireCacheTypeAwareRegionFactoryBean<K, V>
|
||||
* GemFire cache client.
|
||||
*
|
||||
* @param gemfireCache a reference to the GemFire
|
||||
* {@link com.gemstone.gemfire.cache.Cache}.
|
||||
* {@link org.apache.geode.cache.Cache}.
|
||||
* @return a client-server-based GemFire cache {@link Region} to store and manage
|
||||
* Session state.
|
||||
* @throws Exception if the instantiation, configuration and initialization of the
|
||||
* GemFire cache {@link Region} fails.
|
||||
* @see org.springframework.data.gemfire.client.ClientRegionFactoryBean
|
||||
* @see com.gemstone.gemfire.cache.GemFireCache
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see #getClientRegionShortcut()
|
||||
* @see #getRegionAttributes()
|
||||
* @see #getRegionName()
|
||||
@@ -186,7 +186,7 @@ public class GemFireCacheTypeAwareRegionFactoryBean<K, V>
|
||||
*
|
||||
* @return the {@link Region} used to store and manage Session state.
|
||||
* @throws Exception if the {@link Region} reference cannot be obtained.
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @see org.apache.geode.cache.Region
|
||||
*/
|
||||
public Region<K, V> getObject() throws Exception {
|
||||
return this.region;
|
||||
@@ -197,7 +197,7 @@ public class GemFireCacheTypeAwareRegionFactoryBean<K, V>
|
||||
* initialized or Region.class when uninitialized.
|
||||
*
|
||||
* @return the GemFire cache {@link Region} class type constructed by this factory.
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see java.lang.Class
|
||||
*/
|
||||
public Class<?> getObjectType() {
|
||||
@@ -248,7 +248,7 @@ public class GemFireCacheTypeAwareRegionFactoryBean<K, V>
|
||||
*
|
||||
* @param clientRegionShortcut a {@link ClientRegionShortcut} to specify the client
|
||||
* {@link Region} data management policy.
|
||||
* @see com.gemstone.gemfire.cache.client.ClientRegionShortcut
|
||||
* @see org.apache.geode.cache.client.ClientRegionShortcut
|
||||
*/
|
||||
public void setClientRegionShortcut(ClientRegionShortcut clientRegionShortcut) {
|
||||
this.clientRegionShortcut = clientRegionShortcut;
|
||||
@@ -261,7 +261,7 @@ public class GemFireCacheTypeAwareRegionFactoryBean<K, V>
|
||||
* @return a {@link ClientRegionShortcut} specifying the client {@link Region} data
|
||||
* management policy.
|
||||
* @see org.springframework.session.data.gemfire.config.annotation.web.http.GemFireHttpSessionConfiguration#DEFAULT_CLIENT_REGION_SHORTCUT
|
||||
* @see com.gemstone.gemfire.cache.client.ClientRegionShortcut
|
||||
* @see org.apache.geode.cache.client.ClientRegionShortcut
|
||||
*/
|
||||
protected ClientRegionShortcut getClientRegionShortcut() {
|
||||
return (this.clientRegionShortcut != null ? this.clientRegionShortcut : DEFAULT_CLIENT_REGION_SHORTCUT);
|
||||
@@ -319,7 +319,7 @@ public class GemFireCacheTypeAwareRegionFactoryBean<K, V>
|
||||
*
|
||||
* @param regionAttributes the GemFire {@link RegionAttributes} used to configure the
|
||||
* GemFire cache {@link Region}.
|
||||
* @see com.gemstone.gemfire.cache.RegionAttributes
|
||||
* @see org.apache.geode.cache.RegionAttributes
|
||||
*/
|
||||
public void setRegionAttributes(RegionAttributes<K, V> regionAttributes) {
|
||||
this.regionAttributes = regionAttributes;
|
||||
@@ -331,7 +331,7 @@ public class GemFireCacheTypeAwareRegionFactoryBean<K, V>
|
||||
*
|
||||
* @return the GemFire {@link RegionAttributes} used to configure the GemFire cache
|
||||
* {@link Region}.
|
||||
* @see com.gemstone.gemfire.cache.RegionAttributes
|
||||
* @see org.apache.geode.cache.RegionAttributes
|
||||
*/
|
||||
protected RegionAttributes<K, V> getRegionAttributes() {
|
||||
return this.regionAttributes;
|
||||
@@ -352,7 +352,7 @@ public class GemFireCacheTypeAwareRegionFactoryBean<K, V>
|
||||
* manage Session state. Defaults to "ClusteredSpringSessions"
|
||||
*
|
||||
* @return a String specifying the name of the GemFire cache {@link Region}.
|
||||
* @see com.gemstone.gemfire.cache.Region#getName()
|
||||
* @see org.apache.geode.cache.Region#getName()
|
||||
*/
|
||||
protected String getRegionName() {
|
||||
return (StringUtils.hasText(this.regionName) ? this.regionName : DEFAULT_SPRING_SESSION_GEMFIRE_REGION_NAME);
|
||||
@@ -364,7 +364,7 @@ public class GemFireCacheTypeAwareRegionFactoryBean<K, V>
|
||||
*
|
||||
* @param serverRegionShortcut a {@link RegionShortcut} to specify the peer
|
||||
* {@link Region} data management policy.
|
||||
* @see com.gemstone.gemfire.cache.RegionShortcut
|
||||
* @see org.apache.geode.cache.RegionShortcut
|
||||
*/
|
||||
public void setServerRegionShortcut(RegionShortcut serverRegionShortcut) {
|
||||
this.serverRegionShortcut = serverRegionShortcut;
|
||||
@@ -376,10 +376,9 @@ public class GemFireCacheTypeAwareRegionFactoryBean<K, V>
|
||||
*
|
||||
* @return a {@link RegionShortcut} specifying the peer {@link Region} data management
|
||||
* policy.
|
||||
* @see com.gemstone.gemfire.cache.RegionShortcut
|
||||
* @see org.apache.geode.cache.RegionShortcut
|
||||
*/
|
||||
protected RegionShortcut getServerRegionShortcut() {
|
||||
return (this.serverRegionShortcut != null ? this.serverRegionShortcut : DEFAULT_SERVER_REGION_SHORTCUT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.springframework.session.data.gemfire.config.annotation.web.http.supp
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.query.Index;
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.query.Index;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
@@ -41,7 +41,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* @see org.springframework.beans.factory.BeanNameAware
|
||||
* @see org.springframework.beans.factory.FactoryBean
|
||||
* @see org.springframework.beans.factory.InitializingBean
|
||||
* @see com.gemstone.gemfire.cache.query.Index
|
||||
* @see org.apache.geode.cache.query.Index
|
||||
*/
|
||||
public class SessionAttributesIndexFactoryBean implements FactoryBean<Index>,
|
||||
InitializingBean, BeanFactoryAware, BeanNameAware {
|
||||
@@ -107,7 +107,7 @@ public class SessionAttributesIndexFactoryBean implements FactoryBean<Index>,
|
||||
* @return a String composed of all the named Session attributes for which GemFire
|
||||
* will create an Index as an Index definition expression. If the indexable Session
|
||||
* attributes were not configured, then the wildcard ("*") is returned.
|
||||
* @see com.gemstone.gemfire.cache.query.Index#getIndexedExpression()
|
||||
* @see org.apache.geode.cache.query.Index#getIndexedExpression()
|
||||
*/
|
||||
protected String getIndexableSessionAttributesAsGemFireIndexExpression() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
@@ -19,13 +19,13 @@ package org.springframework.session.data.gemfire.support;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.RegionShortcut;
|
||||
import com.gemstone.gemfire.cache.client.ClientCache;
|
||||
import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
|
||||
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.RegionShortcut;
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
import org.apache.geode.cache.client.ClientRegionShortcut;
|
||||
import org.apache.geode.internal.cache.GemFireCacheImpl;
|
||||
|
||||
/**
|
||||
* GemFireUtils is an abstract, extensible utility class for working with GemFire types
|
||||
@@ -62,8 +62,8 @@ public abstract class GemFireUtils {
|
||||
*
|
||||
* @param gemFireCache a reference to the GemFire cache.
|
||||
* @return a boolean value indicating whether the GemFire cache is a client.
|
||||
* @see com.gemstone.gemfire.cache.client.ClientCache
|
||||
* @see com.gemstone.gemfire.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
*/
|
||||
public static boolean isClient(GemFireCache gemFireCache) {
|
||||
boolean client = (gemFireCache instanceof ClientCache);
|
||||
@@ -76,8 +76,8 @@ public abstract class GemFireUtils {
|
||||
*
|
||||
* @param gemFireCache a reference to the GemFire cache.
|
||||
* @return a boolean value indicating whether the GemFire cache is a peer.
|
||||
* @see com.gemstone.gemfire.cache.Cache
|
||||
* @see com.gemstone.gemfire.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
*/
|
||||
public static boolean isPeer(GemFireCache gemFireCache) {
|
||||
return (gemFireCache instanceof Cache && !isClient(gemFireCache));
|
||||
@@ -89,7 +89,7 @@ public abstract class GemFireUtils {
|
||||
* @param shortcut the ClientRegionShortcut to evaluate.
|
||||
* @return a boolean value indicating if the {@link ClientRegionShortcut} is local or
|
||||
* not.
|
||||
* @see com.gemstone.gemfire.cache.client.ClientRegionShortcut
|
||||
* @see org.apache.geode.cache.client.ClientRegionShortcut
|
||||
*/
|
||||
public static boolean isLocal(ClientRegionShortcut shortcut) {
|
||||
switch (shortcut) {
|
||||
@@ -111,7 +111,7 @@ public abstract class GemFireUtils {
|
||||
* @param shortcut the client {@link ClientRegionShortcut} to evaluate.
|
||||
* @return a boolean value indicating whether the client {@link ClientRegionShortcut}
|
||||
* refers to a proxy-based shortcut.
|
||||
* @see com.gemstone.gemfire.cache.client.ClientRegionShortcut
|
||||
* @see org.apache.geode.cache.client.ClientRegionShortcut
|
||||
*/
|
||||
public static boolean isProxy(ClientRegionShortcut shortcut) {
|
||||
switch (shortcut) {
|
||||
@@ -129,7 +129,7 @@ public abstract class GemFireUtils {
|
||||
* @param shortcut the peer {@link RegionShortcut} to evaluate.
|
||||
* @return a boolean value indicating whether the peer {@link RegionShortcut} refers
|
||||
* to a proxy-based shortcut.
|
||||
* @see com.gemstone.gemfire.cache.RegionShortcut
|
||||
* @see org.apache.geode.cache.RegionShortcut
|
||||
*/
|
||||
public static boolean isProxy(RegionShortcut shortcut) {
|
||||
switch (shortcut) {
|
||||
@@ -147,8 +147,8 @@ public abstract class GemFireUtils {
|
||||
*
|
||||
* @param regionName a String specifying the name of the {@link Region}.
|
||||
* @return a String path for the given {@link Region} by name.
|
||||
* @see com.gemstone.gemfire.cache.Region#getFullPath()
|
||||
* @see com.gemstone.gemfire.cache.Region#getName()
|
||||
* @see org.apache.geode.cache.Region#getFullPath()
|
||||
* @see org.apache.geode.cache.Region#getName()
|
||||
*/
|
||||
public static String toRegionPath(String regionName) {
|
||||
return String.format("%1$s%2$s", Region.SEPARATOR, regionName);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.session.data.mongo;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -23,6 +24,8 @@ import com.mongodb.DBObject;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.bson.Document;
|
||||
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.converter.GenericConverter;
|
||||
import org.springframework.data.domain.Sort;
|
||||
@@ -97,14 +100,17 @@ public abstract class AbstractMongoSessionConverter implements GenericConverter
|
||||
new ConvertiblePair(DBObject.class, MongoExpiringSession.class));
|
||||
}
|
||||
|
||||
public Object convert(Object source, TypeDescriptor sourceType,
|
||||
TypeDescriptor targetType) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (DBObject.class.isAssignableFrom(sourceType.getType())) {
|
||||
return convert((DBObject) source);
|
||||
return convert(new Document(((DBObject) source).toMap()));
|
||||
}
|
||||
else if (Document.class.isAssignableFrom(sourceType.getType())) {
|
||||
return convert((Document) source);
|
||||
}
|
||||
else {
|
||||
return convert((MongoExpiringSession) source);
|
||||
@@ -113,5 +119,5 @@ public abstract class AbstractMongoSessionConverter implements GenericConverter
|
||||
|
||||
protected abstract DBObject convert(MongoExpiringSession session);
|
||||
|
||||
protected abstract MongoExpiringSession convert(DBObject sessionWrapper);
|
||||
protected abstract MongoExpiringSession convert(Document sessionWrapper);
|
||||
}
|
||||
|
||||
@@ -27,8 +27,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
||||
import com.mongodb.DBObject;
|
||||
import com.mongodb.util.JSON;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.bson.Document;
|
||||
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
@@ -94,8 +96,9 @@ public class JacksonMongoSessionConverter extends AbstractMongoSessionConverter
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MongoExpiringSession convert(DBObject source) {
|
||||
protected MongoExpiringSession convert(Document source) {
|
||||
String json = JSON.serialize(source);
|
||||
|
||||
try {
|
||||
return this.objectMapper.readValue(json, MongoExpiringSession.class);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.session.data.mongo;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -22,6 +23,9 @@ import java.util.Map;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.DBObject;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.bson.types.Binary;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.core.serializer.support.DeserializingConverter;
|
||||
import org.springframework.core.serializer.support.SerializingConverter;
|
||||
@@ -86,14 +90,15 @@ public class JdkMongoSessionConverter extends AbstractMongoSessionConverter {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MongoExpiringSession convert(DBObject sessionWrapper) {
|
||||
protected MongoExpiringSession convert(Document sessionWrapper) {
|
||||
MongoExpiringSession session = new MongoExpiringSession(
|
||||
(String) sessionWrapper.get(ID),
|
||||
(Integer) sessionWrapper.get(MAX_INTERVAL));
|
||||
session.setCreationTime((Long) sessionWrapper.get(CREATION_TIME));
|
||||
session.setLastAccessedTime((Long) sessionWrapper.get(LAST_ACCESSED_TIME));
|
||||
sessionWrapper.getString(ID), sessionWrapper.getInteger(MAX_INTERVAL));
|
||||
|
||||
session.setCreationTime(sessionWrapper.getLong(CREATION_TIME));
|
||||
session.setLastAccessedTime(sessionWrapper.getLong(LAST_ACCESSED_TIME));
|
||||
session.setExpireAt((Date) sessionWrapper.get(EXPIRE_AT_FIELD_NAME));
|
||||
deserializeAttributes(sessionWrapper, session);
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
@@ -106,13 +111,13 @@ public class JdkMongoSessionConverter extends AbstractMongoSessionConverter {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void deserializeAttributes(DBObject sessionWrapper, Session session) {
|
||||
byte[] attributesBytes = (byte[]) sessionWrapper.get(ATTRIBUTES);
|
||||
Map<String, Object> attributes = (Map<String, Object>) this.deserializer
|
||||
.convert(attributesBytes);
|
||||
private void deserializeAttributes(Document sessionWrapper, Session session) {
|
||||
Object sessionAttributes = sessionWrapper.get(ATTRIBUTES);
|
||||
byte[] attributesBytes = (sessionAttributes instanceof Binary
|
||||
? ((Binary) sessionAttributes).getData() : (byte[]) sessionAttributes);
|
||||
Map<String, Object> attributes = (Map<String, Object>) this.deserializer.convert(attributesBytes);
|
||||
for (Map.Entry<String, Object> entry : attributes.entrySet()) {
|
||||
session.setAttribute(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.session.data.mongo;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -24,6 +25,8 @@ import javax.annotation.PostConstruct;
|
||||
|
||||
import com.mongodb.DBObject;
|
||||
|
||||
import org.bson.Document;
|
||||
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.data.mongodb.core.IndexOperations;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
@@ -56,8 +59,9 @@ public class MongoOperationsSessionRepository
|
||||
|
||||
private final MongoOperations mongoOperations;
|
||||
|
||||
private AbstractMongoSessionConverter mongoSessionConverter = SessionConverterProvider
|
||||
.getDefaultMongoConverter();
|
||||
private AbstractMongoSessionConverter mongoSessionConverter =
|
||||
SessionConverterProvider.getDefaultMongoConverter();
|
||||
|
||||
private Integer maxInactiveIntervalInSeconds = DEFAULT_INACTIVE_INTERVAL;
|
||||
private String collectionName = DEFAULT_COLLECTION_NAME;
|
||||
|
||||
@@ -71,11 +75,11 @@ public class MongoOperationsSessionRepository
|
||||
|
||||
public void save(MongoExpiringSession session) {
|
||||
DBObject sessionDbObject = convertToDBObject(session);
|
||||
this.mongoOperations.getCollection(this.collectionName).save(sessionDbObject);
|
||||
this.mongoOperations.save(sessionDbObject, this.collectionName);
|
||||
}
|
||||
|
||||
public MongoExpiringSession getSession(String id) {
|
||||
DBObject sessionWrapper = findSession(id);
|
||||
Document sessionWrapper = findSession(id);
|
||||
if (sessionWrapper == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -103,9 +107,8 @@ public class MongoOperationsSessionRepository
|
||||
if (query == null) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<DBObject> mapSessions = this.mongoOperations.find(query, DBObject.class,
|
||||
this.collectionName);
|
||||
for (DBObject dbSession : mapSessions) {
|
||||
List<Document> mapSessions = this.mongoOperations.find(query, Document.class, this.collectionName);
|
||||
for (Document dbSession : mapSessions) {
|
||||
MongoExpiringSession mapSession = convertToSession(dbSession);
|
||||
result.put(mapSession.getId(), mapSession);
|
||||
}
|
||||
@@ -123,13 +126,13 @@ public class MongoOperationsSessionRepository
|
||||
this.mongoSessionConverter.ensureIndexes(indexOperations);
|
||||
}
|
||||
|
||||
DBObject findSession(String id) {
|
||||
return this.mongoOperations.findById(id, DBObject.class, this.collectionName);
|
||||
Document findSession(String id) {
|
||||
return this.mongoOperations.findById(id, Document.class, this.collectionName);
|
||||
}
|
||||
|
||||
MongoExpiringSession convertToSession(DBObject session) {
|
||||
MongoExpiringSession convertToSession(Document session) {
|
||||
return (MongoExpiringSession) this.mongoSessionConverter.convert(session,
|
||||
TypeDescriptor.valueOf(DBObject.class),
|
||||
TypeDescriptor.valueOf(Document.class),
|
||||
TypeDescriptor.valueOf(MongoExpiringSession.class));
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,16 +21,16 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
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.apache.geode.cache.AttributesMutator;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.query.SelectResults;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
@@ -64,9 +64,9 @@ import static org.mockito.Mockito.verify;
|
||||
* @see org.junit.runner.RunWith
|
||||
* @see org.mockito.Mock
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.mockito.runners.MockitoJUnitRunner
|
||||
* @see org.mockito.junit.MockitoJUnitRunner
|
||||
* @see org.springframework.session.data.gemfire.GemFireOperationsSessionRepository
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @see org.apache.geode.cache.Region
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class GemFireOperationsSessionRepositoryTest {
|
||||
@@ -89,11 +89,9 @@ 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.<Object, ExpiringSession>getRegion())
|
||||
.willReturn(this.mockRegion);
|
||||
given(this.mockTemplate.<Object, ExpiringSession>getRegion()).willReturn(this.mockRegion);
|
||||
|
||||
this.sessionRepository = new GemFireOperationsSessionRepository(
|
||||
this.mockTemplate);
|
||||
@@ -113,8 +111,7 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
|
||||
@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,8 +125,7 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
|
||||
SelectResults<Object> mockSelectResults = mock(SelectResults.class);
|
||||
|
||||
given(mockSelectResults.asList())
|
||||
.willReturn(Collections.<Object>singletonList(mockSession));
|
||||
given(mockSelectResults.asList()).willReturn(Collections.<Object>singletonList(mockSession));
|
||||
|
||||
String indexName = "vip";
|
||||
String indexValue = "rwinch";
|
||||
@@ -138,11 +134,10 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
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<String, ExpiringSession> sessions = this.sessionRepository
|
||||
.findByIndexNameAndIndexValue(indexName, indexValue);
|
||||
Map<String, ExpiringSession> sessions =
|
||||
this.sessionRepository.findByIndexNameAndIndexValue(indexName, indexValue);
|
||||
|
||||
assertThat(sessions).isNotNull();
|
||||
assertThat(sessions.size()).isEqualTo(1);
|
||||
@@ -158,8 +153,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");
|
||||
@@ -213,10 +207,8 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
given(this.mockTemplate.find(eq(expectedOql), eq(principalName)))
|
||||
.willReturn(mockSelectResults);
|
||||
|
||||
Map<String, ExpiringSession> sessions = this.sessionRepository
|
||||
.findByIndexNameAndIndexValue(
|
||||
FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME,
|
||||
principalName);
|
||||
Map<String, ExpiringSession> sessions = this.sessionRepository.findByIndexNameAndIndexValue(
|
||||
FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, principalName);
|
||||
|
||||
assertThat(sessions).isNotNull();
|
||||
assertThat(sessions.isEmpty()).isTrue();
|
||||
@@ -227,8 +219,9 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
|
||||
@Test
|
||||
public void prepareQueryReturnsPrincipalNameOql() {
|
||||
String actualQql = this.sessionRepository
|
||||
.prepareQuery(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME);
|
||||
String actualQql = this.sessionRepository.prepareQuery(
|
||||
FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME);
|
||||
|
||||
String expectedOql = String.format(
|
||||
GemFireOperationsSessionRepository.FIND_SESSIONS_BY_PRINCIPAL_NAME_QUERY,
|
||||
this.sessionRepository.getFullyQualifiedRegionName());
|
||||
@@ -257,12 +250,9 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
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
|
||||
@@ -278,8 +268,7 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
|
||||
willAnswer(new Answer<Void>() {
|
||||
public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
ApplicationEvent applicationEvent = invocation.getArgumentAt(0,
|
||||
ApplicationEvent.class);
|
||||
ApplicationEvent applicationEvent = invocation.getArgument(0);
|
||||
|
||||
assertThat(applicationEvent).isInstanceOf(SessionDeletedEvent.class);
|
||||
|
||||
@@ -292,8 +281,7 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
|
||||
return null;
|
||||
}
|
||||
}).given(this.mockApplicationEventPublisher)
|
||||
.publishEvent(any(ApplicationEvent.class));
|
||||
}).given(this.mockApplicationEventPublisher).publishEvent(any(ApplicationEvent.class));
|
||||
|
||||
assertThat(this.sessionRepository.getSession(expectedSessionId)).isNull();
|
||||
|
||||
@@ -301,8 +289,7 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
verify(this.mockTemplate, times(1)).remove(eq(expectedSessionId));
|
||||
verify(mockSession, times(1)).isExpired();
|
||||
verify(mockSession, times(2)).getId();
|
||||
verify(this.mockApplicationEventPublisher, times(1))
|
||||
.publishEvent(isA(SessionDeletedEvent.class));
|
||||
verify(this.mockApplicationEventPublisher, times(1)).publishEvent(isA(SessionDeletedEvent.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -319,8 +306,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 +315,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();
|
||||
@@ -373,21 +355,16 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
given(this.mockTemplate.put(eq(expectedSessionId),
|
||||
isA(AbstractGemFireOperationsSessionRepository.GemFireSession.class)))
|
||||
.willAnswer(new Answer<ExpiringSession>() {
|
||||
public ExpiringSession answer(
|
||||
final InvocationOnMock invocation) throws Throwable {
|
||||
ExpiringSession session = invocation.getArgumentAt(1,
|
||||
ExpiringSession.class);
|
||||
public ExpiringSession answer(InvocationOnMock invocation) throws Throwable {
|
||||
ExpiringSession session = invocation.getArgument(1);
|
||||
|
||||
assertThat(session).isNotNull();
|
||||
assertThat(session.getId()).isEqualTo(expectedSessionId);
|
||||
assertThat(session.getCreationTime())
|
||||
.isEqualTo(expectedCreationTime);
|
||||
assertThat(session.getLastAccessedTime())
|
||||
.isEqualTo(expectedLastAccessTime);
|
||||
assertThat(session.getCreationTime()).isEqualTo(expectedCreationTime);
|
||||
assertThat(session.getLastAccessedTime()).isEqualTo(expectedLastAccessTime);
|
||||
assertThat(session.getMaxInactiveIntervalInSeconds())
|
||||
.isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
|
||||
assertThat(session.getAttributeNames().isEmpty())
|
||||
.isTrue();
|
||||
.isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
|
||||
assertThat(session.getAttributeNames().isEmpty()).isTrue();
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -415,8 +392,7 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
|
||||
willAnswer(new Answer<Void>() {
|
||||
public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
ApplicationEvent applicationEvent = invocation.getArgumentAt(0,
|
||||
ApplicationEvent.class);
|
||||
ApplicationEvent applicationEvent = invocation.getArgument(0);
|
||||
|
||||
assertThat(applicationEvent).isInstanceOf(SessionDeletedEvent.class);
|
||||
|
||||
@@ -429,15 +405,13 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
|
||||
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));
|
||||
verify(this.mockApplicationEventPublisher, times(1)).publishEvent(isA(SessionDeletedEvent.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -448,8 +422,7 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
|
||||
willAnswer(new Answer<Void>() {
|
||||
public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
ApplicationEvent applicationEvent = invocation.getArgumentAt(0,
|
||||
ApplicationEvent.class);
|
||||
ApplicationEvent applicationEvent = invocation.getArgument(0);
|
||||
|
||||
assertThat(applicationEvent).isInstanceOf(SessionDeletedEvent.class);
|
||||
|
||||
@@ -468,12 +441,10 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
this.sessionRepository.delete(expectedSessionId);
|
||||
|
||||
verify(this.mockTemplate, times(1)).remove(eq(expectedSessionId));
|
||||
verify(this.mockApplicationEventPublisher, times(1))
|
||||
.publishEvent(isA(SessionDeletedEvent.class));
|
||||
verify(this.mockApplicationEventPublisher, times(1)).publishEvent(isA(SessionDeletedEvent.class));
|
||||
}
|
||||
|
||||
protected abstract class GemfireOperationsAccessor extends GemfireAccessor
|
||||
implements GemfireOperations {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,15 +20,15 @@ import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.ExpirationAction;
|
||||
import com.gemstone.gemfire.cache.ExpirationAttributes;
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.RegionAttributes;
|
||||
import com.gemstone.gemfire.cache.RegionShortcut;
|
||||
import com.gemstone.gemfire.cache.client.ClientCache;
|
||||
import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.ExpirationAction;
|
||||
import org.apache.geode.cache.ExpirationAttributes;
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.RegionAttributes;
|
||||
import org.apache.geode.cache.RegionShortcut;
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
import org.apache.geode.cache.client.ClientRegionShortcut;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -60,12 +60,11 @@ import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
* @see org.springframework.data.gemfire.GemfireOperations
|
||||
* @see org.springframework.data.gemfire.GemfireTemplate
|
||||
* @see org.springframework.session.data.gemfire.GemFireOperationsSessionRepository
|
||||
* @see org.springframework.session.data.gemfire.config.annotation.web.http.
|
||||
* GemFireHttpSessionConfiguration
|
||||
* @see com.gemstone.gemfire.cache.Cache
|
||||
* @see com.gemstone.gemfire.cache.GemFireCache
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @see com.gemstone.gemfire.cache.client.ClientCache
|
||||
* @see org.springframework.session.data.gemfire.config.annotation.web.http.GemFireHttpSessionConfiguration
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
*/
|
||||
public class GemFireHttpSessionConfigurationTest {
|
||||
|
||||
|
||||
@@ -16,14 +16,15 @@
|
||||
|
||||
package org.springframework.session.data.gemfire.config.annotation.web.http.support;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.InterestResultPolicy;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.RegionAttributes;
|
||||
import com.gemstone.gemfire.cache.RegionShortcut;
|
||||
import com.gemstone.gemfire.cache.client.ClientCache;
|
||||
import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.InterestResultPolicy;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.RegionAttributes;
|
||||
import org.apache.geode.cache.RegionShortcut;
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
import org.apache.geode.cache.client.ClientRegionShortcut;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -50,16 +51,15 @@ import static org.mockito.Mockito.mock;
|
||||
* @see org.junit.Test
|
||||
* @see org.junit.rules.ExpectedException
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.springframework.session.data.gemfire.config.annotation.web.http.support.
|
||||
* GemFireCacheTypeAwareRegionFactoryBean
|
||||
* @see com.gemstone.gemfire.cache.Cache
|
||||
* @see com.gemstone.gemfire.cache.GemFireCache
|
||||
* @see com.gemstone.gemfire.cache.InterestResultPolicy
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @see com.gemstone.gemfire.cache.RegionAttributes
|
||||
* @see com.gemstone.gemfire.cache.RegionShortcut
|
||||
* @see com.gemstone.gemfire.cache.client.ClientCache
|
||||
* @see com.gemstone.gemfire.cache.client.ClientRegionShortcut
|
||||
* @see org.springframework.session.data.gemfire.config.annotation.web.http.support.GemFireCacheTypeAwareRegionFactoryBean
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.InterestResultPolicy
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.RegionAttributes
|
||||
* @see org.apache.geode.cache.RegionShortcut
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
* @see org.apache.geode.cache.client.ClientRegionShortcut
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class GemFireCacheTypeAwareRegionFactoryBeanTest {
|
||||
@@ -293,5 +293,4 @@ public class GemFireCacheTypeAwareRegionFactoryBeanTest {
|
||||
assertThat(this.regionFactoryBean.getServerRegionShortcut()).isEqualTo(
|
||||
GemFireCacheTypeAwareRegionFactoryBean.DEFAULT_SERVER_REGION_SHORTCUT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.session.data.gemfire.config.annotation.web.http.support;
|
||||
|
||||
import com.gemstone.gemfire.cache.query.Index;
|
||||
import org.apache.geode.cache.query.Index;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -19,11 +19,12 @@ package org.springframework.session.data.gemfire.support;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.RegionShortcut;
|
||||
import com.gemstone.gemfire.cache.client.ClientCache;
|
||||
import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.RegionShortcut;
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
import org.apache.geode.cache.client.ClientRegionShortcut;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -183,5 +184,4 @@ public class GemFireUtilsTest {
|
||||
assertThat(GemFireUtils.toRegionPath("/")).isEqualTo("//");
|
||||
assertThat(GemFireUtils.toRegionPath("")).isEqualTo("/");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.session.data.mongo;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -20,14 +21,16 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.DBCollection;
|
||||
import com.mongodb.DBObject;
|
||||
|
||||
import org.bson.Document;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
@@ -49,11 +52,12 @@ import static org.mockito.Mockito.verify;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class MongoOperationsSessionRepositoryTests {
|
||||
|
||||
@Mock
|
||||
MongoOperations mongoOperations;
|
||||
@Mock
|
||||
AbstractMongoSessionConverter converter;
|
||||
|
||||
@Mock
|
||||
MongoOperations mongoOperations;
|
||||
|
||||
MongoOperationsSessionRepository sut;
|
||||
|
||||
@Before
|
||||
@@ -78,31 +82,29 @@ public class MongoOperationsSessionRepositoryTests {
|
||||
// given
|
||||
MongoExpiringSession session = new MongoExpiringSession();
|
||||
BasicDBObject dbSession = new BasicDBObject();
|
||||
DBCollection collection = mock(DBCollection.class);
|
||||
|
||||
given(this.converter.convert(session,
|
||||
TypeDescriptor.valueOf(MongoExpiringSession.class),
|
||||
TypeDescriptor.valueOf(DBObject.class))).willReturn(dbSession);
|
||||
given(this.mongoOperations
|
||||
.getCollection(MongoOperationsSessionRepository.DEFAULT_COLLECTION_NAME))
|
||||
.willReturn(collection);
|
||||
// when
|
||||
this.sut.save(session);
|
||||
|
||||
// then
|
||||
verify(collection).save(dbSession);
|
||||
verify(this.mongoOperations).save(dbSession, MongoOperationsSessionRepository.DEFAULT_COLLECTION_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGetSession() throws Exception {
|
||||
// given
|
||||
String sessionId = UUID.randomUUID().toString();
|
||||
BasicDBObject dbSession = new BasicDBObject();
|
||||
given(this.mongoOperations.findById(sessionId, DBObject.class,
|
||||
MongoOperationsSessionRepository.DEFAULT_COLLECTION_NAME))
|
||||
.willReturn(dbSession);
|
||||
Document sessionDocument = new Document();
|
||||
|
||||
given(this.mongoOperations.findById(sessionId, Document.class,
|
||||
MongoOperationsSessionRepository.DEFAULT_COLLECTION_NAME)).willReturn(sessionDocument);
|
||||
|
||||
MongoExpiringSession session = new MongoExpiringSession();
|
||||
given(this.converter.convert(dbSession, TypeDescriptor.valueOf(DBObject.class),
|
||||
|
||||
given(this.converter.convert(sessionDocument, TypeDescriptor.valueOf(Document.class),
|
||||
TypeDescriptor.valueOf(MongoExpiringSession.class))).willReturn(session);
|
||||
|
||||
// when
|
||||
@@ -116,21 +118,22 @@ public class MongoOperationsSessionRepositoryTests {
|
||||
public void shouldHandleExpiredSession() throws Exception {
|
||||
// given
|
||||
String sessionId = UUID.randomUUID().toString();
|
||||
BasicDBObject dbSession = new BasicDBObject();
|
||||
given(this.mongoOperations.findById(sessionId, DBObject.class,
|
||||
MongoOperationsSessionRepository.DEFAULT_COLLECTION_NAME))
|
||||
.willReturn(dbSession);
|
||||
Document sessionDocument = new Document();
|
||||
|
||||
given(this.mongoOperations.findById(sessionId, Document.class,
|
||||
MongoOperationsSessionRepository.DEFAULT_COLLECTION_NAME)).willReturn(sessionDocument);
|
||||
|
||||
MongoExpiringSession session = mock(MongoExpiringSession.class);
|
||||
|
||||
given(session.isExpired()).willReturn(true);
|
||||
given(session.getId()).willReturn(sessionId);
|
||||
given(this.converter.convert(dbSession, TypeDescriptor.valueOf(DBObject.class),
|
||||
TypeDescriptor.valueOf(MongoExpiringSession.class))).willReturn(session);
|
||||
given(this.converter.convert(sessionDocument, TypeDescriptor.valueOf(Document.class),
|
||||
TypeDescriptor.valueOf(MongoExpiringSession.class))).willReturn(session);
|
||||
|
||||
// when
|
||||
this.sut.getSession(sessionId);
|
||||
|
||||
// then
|
||||
verify(this.mongoOperations).remove(any(DBObject.class),
|
||||
verify(this.mongoOperations).remove(any(Document.class),
|
||||
eq(MongoOperationsSessionRepository.DEFAULT_COLLECTION_NAME));
|
||||
}
|
||||
|
||||
@@ -139,12 +142,17 @@ public class MongoOperationsSessionRepositoryTests {
|
||||
// given
|
||||
String sessionId = UUID.randomUUID().toString();
|
||||
|
||||
Document sessionDocument = new Document();
|
||||
|
||||
given(this.mongoOperations.findById(eq(sessionId), eq(Document.class),
|
||||
eq(MongoOperationsSessionRepository.DEFAULT_COLLECTION_NAME))).willReturn(sessionDocument);
|
||||
|
||||
// when
|
||||
this.sut.delete(sessionId);
|
||||
|
||||
// then
|
||||
verify(this.mongoOperations).remove(any(DBObject.class),
|
||||
eq(MongoOperationsSessionRepository.DEFAULT_COLLECTION_NAME));
|
||||
verify(this.mongoOperations).remove(any(Document.class),
|
||||
eq(MongoOperationsSessionRepository.DEFAULT_COLLECTION_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -152,21 +160,23 @@ public class MongoOperationsSessionRepositoryTests {
|
||||
// given
|
||||
String principalNameIndexName = FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME;
|
||||
|
||||
DBObject dbSession = new BasicDBObject();
|
||||
given(this.converter.getQueryForIndex(anyString(), Matchers.anyObject()))
|
||||
.willReturn(mock(Query.class));
|
||||
given(this.mongoOperations.find(any(Query.class), eq(DBObject.class),
|
||||
Document document = new Document();
|
||||
|
||||
given(this.converter.getQueryForIndex(anyString(), Matchers.anyObject())).willReturn(mock(Query.class));
|
||||
given(this.mongoOperations.find(any(Query.class), eq(Document.class),
|
||||
eq(MongoOperationsSessionRepository.DEFAULT_COLLECTION_NAME)))
|
||||
.willReturn(Collections.singletonList(dbSession));
|
||||
.willReturn(Collections.singletonList(document));
|
||||
|
||||
String sessionId = UUID.randomUUID().toString();
|
||||
|
||||
MongoExpiringSession session = new MongoExpiringSession(sessionId, 1800);
|
||||
given(this.converter.convert(dbSession, TypeDescriptor.valueOf(DBObject.class),
|
||||
|
||||
given(this.converter.convert(document, TypeDescriptor.valueOf(Document.class),
|
||||
TypeDescriptor.valueOf(MongoExpiringSession.class))).willReturn(session);
|
||||
|
||||
// when
|
||||
Map<String, MongoExpiringSession> sessionsMap = this.sut
|
||||
.findByIndexNameAndIndexValue(principalNameIndexName, "john");
|
||||
Map<String, MongoExpiringSession> sessionsMap =
|
||||
this.sut.findByIndexNameAndIndexValue(principalNameIndexName, "john");
|
||||
|
||||
// then
|
||||
assertThat(sessionsMap).containsOnlyKeys(sessionId);
|
||||
@@ -185,5 +195,4 @@ public class MongoOperationsSessionRepositoryTests {
|
||||
// then
|
||||
assertThat(sessionsMap).isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.data.redis.connection.DefaultMessage;
|
||||
@@ -298,8 +298,6 @@ public class RedisOperationsSessionRepositoryTests {
|
||||
.willReturn(this.boundHashOperations);
|
||||
given(this.redisOperations.boundSetOps(anyString()))
|
||||
.willReturn(this.boundSetOperations);
|
||||
given(this.redisOperations.boundValueOps(anyString()))
|
||||
.willReturn(this.boundValueOperations);
|
||||
|
||||
this.redisRepository.save(session);
|
||||
|
||||
@@ -329,8 +327,6 @@ public class RedisOperationsSessionRepositoryTests {
|
||||
.willReturn(this.boundHashOperations);
|
||||
given(this.redisOperations.boundSetOps(anyString()))
|
||||
.willReturn(this.boundSetOperations);
|
||||
given(this.redisOperations.boundValueOps(anyString()))
|
||||
.willReturn(this.boundValueOperations);
|
||||
Map map = map(RedisOperationsSessionRepository.getSessionAttrNameKey(attrName),
|
||||
expected.getAttribute(attrName),
|
||||
RedisOperationsSessionRepository.CREATION_TIME_ATTR,
|
||||
@@ -356,10 +352,6 @@ public class RedisOperationsSessionRepositoryTests {
|
||||
public void deleteNullSession() {
|
||||
given(this.redisOperations.boundHashOps(anyString()))
|
||||
.willReturn(this.boundHashOperations);
|
||||
given(this.redisOperations.boundSetOps(anyString()))
|
||||
.willReturn(this.boundSetOperations);
|
||||
given(this.redisOperations.boundValueOps(anyString()))
|
||||
.willReturn(this.boundValueOperations);
|
||||
|
||||
String id = "abc";
|
||||
this.redisRepository.delete(id);
|
||||
@@ -474,8 +466,6 @@ public class RedisOperationsSessionRepositoryTests {
|
||||
@Test
|
||||
public void cleanupExpiredSessions() {
|
||||
String expiredId = "expired-id";
|
||||
given(this.redisOperations.boundHashOps(getKey(expiredId)))
|
||||
.willReturn(this.boundHashOperations);
|
||||
given(this.redisOperations.boundSetOps(anyString()))
|
||||
.willReturn(this.boundSetOperations);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.http.server.ServletServerHttpRequest;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -285,14 +285,11 @@ public class SessionRepositoryMessageInterceptorTests {
|
||||
return new AlmostNowMatcher();
|
||||
}
|
||||
|
||||
static class AlmostNowMatcher extends ArgumentMatcher<Long> {
|
||||
static class AlmostNowMatcher implements ArgumentMatcher<Long> {
|
||||
|
||||
@Override
|
||||
public boolean matches(Object argument) {
|
||||
long other = (Long) argument;
|
||||
public boolean matches(Long argument) {
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
long delta = now - other;
|
||||
long delta = now - argument;
|
||||
return delta >= 0 && delta < TimeUnit.SECONDS.toMillis(3);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<bean class="org.springframework.session.data.gemfire.config.annotation.web.http.GemFireHttpSessionConfiguration"
|
||||
p:indexableSessionAttributes="one, two, three" p:maxInactiveIntervalInSeconds="3600"
|
||||
p:serverRegionShortcut="#{T(com.gemstone.gemfire.cache.RegionShortcut).LOCAL}"
|
||||
p:serverRegionShortcut="#{T(org.apache.geode.cache.RegionShortcut).LOCAL}"
|
||||
p:springSessionGemFireRegionName="XmlExample"/>
|
||||
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user