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");
}
use of org.springframework.beans.DirectFieldAccessor in project spring-boot by spring-projects.
the class RabbitAutoConfigurationTests method testRabbitTemplateRetry.
@Test
public void testRabbitTemplateRetry() {
load(TestConfiguration.class, "spring.rabbitmq.template.retry.enabled:true", "spring.rabbitmq.template.retry.maxAttempts:4", "spring.rabbitmq.template.retry.initialInterval:2000", "spring.rabbitmq.template.retry.multiplier:1.5", "spring.rabbitmq.template.retry.maxInterval:5000", "spring.rabbitmq.template.receiveTimeout:123", "spring.rabbitmq.template.replyTimeout:456");
RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitTemplate);
assertThat(dfa.getPropertyValue("receiveTimeout")).isEqualTo(123L);
assertThat(dfa.getPropertyValue("replyTimeout")).isEqualTo(456L);
RetryTemplate retryTemplate = (RetryTemplate) dfa.getPropertyValue("retryTemplate");
assertThat(retryTemplate).isNotNull();
dfa = new DirectFieldAccessor(retryTemplate);
SimpleRetryPolicy retryPolicy = (SimpleRetryPolicy) dfa.getPropertyValue("retryPolicy");
ExponentialBackOffPolicy backOffPolicy = (ExponentialBackOffPolicy) dfa.getPropertyValue("backOffPolicy");
assertThat(retryPolicy.getMaxAttempts()).isEqualTo(4);
assertThat(backOffPolicy.getInitialInterval()).isEqualTo(2000);
assertThat(backOffPolicy.getMultiplier()).isEqualTo(1.5);
assertThat(backOffPolicy.getMaxInterval()).isEqualTo(5000);
}
use of org.springframework.beans.DirectFieldAccessor in project spring-boot by spring-projects.
the class RabbitAutoConfigurationTests method testConnectionFactoryCacheSettings.
@Test
public void testConnectionFactoryCacheSettings() {
load(TestConfiguration.class, "spring.rabbitmq.cache.channel.size=23", "spring.rabbitmq.cache.channel.checkoutTimeout=1000", "spring.rabbitmq.cache.connection.mode=CONNECTION", "spring.rabbitmq.cache.connection.size=2");
CachingConnectionFactory connectionFactory = this.context.getBean(CachingConnectionFactory.class);
DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory);
assertThat(dfa.getPropertyValue("channelCacheSize")).isEqualTo(23);
assertThat(dfa.getPropertyValue("cacheMode")).isEqualTo(CacheMode.CONNECTION);
assertThat(dfa.getPropertyValue("connectionCacheSize")).isEqualTo(2);
assertThat(dfa.getPropertyValue("channelCheckoutTimeout")).isEqualTo(1000L);
}
use of org.springframework.beans.DirectFieldAccessor in project spring-boot by spring-projects.
the class RabbitAutoConfigurationTests method testConnectionFactoryWithOverrides.
@Test
public void testConnectionFactoryWithOverrides() {
load(TestConfiguration.class, "spring.rabbitmq.host:remote-server", "spring.rabbitmq.port:9000", "spring.rabbitmq.username:alice", "spring.rabbitmq.password:secret", "spring.rabbitmq.virtual_host:/vhost", "spring.rabbitmq.connection-timeout:123");
CachingConnectionFactory connectionFactory = this.context.getBean(CachingConnectionFactory.class);
assertThat(connectionFactory.getHost()).isEqualTo("remote-server");
assertThat(connectionFactory.getPort()).isEqualTo(9000);
assertThat(connectionFactory.getVirtualHost()).isEqualTo("/vhost");
DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory);
com.rabbitmq.client.ConnectionFactory rcf = (com.rabbitmq.client.ConnectionFactory) dfa.getPropertyValue("rabbitConnectionFactory");
assertThat(rcf.getConnectionTimeout()).isEqualTo(123);
assertThat((Address[]) dfa.getPropertyValue("addresses")).hasSize(1);
}
Aggregations