|
|
|
|
@ -49,6 +49,7 @@ import org.springframework.session.data.mongo.MongoIndexedSessionRepository;
@@ -49,6 +49,7 @@ import org.springframework.session.data.mongo.MongoIndexedSessionRepository;
|
|
|
|
|
import org.springframework.session.data.redis.RedisIndexedSessionRepository; |
|
|
|
|
import org.springframework.session.hazelcast.HazelcastIndexedSessionRepository; |
|
|
|
|
import org.springframework.session.jdbc.JdbcIndexedSessionRepository; |
|
|
|
|
import org.springframework.session.jdbc.PostgreSqlJdbcIndexedSessionRepositoryCustomizer; |
|
|
|
|
import org.springframework.session.jdbc.config.annotation.SpringSessionDataSource; |
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
@ -243,6 +244,24 @@ class SessionAutoConfigurationJdbcTests extends AbstractSessionAutoConfiguration
@@ -243,6 +244,24 @@ class SessionAutoConfigurationJdbcTests extends AbstractSessionAutoConfiguration
|
|
|
|
|
.hasBean("customInitializer")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void whenTheUserDefinesTheirOwnJdbcIndexedSessionRepositoryCustomizerThenDefaultConfigurationIsOverwritten() { |
|
|
|
|
String expectedCreateSessionAttributeQuery = """ |
|
|
|
|
INSERT INTO SPRING_SESSION_ATTRIBUTES (SESSION_PRIMARY_ID, ATTRIBUTE_NAME, ATTRIBUTE_BYTES) |
|
|
|
|
VALUES (?, ?, ?) |
|
|
|
|
ON CONFLICT (SESSION_PRIMARY_ID, ATTRIBUTE_NAME) |
|
|
|
|
DO UPDATE SET ATTRIBUTE_BYTES = EXCLUDED.ATTRIBUTE_BYTES |
|
|
|
|
"""; |
|
|
|
|
|
|
|
|
|
this.contextRunner.withUserConfiguration(CustomJdbcIndexedSessionRepositoryCustomizerConfiguration.class) |
|
|
|
|
.withConfiguration(AutoConfigurations.of(JdbcSessionConfiguration.class)).run((context) -> { |
|
|
|
|
JdbcIndexedSessionRepository repository = validateSessionRepository(context, |
|
|
|
|
JdbcIndexedSessionRepository.class); |
|
|
|
|
assertThat(repository).hasFieldOrPropertyWithValue("createSessionAttributeQuery", |
|
|
|
|
expectedCreateSessionAttributeQuery); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
|
static class SessionDataSourceConfiguration { |
|
|
|
|
|
|
|
|
|
@ -289,4 +308,14 @@ class SessionAutoConfigurationJdbcTests extends AbstractSessionAutoConfiguration
@@ -289,4 +308,14 @@ class SessionAutoConfigurationJdbcTests extends AbstractSessionAutoConfiguration
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
|
static class CustomJdbcIndexedSessionRepositoryCustomizerConfiguration { |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
PostgreSqlJdbcIndexedSessionRepositoryCustomizer postgreSqlJdbcIndexedSessionRepositoryCustomizer() { |
|
|
|
|
return new PostgreSqlJdbcIndexedSessionRepositoryCustomizer(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|