Search in sources :

Example 16 with DirectFieldAccessor

use of org.springframework.beans.DirectFieldAccessor in project spring-framework by spring-projects.

the class MessageBrokerConfigurationTests method customPathMatcher.

@Test
public void customPathMatcher() {
    SimpleBrokerMessageHandler broker = this.customContext.getBean(SimpleBrokerMessageHandler.class);
    DefaultSubscriptionRegistry registry = (DefaultSubscriptionRegistry) broker.getSubscriptionRegistry();
    assertEquals("a.a", registry.getPathMatcher().combine("a", "a"));
    SimpAnnotationMethodMessageHandler handler = this.customContext.getBean(SimpAnnotationMethodMessageHandler.class);
    assertEquals("a.a", handler.getPathMatcher().combine("a", "a"));
    DefaultUserDestinationResolver resolver = this.customContext.getBean(DefaultUserDestinationResolver.class);
    assertNotNull(resolver);
    assertEquals(false, new DirectFieldAccessor(resolver).getPropertyValue("keepLeadingSlash"));
}
Also used : DefaultSubscriptionRegistry(org.springframework.messaging.simp.broker.DefaultSubscriptionRegistry) SimpleBrokerMessageHandler(org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) SimpAnnotationMethodMessageHandler(org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler) DefaultUserDestinationResolver(org.springframework.messaging.simp.user.DefaultUserDestinationResolver) Test(org.junit.Test)

Example 17 with DirectFieldAccessor

use of org.springframework.beans.DirectFieldAccessor in project spring-framework by spring-projects.

the class DefaultMockMvcBuilderTests method dispatcherServletCustomizer.

/**
	 * See /SPR-14277
	 */
@Test
public void dispatcherServletCustomizer() {
    StubWebApplicationContext root = new StubWebApplicationContext(this.servletContext);
    DefaultMockMvcBuilder builder = webAppContextSetup(root);
    builder.addDispatcherServletCustomizer(ds -> ds.setContextId("test-id"));
    builder.dispatchOptions(true);
    MockMvc mvc = builder.build();
    DispatcherServlet ds = (DispatcherServlet) new DirectFieldAccessor(mvc).getPropertyValue("servlet");
    assertEquals("test-id", ds.getContextId());
}
Also used : DispatcherServlet(org.springframework.web.servlet.DispatcherServlet) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) MockMvc(org.springframework.test.web.servlet.MockMvc) Test(org.junit.Test)

Example 18 with DirectFieldAccessor

use of org.springframework.beans.DirectFieldAccessor in project spring-boot by spring-projects.

the class SessionAutoConfigurationHazelcastTests method customFlushMode.

@Test
public void customFlushMode() {
    load(Collections.<Class<?>>singletonList(HazelcastConfiguration.class), "spring.session.store-type=hazelcast", "spring.session.hazelcast.flush-mode=immediate");
    HazelcastSessionRepository repository = validateSessionRepository(HazelcastSessionRepository.class);
    assertThat(new DirectFieldAccessor(repository).getPropertyValue("hazelcastFlushMode")).isEqualTo(HazelcastFlushMode.IMMEDIATE);
}
Also used : HazelcastSessionRepository(org.springframework.session.hazelcast.HazelcastSessionRepository) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 19 with DirectFieldAccessor

use of org.springframework.beans.DirectFieldAccessor in project spring-boot by spring-projects.

the class SessionAutoConfigurationJdbcTests method disableDatabaseInitializer.

@Test
public void disableDatabaseInitializer() {
    load(Arrays.asList(EmbeddedDataSourceConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class), "spring.session.store-type=jdbc", "spring.session.jdbc.initializer.enabled=false");
    JdbcOperationsSessionRepository repository = validateSessionRepository(JdbcOperationsSessionRepository.class);
    assertThat(new DirectFieldAccessor(repository).getPropertyValue("tableName")).isEqualTo("SPRING_SESSION");
    assertThat(this.context.getBean(SessionProperties.class).getJdbc().getInitializer().isEnabled()).isFalse();
    this.thrown.expect(BadSqlGrammarException.class);
    assertThat(this.context.getBean(JdbcOperations.class).queryForList("select * from SPRING_SESSION")).isEmpty();
}
Also used : EmbeddedDataSourceConfiguration(org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration) JdbcOperationsSessionRepository(org.springframework.session.jdbc.JdbcOperationsSessionRepository) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JdbcOperations(org.springframework.jdbc.core.JdbcOperations) DataSourceTransactionManagerAutoConfiguration(org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration) Test(org.junit.Test)

Example 20 with DirectFieldAccessor

use of org.springframework.beans.DirectFieldAccessor in project spring-boot by spring-projects.

the class SessionAutoConfigurationJdbcTests method defaultConfig.

@Test
public void defaultConfig() {
    load(Arrays.asList(EmbeddedDataSourceConfiguration.class, JdbcTemplateAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class), "spring.session.store-type=jdbc");
    JdbcOperationsSessionRepository repository = validateSessionRepository(JdbcOperationsSessionRepository.class);
    assertThat(new DirectFieldAccessor(repository).getPropertyValue("tableName")).isEqualTo("SPRING_SESSION");
    assertThat(this.context.getBean(SessionProperties.class).getJdbc().getInitializer().isEnabled()).isTrue();
    assertThat(this.context.getBean(JdbcOperations.class).queryForList("select * from SPRING_SESSION")).isEmpty();
}
Also used : EmbeddedDataSourceConfiguration(org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration) JdbcOperationsSessionRepository(org.springframework.session.jdbc.JdbcOperationsSessionRepository) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JdbcTemplateAutoConfiguration(org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration) JdbcOperations(org.springframework.jdbc.core.JdbcOperations) DataSourceTransactionManagerAutoConfiguration(org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration) 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