Search in sources :

Example 21 with JmsMessageDrivenEndpoint

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

the class JmsInboundGatewayParserTests method testGatewayWithContainerSettings.

@Test
public void testGatewayWithContainerSettings() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsGatewayWithContainerSettings.xml", this.getClass());
    JmsMessageDrivenEndpoint gateway = (JmsMessageDrivenEndpoint) context.getBean("gatewayWithConcurrentConsumers");
    AbstractMessageListenerContainer container = (AbstractMessageListenerContainer) new DirectFieldAccessor(gateway).getPropertyValue("listenerContainer");
    assertEquals(3, new DirectFieldAccessor(container).getPropertyValue("concurrentConsumers"));
    gateway = (JmsMessageDrivenEndpoint) context.getBean("gatewayWithMaxConcurrentConsumers");
    container = (AbstractMessageListenerContainer) new DirectFieldAccessor(gateway).getPropertyValue("listenerContainer");
    assertEquals(22, new DirectFieldAccessor(container).getPropertyValue("maxConcurrentConsumers"));
    gateway = (JmsMessageDrivenEndpoint) context.getBean("gatewayWithMaxMessagesPerTask");
    container = (AbstractMessageListenerContainer) new DirectFieldAccessor(gateway).getPropertyValue("listenerContainer");
    assertEquals(99, new DirectFieldAccessor(container).getPropertyValue("maxMessagesPerTask"));
    gateway = (JmsMessageDrivenEndpoint) context.getBean("gatewayWithReceiveTimeout");
    container = (AbstractMessageListenerContainer) new DirectFieldAccessor(gateway).getPropertyValue("listenerContainer");
    assertEquals(1111L, new DirectFieldAccessor(container).getPropertyValue("receiveTimeout"));
    gateway = (JmsMessageDrivenEndpoint) context.getBean("gatewayWithRecoveryInterval");
    container = (AbstractMessageListenerContainer) new DirectFieldAccessor(gateway).getPropertyValue("listenerContainer");
    Object recoveryInterval;
    try {
        recoveryInterval = TestUtils.getPropertyValue(container, "recoveryInterval");
    } catch (NotReadablePropertyException e) {
        recoveryInterval = TestUtils.getPropertyValue(container, "backOff.interval");
    }
    assertEquals(2222L, recoveryInterval);
    gateway = (JmsMessageDrivenEndpoint) context.getBean("gatewayWithIdleTaskExecutionLimit");
    container = (AbstractMessageListenerContainer) new DirectFieldAccessor(gateway).getPropertyValue("listenerContainer");
    assertEquals(7, new DirectFieldAccessor(container).getPropertyValue("idleTaskExecutionLimit"));
    gateway = (JmsMessageDrivenEndpoint) context.getBean("gatewayWithIdleConsumerLimit");
    container = (AbstractMessageListenerContainer) new DirectFieldAccessor(gateway).getPropertyValue("listenerContainer");
    assertEquals(33, new DirectFieldAccessor(container).getPropertyValue("idleConsumerLimit"));
    gateway = (JmsMessageDrivenEndpoint) context.getBean("gatewayWithMessageSelector");
    container = (AbstractMessageListenerContainer) new DirectFieldAccessor(gateway).getPropertyValue("listenerContainer");
    String messageSelector = (String) new DirectFieldAccessor(container).getPropertyValue("messageSelector");
    assertEquals("TestProperty = 'foo'", messageSelector);
    context.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) NotReadablePropertyException(org.springframework.beans.NotReadablePropertyException) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsMessageDrivenEndpoint(org.springframework.integration.jms.JmsMessageDrivenEndpoint) AbstractMessageListenerContainer(org.springframework.jms.listener.AbstractMessageListenerContainer) Test(org.junit.Test)

Example 22 with JmsMessageDrivenEndpoint

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

the class JmsInboundGatewayParserTests method testGatewayWithExtractPayloadAttributes.

@Test
public void testGatewayWithExtractPayloadAttributes() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsGatewaysWithExtractPayloadAttributes.xml", this.getClass());
    JmsMessageDrivenEndpoint gateway = (JmsMessageDrivenEndpoint) context.getBean("defaultGateway");
    DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
    accessor = new DirectFieldAccessor(accessor.getPropertyValue("listener"));
    assertEquals(Boolean.TRUE, accessor.getPropertyValue("extractReplyPayload"));
    gateway = (JmsMessageDrivenEndpoint) context.getBean("extractReplyPayloadTrue");
    accessor = new DirectFieldAccessor(gateway);
    accessor = new DirectFieldAccessor(accessor.getPropertyValue("listener"));
    assertEquals(Boolean.TRUE, accessor.getPropertyValue("extractReplyPayload"));
    gateway = (JmsMessageDrivenEndpoint) context.getBean("extractReplyPayloadFalse");
    accessor = new DirectFieldAccessor(gateway);
    accessor = new DirectFieldAccessor(accessor.getPropertyValue("listener"));
    assertEquals(Boolean.FALSE, accessor.getPropertyValue("extractReplyPayload"));
    gateway = (JmsMessageDrivenEndpoint) context.getBean("extractRequestPayloadTrue");
    accessor = new DirectFieldAccessor(gateway);
    accessor = new DirectFieldAccessor(accessor.getPropertyValue("listener"));
    assertEquals(Boolean.TRUE, accessor.getPropertyValue("extractRequestPayload"));
    gateway = (JmsMessageDrivenEndpoint) context.getBean("extractRequestPayloadFalse");
    accessor = new DirectFieldAccessor(gateway);
    accessor = new DirectFieldAccessor(accessor.getPropertyValue("listener"));
    assertEquals(Boolean.FALSE, accessor.getPropertyValue("extractRequestPayload"));
    context.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsMessageDrivenEndpoint(org.springframework.integration.jms.JmsMessageDrivenEndpoint) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)22 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)22 JmsMessageDrivenEndpoint (org.springframework.integration.jms.JmsMessageDrivenEndpoint)22 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)15 AbstractMessageListenerContainer (org.springframework.jms.listener.AbstractMessageListenerContainer)7 PollableChannel (org.springframework.messaging.PollableChannel)5 DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)3 Properties (java.util.Properties)2 NotReadablePropertyException (org.springframework.beans.NotReadablePropertyException)2 MessageHistory (org.springframework.integration.history.MessageHistory)2 ConnectionFactory (javax.jms.ConnectionFactory)1 SmartLifecycle (org.springframework.context.SmartLifecycle)1 SmartLifecycleRoleController (org.springframework.integration.support.SmartLifecycleRoleController)1 JmsTemplate (org.springframework.jms.core.JmsTemplate)1 JmsDestinationAccessor (org.springframework.jms.support.destination.JmsDestinationAccessor)1 MessageChannel (org.springframework.messaging.MessageChannel)1