use of org.springframework.beans.DirectFieldAccessor in project spring-boot by spring-projects.
the class WebMvcAutoConfigurationTests method testLogResolvedExceptionCustomization.
private void testLogResolvedExceptionCustomization(final boolean expected) {
HandlerExceptionResolver exceptionResolver = this.context.getBean(HandlerExceptionResolver.class);
assertThat(exceptionResolver).isInstanceOf(HandlerExceptionResolverComposite.class);
List<HandlerExceptionResolver> delegates = ((HandlerExceptionResolverComposite) exceptionResolver).getExceptionResolvers();
for (HandlerExceptionResolver delegate : delegates) {
if (delegate instanceof AbstractHandlerMethodAdapter) {
assertThat(new DirectFieldAccessor(delegate).getPropertyValue("warnLogger")).is(new Condition<Object>() {
@Override
public boolean matches(Object value) {
return (expected ? value != null : value == null);
}
});
}
}
}
use of org.springframework.beans.DirectFieldAccessor 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.beans.DirectFieldAccessor 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.beans.DirectFieldAccessor in project spring-boot by spring-projects.
the class SessionAutoConfigurationRedisTests method redisSessionStoreWithCustomizations.
@Test
public void redisSessionStoreWithCustomizations() {
load(Collections.<Class<?>>singletonList(RedisAutoConfiguration.class), "spring.session.store-type=redis", "spring.session.redis.namespace=foo", "spring.session.redis.flush-mode=immediate");
RedisOperationsSessionRepository repository = validateSessionRepository(RedisOperationsSessionRepository.class);
assertThat(repository.getSessionCreatedChannelPrefix()).isEqualTo("spring:session:foo:event:created:");
assertThat(new DirectFieldAccessor(repository).getPropertyValue("redisFlushMode")).isEqualTo(RedisFlushMode.IMMEDIATE);
}
use of org.springframework.beans.DirectFieldAccessor in project spring-boot by spring-projects.
the class SessionAutoConfigurationTests method mongoSessionStoreWithCustomizations.
@Test
public void mongoSessionStoreWithCustomizations() {
load(Arrays.asList(EmbeddedMongoAutoConfiguration.class, MongoAutoConfiguration.class, MongoDataAutoConfiguration.class), "spring.session.store-type=mongo", "spring.session.mongo.collection-name=foobar");
MongoOperationsSessionRepository repository = validateSessionRepository(MongoOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue("collectionName")).isEqualTo("foobar");
}
Aggregations