Search in sources :

Example 1 with SpringBootJdbcHttpSessionConfiguration

use of org.springframework.boot.autoconfigure.session.JdbcSessionConfiguration.SpringBootJdbcHttpSessionConfiguration in project spring-boot by spring-projects.

the class SessionAutoConfigurationJdbcTests method validateDefaultConfig.

private void validateDefaultConfig(AssertableWebApplicationContext context) {
    JdbcIndexedSessionRepository repository = validateSessionRepository(context, JdbcIndexedSessionRepository.class);
    assertThat(repository).hasFieldOrPropertyWithValue("defaultMaxInactiveInterval", (int) new ServerProperties().getServlet().getSession().getTimeout().getSeconds());
    assertThat(repository).hasFieldOrPropertyWithValue("tableName", "SPRING_SESSION");
    assertThat(context.getBean(JdbcSessionProperties.class).getInitializeSchema()).isEqualTo(DatabaseInitializationMode.EMBEDDED);
    assertThat(context.getBean(JdbcOperations.class).queryForList("select * from SPRING_SESSION")).isEmpty();
    SpringBootJdbcHttpSessionConfiguration configuration = context.getBean(SpringBootJdbcHttpSessionConfiguration.class);
    assertThat(configuration).hasFieldOrPropertyWithValue("cleanupCron", "0 * * * * *");
}
Also used : ServerProperties(org.springframework.boot.autoconfigure.web.ServerProperties) JdbcIndexedSessionRepository(org.springframework.session.jdbc.JdbcIndexedSessionRepository) JdbcOperations(org.springframework.jdbc.core.JdbcOperations) SpringBootJdbcHttpSessionConfiguration(org.springframework.boot.autoconfigure.session.JdbcSessionConfiguration.SpringBootJdbcHttpSessionConfiguration)

Example 2 with SpringBootJdbcHttpSessionConfiguration

use of org.springframework.boot.autoconfigure.session.JdbcSessionConfiguration.SpringBootJdbcHttpSessionConfiguration in project spring-boot by spring-projects.

the class SessionAutoConfigurationJdbcTests method customCleanupCron.

@Test
void customCleanupCron() {
    this.contextRunner.withPropertyValues("spring.session.store-type=jdbc", "spring.session.jdbc.cleanup-cron=0 0 12 * * *").run((context) -> {
        assertThat(context.getBean(JdbcSessionProperties.class).getCleanupCron()).isEqualTo("0 0 12 * * *");
        SpringBootJdbcHttpSessionConfiguration configuration = context.getBean(SpringBootJdbcHttpSessionConfiguration.class);
        assertThat(configuration).hasFieldOrPropertyWithValue("cleanupCron", "0 0 12 * * *");
    });
}
Also used : SpringBootJdbcHttpSessionConfiguration(org.springframework.boot.autoconfigure.session.JdbcSessionConfiguration.SpringBootJdbcHttpSessionConfiguration) Test(org.junit.jupiter.api.Test)

Example 3 with SpringBootJdbcHttpSessionConfiguration

use of org.springframework.boot.autoconfigure.session.JdbcSessionConfiguration.SpringBootJdbcHttpSessionConfiguration in project spring-boot by spring-projects.

the class SessionAutoConfigurationJdbcTests method customSaveMode.

@Test
void customSaveMode() {
    this.contextRunner.withPropertyValues("spring.session.store-type=jdbc", "spring.session.jdbc.save-mode=on-get-attribute").run((context) -> {
        assertThat(context.getBean(JdbcSessionProperties.class).getSaveMode()).isEqualTo(SaveMode.ON_GET_ATTRIBUTE);
        SpringBootJdbcHttpSessionConfiguration configuration = context.getBean(SpringBootJdbcHttpSessionConfiguration.class);
        assertThat(configuration).hasFieldOrPropertyWithValue("saveMode", SaveMode.ON_GET_ATTRIBUTE);
    });
}
Also used : SpringBootJdbcHttpSessionConfiguration(org.springframework.boot.autoconfigure.session.JdbcSessionConfiguration.SpringBootJdbcHttpSessionConfiguration) Test(org.junit.jupiter.api.Test)

Example 4 with SpringBootJdbcHttpSessionConfiguration

use of org.springframework.boot.autoconfigure.session.JdbcSessionConfiguration.SpringBootJdbcHttpSessionConfiguration in project spring-boot by spring-projects.

the class SessionAutoConfigurationJdbcTests method customFlushMode.

@Test
void customFlushMode() {
    this.contextRunner.withPropertyValues("spring.session.store-type=jdbc", "spring.session.jdbc.flush-mode=immediate").run((context) -> {
        assertThat(context.getBean(JdbcSessionProperties.class).getFlushMode()).isEqualTo(FlushMode.IMMEDIATE);
        SpringBootJdbcHttpSessionConfiguration configuration = context.getBean(SpringBootJdbcHttpSessionConfiguration.class);
        assertThat(configuration).hasFieldOrPropertyWithValue("flushMode", FlushMode.IMMEDIATE);
    });
}
Also used : SpringBootJdbcHttpSessionConfiguration(org.springframework.boot.autoconfigure.session.JdbcSessionConfiguration.SpringBootJdbcHttpSessionConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

SpringBootJdbcHttpSessionConfiguration (org.springframework.boot.autoconfigure.session.JdbcSessionConfiguration.SpringBootJdbcHttpSessionConfiguration)4 Test (org.junit.jupiter.api.Test)3 ServerProperties (org.springframework.boot.autoconfigure.web.ServerProperties)1 JdbcOperations (org.springframework.jdbc.core.JdbcOperations)1 JdbcIndexedSessionRepository (org.springframework.session.jdbc.JdbcIndexedSessionRepository)1