Search in sources :

Example 26 with DirectFieldAccessor

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);
}
Also used : LiteDeviceDelegatingViewResolver(org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor)

Example 27 with DirectFieldAccessor

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("");
}
Also used : LiteDeviceDelegatingViewResolver(org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 28 with DirectFieldAccessor

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);
}
Also used : DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 29 with DirectFieldAccessor

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();
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) JmsListenerEndpoint(org.springframework.jms.config.JmsListenerEndpoint) DefaultJmsListenerContainerFactory(org.springframework.jms.config.DefaultJmsListenerContainerFactory) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 30 with DirectFieldAccessor

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();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Set(java.util.Set) MBeanExporter(org.springframework.jmx.export.MBeanExporter) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) BasicDataSource(org.apache.commons.dbcp2.BasicDataSource) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Aggregations

DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)95 Test (org.junit.Test)79 List (java.util.List)25 Method (java.lang.reflect.Method)16 ScheduledMethodRunnable (org.springframework.scheduling.support.ScheduledMethodRunnable)16 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)15 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)15 ScheduledTaskRegistrar (org.springframework.scheduling.config.ScheduledTaskRegistrar)15 IntervalTask (org.springframework.scheduling.config.IntervalTask)8 CronTask (org.springframework.scheduling.config.CronTask)7 DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)5 CachingConnectionFactory (org.springframework.amqp.rabbit.connection.CachingConnectionFactory)4 DataSourceTransactionManagerAutoConfiguration (org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration)4 EmbeddedDataSourceConfiguration (org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration)4 HttpMessageConverter (org.springframework.http.converter.HttpMessageConverter)4 JdbcOperations (org.springframework.jdbc.core.JdbcOperations)4 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)4 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)4 JdbcOperationsSessionRepository (org.springframework.session.jdbc.JdbcOperationsSessionRepository)4 ViewResolver (org.springframework.web.servlet.ViewResolver)4