Compare commits
4 Commits
1.2.0.RC3
...
1.2.0.RELE
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a3ec2f4b9 | ||
|
|
458ac6e700 | ||
|
|
33321d2e53 | ||
|
|
20130f8e8a |
@@ -4,7 +4,7 @@ jacksonVersion=2.6.5
|
||||
jspApiVersion=2.0
|
||||
servletApiVersion=3.0.1
|
||||
jstlelVersion=1.2.5
|
||||
version=1.2.0.RC3
|
||||
version=1.2.0.RELEASE
|
||||
springDataRedisVersion=1.7.1.RELEASE
|
||||
commonsLoggingVersion=1.2
|
||||
junitVersion=4.12
|
||||
|
||||
@@ -109,7 +109,7 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* CREATE TABLE SPRING_SESSION_ATTRIBUTES (
|
||||
* SESSION_ID CHAR(36),
|
||||
* ATTRIBUTE_NAME VARCHAR(100),
|
||||
* ATTRIBUTE_NAME VARCHAR(200),
|
||||
* ATTRIBUTE_BYTES BYTEA,
|
||||
* CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_ID, ATTRIBUTE_NAME),
|
||||
* CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_ID) REFERENCES SPRING_SESSION(SESSION_ID) ON DELETE CASCADE
|
||||
|
||||
@@ -11,7 +11,7 @@ CREATE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (LAST_ACCESS_TIME);
|
||||
|
||||
CREATE TABLE SPRING_SESSION_ATTRIBUTES (
|
||||
SESSION_ID CHAR(36),
|
||||
ATTRIBUTE_NAME VARCHAR(100),
|
||||
ATTRIBUTE_NAME VARCHAR(200),
|
||||
ATTRIBUTE_BYTES BLOB,
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_ID, ATTRIBUTE_NAME),
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_ID) REFERENCES SPRING_SESSION(SESSION_ID) ON DELETE CASCADE
|
||||
|
||||
@@ -11,7 +11,7 @@ CREATE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (LAST_ACCESS_TIME);
|
||||
|
||||
CREATE TABLE SPRING_SESSION_ATTRIBUTES (
|
||||
SESSION_ID CHAR(36),
|
||||
ATTRIBUTE_NAME VARCHAR(100),
|
||||
ATTRIBUTE_NAME VARCHAR(200),
|
||||
ATTRIBUTE_BYTES BLOB,
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_ID, ATTRIBUTE_NAME),
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_ID) REFERENCES SPRING_SESSION(SESSION_ID) ON DELETE CASCADE
|
||||
|
||||
@@ -11,7 +11,7 @@ CREATE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (LAST_ACCESS_TIME);
|
||||
|
||||
CREATE TABLE SPRING_SESSION_ATTRIBUTES (
|
||||
SESSION_ID CHAR(36),
|
||||
ATTRIBUTE_NAME VARCHAR(100),
|
||||
ATTRIBUTE_NAME VARCHAR(200),
|
||||
ATTRIBUTE_BYTES LONGVARBINARY,
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_ID, ATTRIBUTE_NAME),
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_ID) REFERENCES SPRING_SESSION(SESSION_ID) ON DELETE CASCADE
|
||||
|
||||
@@ -11,7 +11,7 @@ CREATE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (LAST_ACCESS_TIME);
|
||||
|
||||
CREATE TABLE SPRING_SESSION_ATTRIBUTES (
|
||||
SESSION_ID CHAR(36),
|
||||
ATTRIBUTE_NAME VARCHAR(100),
|
||||
ATTRIBUTE_NAME VARCHAR(200),
|
||||
ATTRIBUTE_BYTES LONGVARBINARY,
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_ID, ATTRIBUTE_NAME),
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_ID) REFERENCES SPRING_SESSION(SESSION_ID) ON DELETE CASCADE
|
||||
|
||||
@@ -11,7 +11,7 @@ CREATE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (LAST_ACCESS_TIME);
|
||||
|
||||
CREATE TABLE SPRING_SESSION_ATTRIBUTES (
|
||||
SESSION_ID CHAR(36),
|
||||
ATTRIBUTE_NAME VARCHAR(100),
|
||||
ATTRIBUTE_NAME VARCHAR(200),
|
||||
ATTRIBUTE_BYTES BLOB,
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_ID, ATTRIBUTE_NAME),
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_ID) REFERENCES SPRING_SESSION(SESSION_ID) ON DELETE CASCADE
|
||||
|
||||
@@ -11,7 +11,7 @@ CREATE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (LAST_ACCESS_TIME);
|
||||
|
||||
CREATE TABLE SPRING_SESSION_ATTRIBUTES (
|
||||
SESSION_ID CHAR(36),
|
||||
ATTRIBUTE_NAME VARCHAR2(100 CHAR),
|
||||
ATTRIBUTE_NAME VARCHAR2(200 CHAR),
|
||||
ATTRIBUTE_BYTES BLOB,
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_ID, ATTRIBUTE_NAME),
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_ID) REFERENCES SPRING_SESSION(SESSION_ID) ON DELETE CASCADE
|
||||
|
||||
@@ -11,7 +11,7 @@ CREATE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (LAST_ACCESS_TIME);
|
||||
|
||||
CREATE TABLE SPRING_SESSION_ATTRIBUTES (
|
||||
SESSION_ID CHAR(36),
|
||||
ATTRIBUTE_NAME VARCHAR(100),
|
||||
ATTRIBUTE_NAME VARCHAR(200),
|
||||
ATTRIBUTE_BYTES BYTEA,
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_ID, ATTRIBUTE_NAME),
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_ID) REFERENCES SPRING_SESSION(SESSION_ID) ON DELETE CASCADE
|
||||
|
||||
@@ -11,7 +11,7 @@ CREATE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (LAST_ACCESS_TIME);
|
||||
|
||||
CREATE TABLE SPRING_SESSION_ATTRIBUTES (
|
||||
SESSION_ID CHAR(36),
|
||||
ATTRIBUTE_NAME VARCHAR(100),
|
||||
ATTRIBUTE_NAME VARCHAR(200),
|
||||
ATTRIBUTE_BYTES BLOB,
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_ID, ATTRIBUTE_NAME),
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_ID) REFERENCES SPRING_SESSION(SESSION_ID) ON DELETE CASCADE
|
||||
|
||||
@@ -11,7 +11,7 @@ CREATE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (LAST_ACCESS_TIME);
|
||||
|
||||
CREATE TABLE SPRING_SESSION_ATTRIBUTES (
|
||||
SESSION_ID CHAR(36),
|
||||
ATTRIBUTE_NAME VARCHAR(100),
|
||||
ATTRIBUTE_NAME VARCHAR(200),
|
||||
ATTRIBUTE_BYTES IMAGE,
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_ID, ATTRIBUTE_NAME),
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_ID) REFERENCES SPRING_SESSION(SESSION_ID) ON DELETE CASCADE
|
||||
|
||||
@@ -11,7 +11,7 @@ CREATE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (LAST_ACCESS_TIME);
|
||||
|
||||
CREATE TABLE SPRING_SESSION_ATTRIBUTES (
|
||||
SESSION_ID CHAR(36),
|
||||
ATTRIBUTE_NAME VARCHAR(100),
|
||||
ATTRIBUTE_NAME VARCHAR(200),
|
||||
ATTRIBUTE_BYTES IMAGE,
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_ID, ATTRIBUTE_NAME),
|
||||
CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_ID) REFERENCES SPRING_SESSION(SESSION_ID) ON DELETE CASCADE
|
||||
|
||||
@@ -1,159 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.session.data.mongo.config.annotation.web.http;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.mongodb.core.IndexOperations;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.session.data.mongo.MongoOperationsSessionRepository;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* @author Eddú Meléndez
|
||||
*/
|
||||
public class MongoHttpSessionConfigurationTest {
|
||||
|
||||
private AnnotationConfigApplicationContext context;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultCollectionName() {
|
||||
registerAndRefresh(DefaultConfiguration.class);
|
||||
MongoHttpSessionConfiguration session = this.context
|
||||
.getBean(MongoHttpSessionConfiguration.class);
|
||||
assertThat(session).isNotNull();
|
||||
assertThat(ReflectionTestUtils.getField(session, "collectionName")).isEqualTo(
|
||||
"sessions");
|
||||
MongoOperationsSessionRepository repository = this.context.getBean(MongoOperationsSessionRepository.class);
|
||||
assertThat(ReflectionTestUtils.getField(repository, "collectionName")).isEqualTo(
|
||||
"sessions");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customCollectionName() {
|
||||
registerAndRefresh(CustomCollectionNameConfiguration.class);
|
||||
MongoHttpSessionConfiguration session = this.context
|
||||
.getBean(MongoHttpSessionConfiguration.class);
|
||||
assertThat(session).isNotNull();
|
||||
assertThat(ReflectionTestUtils.getField(session, "collectionName")).isEqualTo(
|
||||
"testSessions");
|
||||
|
||||
MongoOperationsSessionRepository repository = this.context.getBean(MongoOperationsSessionRepository.class);
|
||||
assertThat(ReflectionTestUtils.getField(repository, "collectionName")).isEqualTo(
|
||||
"testSessions");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setCustomCollectionName() {
|
||||
registerAndRefresh(CustomConfiguration.class, CustomCollectionNameSetConfiguration.class);
|
||||
MongoHttpSessionConfiguration session = this.context
|
||||
.getBean(MongoHttpSessionConfiguration.class);
|
||||
assertThat(session).isNotNull();
|
||||
assertThat(ReflectionTestUtils.getField(session, "collectionName")).isEqualTo(
|
||||
"customSession");
|
||||
MongoOperationsSessionRepository repository = this.context.getBean(MongoOperationsSessionRepository.class);
|
||||
assertThat(ReflectionTestUtils.getField(repository, "collectionName")).isEqualTo(
|
||||
"customSession");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customMaxInactiveIntervalInSeconds() {
|
||||
registerAndRefresh(CustomConfiguration.class, CustomMaxInactiveIntervalInSecondsSetConfiguration.class);
|
||||
MongoHttpSessionConfiguration session = this.context
|
||||
.getBean(MongoHttpSessionConfiguration.class);
|
||||
assertThat(session).isNotNull();
|
||||
assertThat(ReflectionTestUtils.getField(session, "maxInactiveIntervalInSeconds")).isEqualTo(
|
||||
10);
|
||||
MongoOperationsSessionRepository repository = this.context.getBean(MongoOperationsSessionRepository.class);
|
||||
assertThat(ReflectionTestUtils.getField(repository, "maxInactiveIntervalInSeconds")).isEqualTo(
|
||||
10);
|
||||
}
|
||||
|
||||
private void registerAndRefresh(Class<?>... annotatedClasses) {
|
||||
this.context.register(annotatedClasses);
|
||||
this.context.refresh();
|
||||
}
|
||||
|
||||
static class BaseConfiguration {
|
||||
|
||||
@Bean
|
||||
public MongoOperations mongoOperations() throws UnknownHostException {
|
||||
MongoOperations mongoOperations = mock(MongoOperations.class);
|
||||
IndexOperations indexOperations = mock(IndexOperations.class);
|
||||
given(mongoOperations.indexOps(anyString())).willReturn(indexOperations);
|
||||
return mongoOperations;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableMongoHttpSession(collectionName = "testSessions")
|
||||
static class CustomCollectionNameConfiguration extends BaseConfiguration {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableMongoHttpSession
|
||||
static class DefaultConfiguration extends BaseConfiguration {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class CustomCollectionNameSetConfiguration extends MongoHttpSessionConfiguration {
|
||||
|
||||
CustomCollectionNameSetConfiguration() {
|
||||
setCollectionName("customSession");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class CustomMaxInactiveIntervalInSecondsSetConfiguration extends MongoHttpSessionConfiguration {
|
||||
|
||||
CustomMaxInactiveIntervalInSecondsSetConfiguration() {
|
||||
setMaxInactiveIntervalInSeconds(10);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class CustomConfiguration extends BaseConfiguration {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.session.data.mongo.config.annotation.web.http;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.beans.factory.UnsatisfiedDependencyException;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.mongodb.core.IndexOperations;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.session.data.mongo.AbstractMongoSessionConverter;
|
||||
import org.springframework.session.data.mongo.MongoOperationsSessionRepository;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for {@link MongoHttpSessionConfiguration}.
|
||||
*
|
||||
* @author Eddú Meléndez
|
||||
* @author Vedran Pavic
|
||||
*/
|
||||
public class MongoHttpSessionConfigurationTests {
|
||||
|
||||
private static final String COLLECTION_NAME = "testSessions";
|
||||
|
||||
private static final int MAX_INACTIVE_INTERVAL_IN_SECONDS = 600;
|
||||
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noMongoOperationsConfiguration() {
|
||||
this.thrown.expect(UnsatisfiedDependencyException.class);
|
||||
this.thrown.expectMessage("mongoSessionRepository");
|
||||
|
||||
registerAndRefresh(EmptyConfiguration.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultConfiguration() {
|
||||
registerAndRefresh(DefaultConfiguration.class);
|
||||
|
||||
assertThat(this.context.getBean(MongoOperationsSessionRepository.class))
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customCollectionName() {
|
||||
registerAndRefresh(CustomCollectionNameConfiguration.class);
|
||||
|
||||
MongoOperationsSessionRepository repository = this.context
|
||||
.getBean(MongoOperationsSessionRepository.class);
|
||||
assertThat(repository).isNotNull();
|
||||
assertThat(ReflectionTestUtils.getField(repository, "collectionName"))
|
||||
.isEqualTo(COLLECTION_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setCustomCollectionName() {
|
||||
registerAndRefresh(CustomCollectionNameSetConfiguration.class);
|
||||
|
||||
MongoHttpSessionConfiguration session = this.context
|
||||
.getBean(MongoHttpSessionConfiguration.class);
|
||||
assertThat(session).isNotNull();
|
||||
assertThat(ReflectionTestUtils.getField(session, "collectionName"))
|
||||
.isEqualTo(COLLECTION_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customMaxInactiveIntervalInSeconds() {
|
||||
registerAndRefresh(CustomMaxInactiveIntervalInSecondsConfiguration.class);
|
||||
|
||||
MongoOperationsSessionRepository repository = this.context
|
||||
.getBean(MongoOperationsSessionRepository.class);
|
||||
assertThat(repository).isNotNull();
|
||||
assertThat(ReflectionTestUtils.getField(repository, "maxInactiveIntervalInSeconds"))
|
||||
.isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setCustomMaxInactiveIntervalInSeconds() {
|
||||
registerAndRefresh(CustomMaxInactiveIntervalInSecondsSetConfiguration.class);
|
||||
|
||||
MongoOperationsSessionRepository repository = this.context
|
||||
.getBean(MongoOperationsSessionRepository.class);
|
||||
assertThat(repository).isNotNull();
|
||||
assertThat(ReflectionTestUtils.getField(repository, "maxInactiveIntervalInSeconds"))
|
||||
.isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setCustomSessionConverterConfiguration() {
|
||||
registerAndRefresh(CustomSessionConverterConfiguration.class);
|
||||
|
||||
MongoOperationsSessionRepository repository = this.context
|
||||
.getBean(MongoOperationsSessionRepository.class);
|
||||
AbstractMongoSessionConverter mongoSessionConverter = this.context
|
||||
.getBean(AbstractMongoSessionConverter.class);
|
||||
assertThat(repository).isNotNull();
|
||||
assertThat(mongoSessionConverter).isNotNull();
|
||||
assertThat(ReflectionTestUtils.getField(repository, "mongoSessionConverter"))
|
||||
.isEqualTo(mongoSessionConverter);
|
||||
}
|
||||
|
||||
private void registerAndRefresh(Class<?>... annotatedClasses) {
|
||||
this.context.register(annotatedClasses);
|
||||
this.context.refresh();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableMongoHttpSession
|
||||
static class EmptyConfiguration {
|
||||
|
||||
}
|
||||
|
||||
static class BaseConfiguration {
|
||||
|
||||
@Bean
|
||||
public MongoOperations mongoOperations() throws UnknownHostException {
|
||||
MongoOperations mongoOperations = mock(MongoOperations.class);
|
||||
IndexOperations indexOperations = mock(IndexOperations.class);
|
||||
given(mongoOperations.indexOps(anyString())).willReturn(indexOperations);
|
||||
return mongoOperations;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableMongoHttpSession
|
||||
static class DefaultConfiguration extends BaseConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class MongoConfiguration extends BaseConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableMongoHttpSession(collectionName = COLLECTION_NAME)
|
||||
static class CustomCollectionNameConfiguration extends BaseConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Import(MongoConfiguration.class)
|
||||
static class CustomCollectionNameSetConfiguration extends MongoHttpSessionConfiguration {
|
||||
|
||||
CustomCollectionNameSetConfiguration() {
|
||||
setCollectionName(COLLECTION_NAME);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableMongoHttpSession(maxInactiveIntervalInSeconds = MAX_INACTIVE_INTERVAL_IN_SECONDS)
|
||||
static class CustomMaxInactiveIntervalInSecondsConfiguration extends BaseConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Import(MongoConfiguration.class)
|
||||
static class CustomMaxInactiveIntervalInSecondsSetConfiguration extends MongoHttpSessionConfiguration {
|
||||
|
||||
CustomMaxInactiveIntervalInSecondsSetConfiguration() {
|
||||
setMaxInactiveIntervalInSeconds(MAX_INACTIVE_INTERVAL_IN_SECONDS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Import(MongoConfiguration.class)
|
||||
static class CustomSessionConverterConfiguration extends MongoHttpSessionConfiguration {
|
||||
|
||||
@Bean
|
||||
public AbstractMongoSessionConverter mongoSessionConverter() {
|
||||
return mock(AbstractMongoSessionConverter.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user