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"));
}
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());
}
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);
}
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();
}
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();
}
Aggregations