use of org.springframework.beans.DirectFieldAccessor in project spring-boot by spring-projects.
the class DeviceDelegatingViewResolverAutoConfigurationTests method getLiteDeviceDelegatingViewResolverAccessor.
private PropertyAccessor getLiteDeviceDelegatingViewResolverAccessor(String... configuration) {
load(configuration);
LiteDeviceDelegatingViewResolver liteDeviceDelegatingViewResolver = this.context.getBean("deviceDelegatingJspViewResolver", LiteDeviceDelegatingViewResolver.class);
return new DirectFieldAccessor(liteDeviceDelegatingViewResolver);
}
use of org.springframework.beans.DirectFieldAccessor in project spring-boot by spring-projects.
the class DeviceDelegatingViewResolverAutoConfigurationTests method defaultPropertyValues.
@Test
public void defaultPropertyValues() throws Exception {
load("spring.mobile.devicedelegatingviewresolver.enabled:true");
LiteDeviceDelegatingViewResolver liteDeviceDelegatingViewResolver = this.context.getBean("deviceDelegatingJspViewResolver", LiteDeviceDelegatingViewResolver.class);
DirectFieldAccessor accessor = new DirectFieldAccessor(liteDeviceDelegatingViewResolver);
assertThat(accessor.getPropertyValue("enableFallback")).isEqualTo(Boolean.FALSE);
assertThat(accessor.getPropertyValue("normalPrefix")).isEqualTo("");
assertThat(accessor.getPropertyValue("mobilePrefix")).isEqualTo("mobile/");
assertThat(accessor.getPropertyValue("tabletPrefix")).isEqualTo("tablet/");
assertThat(accessor.getPropertyValue("normalSuffix")).isEqualTo("");
assertThat(accessor.getPropertyValue("mobileSuffix")).isEqualTo("");
assertThat(accessor.getPropertyValue("tabletSuffix")).isEqualTo("");
}
use of org.springframework.beans.DirectFieldAccessor in project spring-boot by spring-projects.
the class KafkaAutoConfigurationTests method listenerProperties.
@Test
public void listenerProperties() {
load("spring.kafka.template.default-topic=testTopic", "spring.kafka.listener.ack-mode=MANUAL", "spring.kafka.listener.ack-count=123", "spring.kafka.listener.ack-time=456", "spring.kafka.listener.concurrency=3", "spring.kafka.listener.poll-timeout=2000");
DefaultKafkaProducerFactory<?, ?> producerFactory = this.context.getBean(DefaultKafkaProducerFactory.class);
DefaultKafkaConsumerFactory<?, ?> consumerFactory = this.context.getBean(DefaultKafkaConsumerFactory.class);
KafkaTemplate<?, ?> kafkaTemplate = this.context.getBean(KafkaTemplate.class);
KafkaListenerContainerFactory<?> kafkaListenerContainerFactory = this.context.getBean(KafkaListenerContainerFactory.class);
assertThat(new DirectFieldAccessor(kafkaTemplate).getPropertyValue("producerFactory")).isEqualTo(producerFactory);
assertThat(kafkaTemplate.getDefaultTopic()).isEqualTo("testTopic");
DirectFieldAccessor dfa = new DirectFieldAccessor(kafkaListenerContainerFactory);
assertThat(dfa.getPropertyValue("consumerFactory")).isEqualTo(consumerFactory);
assertThat(dfa.getPropertyValue("containerProperties.ackMode")).isEqualTo(AckMode.MANUAL);
assertThat(dfa.getPropertyValue("containerProperties.ackCount")).isEqualTo(123);
assertThat(dfa.getPropertyValue("containerProperties.ackTime")).isEqualTo(456L);
assertThat(dfa.getPropertyValue("concurrency")).isEqualTo(3);
assertThat(dfa.getPropertyValue("containerProperties.pollTimeout")).isEqualTo(2000L);
}
use of org.springframework.beans.DirectFieldAccessor in project spring-boot by spring-projects.
the class JmsAutoConfigurationTests method testDefaultContainerFactoryNonJtaTransactionManager.
@Test
public void testDefaultContainerFactoryNonJtaTransactionManager() {
this.context = createContext(TestConfiguration8.class, EnableJmsConfiguration.class);
JmsListenerContainerFactory<?> jmsListenerContainerFactory = this.context.getBean("jmsListenerContainerFactory", JmsListenerContainerFactory.class);
assertThat(jmsListenerContainerFactory.getClass()).isEqualTo(DefaultJmsListenerContainerFactory.class);
DefaultMessageListenerContainer listenerContainer = ((DefaultJmsListenerContainerFactory) jmsListenerContainerFactory).createListenerContainer(mock(JmsListenerEndpoint.class));
assertThat(listenerContainer.isSessionTransacted()).isTrue();
assertThat(new DirectFieldAccessor(listenerContainer).getPropertyValue("transactionManager")).isNull();
}
use of org.springframework.beans.DirectFieldAccessor in project spring-boot by spring-projects.
the class JndiDataSourceAutoConfigurationTests method standardDataSourceIsNotExcludedFromExport.
@SuppressWarnings("unchecked")
@Test
public void standardDataSourceIsNotExcludedFromExport() throws IllegalStateException, NamingException {
DataSource dataSource = mock(DataSource.class);
configureJndi("foo", dataSource);
this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.jndi-name:foo");
this.context.register(JndiDataSourceAutoConfiguration.class, MBeanExporterConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(DataSource.class)).isEqualTo(dataSource);
MBeanExporter exporter = this.context.getBean(MBeanExporter.class);
Set<String> excludedBeans = (Set<String>) new DirectFieldAccessor(exporter).getPropertyValue("excludedBeans");
assertThat(excludedBeans).isEmpty();
}
Aggregations