Search in sources :

Example 31 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 32 with DirectFieldAccessor

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"));
}
Also used : MessageListenerAdapter(org.springframework.jms.listener.adapter.MessageListenerAdapter) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) MessageListener(javax.jms.MessageListener) Test(org.junit.Test)

Example 33 with DirectFieldAccessor

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

Example 34 with DirectFieldAccessor

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"));
}
Also used : DestinationResolver(org.springframework.jms.support.destination.DestinationResolver) MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) MessageConverter(org.springframework.jms.support.converter.MessageConverter) Test(org.junit.Test)

Example 35 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)

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