use of org.springframework.session.jdbc.JdbcOperationsSessionRepository in project spring-boot by spring-projects.
the class SessionAutoConfigurationJdbcTests method disableDatabaseInitializer.
@Test
public void disableDatabaseInitializer() {
load(Arrays.asList(EmbeddedDataSourceConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class), "spring.session.store-type=jdbc", "spring.session.jdbc.initializer.enabled=false");
JdbcOperationsSessionRepository repository = validateSessionRepository(JdbcOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue("tableName")).isEqualTo("SPRING_SESSION");
assertThat(this.context.getBean(SessionProperties.class).getJdbc().getInitializer().isEnabled()).isFalse();
this.thrown.expect(BadSqlGrammarException.class);
assertThat(this.context.getBean(JdbcOperations.class).queryForList("select * from SPRING_SESSION")).isEmpty();
}
use of org.springframework.session.jdbc.JdbcOperationsSessionRepository in project spring-boot by spring-projects.
the class SessionAutoConfigurationJdbcTests method defaultConfig.
@Test
public void defaultConfig() {
load(Arrays.asList(EmbeddedDataSourceConfiguration.class, JdbcTemplateAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class), "spring.session.store-type=jdbc");
JdbcOperationsSessionRepository repository = validateSessionRepository(JdbcOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue("tableName")).isEqualTo("SPRING_SESSION");
assertThat(this.context.getBean(SessionProperties.class).getJdbc().getInitializer().isEnabled()).isTrue();
assertThat(this.context.getBean(JdbcOperations.class).queryForList("select * from SPRING_SESSION")).isEmpty();
}
use of org.springframework.session.jdbc.JdbcOperationsSessionRepository in project spring-boot by spring-projects.
the class SessionAutoConfigurationJdbcTests method customTableName.
@Test
public void customTableName() {
load(Arrays.asList(EmbeddedDataSourceConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class), "spring.session.store-type=jdbc", "spring.session.jdbc.table-name=FOO_BAR", "spring.session.jdbc.schema=classpath:session/custom-schema-h2.sql");
JdbcOperationsSessionRepository repository = validateSessionRepository(JdbcOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue("tableName")).isEqualTo("FOO_BAR");
assertThat(this.context.getBean(SessionProperties.class).getJdbc().getInitializer().isEnabled()).isTrue();
assertThat(this.context.getBean(JdbcOperations.class).queryForList("select * from FOO_BAR")).isEmpty();
}
use of org.springframework.session.jdbc.JdbcOperationsSessionRepository in project spring-boot by spring-projects.
the class SessionAutoConfigurationJdbcTests method customTableNameWithDefaultSchemaDisablesInitializer.
@Test
public void customTableNameWithDefaultSchemaDisablesInitializer() {
load(Arrays.asList(EmbeddedDataSourceConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class), "spring.session.store-type=jdbc", "spring.session.jdbc.table-name=FOO_BAR");
JdbcOperationsSessionRepository repository = validateSessionRepository(JdbcOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue("tableName")).isEqualTo("FOO_BAR");
assertThat(this.context.getBean(SessionProperties.class).getJdbc().getInitializer().isEnabled()).isFalse();
this.thrown.expect(BadSqlGrammarException.class);
assertThat(this.context.getBean(JdbcOperations.class).queryForList("select * from SPRING_SESSION")).isEmpty();
}
Aggregations