Search in sources :

Example 6 with SubscribableJmsChannel

use of org.springframework.integration.jms.SubscribableJmsChannel in project spring-integration by spring-projects.

the class JmsChannelParserTests method queueNameChannel.

@Test
public void queueNameChannel() {
    assertEquals(SubscribableJmsChannel.class, queueNameChannel.getClass());
    SubscribableJmsChannel channel = (SubscribableJmsChannel) queueNameChannel;
    DirectFieldAccessor accessor = new DirectFieldAccessor(channel);
    JmsTemplate jmsTemplate = (JmsTemplate) accessor.getPropertyValue("jmsTemplate");
    AbstractMessageListenerContainer container = (AbstractMessageListenerContainer) accessor.getPropertyValue("container");
    assertEquals("test.queue", jmsTemplate.getDefaultDestinationName());
    assertEquals("test.queue", container.getDestinationName());
    assertEquals(1, TestUtils.getPropertyValue(TestUtils.getPropertyValue(channel, "dispatcher"), "maxSubscribers", Integer.class).intValue());
}
Also used : SubscribableJmsChannel(org.springframework.integration.jms.SubscribableJmsChannel) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsTemplate(org.springframework.jms.core.JmsTemplate) AbstractMessageListenerContainer(org.springframework.jms.listener.AbstractMessageListenerContainer) Test(org.junit.Test)

Example 7 with SubscribableJmsChannel

use of org.springframework.integration.jms.SubscribableJmsChannel in project spring-integration by spring-projects.

the class JmsChannelParserTests method topicNameChannel.

@Test
public void topicNameChannel() {
    assertEquals(SubscribableJmsChannel.class, topicNameChannel.getClass());
    SubscribableJmsChannel channel = (SubscribableJmsChannel) topicNameChannel;
    DirectFieldAccessor accessor = new DirectFieldAccessor(channel);
    JmsTemplate jmsTemplate = (JmsTemplate) accessor.getPropertyValue("jmsTemplate");
    AbstractMessageListenerContainer container = (AbstractMessageListenerContainer) accessor.getPropertyValue("container");
    assertEquals("test.topic", jmsTemplate.getDefaultDestinationName());
    assertEquals("test.topic", container.getDestinationName());
    assertTrue(container.isSubscriptionShared());
    assertTrue(container.isSubscriptionDurable());
    assertEquals("subName", container.getSubscriptionName());
}
Also used : SubscribableJmsChannel(org.springframework.integration.jms.SubscribableJmsChannel) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsTemplate(org.springframework.jms.core.JmsTemplate) AbstractMessageListenerContainer(org.springframework.jms.listener.AbstractMessageListenerContainer) Test(org.junit.Test)

Example 8 with SubscribableJmsChannel

use of org.springframework.integration.jms.SubscribableJmsChannel in project spring-integration by spring-projects.

the class JmsChannelParserTests method topicReferenceChannel.

@Test
public void topicReferenceChannel() {
    assertEquals(SubscribableJmsChannel.class, topicReferenceChannel.getClass());
    SubscribableJmsChannel channel = (SubscribableJmsChannel) topicReferenceChannel;
    DirectFieldAccessor accessor = new DirectFieldAccessor(channel);
    JmsTemplate jmsTemplate = (JmsTemplate) accessor.getPropertyValue("jmsTemplate");
    AbstractMessageListenerContainer container = (AbstractMessageListenerContainer) accessor.getPropertyValue("container");
    assertEquals(topic, jmsTemplate.getDefaultDestination());
    assertEquals(topic, container.getDestination());
    assertSame(this.messageBuilderFactory, TestUtils.getPropertyValue(channel, "container.messageListener.messageBuilderFactory"));
}
Also used : SubscribableJmsChannel(org.springframework.integration.jms.SubscribableJmsChannel) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsTemplate(org.springframework.jms.core.JmsTemplate) AbstractMessageListenerContainer(org.springframework.jms.listener.AbstractMessageListenerContainer) Test(org.junit.Test)

Example 9 with SubscribableJmsChannel

use of org.springframework.integration.jms.SubscribableJmsChannel in project spring-integration by spring-projects.

the class JmsChannelParserTests method queueChannelWithInterceptors.

@Test
@SuppressWarnings("unchecked")
public void queueChannelWithInterceptors() {
    assertEquals(SubscribableJmsChannel.class, queueChannelWithInterceptors.getClass());
    SubscribableJmsChannel channel = (SubscribableJmsChannel) queueChannelWithInterceptors;
    DirectFieldAccessor accessor = new DirectFieldAccessor(channel);
    List<ChannelInterceptor> interceptors = (List<ChannelInterceptor>) new DirectFieldAccessor(accessor.getPropertyValue("interceptors")).getPropertyValue("interceptors");
    assertEquals(1, interceptors.size());
    assertEquals(TestInterceptor.class, interceptors.get(0).getClass());
}
Also used : SubscribableJmsChannel(org.springframework.integration.jms.SubscribableJmsChannel) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) ChannelInterceptor(org.springframework.messaging.support.ChannelInterceptor) List(java.util.List) Test(org.junit.Test)

Example 10 with SubscribableJmsChannel

use of org.springframework.integration.jms.SubscribableJmsChannel in project spring-integration by spring-projects.

the class JmsChannelParserTests method topicChannelWithInterceptors.

@Test
@SuppressWarnings("unchecked")
public void topicChannelWithInterceptors() {
    assertEquals(SubscribableJmsChannel.class, topicChannelWithInterceptors.getClass());
    SubscribableJmsChannel channel = (SubscribableJmsChannel) topicChannelWithInterceptors;
    DirectFieldAccessor accessor = new DirectFieldAccessor(channel);
    List<ChannelInterceptor> interceptors = (List<ChannelInterceptor>) new DirectFieldAccessor(accessor.getPropertyValue("interceptors")).getPropertyValue("interceptors");
    assertEquals(2, interceptors.size());
    assertEquals(TestInterceptor.class, interceptors.get(0).getClass());
    assertEquals(TestInterceptor.class, interceptors.get(1).getClass());
}
Also used : SubscribableJmsChannel(org.springframework.integration.jms.SubscribableJmsChannel) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) ChannelInterceptor(org.springframework.messaging.support.ChannelInterceptor) List(java.util.List) Test(org.junit.Test)

Aggregations

SubscribableJmsChannel (org.springframework.integration.jms.SubscribableJmsChannel)11 Test (org.junit.Test)10 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)9 JmsTemplate (org.springframework.jms.core.JmsTemplate)7 AbstractMessageListenerContainer (org.springframework.jms.listener.AbstractMessageListenerContainer)7 List (java.util.List)2 ChannelInterceptor (org.springframework.messaging.support.ChannelInterceptor)2 MessageHistory (org.springframework.integration.history.MessageHistory)1 PollableJmsChannel (org.springframework.integration.jms.PollableJmsChannel)1 DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)1 Message (org.springframework.messaging.Message)1 GenericMessage (org.springframework.messaging.support.GenericMessage)1