Merge pull request #15312 from dreis2211

* pr/15312:
  Replace DirectFieldAccessor usages by hasFieldOrPropertyWithValue
pull/15325/head
Stephane Nicoll 6 years ago
commit ce8556e4d3

@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.system;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration;
import org.springframework.boot.actuate.health.ApplicationHealthIndicator; import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
import org.springframework.boot.actuate.system.DiskSpaceHealthIndicator; import org.springframework.boot.actuate.system.DiskSpaceHealthIndicator;
@ -63,10 +62,9 @@ public class DiskSpaceHealthIndicatorAutoConfigurationTests {
.withPropertyValues("management.health.diskspace.threshold=20MB") .withPropertyValues("management.health.diskspace.threshold=20MB")
.run((context) -> { .run((context) -> {
assertThat(context).hasSingleBean(DiskSpaceHealthIndicator.class); assertThat(context).hasSingleBean(DiskSpaceHealthIndicator.class);
DirectFieldAccessor dfa = new DirectFieldAccessor( assertThat(context.getBean(DiskSpaceHealthIndicator.class))
context.getBean(DiskSpaceHealthIndicator.class)); .hasFieldOrPropertyWithValue("threshold",
assertThat(dfa.getPropertyValue("threshold")) DataSize.ofMegabytes(20));
.isEqualTo(DataSize.ofMegabytes(20));
}); });
} }

@ -47,9 +47,7 @@ import org.springframework.amqp.rabbit.core.RabbitMessagingTemplate;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory; import org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.retry.MessageRecoverer; import org.springframework.amqp.rabbit.retry.MessageRecoverer;
import org.springframework.amqp.rabbit.support.ValueExpression;
import org.springframework.amqp.support.converter.MessageConverter; import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext; import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
@ -96,7 +94,6 @@ public class RabbitAutoConfigurationTests {
.getBean(RabbitMessagingTemplate.class); .getBean(RabbitMessagingTemplate.class);
CachingConnectionFactory connectionFactory = context CachingConnectionFactory connectionFactory = context
.getBean(CachingConnectionFactory.class); .getBean(CachingConnectionFactory.class);
DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory);
RabbitAdmin amqpAdmin = context.getBean(RabbitAdmin.class); RabbitAdmin amqpAdmin = context.getBean(RabbitAdmin.class);
assertThat(rabbitTemplate.getConnectionFactory()) assertThat(rabbitTemplate.getConnectionFactory())
.isEqualTo(connectionFactory); .isEqualTo(connectionFactory);
@ -105,9 +102,8 @@ public class RabbitAutoConfigurationTests {
.isEqualTo(rabbitTemplate); .isEqualTo(rabbitTemplate);
assertThat(amqpAdmin).isNotNull(); assertThat(amqpAdmin).isNotNull();
assertThat(connectionFactory.getHost()).isEqualTo("localhost"); assertThat(connectionFactory.getHost()).isEqualTo("localhost");
assertThat(dfa.getPropertyValue("publisherConfirms")) assertThat(connectionFactory.isPublisherConfirms()).isFalse();
.isEqualTo(false); assertThat(connectionFactory.isPublisherReturns()).isFalse();
assertThat(dfa.getPropertyValue("publisherReturns")).isEqualTo(false);
assertThat(context.containsBean("rabbitListenerContainerFactory")) assertThat(context.containsBean("rabbitListenerContainerFactory"))
.as("Listener container factory should be created by default") .as("Listener container factory should be created by default")
.isTrue(); .isTrue();
@ -155,11 +151,11 @@ public class RabbitAutoConfigurationTests {
assertThat(connectionFactory.getHost()).isEqualTo("remote-server"); assertThat(connectionFactory.getHost()).isEqualTo("remote-server");
assertThat(connectionFactory.getPort()).isEqualTo(9000); assertThat(connectionFactory.getPort()).isEqualTo(9000);
assertThat(connectionFactory.getVirtualHost()).isEqualTo("/vhost"); assertThat(connectionFactory.getVirtualHost()).isEqualTo("/vhost");
DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory); com.rabbitmq.client.ConnectionFactory rcf = connectionFactory
com.rabbitmq.client.ConnectionFactory rcf = (com.rabbitmq.client.ConnectionFactory) dfa .getRabbitConnectionFactory();
.getPropertyValue("rabbitConnectionFactory");
assertThat(rcf.getConnectionTimeout()).isEqualTo(123); assertThat(rcf.getConnectionTimeout()).isEqualTo(123);
assertThat((Address[]) dfa.getPropertyValue("addresses")).hasSize(1); assertThat((Address[]) ReflectionTestUtils.getField(connectionFactory,
"addresses")).hasSize(1);
}); });
} }
@ -170,14 +166,15 @@ public class RabbitAutoConfigurationTests {
.run((context) -> { .run((context) -> {
CachingConnectionFactory connectionFactory = context CachingConnectionFactory connectionFactory = context
.getBean(CachingConnectionFactory.class); .getBean(CachingConnectionFactory.class);
DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory); Address[] addresses = (Address[]) ReflectionTestUtils
Address[] addresses = (Address[]) dfa.getPropertyValue("addresses"); .getField(connectionFactory, "addresses");
assertThat(addresses).hasSize(1); assertThat(addresses).hasSize(1);
com.rabbitmq.client.ConnectionFactory rcf = mock( com.rabbitmq.client.ConnectionFactory rcf = mock(
com.rabbitmq.client.ConnectionFactory.class); com.rabbitmq.client.ConnectionFactory.class);
given(rcf.newConnection(isNull(), eq(addresses), anyString())) given(rcf.newConnection(isNull(), eq(addresses), anyString()))
.willReturn(mock(Connection.class)); .willReturn(mock(Connection.class));
dfa.setPropertyValue("rabbitConnectionFactory", rcf); ReflectionTestUtils.setField(connectionFactory,
"rabbitConnectionFactory", rcf);
connectionFactory.createConnection(); connectionFactory.createConnection();
verify(rcf).newConnection(isNull(), eq(addresses), eq("test#0")); verify(rcf).newConnection(isNull(), eq(addresses), eq("test#0"));
connectionFactory.resetConnection(); connectionFactory.resetConnection();
@ -236,9 +233,8 @@ public class RabbitAutoConfigurationTests {
CachingConnectionFactory connectionFactory = context CachingConnectionFactory connectionFactory = context
.getBean(CachingConnectionFactory.class); .getBean(CachingConnectionFactory.class);
RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.class); RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.class);
DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory); assertThat(connectionFactory.isPublisherConfirms()).isTrue();
assertThat(dfa.getPropertyValue("publisherConfirms")).isEqualTo(true); assertThat(connectionFactory.isPublisherReturns()).isTrue();
assertThat(dfa.getPropertyValue("publisherReturns")).isEqualTo(true);
assertThat(getMandatory(rabbitTemplate)).isTrue(); assertThat(getMandatory(rabbitTemplate)).isTrue();
}); });
} }
@ -250,8 +246,8 @@ public class RabbitAutoConfigurationTests {
RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.class); RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.class);
assertThat(rabbitTemplate.getMessageConverter()) assertThat(rabbitTemplate.getMessageConverter())
.isSameAs(context.getBean("myMessageConverter")); .isSameAs(context.getBean("myMessageConverter"));
DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitTemplate); assertThat(rabbitTemplate)
assertThat(dfa.getPropertyValue("retryTemplate")).isNull(); .hasFieldOrPropertyWithValue("retryTemplate", null);
}); });
} }
@ -267,17 +263,17 @@ public class RabbitAutoConfigurationTests {
"spring.rabbitmq.template.replyTimeout:456") "spring.rabbitmq.template.replyTimeout:456")
.run((context) -> { .run((context) -> {
RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.class); RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.class);
DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitTemplate); assertThat(rabbitTemplate)
assertThat(dfa.getPropertyValue("receiveTimeout")).isEqualTo(123L); .hasFieldOrPropertyWithValue("receiveTimeout", 123L);
assertThat(dfa.getPropertyValue("replyTimeout")).isEqualTo(456L); assertThat(rabbitTemplate).hasFieldOrPropertyWithValue("replyTimeout",
RetryTemplate retryTemplate = (RetryTemplate) dfa 456L);
.getPropertyValue("retryTemplate"); RetryTemplate retryTemplate = (RetryTemplate) ReflectionTestUtils
.getField(rabbitTemplate, "retryTemplate");
assertThat(retryTemplate).isNotNull(); assertThat(retryTemplate).isNotNull();
dfa = new DirectFieldAccessor(retryTemplate); SimpleRetryPolicy retryPolicy = (SimpleRetryPolicy) ReflectionTestUtils
SimpleRetryPolicy retryPolicy = (SimpleRetryPolicy) dfa .getField(retryTemplate, "retryPolicy");
.getPropertyValue("retryPolicy"); ExponentialBackOffPolicy backOffPolicy = (ExponentialBackOffPolicy) ReflectionTestUtils
ExponentialBackOffPolicy backOffPolicy = (ExponentialBackOffPolicy) dfa .getField(retryTemplate, "backOffPolicy");
.getPropertyValue("backOffPolicy");
assertThat(retryPolicy.getMaxAttempts()).isEqualTo(4); assertThat(retryPolicy.getMaxAttempts()).isEqualTo(4);
assertThat(backOffPolicy.getInitialInterval()).isEqualTo(2000); assertThat(backOffPolicy.getInitialInterval()).isEqualTo(2000);
assertThat(backOffPolicy.getMultiplier()).isEqualTo(1.5); assertThat(backOffPolicy.getMultiplier()).isEqualTo(1.5);
@ -293,16 +289,13 @@ public class RabbitAutoConfigurationTests {
"spring.rabbitmq.template.retry.initialInterval:2000") "spring.rabbitmq.template.retry.initialInterval:2000")
.run((context) -> { .run((context) -> {
RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.class); RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.class);
DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitTemplate); RetryTemplate retryTemplate = (RetryTemplate) ReflectionTestUtils
RetryTemplate retryTemplate = (RetryTemplate) dfa .getField(rabbitTemplate, "retryTemplate");
.getPropertyValue("retryTemplate");
assertThat(retryTemplate).isNotNull(); assertThat(retryTemplate).isNotNull();
dfa = new DirectFieldAccessor(retryTemplate); ExponentialBackOffPolicy backOffPolicy = (ExponentialBackOffPolicy) ReflectionTestUtils
assertThat(dfa.getPropertyValue("backOffPolicy")) .getField(retryTemplate, "backOffPolicy");
.isSameAs(context.getBean( assertThat(backOffPolicy).isSameAs(context.getBean(
RabbitRetryTemplateCustomizerConfiguration.class).backOffPolicy); RabbitRetryTemplateCustomizerConfiguration.class).backOffPolicy);
ExponentialBackOffPolicy backOffPolicy = (ExponentialBackOffPolicy) dfa
.getPropertyValue("backOffPolicy");
assertThat(backOffPolicy.getInitialInterval()).isEqualTo(100); assertThat(backOffPolicy.getInitialInterval()).isEqualTo(100);
}); });
} }
@ -389,13 +382,12 @@ public class RabbitAutoConfigurationTests {
.run((context) -> { .run((context) -> {
CachingConnectionFactory connectionFactory = context CachingConnectionFactory connectionFactory = context
.getBean(CachingConnectionFactory.class); .getBean(CachingConnectionFactory.class);
DirectFieldAccessor dfa = new DirectFieldAccessor(connectionFactory); assertThat(connectionFactory.getChannelCacheSize()).isEqualTo(23);
assertThat(dfa.getPropertyValue("channelCacheSize")).isEqualTo(23); assertThat(connectionFactory.getCacheMode())
assertThat(dfa.getPropertyValue("cacheMode"))
.isEqualTo(CacheMode.CONNECTION); .isEqualTo(CacheMode.CONNECTION);
assertThat(dfa.getPropertyValue("connectionCacheSize")).isEqualTo(2); assertThat(connectionFactory.getConnectionCacheSize()).isEqualTo(2);
assertThat(dfa.getPropertyValue("channelCheckoutTimeout")) assertThat(connectionFactory)
.isEqualTo(1000L); .hasFieldOrPropertyWithValue("channelCheckoutTimeout", 1000L);
}); });
} }
@ -453,10 +445,7 @@ public class RabbitAutoConfigurationTests {
SimpleRabbitListenerContainerFactory.class); SimpleRabbitListenerContainerFactory.class);
rabbitListenerContainerFactory.setTxSize(10); rabbitListenerContainerFactory.setTxSize(10);
verify(rabbitListenerContainerFactory).setTxSize(10); verify(rabbitListenerContainerFactory).setTxSize(10);
DirectFieldAccessor dfa = new DirectFieldAccessor( assertThat(rabbitListenerContainerFactory.getAdviceChain()).isNull();
rabbitListenerContainerFactory);
Advice[] adviceChain = (Advice[]) dfa.getPropertyValue("adviceChain");
assertThat(adviceChain).isNull();
}); });
} }
@ -483,15 +472,15 @@ public class RabbitAutoConfigurationTests {
SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = context SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = context
.getBean("rabbitListenerContainerFactory", .getBean("rabbitListenerContainerFactory",
SimpleRabbitListenerContainerFactory.class); SimpleRabbitListenerContainerFactory.class);
DirectFieldAccessor dfa = new DirectFieldAccessor( assertThat(rabbitListenerContainerFactory)
rabbitListenerContainerFactory); .hasFieldOrPropertyWithValue("concurrentConsumers", 5);
assertThat(dfa.getPropertyValue("concurrentConsumers")).isEqualTo(5); assertThat(rabbitListenerContainerFactory)
assertThat(dfa.getPropertyValue("maxConcurrentConsumers")) .hasFieldOrPropertyWithValue("maxConcurrentConsumers", 10);
.isEqualTo(10); assertThat(rabbitListenerContainerFactory)
assertThat(dfa.getPropertyValue("txSize")).isEqualTo(20); .hasFieldOrPropertyWithValue("txSize", 20);
assertThat(dfa.getPropertyValue("missingQueuesFatal")) assertThat(rabbitListenerContainerFactory)
.isEqualTo(false); .hasFieldOrPropertyWithValue("missingQueuesFatal", false);
checkCommonProps(context, dfa); checkCommonProps(context, rabbitListenerContainerFactory);
}); });
} }
@ -517,12 +506,11 @@ public class RabbitAutoConfigurationTests {
DirectRabbitListenerContainerFactory rabbitListenerContainerFactory = context DirectRabbitListenerContainerFactory rabbitListenerContainerFactory = context
.getBean("rabbitListenerContainerFactory", .getBean("rabbitListenerContainerFactory",
DirectRabbitListenerContainerFactory.class); DirectRabbitListenerContainerFactory.class);
DirectFieldAccessor dfa = new DirectFieldAccessor( assertThat(rabbitListenerContainerFactory)
rabbitListenerContainerFactory); .hasFieldOrPropertyWithValue("consumersPerQueue", 5);
assertThat(dfa.getPropertyValue("consumersPerQueue")).isEqualTo(5); assertThat(rabbitListenerContainerFactory)
assertThat(dfa.getPropertyValue("missingQueuesFatal")) .hasFieldOrPropertyWithValue("missingQueuesFatal", true);
.isEqualTo(true); checkCommonProps(context, rabbitListenerContainerFactory);
checkCommonProps(context, dfa);
}); });
} }
@ -562,15 +550,13 @@ public class RabbitAutoConfigurationTests {
private void assertListenerRetryTemplate( private void assertListenerRetryTemplate(
AbstractRabbitListenerContainerFactory<?> rabbitListenerContainerFactory, AbstractRabbitListenerContainerFactory<?> rabbitListenerContainerFactory,
RetryPolicy retryPolicy) { RetryPolicy retryPolicy) {
DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitListenerContainerFactory); Advice[] adviceChain = rabbitListenerContainerFactory.getAdviceChain();
Advice[] adviceChain = (Advice[]) dfa.getPropertyValue("adviceChain");
assertThat(adviceChain).isNotNull(); assertThat(adviceChain).isNotNull();
assertThat(adviceChain.length).isEqualTo(1); assertThat(adviceChain.length).isEqualTo(1);
dfa = new DirectFieldAccessor(adviceChain[0]); Advice advice = adviceChain[0];
RetryTemplate retryTemplate = (RetryTemplate) dfa RetryTemplate retryTemplate = (RetryTemplate) ReflectionTestUtils.getField(advice,
.getPropertyValue("retryOperations"); "retryOperations");
dfa = new DirectFieldAccessor(retryTemplate); assertThat(retryTemplate).hasFieldOrPropertyWithValue("retryPolicy", retryPolicy);
assertThat(dfa.getPropertyValue("retryPolicy")).isSameAs(retryPolicy);
} }
@Test @Test
@ -628,36 +614,36 @@ public class RabbitAutoConfigurationTests {
} }
private void checkCommonProps(AssertableApplicationContext context, private void checkCommonProps(AssertableApplicationContext context,
DirectFieldAccessor dfa) { AbstractRabbitListenerContainerFactory containerFactory) {
assertThat(dfa.getPropertyValue("autoStartup")).isEqualTo(Boolean.FALSE); assertThat(containerFactory).hasFieldOrPropertyWithValue("autoStartup",
assertThat(dfa.getPropertyValue("acknowledgeMode")) Boolean.FALSE);
.isEqualTo(AcknowledgeMode.MANUAL); assertThat(containerFactory).hasFieldOrPropertyWithValue("acknowledgeMode",
assertThat(dfa.getPropertyValue("prefetchCount")).isEqualTo(40); AcknowledgeMode.MANUAL);
assertThat(dfa.getPropertyValue("messageConverter")) assertThat(containerFactory).hasFieldOrPropertyWithValue("prefetchCount", 40);
.isSameAs(context.getBean("myMessageConverter")); assertThat(containerFactory).hasFieldOrPropertyWithValue("messageConverter",
assertThat(dfa.getPropertyValue("defaultRequeueRejected")) context.getBean("myMessageConverter"));
.isEqualTo(Boolean.FALSE); assertThat(containerFactory).hasFieldOrPropertyWithValue("defaultRequeueRejected",
assertThat(dfa.getPropertyValue("idleEventInterval")).isEqualTo(5L); Boolean.FALSE);
Advice[] adviceChain = (Advice[]) dfa.getPropertyValue("adviceChain"); assertThat(containerFactory).hasFieldOrPropertyWithValue("idleEventInterval", 5L);
Advice[] adviceChain = containerFactory.getAdviceChain();
assertThat(adviceChain).isNotNull(); assertThat(adviceChain).isNotNull();
assertThat(adviceChain.length).isEqualTo(1); assertThat(adviceChain.length).isEqualTo(1);
dfa = new DirectFieldAccessor(adviceChain[0]); Advice advice = adviceChain[0];
MessageRecoverer messageRecoverer = context.getBean("myMessageRecoverer", MessageRecoverer messageRecoverer = context.getBean("myMessageRecoverer",
MessageRecoverer.class); MessageRecoverer.class);
MethodInvocationRecoverer<?> mir = (MethodInvocationRecoverer<?>) dfa MethodInvocationRecoverer<?> mir = (MethodInvocationRecoverer<?>) ReflectionTestUtils
.getPropertyValue("recoverer"); .getField(advice, "recoverer");
Message message = mock(Message.class); Message message = mock(Message.class);
Exception ex = new Exception("test"); Exception ex = new Exception("test");
mir.recover(new Object[] { "foo", message }, ex); mir.recover(new Object[] { "foo", message }, ex);
verify(messageRecoverer).recover(message, ex); verify(messageRecoverer).recover(message, ex);
RetryTemplate retryTemplate = (RetryTemplate) dfa RetryTemplate retryTemplate = (RetryTemplate) ReflectionTestUtils.getField(advice,
.getPropertyValue("retryOperations"); "retryOperations");
assertThat(retryTemplate).isNotNull(); assertThat(retryTemplate).isNotNull();
dfa = new DirectFieldAccessor(retryTemplate); SimpleRetryPolicy retryPolicy = (SimpleRetryPolicy) ReflectionTestUtils
SimpleRetryPolicy retryPolicy = (SimpleRetryPolicy) dfa .getField(retryTemplate, "retryPolicy");
.getPropertyValue("retryPolicy"); ExponentialBackOffPolicy backOffPolicy = (ExponentialBackOffPolicy) ReflectionTestUtils
ExponentialBackOffPolicy backOffPolicy = (ExponentialBackOffPolicy) dfa .getField(retryTemplate, "backOffPolicy");
.getPropertyValue("backOffPolicy");
assertThat(retryPolicy.getMaxAttempts()).isEqualTo(4); assertThat(retryPolicy.getMaxAttempts()).isEqualTo(4);
assertThat(backOffPolicy.getInitialInterval()).isEqualTo(2000); assertThat(backOffPolicy.getInitialInterval()).isEqualTo(2000);
assertThat(backOffPolicy.getMultiplier()).isEqualTo(1.5); assertThat(backOffPolicy.getMultiplier()).isEqualTo(1.5);
@ -825,15 +811,11 @@ public class RabbitAutoConfigurationTests {
AssertableApplicationContext context) { AssertableApplicationContext context) {
CachingConnectionFactory connectionFactory = context CachingConnectionFactory connectionFactory = context
.getBean(CachingConnectionFactory.class); .getBean(CachingConnectionFactory.class);
return (com.rabbitmq.client.ConnectionFactory) new DirectFieldAccessor( return connectionFactory.getRabbitConnectionFactory();
connectionFactory).getPropertyValue("rabbitConnectionFactory");
} }
@SuppressWarnings("unchecked")
private boolean getMandatory(RabbitTemplate rabbitTemplate) { private boolean getMandatory(RabbitTemplate rabbitTemplate) {
ValueExpression<Boolean> expression = (ValueExpression<Boolean>) new DirectFieldAccessor( return rabbitTemplate.isMandatoryFor(mock(Message.class));
rabbitTemplate).getPropertyValue("mandatoryExpression");
return expression.getValue();
} }
@Configuration @Configuration

@ -22,7 +22,6 @@ import org.springframework.amqp.rabbit.config.DirectRabbitListenerContainerFacto
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer; import org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.beans.DirectFieldAccessor;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -237,24 +236,22 @@ public class RabbitPropertiesTests {
public void simpleContainerUseConsistentDefaultValues() { public void simpleContainerUseConsistentDefaultValues() {
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory(); SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
SimpleMessageListenerContainer container = factory.createListenerContainer(); SimpleMessageListenerContainer container = factory.createListenerContainer();
DirectFieldAccessor dfa = new DirectFieldAccessor(container);
RabbitProperties.SimpleContainer simple = this.properties.getListener() RabbitProperties.SimpleContainer simple = this.properties.getListener()
.getSimple(); .getSimple();
assertThat(simple.isAutoStartup()).isEqualTo(container.isAutoStartup()); assertThat(simple.isAutoStartup()).isEqualTo(container.isAutoStartup());
assertThat(simple.isMissingQueuesFatal()) assertThat(container).hasFieldOrPropertyWithValue("missingQueuesFatal",
.isEqualTo(dfa.getPropertyValue("missingQueuesFatal")); simple.isMissingQueuesFatal());
} }
@Test @Test
public void directContainerUseConsistentDefaultValues() { public void directContainerUseConsistentDefaultValues() {
DirectRabbitListenerContainerFactory factory = new DirectRabbitListenerContainerFactory(); DirectRabbitListenerContainerFactory factory = new DirectRabbitListenerContainerFactory();
DirectMessageListenerContainer container = factory.createListenerContainer(); DirectMessageListenerContainer container = factory.createListenerContainer();
DirectFieldAccessor dfa = new DirectFieldAccessor(container);
RabbitProperties.DirectContainer direct = this.properties.getListener() RabbitProperties.DirectContainer direct = this.properties.getListener()
.getDirect(); .getDirect();
assertThat(direct.isAutoStartup()).isEqualTo(container.isAutoStartup()); assertThat(direct.isAutoStartup()).isEqualTo(container.isAutoStartup());
assertThat(direct.isMissingQueuesFatal()) assertThat(container).hasFieldOrPropertyWithValue("missingQueuesFatal",
.isEqualTo(dfa.getPropertyValue("missingQueuesFatal")); direct.isMissingQueuesFatal());
} }
} }

@ -43,7 +43,6 @@ import org.infinispan.spring.provider.SpringEmbeddedCacheManager;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
@ -69,8 +68,10 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.cache.RedisCacheManager; import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
@ -284,8 +285,8 @@ public class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationT
RedisCacheManager cacheManager = getCacheManager(context, RedisCacheManager cacheManager = getCacheManager(context,
RedisCacheManager.class); RedisCacheManager.class);
assertThat(cacheManager.getCacheNames()).isEmpty(); assertThat(cacheManager.getCacheNames()).isEmpty();
org.springframework.data.redis.cache.RedisCacheConfiguration redisCacheConfiguration = (org.springframework.data.redis.cache.RedisCacheConfiguration) new DirectFieldAccessor( RedisCacheConfiguration redisCacheConfiguration = getDefaultRedisCacheConfiguration(
cacheManager).getPropertyValue("defaultCacheConfig"); cacheManager);
assertThat(redisCacheConfiguration.getTtl()) assertThat(redisCacheConfiguration.getTtl())
.isEqualTo(java.time.Duration.ofSeconds(15)); .isEqualTo(java.time.Duration.ofSeconds(15));
assertThat(redisCacheConfiguration.getAllowCacheNullValues()) assertThat(redisCacheConfiguration.getAllowCacheNullValues())
@ -307,8 +308,8 @@ public class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationT
RedisCacheManager cacheManager = getCacheManager(context, RedisCacheManager cacheManager = getCacheManager(context,
RedisCacheManager.class); RedisCacheManager.class);
assertThat(cacheManager.getCacheNames()).isEmpty(); assertThat(cacheManager.getCacheNames()).isEmpty();
org.springframework.data.redis.cache.RedisCacheConfiguration redisCacheConfiguration = (org.springframework.data.redis.cache.RedisCacheConfiguration) new DirectFieldAccessor( RedisCacheConfiguration redisCacheConfiguration = getDefaultRedisCacheConfiguration(
cacheManager).getPropertyValue("defaultCacheConfig"); cacheManager);
assertThat(redisCacheConfiguration.getTtl()) assertThat(redisCacheConfiguration.getTtl())
.isEqualTo(java.time.Duration.ofSeconds(30)); .isEqualTo(java.time.Duration.ofSeconds(30));
assertThat(redisCacheConfiguration.getKeyPrefixFor("")) assertThat(redisCacheConfiguration.getKeyPrefixFor(""))
@ -333,8 +334,8 @@ public class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationT
RedisCacheManager cacheManager = getCacheManager(context, RedisCacheManager cacheManager = getCacheManager(context,
RedisCacheManager.class); RedisCacheManager.class);
assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar"); assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
org.springframework.data.redis.cache.RedisCacheConfiguration redisCacheConfiguration = (org.springframework.data.redis.cache.RedisCacheConfiguration) new DirectFieldAccessor( RedisCacheConfiguration redisCacheConfiguration = getDefaultRedisCacheConfiguration(
cacheManager).getPropertyValue("defaultCacheConfig"); cacheManager);
assertThat(redisCacheConfiguration.getTtl()) assertThat(redisCacheConfiguration.getTtl())
.isEqualTo(java.time.Duration.ofMinutes(0)); .isEqualTo(java.time.Duration.ofMinutes(0));
assertThat(redisCacheConfiguration.getAllowCacheNullValues()) assertThat(redisCacheConfiguration.getAllowCacheNullValues())
@ -786,6 +787,12 @@ public class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationT
.isEqualTo(1L); .isEqualTo(1L);
} }
private RedisCacheConfiguration getDefaultRedisCacheConfiguration(
RedisCacheManager cacheManager) {
return (RedisCacheConfiguration) ReflectionTestUtils.getField(cacheManager,
"defaultCacheConfig");
}
@Configuration @Configuration
static class EmptyConfiguration { static class EmptyConfiguration {

@ -21,7 +21,6 @@ import java.util.Locale;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext; import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ApplicationContextRunner;
@ -99,8 +98,8 @@ public class MessageSourceAutoConfigurationTests {
private ContextConsumer<AssertableApplicationContext> assertCache(long expected) { private ContextConsumer<AssertableApplicationContext> assertCache(long expected) {
return (context) -> { return (context) -> {
assertThat(context).hasSingleBean(MessageSource.class); assertThat(context).hasSingleBean(MessageSource.class);
assertThat(new DirectFieldAccessor(context.getBean(MessageSource.class)) assertThat(context.getBean(MessageSource.class))
.getPropertyValue("cacheMillis")).isEqualTo(expected); .hasFieldOrPropertyWithValue("cacheMillis", expected);
}; };
} }
@ -138,9 +137,8 @@ public class MessageSourceAutoConfigurationTests {
@Test @Test
public void testFallbackDefault() { public void testFallbackDefault() {
this.contextRunner.withPropertyValues("spring.messages.basename:test/messages") this.contextRunner.withPropertyValues("spring.messages.basename:test/messages")
.run((context) -> assertThat( .run((context) -> assertThat(context.getBean(MessageSource.class))
isFallbackToSystemLocale(context.getBean(MessageSource.class))) .hasFieldOrPropertyWithValue("fallbackToSystemLocale", true));
.isTrue());
} }
@Test @Test
@ -148,17 +146,15 @@ public class MessageSourceAutoConfigurationTests {
this.contextRunner this.contextRunner
.withPropertyValues("spring.messages.basename:test/messages", .withPropertyValues("spring.messages.basename:test/messages",
"spring.messages.fallback-to-system-locale:false") "spring.messages.fallback-to-system-locale:false")
.run((context) -> assertThat( .run((context) -> assertThat(context.getBean(MessageSource.class))
isFallbackToSystemLocale(context.getBean(MessageSource.class))) .hasFieldOrPropertyWithValue("fallbackToSystemLocale", false));
.isFalse());
} }
@Test @Test
public void testFormatMessageDefault() { public void testFormatMessageDefault() {
this.contextRunner.withPropertyValues("spring.messages.basename:test/messages") this.contextRunner.withPropertyValues("spring.messages.basename:test/messages")
.run((context) -> assertThat( .run((context) -> assertThat(context.getBean(MessageSource.class))
isAlwaysUseMessageFormat(context.getBean(MessageSource.class))) .hasFieldOrPropertyWithValue("alwaysUseMessageFormat", false));
.isFalse());
} }
@Test @Test
@ -166,27 +162,15 @@ public class MessageSourceAutoConfigurationTests {
this.contextRunner this.contextRunner
.withPropertyValues("spring.messages.basename:test/messages", .withPropertyValues("spring.messages.basename:test/messages",
"spring.messages.always-use-message-format:true") "spring.messages.always-use-message-format:true")
.run((context) -> assertThat( .run((context) -> assertThat(context.getBean(MessageSource.class))
isAlwaysUseMessageFormat(context.getBean(MessageSource.class))) .hasFieldOrPropertyWithValue("alwaysUseMessageFormat", true));
.isTrue());
}
private boolean isFallbackToSystemLocale(MessageSource messageSource) {
return (boolean) new DirectFieldAccessor(messageSource)
.getPropertyValue("fallbackToSystemLocale");
}
private boolean isAlwaysUseMessageFormat(MessageSource messageSource) {
return (boolean) new DirectFieldAccessor(messageSource)
.getPropertyValue("alwaysUseMessageFormat");
} }
@Test @Test
public void testUseCodeAsDefaultMessageDefault() { public void testUseCodeAsDefaultMessageDefault() {
this.contextRunner.withPropertyValues("spring.messages.basename:test/messages") this.contextRunner.withPropertyValues("spring.messages.basename:test/messages")
.run((context) -> assertThat( .run((context) -> assertThat(context.getBean(MessageSource.class))
isUseCodeAsDefaultMessage(context.getBean(MessageSource.class))) .hasFieldOrPropertyWithValue("useCodeAsDefaultMessage", false));
.isFalse());
} }
@Test @Test
@ -194,14 +178,8 @@ public class MessageSourceAutoConfigurationTests {
this.contextRunner this.contextRunner
.withPropertyValues("spring.messages.basename:test/messages", .withPropertyValues("spring.messages.basename:test/messages",
"spring.messages.use-code-as-default-message:true") "spring.messages.use-code-as-default-message:true")
.run((context) -> assertThat( .run((context) -> assertThat(context.getBean(MessageSource.class))
isUseCodeAsDefaultMessage(context.getBean(MessageSource.class))) .hasFieldOrPropertyWithValue("useCodeAsDefaultMessage", true));
.isTrue());
}
private boolean isUseCodeAsDefaultMessage(MessageSource messageSource) {
return (boolean) new DirectFieldAccessor(messageSource)
.getPropertyValue("useCodeAsDefaultMessage");
} }
@Test @Test

@ -21,7 +21,6 @@ import java.util.List;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.FatalBeanException; import org.springframework.beans.FatalBeanException;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.NoUniqueBeanDefinitionException; import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
@ -38,6 +37,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -227,8 +227,8 @@ public class NoSuchBeanDefinitionFailureAnalyzerTests {
private static void addExclusions(NoSuchBeanDefinitionFailureAnalyzer analyzer, private static void addExclusions(NoSuchBeanDefinitionFailureAnalyzer analyzer,
Class<?>... classes) { Class<?>... classes) {
ConditionEvaluationReport report = (ConditionEvaluationReport) new DirectFieldAccessor( ConditionEvaluationReport report = (ConditionEvaluationReport) ReflectionTestUtils
analyzer).getPropertyValue("report"); .getField(analyzer, "report");
List<String> exclusions = new ArrayList<>(report.getExclusions()); List<String> exclusions = new ArrayList<>(report.getExclusions());
for (Class<?> c : classes) { for (Class<?> c : classes) {
exclusions.add(c.getName()); exclusions.add(c.getName());

@ -24,13 +24,13 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext; import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.rule.OutputCapture; import org.springframework.boot.test.rule.OutputCapture;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -118,10 +118,8 @@ public class InfluxDbAutoConfigurationTests {
private int getReadTimeoutProperty(AssertableApplicationContext context) { private int getReadTimeoutProperty(AssertableApplicationContext context) {
InfluxDB influxDB = context.getBean(InfluxDB.class); InfluxDB influxDB = context.getBean(InfluxDB.class);
Retrofit retrofit = (Retrofit) new DirectFieldAccessor(influxDB) Retrofit retrofit = (Retrofit) ReflectionTestUtils.getField(influxDB, "retrofit");
.getPropertyValue("retrofit"); OkHttpClient callFactory = (OkHttpClient) retrofit.callFactory();
OkHttpClient callFactory = (OkHttpClient) new DirectFieldAccessor(retrofit)
.getPropertyValue("callFactory");
return callFactory.readTimeoutMillis(); return callFactory.readTimeoutMillis();
} }

@ -20,7 +20,6 @@ import javax.management.MBeanServer;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration.IntegrationComponentScanConfiguration; import org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration.IntegrationComponentScanConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
@ -213,8 +212,8 @@ public class IntegrationAutoConfigurationTests {
this.contextRunner.withUserConfiguration(MessageSourceConfiguration.class) this.contextRunner.withUserConfiguration(MessageSourceConfiguration.class)
.run((context) -> { .run((context) -> {
assertThat(context).hasBean("myMessageSource"); assertThat(context).hasBean("myMessageSource");
assertThat(new DirectFieldAccessor(context.getBean("myMessageSource")) assertThat(((MessageProcessorMessageSource) context
.getPropertyValue("countsEnabled")).isEqualTo(true); .getBean("myMessageSource")).isCountsEnabled()).isTrue();
}); });
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,13 +27,13 @@ import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.jndi.JndiPropertiesHidingClassLoader; import org.springframework.boot.autoconfigure.jndi.JndiPropertiesHidingClassLoader;
import org.springframework.boot.autoconfigure.jndi.TestableInitialContextFactory; import org.springframework.boot.autoconfigure.jndi.TestableInitialContextFactory;
import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.jmx.export.MBeanExporter; import org.springframework.jmx.export.MBeanExporter;
import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
@ -110,8 +110,8 @@ public class JndiDataSourceAutoConfigurationTests {
assertThat(this.context.getBean(DataSource.class)).isEqualTo(dataSource); assertThat(this.context.getBean(DataSource.class)).isEqualTo(dataSource);
MBeanExporter exporter = this.context.getBean(MBeanExporter.class); MBeanExporter exporter = this.context.getBean(MBeanExporter.class);
Set<String> excludedBeans = (Set<String>) new DirectFieldAccessor(exporter) Set<String> excludedBeans = (Set<String>) ReflectionTestUtils.getField(exporter,
.getPropertyValue("excludedBeans"); "excludedBeans");
assertThat(excludedBeans).containsExactly("dataSource"); assertThat(excludedBeans).containsExactly("dataSource");
} }
@ -130,8 +130,8 @@ public class JndiDataSourceAutoConfigurationTests {
assertThat(this.context.getBean(DataSource.class)).isEqualTo(dataSource); assertThat(this.context.getBean(DataSource.class)).isEqualTo(dataSource);
for (MBeanExporter exporter : this.context.getBeansOfType(MBeanExporter.class) for (MBeanExporter exporter : this.context.getBeansOfType(MBeanExporter.class)
.values()) { .values()) {
Set<String> excludedBeans = (Set<String>) new DirectFieldAccessor(exporter) Set<String> excludedBeans = (Set<String>) ReflectionTestUtils
.getPropertyValue("excludedBeans"); .getField(exporter, "excludedBeans");
assertThat(excludedBeans).containsExactly("dataSource"); assertThat(excludedBeans).containsExactly("dataSource");
} }
} }
@ -151,8 +151,8 @@ public class JndiDataSourceAutoConfigurationTests {
assertThat(this.context.getBean(DataSource.class)).isEqualTo(dataSource); assertThat(this.context.getBean(DataSource.class)).isEqualTo(dataSource);
MBeanExporter exporter = this.context.getBean(MBeanExporter.class); MBeanExporter exporter = this.context.getBean(MBeanExporter.class);
Set<String> excludedBeans = (Set<String>) new DirectFieldAccessor(exporter) Set<String> excludedBeans = (Set<String>) ReflectionTestUtils.getField(exporter,
.getPropertyValue("excludedBeans"); "excludedBeans");
assertThat(excludedBeans).isEmpty(); assertThat(excludedBeans).isEmpty();
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,7 +26,6 @@ import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration;
@ -55,9 +54,8 @@ public class JerseyAutoConfigurationCustomLoadOnStartupTests {
@Test @Test
public void contextLoads() { public void contextLoads() {
assertThat( assertThat(this.context.getBean("jerseyServletRegistration"))
new DirectFieldAccessor(this.context.getBean("jerseyServletRegistration")) .hasFieldOrPropertyWithValue("loadOnStartup", 5);
.getPropertyValue("loadOnStartup")).isEqualTo(5);
} }
@MinimalWebConfiguration @MinimalWebConfiguration

@ -24,7 +24,6 @@ import org.junit.Test;
import org.messaginghub.pooled.jms.JmsPoolConnectionFactory; import org.messaginghub.pooled.jms.JmsPoolConnectionFactory;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration; import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration;
@ -184,8 +183,8 @@ public class JmsAutoConfigurationTests {
DefaultMessageListenerContainer container = getContainer(context, DefaultMessageListenerContainer container = getContainer(context,
"jmsListenerContainerFactory"); "jmsListenerContainerFactory");
assertThat(container.isSessionTransacted()).isFalse(); assertThat(container.isSessionTransacted()).isFalse();
assertThat(new DirectFieldAccessor(container) assertThat(container).hasFieldOrPropertyWithValue(
.getPropertyValue("transactionManager")).isSameAs( "transactionManager",
context.getBean(JtaTransactionManager.class)); context.getBean(JtaTransactionManager.class));
}); });
} }
@ -197,8 +196,8 @@ public class JmsAutoConfigurationTests {
DefaultMessageListenerContainer container = getContainer(context, DefaultMessageListenerContainer container = getContainer(context,
"jmsListenerContainerFactory"); "jmsListenerContainerFactory");
assertThat(container.isSessionTransacted()).isTrue(); assertThat(container.isSessionTransacted()).isTrue();
assertThat(new DirectFieldAccessor(container) assertThat(container)
.getPropertyValue("transactionManager")).isNull(); .hasFieldOrPropertyWithValue("transactionManager", null);
}); });
} }
@ -209,8 +208,8 @@ public class JmsAutoConfigurationTests {
DefaultMessageListenerContainer container = getContainer(context, DefaultMessageListenerContainer container = getContainer(context,
"jmsListenerContainerFactory"); "jmsListenerContainerFactory");
assertThat(container.isSessionTransacted()).isTrue(); assertThat(container.isSessionTransacted()).isTrue();
assertThat(new DirectFieldAccessor(container) assertThat(container)
.getPropertyValue("transactionManager")).isNull(); .hasFieldOrPropertyWithValue("transactionManager", null);
}); });
} }

@ -81,10 +81,8 @@ public class ActiveMQAutoConfigurationTests {
.getBean(CachingConnectionFactory.class); .getBean(CachingConnectionFactory.class);
assertThat(connectionFactory.getTargetConnectionFactory()) assertThat(connectionFactory.getTargetConnectionFactory())
.isInstanceOf(ActiveMQConnectionFactory.class); .isInstanceOf(ActiveMQConnectionFactory.class);
assertThat(connectionFactory) assertThat(connectionFactory.isCacheConsumers()).isFalse();
.hasFieldOrPropertyWithValue("cacheConsumers", false); assertThat(connectionFactory.isCacheProducers()).isTrue();
assertThat(connectionFactory)
.hasFieldOrPropertyWithValue("cacheProducers", true);
assertThat(connectionFactory.getSessionCacheSize()).isEqualTo(1); assertThat(connectionFactory.getSessionCacheSize()).isEqualTo(1);
}); });
} }
@ -100,10 +98,8 @@ public class ActiveMQAutoConfigurationTests {
assertThat(context).hasSingleBean(CachingConnectionFactory.class); assertThat(context).hasSingleBean(CachingConnectionFactory.class);
CachingConnectionFactory connectionFactory = context CachingConnectionFactory connectionFactory = context
.getBean(CachingConnectionFactory.class); .getBean(CachingConnectionFactory.class);
assertThat(connectionFactory) assertThat(connectionFactory.isCacheConsumers()).isTrue();
.hasFieldOrPropertyWithValue("cacheConsumers", true); assertThat(connectionFactory.isCacheProducers()).isFalse();
assertThat(connectionFactory)
.hasFieldOrPropertyWithValue("cacheProducers", false);
assertThat(connectionFactory.getSessionCacheSize()).isEqualTo(10); assertThat(connectionFactory.getSessionCacheSize()).isEqualTo(10);
}); });
} }

@ -81,10 +81,8 @@ public class ArtemisAutoConfigurationTests {
.getBean(CachingConnectionFactory.class); .getBean(CachingConnectionFactory.class);
assertThat(connectionFactory.getTargetConnectionFactory()) assertThat(connectionFactory.getTargetConnectionFactory())
.isInstanceOf(ActiveMQConnectionFactory.class); .isInstanceOf(ActiveMQConnectionFactory.class);
assertThat(connectionFactory) assertThat(connectionFactory.isCacheConsumers()).isFalse();
.hasFieldOrPropertyWithValue("cacheConsumers", false); assertThat(connectionFactory.isCacheProducers()).isTrue();
assertThat(connectionFactory)
.hasFieldOrPropertyWithValue("cacheProducers", true);
assertThat(connectionFactory.getSessionCacheSize()).isEqualTo(1); assertThat(connectionFactory.getSessionCacheSize()).isEqualTo(1);
}); });
} }
@ -100,10 +98,8 @@ public class ArtemisAutoConfigurationTests {
assertThat(context).hasSingleBean(CachingConnectionFactory.class); assertThat(context).hasSingleBean(CachingConnectionFactory.class);
CachingConnectionFactory connectionFactory = context CachingConnectionFactory connectionFactory = context
.getBean(CachingConnectionFactory.class); .getBean(CachingConnectionFactory.class);
assertThat(connectionFactory) assertThat(connectionFactory.isCacheConsumers()).isTrue();
.hasFieldOrPropertyWithValue("cacheConsumers", true); assertThat(connectionFactory.isCacheProducers()).isFalse();
assertThat(connectionFactory)
.hasFieldOrPropertyWithValue("cacheProducers", false);
assertThat(connectionFactory.getSessionCacheSize()).isEqualTo(10); assertThat(connectionFactory.getSessionCacheSize()).isEqualTo(10);
}); });
} }

@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.jmx;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration; import org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
@ -139,8 +138,7 @@ public class JmxAutoConfigurationTests {
this.context.refresh(); this.context.refresh();
IntegrationMBeanExporter mbeanExporter = this.context IntegrationMBeanExporter mbeanExporter = this.context
.getBean(IntegrationMBeanExporter.class); .getBean(IntegrationMBeanExporter.class);
DirectFieldAccessor dfa = new DirectFieldAccessor(mbeanExporter); assertThat(mbeanExporter).hasFieldOrPropertyWithValue("domain", "foo.my");
assertThat(dfa.getPropertyValue("domain")).isEqualTo("foo.my");
} }
@Configuration @Configuration

@ -36,7 +36,6 @@ import org.apache.kafka.streams.StreamsBuilder;
import org.apache.kafka.streams.StreamsConfig; import org.apache.kafka.streams.StreamsConfig;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -44,6 +43,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.kafka.annotation.EnableKafkaStreams; import org.springframework.kafka.annotation.EnableKafkaStreams;
import org.springframework.kafka.annotation.KafkaStreamsDefaultConfiguration; import org.springframework.kafka.annotation.KafkaStreamsDefaultConfiguration;
import org.springframework.kafka.config.AbstractKafkaListenerContainerFactory;
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory; import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
import org.springframework.kafka.config.KafkaListenerContainerFactory; import org.springframework.kafka.config.KafkaListenerContainerFactory;
import org.springframework.kafka.config.KafkaStreamsConfiguration; import org.springframework.kafka.config.KafkaStreamsConfiguration;
@ -52,6 +52,7 @@ import org.springframework.kafka.core.DefaultKafkaProducerFactory;
import org.springframework.kafka.core.KafkaAdmin; import org.springframework.kafka.core.KafkaAdmin;
import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.listener.AfterRollbackProcessor; import org.springframework.kafka.listener.AfterRollbackProcessor;
import org.springframework.kafka.listener.ContainerProperties;
import org.springframework.kafka.listener.ContainerProperties.AckMode; import org.springframework.kafka.listener.ContainerProperties.AckMode;
import org.springframework.kafka.listener.SeekToCurrentErrorHandler; import org.springframework.kafka.listener.SeekToCurrentErrorHandler;
import org.springframework.kafka.security.jaas.KafkaJaasLoginModuleInitializer; import org.springframework.kafka.security.jaas.KafkaJaasLoginModuleInitializer;
@ -61,6 +62,7 @@ import org.springframework.kafka.test.utils.KafkaTestUtils;
import org.springframework.kafka.transaction.ChainedKafkaTransactionManager; import org.springframework.kafka.transaction.ChainedKafkaTransactionManager;
import org.springframework.kafka.transaction.KafkaAwareTransactionManager; import org.springframework.kafka.transaction.KafkaAwareTransactionManager;
import org.springframework.kafka.transaction.KafkaTransactionManager; import org.springframework.kafka.transaction.KafkaTransactionManager;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.PlatformTransactionManager;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -448,55 +450,43 @@ public class KafkaAutoConfigurationTests {
.getBean(DefaultKafkaConsumerFactory.class); .getBean(DefaultKafkaConsumerFactory.class);
KafkaTemplate<?, ?> kafkaTemplate = context KafkaTemplate<?, ?> kafkaTemplate = context
.getBean(KafkaTemplate.class); .getBean(KafkaTemplate.class);
KafkaListenerContainerFactory<?> kafkaListenerContainerFactory = context AbstractKafkaListenerContainerFactory kafkaListenerContainerFactory = (AbstractKafkaListenerContainerFactory) context
.getBean(KafkaListenerContainerFactory.class); .getBean(KafkaListenerContainerFactory.class);
assertThat(kafkaTemplate.getMessageConverter()) assertThat(kafkaTemplate.getMessageConverter())
.isInstanceOf(MessagingMessageConverter.class); .isInstanceOf(MessagingMessageConverter.class);
assertThat(new DirectFieldAccessor(kafkaTemplate) assertThat(kafkaTemplate).hasFieldOrPropertyWithValue(
.getPropertyValue("producerFactory")) "producerFactory", producerFactory);
.isEqualTo(producerFactory);
assertThat(kafkaTemplate.getDefaultTopic()).isEqualTo("testTopic"); assertThat(kafkaTemplate.getDefaultTopic()).isEqualTo("testTopic");
DirectFieldAccessor dfa = new DirectFieldAccessor( assertThat(kafkaListenerContainerFactory.getConsumerFactory())
kafkaListenerContainerFactory);
assertThat(dfa.getPropertyValue("consumerFactory"))
.isEqualTo(consumerFactory); .isEqualTo(consumerFactory);
assertThat(dfa.getPropertyValue("containerProperties.ackMode")) ContainerProperties containerProperties = kafkaListenerContainerFactory
.getContainerProperties();
assertThat(containerProperties.getAckMode())
.isEqualTo(AckMode.MANUAL); .isEqualTo(AckMode.MANUAL);
assertThat(dfa.getPropertyValue("containerProperties.clientId")) assertThat(containerProperties.getClientId()).isEqualTo("client");
.isEqualTo("client"); assertThat(containerProperties.getAckCount()).isEqualTo(123);
assertThat(dfa.getPropertyValue("containerProperties.ackCount")) assertThat(containerProperties.getAckTime()).isEqualTo(456L);
.isEqualTo(123); assertThat(containerProperties.getPollTimeout()).isEqualTo(2000L);
assertThat(dfa.getPropertyValue("containerProperties.ackTime")) assertThat(containerProperties.getNoPollThreshold()).isEqualTo(2.5f);
.isEqualTo(456L); assertThat(containerProperties.getIdleEventInterval())
assertThat(dfa.getPropertyValue("concurrency")).isEqualTo(3);
assertThat(dfa.getPropertyValue("containerProperties.pollTimeout"))
.isEqualTo(2000L);
assertThat(
dfa.getPropertyValue("containerProperties.noPollThreshold"))
.isEqualTo(2.5f);
assertThat(
dfa.getPropertyValue("containerProperties.idleEventInterval"))
.isEqualTo(1000L); .isEqualTo(1000L);
assertThat( assertThat(containerProperties.getMonitorInterval()).isEqualTo(45);
dfa.getPropertyValue("containerProperties.monitorInterval")) assertThat(containerProperties.isLogContainerConfig()).isTrue();
.isEqualTo(45); assertThat(ReflectionTestUtils.getField(kafkaListenerContainerFactory,
assertThat(dfa "concurrency")).isEqualTo(3);
.getPropertyValue("containerProperties.logContainerConfig")) assertThat(kafkaListenerContainerFactory.isBatchListener()).isTrue();
.isEqualTo(Boolean.TRUE);
assertThat(dfa.getPropertyValue("batchListener")).isEqualTo(true);
assertThat( assertThat(
context.getBeansOfType(KafkaJaasLoginModuleInitializer.class)) context.getBeansOfType(KafkaJaasLoginModuleInitializer.class))
.hasSize(1); .hasSize(1);
KafkaJaasLoginModuleInitializer jaas = context KafkaJaasLoginModuleInitializer jaas = context
.getBean(KafkaJaasLoginModuleInitializer.class); .getBean(KafkaJaasLoginModuleInitializer.class);
dfa = new DirectFieldAccessor(jaas); assertThat(jaas).hasFieldOrPropertyWithValue("loginModule", "foo");
assertThat(dfa.getPropertyValue("loginModule")).isEqualTo("foo"); assertThat(jaas).hasFieldOrPropertyWithValue("controlFlag",
assertThat(dfa.getPropertyValue("controlFlag")).isEqualTo(
AppConfigurationEntry.LoginModuleControlFlag.REQUISITE); AppConfigurationEntry.LoginModuleControlFlag.REQUISITE);
assertThat(context.getBeansOfType(KafkaTransactionManager.class)) assertThat(context.getBeansOfType(KafkaTransactionManager.class))
.hasSize(1); .hasSize(1);
assertThat(((Map<String, String>) dfa.getPropertyValue("options"))) assertThat(((Map<String, String>) ReflectionTestUtils.getField(jaas,
.containsExactly(entry("useKeyTab", "true")); "options"))).containsExactly(entry("useKeyTab", "true"));
}); });
} }
@ -518,10 +508,8 @@ public class KafkaAutoConfigurationTests {
.run((context) -> { .run((context) -> {
ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory = context ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory = context
.getBean(ConcurrentKafkaListenerContainerFactory.class); .getBean(ConcurrentKafkaListenerContainerFactory.class);
DirectFieldAccessor dfa = new DirectFieldAccessor( assertThat(kafkaListenerContainerFactory).hasFieldOrPropertyWithValue(
kafkaListenerContainerFactory); "messageConverter", context.getBean("myMessageConverter"));
assertThat(dfa.getPropertyValue("messageConverter"))
.isSameAs(context.getBean("myMessageConverter"));
}); });
} }
@ -569,9 +557,9 @@ public class KafkaAutoConfigurationTests {
.run((context) -> { .run((context) -> {
ConcurrentKafkaListenerContainerFactory<?, ?> factory = context ConcurrentKafkaListenerContainerFactory<?, ?> factory = context
.getBean(ConcurrentKafkaListenerContainerFactory.class); .getBean(ConcurrentKafkaListenerContainerFactory.class);
DirectFieldAccessor dfa = new DirectFieldAccessor(factory); assertThat(factory).hasFieldOrPropertyWithValue(
assertThat(dfa.getPropertyValue("afterRollbackProcessor")) "afterRollbackProcessor",
.isSameAs(context.getBean("afterRollbackProcessor")); context.getBean("afterRollbackProcessor"));
}); });
} }
@ -580,10 +568,8 @@ public class KafkaAutoConfigurationTests {
this.contextRunner.run((context) -> { this.contextRunner.run((context) -> {
ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory = context ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory = context
.getBean(ConcurrentKafkaListenerContainerFactory.class); .getBean(ConcurrentKafkaListenerContainerFactory.class);
DirectFieldAccessor dfa = new DirectFieldAccessor( assertThat(kafkaListenerContainerFactory).hasFieldOrPropertyWithValue(
kafkaListenerContainerFactory); "replyTemplate", context.getBean(KafkaTemplate.class));
assertThat(dfa.getPropertyValue("replyTemplate"))
.isSameAs(context.getBean(KafkaTemplate.class));
}); });
} }

@ -37,7 +37,6 @@ import org.quartz.impl.calendar.MonthlyCalendar;
import org.quartz.impl.calendar.WeeklyCalendar; import org.quartz.impl.calendar.WeeklyCalendar;
import org.quartz.simpl.RAMJobStore; import org.quartz.simpl.RAMJobStore;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@ -233,16 +232,18 @@ public class QuartzAutoConfigurationTests {
assertThat(context).hasSingleBean(SchedulerFactoryBean.class); assertThat(context).hasSingleBean(SchedulerFactoryBean.class);
SchedulerFactoryBean schedulerFactory = context SchedulerFactoryBean schedulerFactory = context
.getBean(SchedulerFactoryBean.class); .getBean(SchedulerFactoryBean.class);
DirectFieldAccessor dfa = new DirectFieldAccessor(schedulerFactory);
QuartzProperties properties = new QuartzProperties(); QuartzProperties properties = new QuartzProperties();
assertThat(properties.isAutoStartup()) assertThat(properties.isAutoStartup())
.isEqualTo(schedulerFactory.isAutoStartup()); .isEqualTo(schedulerFactory.isAutoStartup());
assertThat((int) properties.getStartupDelay().getSeconds()) assertThat(schedulerFactory).hasFieldOrPropertyWithValue(
.isEqualTo(dfa.getPropertyValue("startupDelay")); "startupDelay",
assertThat(properties.isWaitForJobsToCompleteOnShutdown()).isEqualTo( (int) properties.getStartupDelay().getSeconds());
dfa.getPropertyValue("waitForJobsToCompleteOnShutdown")); assertThat(schedulerFactory).hasFieldOrPropertyWithValue(
assertThat(properties.isOverwriteExistingJobs()) "waitForJobsToCompleteOnShutdown",
.isEqualTo(dfa.getPropertyValue("overwriteExistingJobs")); properties.isWaitForJobsToCompleteOnShutdown());
assertThat(schedulerFactory).hasFieldOrPropertyWithValue(
"overwriteExistingJobs",
properties.isOverwriteExistingJobs());
}); });
@ -257,13 +258,13 @@ public class QuartzAutoConfigurationTests {
assertThat(context).hasSingleBean(SchedulerFactoryBean.class); assertThat(context).hasSingleBean(SchedulerFactoryBean.class);
SchedulerFactoryBean schedulerFactory = context SchedulerFactoryBean schedulerFactory = context
.getBean(SchedulerFactoryBean.class); .getBean(SchedulerFactoryBean.class);
DirectFieldAccessor dfa = new DirectFieldAccessor(schedulerFactory);
assertThat(schedulerFactory.isAutoStartup()).isFalse(); assertThat(schedulerFactory.isAutoStartup()).isFalse();
assertThat(dfa.getPropertyValue("startupDelay")).isEqualTo(60); assertThat(schedulerFactory)
assertThat(dfa.getPropertyValue("waitForJobsToCompleteOnShutdown")) .hasFieldOrPropertyWithValue("startupDelay", 60);
.isEqualTo(true); assertThat(schedulerFactory).hasFieldOrPropertyWithValue(
assertThat(dfa.getPropertyValue("overwriteExistingJobs")) "waitForJobsToCompleteOnShutdown", true);
.isEqualTo(true); assertThat(schedulerFactory)
.hasFieldOrPropertyWithValue("overwriteExistingJobs", true);
}); });
} }
@ -301,8 +302,8 @@ public class QuartzAutoConfigurationTests {
assertThat(context).hasSingleBean(SchedulerFactoryBean.class); assertThat(context).hasSingleBean(SchedulerFactoryBean.class);
SchedulerFactoryBean schedulerFactory = context SchedulerFactoryBean schedulerFactory = context
.getBean(SchedulerFactoryBean.class); .getBean(SchedulerFactoryBean.class);
DirectFieldAccessor dfa = new DirectFieldAccessor(schedulerFactory); assertThat(schedulerFactory).hasFieldOrPropertyWithValue("schedulerName",
assertThat(dfa.getPropertyValue("schedulerName")).isEqualTo(schedulerName); schedulerName);
}; };
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package org.springframework.boot.autoconfigure.session; package org.springframework.boot.autoconfigure.session;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.test.context.assertj.AssertableReactiveWebApplicationContext; import org.springframework.boot.test.context.assertj.AssertableReactiveWebApplicationContext;
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext; import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;
import org.springframework.session.ReactiveSessionRepository; import org.springframework.session.ReactiveSessionRepository;
@ -42,11 +41,6 @@ public abstract class AbstractSessionAutoConfigurationTests {
return type.cast(repository); return type.cast(repository);
} }
protected Integer getSessionTimeout(SessionRepository<?> sessionRepository) {
return (Integer) new DirectFieldAccessor(sessionRepository)
.getPropertyValue("defaultMaxInactiveInterval");
}
protected <T extends ReactiveSessionRepository<?>> T validateSessionRepository( protected <T extends ReactiveSessionRepository<?>> T validateSessionRepository(
AssertableReactiveWebApplicationContext context, Class<T> type) { AssertableReactiveWebApplicationContext context, Class<T> type) {
assertThat(context).hasSingleBean(WebSessionManager.class); assertThat(context).hasSingleBean(WebSessionManager.class);
@ -57,9 +51,4 @@ public abstract class AbstractSessionAutoConfigurationTests {
return type.cast(repository); return type.cast(repository);
} }
protected Integer getSessionTimeout(ReactiveSessionRepository<?> sessionRepository) {
return (Integer) new DirectFieldAccessor(sessionRepository)
.getPropertyValue("defaultMaxInactiveInterval");
}
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.session;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration; import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration; import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration;
@ -87,8 +86,7 @@ public class ReactiveSessionAutoConfigurationMongoTests
return (context) -> { return (context) -> {
ReactiveMongoOperationsSessionRepository repository = validateSessionRepository( ReactiveMongoOperationsSessionRepository repository = validateSessionRepository(
context, ReactiveMongoOperationsSessionRepository.class); context, ReactiveMongoOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository) assertThat(repository.getCollectionName()).isEqualTo(collectionName);
.getPropertyValue("collectionName")).isEqualTo(collectionName);
}; };
} }

@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.session;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisReactiveAutoConfiguration; import org.springframework.boot.autoconfigure.data.redis.RedisReactiveAutoConfiguration;
@ -81,10 +80,9 @@ public class ReactiveSessionAutoConfigurationRedisTests
return (context) -> { return (context) -> {
ReactiveRedisOperationsSessionRepository repository = validateSessionRepository( ReactiveRedisOperationsSessionRepository repository = validateSessionRepository(
context, ReactiveRedisOperationsSessionRepository.class); context, ReactiveRedisOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue("namespace")) assertThat(repository).hasFieldOrPropertyWithValue("namespace", namespace);
.isEqualTo(namespace); assertThat(repository).hasFieldOrPropertyWithValue("redisFlushMode",
assertThat(new DirectFieldAccessor(repository) flushMode);
.getPropertyValue("redisFlushMode")).isEqualTo(flushMode);
}; };
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,7 +20,6 @@ import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap; import com.hazelcast.core.IMap;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.FilteredClassLoader; import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext; import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;
@ -94,9 +93,8 @@ public class SessionAutoConfigurationHazelcastTests
.run((context) -> { .run((context) -> {
HazelcastSessionRepository repository = validateSessionRepository( HazelcastSessionRepository repository = validateSessionRepository(
context, HazelcastSessionRepository.class); context, HazelcastSessionRepository.class);
assertThat(new DirectFieldAccessor(repository) assertThat(repository).hasFieldOrPropertyWithValue(
.getPropertyValue("hazelcastFlushMode")) "hazelcastFlushMode", HazelcastFlushMode.IMMEDIATE);
.isEqualTo(HazelcastFlushMode.IMMEDIATE);
}); });
} }

@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.session;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
@ -72,16 +71,15 @@ public class SessionAutoConfigurationJdbcTests
private void validateDefaultConfig(AssertableWebApplicationContext context) { private void validateDefaultConfig(AssertableWebApplicationContext context) {
JdbcOperationsSessionRepository repository = validateSessionRepository(context, JdbcOperationsSessionRepository repository = validateSessionRepository(context,
JdbcOperationsSessionRepository.class); JdbcOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository).getPropertyValue("tableName")) assertThat(repository).hasFieldOrPropertyWithValue("tableName", "SPRING_SESSION");
.isEqualTo("SPRING_SESSION");
assertThat(context.getBean(JdbcSessionProperties.class).getInitializeSchema()) assertThat(context.getBean(JdbcSessionProperties.class).getInitializeSchema())
.isEqualTo(DataSourceInitializationMode.EMBEDDED); .isEqualTo(DataSourceInitializationMode.EMBEDDED);
assertThat(context.getBean(JdbcOperations.class) assertThat(context.getBean(JdbcOperations.class)
.queryForList("select * from SPRING_SESSION")).isEmpty(); .queryForList("select * from SPRING_SESSION")).isEmpty();
SpringBootJdbcHttpSessionConfiguration configuration = context SpringBootJdbcHttpSessionConfiguration configuration = context
.getBean(SpringBootJdbcHttpSessionConfiguration.class); .getBean(SpringBootJdbcHttpSessionConfiguration.class);
assertThat(new DirectFieldAccessor(configuration).getPropertyValue("cleanupCron")) assertThat(configuration).hasFieldOrPropertyWithValue("cleanupCron",
.isEqualTo("0 * * * * *"); "0 * * * * *");
} }
@Test @Test
@ -100,8 +98,8 @@ public class SessionAutoConfigurationJdbcTests
"spring.session.jdbc.initialize-schema=never").run((context) -> { "spring.session.jdbc.initialize-schema=never").run((context) -> {
JdbcOperationsSessionRepository repository = validateSessionRepository( JdbcOperationsSessionRepository repository = validateSessionRepository(
context, JdbcOperationsSessionRepository.class); context, JdbcOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository) assertThat(repository).hasFieldOrPropertyWithValue("tableName",
.getPropertyValue("tableName")).isEqualTo("SPRING_SESSION"); "SPRING_SESSION");
assertThat(context.getBean(JdbcSessionProperties.class) assertThat(context.getBean(JdbcSessionProperties.class)
.getInitializeSchema()) .getInitializeSchema())
.isEqualTo(DataSourceInitializationMode.NEVER); .isEqualTo(DataSourceInitializationMode.NEVER);
@ -119,8 +117,8 @@ public class SessionAutoConfigurationJdbcTests
.run((context) -> { .run((context) -> {
JdbcOperationsSessionRepository repository = validateSessionRepository( JdbcOperationsSessionRepository repository = validateSessionRepository(
context, JdbcOperationsSessionRepository.class); context, JdbcOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository) assertThat(repository).hasFieldOrPropertyWithValue("tableName",
.getPropertyValue("tableName")).isEqualTo("FOO_BAR"); "FOO_BAR");
assertThat(context.getBean(JdbcSessionProperties.class) assertThat(context.getBean(JdbcSessionProperties.class)
.getInitializeSchema()) .getInitializeSchema())
.isEqualTo(DataSourceInitializationMode.EMBEDDED); .isEqualTo(DataSourceInitializationMode.EMBEDDED);
@ -140,8 +138,8 @@ public class SessionAutoConfigurationJdbcTests
.isEqualTo("0 0 12 * * *"); .isEqualTo("0 0 12 * * *");
SpringBootJdbcHttpSessionConfiguration configuration = context SpringBootJdbcHttpSessionConfiguration configuration = context
.getBean(SpringBootJdbcHttpSessionConfiguration.class); .getBean(SpringBootJdbcHttpSessionConfiguration.class);
assertThat(new DirectFieldAccessor(configuration) assertThat(configuration).hasFieldOrPropertyWithValue("cleanupCron",
.getPropertyValue("cleanupCron")).isEqualTo("0 0 12 * * *"); "0 0 12 * * *");
}); });
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.session;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration; import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
@ -82,8 +81,8 @@ public class SessionAutoConfigurationMongoTests
return (context) -> { return (context) -> {
MongoOperationsSessionRepository repository = validateSessionRepository( MongoOperationsSessionRepository repository = validateSessionRepository(
context, MongoOperationsSessionRepository.class); context, MongoOperationsSessionRepository.class);
assertThat(new DirectFieldAccessor(repository) assertThat(repository).hasFieldOrPropertyWithValue("collectionName",
.getPropertyValue("collectionName")).isEqualTo(collectionName); collectionName);
}; };
} }

@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.session;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.session.RedisSessionConfiguration.SpringBootRedisHttpSessionConfiguration; import org.springframework.boot.autoconfigure.session.RedisSessionConfiguration.SpringBootRedisHttpSessionConfiguration;
@ -94,12 +93,12 @@ public class SessionAutoConfigurationRedisTests
context, RedisOperationsSessionRepository.class); context, RedisOperationsSessionRepository.class);
assertThat(repository.getSessionCreatedChannelPrefix()) assertThat(repository.getSessionCreatedChannelPrefix())
.isEqualTo(sessionCreatedChannelPrefix); .isEqualTo(sessionCreatedChannelPrefix);
assertThat(new DirectFieldAccessor(repository) assertThat(repository).hasFieldOrPropertyWithValue("redisFlushMode",
.getPropertyValue("redisFlushMode")).isEqualTo(flushMode); flushMode);
SpringBootRedisHttpSessionConfiguration configuration = context SpringBootRedisHttpSessionConfiguration configuration = context
.getBean(SpringBootRedisHttpSessionConfiguration.class); .getBean(SpringBootRedisHttpSessionConfiguration.class);
assertThat(new DirectFieldAccessor(configuration) assertThat(configuration).hasFieldOrPropertyWithValue("cleanupCron",
.getPropertyValue("cleanupCron")).isEqualTo(cleanupCron); cleanupCron);
}; };
} }

@ -23,7 +23,6 @@ import java.util.function.Consumer;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.task.TaskExecutorBuilder; import org.springframework.boot.task.TaskExecutorBuilder;
import org.springframework.boot.task.TaskExecutorCustomizer; import org.springframework.boot.task.TaskExecutorCustomizer;
@ -70,12 +69,12 @@ public class TaskExecutionAutoConfigurationTests {
"spring.task.execution.pool.keep-alive=5s", "spring.task.execution.pool.keep-alive=5s",
"spring.task.execution.thread-name-prefix=mytest-") "spring.task.execution.thread-name-prefix=mytest-")
.run(assertTaskExecutor((taskExecutor) -> { .run(assertTaskExecutor((taskExecutor) -> {
DirectFieldAccessor dfa = new DirectFieldAccessor(taskExecutor); assertThat(taskExecutor).hasFieldOrPropertyWithValue("queueCapacity",
assertThat(dfa.getPropertyValue("queueCapacity")).isEqualTo(10); 10);
assertThat(taskExecutor.getCorePoolSize()).isEqualTo(2); assertThat(taskExecutor.getCorePoolSize()).isEqualTo(2);
assertThat(taskExecutor.getMaxPoolSize()).isEqualTo(4); assertThat(taskExecutor.getMaxPoolSize()).isEqualTo(4);
assertThat(dfa.getPropertyValue("allowCoreThreadTimeOut")) assertThat(taskExecutor)
.isEqualTo(true); .hasFieldOrPropertyWithValue("allowCoreThreadTimeOut", true);
assertThat(taskExecutor.getKeepAliveSeconds()).isEqualTo(5); assertThat(taskExecutor.getKeepAliveSeconds()).isEqualTo(5);
assertThat(taskExecutor.getThreadNamePrefix()).isEqualTo("mytest-"); assertThat(taskExecutor.getThreadNamePrefix()).isEqualTo("mytest-");
})); }));

@ -27,7 +27,6 @@ import javax.validation.constraints.Size;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfigurationTests.CustomValidatorConfiguration.TestBeanPostProcessor; import org.springframework.boot.autoconfigure.validation.ValidationAutoConfigurationTests.CustomValidatorConfiguration.TestBeanPostProcessor;
import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.boot.test.util.TestPropertyValues;
@ -35,6 +34,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.validation.beanvalidation.CustomValidatorBean; import org.springframework.validation.beanvalidation.CustomValidatorBean;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
@ -195,9 +195,8 @@ public class ValidationAutoConfigurationTests {
.isSameAs(userMethodValidationPostProcessor); .isSameAs(userMethodValidationPostProcessor);
assertThat(this.context.getBeansOfType(MethodValidationPostProcessor.class)) assertThat(this.context.getBeansOfType(MethodValidationPostProcessor.class))
.hasSize(1); .hasSize(1);
assertThat(this.context.getBean(Validator.class)) assertThat(this.context.getBean(Validator.class)).isNotSameAs(ReflectionTestUtils
.isNotSameAs(new DirectFieldAccessor(userMethodValidationPostProcessor) .getField(userMethodValidationPostProcessor, "validator"));
.getPropertyValue("validator"));
} }
@Test @Test

@ -27,7 +27,6 @@ import javax.validation.ValidatorFactory;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration; import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
import org.springframework.boot.autoconfigure.validation.ValidatorAdapter; import org.springframework.boot.autoconfigure.validation.ValidatorAdapter;
@ -355,9 +354,8 @@ public class WebFluxAutoConfigurationTests {
Validator validator = context.getBean(Validator.class); Validator validator = context.getBean(Validator.class);
assertThat(validator).isInstanceOf(ValidatorAdapter.class); assertThat(validator).isInstanceOf(ValidatorAdapter.class);
Validator target = ((ValidatorAdapter) validator).getTarget(); Validator target = ((ValidatorAdapter) validator).getTarget();
assertThat(new DirectFieldAccessor(target) assertThat(target).hasFieldOrPropertyWithValue("targetValidator",
.getPropertyValue("targetValidator")) context.getBean("customValidator"));
.isSameAs(context.getBean("customValidator"));
}); });
} }

@ -21,7 +21,6 @@ import javax.servlet.http.HttpServletRequest;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.boot.web.servlet.MultipartConfigFactory; import org.springframework.boot.web.servlet.MultipartConfigFactory;
@ -178,9 +177,8 @@ public class DispatcherServletAutoConfigurationTests {
.containsExactly(false); .containsExactly(false);
assertThat(dispatcherServlet).extracting("enableLoggingRequestDetails") assertThat(dispatcherServlet).extracting("enableLoggingRequestDetails")
.containsExactly(false); .containsExactly(false);
assertThat(new DirectFieldAccessor( assertThat(context.getBean("dispatcherServletRegistration"))
context.getBean("dispatcherServletRegistration")) .hasFieldOrPropertyWithValue("loadOnStartup", -1);
.getPropertyValue("loadOnStartup")).isEqualTo(-1);
}); });
} }
@ -201,9 +199,8 @@ public class DispatcherServletAutoConfigurationTests {
.containsExactly(false); .containsExactly(false);
assertThat(dispatcherServlet).extracting("dispatchTraceRequest") assertThat(dispatcherServlet).extracting("dispatchTraceRequest")
.containsExactly(true); .containsExactly(true);
assertThat(new DirectFieldAccessor( assertThat(context.getBean("dispatcherServletRegistration"))
context.getBean("dispatcherServletRegistration")) .hasFieldOrPropertyWithValue("loadOnStartup", 5);
.getPropertyValue("loadOnStartup")).isEqualTo(5);
}); });
} }

@ -21,7 +21,7 @@ import java.util.List;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor; import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
@ -174,10 +174,8 @@ public class DeferredLogTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void switchTo() { public void switchTo() {
DirectFieldAccessor deferredLogFieldAccessor = new DirectFieldAccessor( List<String> lines = (List<String>) ReflectionTestUtils.getField(this.deferredLog,
this.deferredLog); "lines");
List<String> lines = (List<String>) deferredLogFieldAccessor
.getPropertyValue("lines");
assertThat(lines).isEmpty(); assertThat(lines).isEmpty();
this.deferredLog.error(this.message, this.throwable); this.deferredLog.error(this.message, this.throwable);

@ -22,7 +22,6 @@ import java.util.Set;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.core.task.TaskDecorator; import org.springframework.core.task.TaskDecorator;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.util.ReflectionTestUtils;
@ -48,11 +47,10 @@ public class TaskExecutorBuilderTests {
ThreadPoolTaskExecutor executor = this.builder.queueCapacity(10).corePoolSize(4) ThreadPoolTaskExecutor executor = this.builder.queueCapacity(10).corePoolSize(4)
.maxPoolSize(8).allowCoreThreadTimeOut(true) .maxPoolSize(8).allowCoreThreadTimeOut(true)
.keepAlive(Duration.ofMinutes(1)).build(); .keepAlive(Duration.ofMinutes(1)).build();
DirectFieldAccessor dfa = new DirectFieldAccessor(executor); assertThat(executor).hasFieldOrPropertyWithValue("queueCapacity", 10);
assertThat(dfa.getPropertyValue("queueCapacity")).isEqualTo(10);
assertThat(executor.getCorePoolSize()).isEqualTo(4); assertThat(executor.getCorePoolSize()).isEqualTo(4);
assertThat(executor.getMaxPoolSize()).isEqualTo(8); assertThat(executor.getMaxPoolSize()).isEqualTo(8);
assertThat(dfa.getPropertyValue("allowCoreThreadTimeOut")).isEqualTo(true); assertThat(executor).hasFieldOrPropertyWithValue("allowCoreThreadTimeOut", true);
assertThat(executor.getKeepAliveSeconds()).isEqualTo(60); assertThat(executor.getKeepAliveSeconds()).isEqualTo(60);
} }

@ -25,7 +25,6 @@ import org.junit.After;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent; import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
@ -100,13 +99,11 @@ public class SpringBootServletInitializerTests {
} }
@Test @Test
@SuppressWarnings("rawtypes")
public void mainClassHasSensibleDefault() { public void mainClassHasSensibleDefault() {
new WithConfigurationAnnotation() new WithConfigurationAnnotation()
.createRootApplicationContext(this.servletContext); .createRootApplicationContext(this.servletContext);
Class mainApplicationClass = (Class<?>) new DirectFieldAccessor(this.application) assertThat(this.application).hasFieldOrPropertyWithValue("mainApplicationClass",
.getPropertyValue("mainApplicationClass"); WithConfigurationAnnotation.class);
assertThat(mainApplicationClass).isEqualTo(WithConfigurationAnnotation.class);
} }
@Test @Test

Loading…
Cancel
Save