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-framework by spring-projects.
the class JmsListenerEndpointTests method setupConcurrencySimpleContainer.
@Test
public void setupConcurrencySimpleContainer() {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
MessageListener messageListener = new MessageListenerAdapter();
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
// simple implementation only support max value
endpoint.setConcurrency("5-10");
endpoint.setMessageListener(messageListener);
endpoint.setupListenerContainer(container);
assertEquals(10, new DirectFieldAccessor(container).getPropertyValue("concurrentConsumers"));
}
use of org.springframework.beans.DirectFieldAccessor in project spring-framework by spring-projects.
the class JmsNamespaceHandlerTests method testJmsContainerFactoryConfiguration.
@Test
public void testJmsContainerFactoryConfiguration() {
Map<String, DefaultJmsListenerContainerFactory> containers = context.getBeansOfType(DefaultJmsListenerContainerFactory.class);
DefaultJmsListenerContainerFactory factory = containers.get("testJmsFactory");
assertNotNull("No factory registered with testJmsFactory id", factory);
DefaultMessageListenerContainer container = factory.createListenerContainer(createDummyEndpoint());
assertEquals("explicit connection factory not set", context.getBean(EXPLICIT_CONNECTION_FACTORY), container.getConnectionFactory());
assertEquals("explicit destination resolver not set", context.getBean("testDestinationResolver"), container.getDestinationResolver());
assertEquals("explicit message converter not set", context.getBean("testMessageConverter"), container.getMessageConverter());
assertEquals("Wrong pub/sub", true, container.isPubSubDomain());
assertEquals("Wrong durable flag", true, container.isSubscriptionDurable());
assertEquals("wrong cache", DefaultMessageListenerContainer.CACHE_CONNECTION, container.getCacheLevel());
assertEquals("wrong concurrency", 3, container.getConcurrentConsumers());
assertEquals("wrong concurrency", 5, container.getMaxConcurrentConsumers());
assertEquals("wrong prefetch", 50, container.getMaxMessagesPerTask());
assertEquals("Wrong phase", 99, container.getPhase());
assertSame(context.getBean("testBackOff"), new DirectFieldAccessor(container).getPropertyValue("backOff"));
}
use of org.springframework.beans.DirectFieldAccessor in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method setExtraCollaborators.
@Test
public void setExtraCollaborators() {
MessageConverter messageConverter = mock(MessageConverter.class);
DestinationResolver destinationResolver = mock(DestinationResolver.class);
this.container.setMessageConverter(messageConverter);
this.container.setDestinationResolver(destinationResolver);
MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod("resolveObjectPayload", MyBean.class), container);
DirectFieldAccessor accessor = new DirectFieldAccessor(listener);
assertSame(messageConverter, accessor.getPropertyValue("messageConverter"));
assertSame(destinationResolver, accessor.getPropertyValue("destinationResolver"));
}
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"));
}
Aggregations