Search in sources :

Example 6 with JmsOutboundGateway

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

the class JmsOutboundGatewayParserTests method gatewayWithDestName.

@Test
public void gatewayWithDestName() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundGatewayReplyDestOptions.xml", this.getClass());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("jmsGatewayDestName");
    DirectFieldAccessor accessor = new DirectFieldAccessor(endpoint);
    JmsOutboundGateway gateway = (JmsOutboundGateway) accessor.getPropertyValue("handler");
    accessor = new DirectFieldAccessor(gateway);
    assertEquals("replyQueueName", accessor.getPropertyValue("replyDestinationName"));
    context.close();
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsOutboundGateway(org.springframework.integration.jms.JmsOutboundGateway) Test(org.junit.Test)

Example 7 with JmsOutboundGateway

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

the class JmsOutboundGatewayParserTests method gatewayWithDestBeanRefExpression.

@Test
public void gatewayWithDestBeanRefExpression() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundGatewayReplyDestOptions.xml", this.getClass());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("jmsGatewayDestExpressionBeanRef");
    DirectFieldAccessor accessor = new DirectFieldAccessor(endpoint);
    JmsOutboundGateway gateway = (JmsOutboundGateway) accessor.getPropertyValue("handler");
    ExpressionEvaluatingMessageProcessor<?> processor = TestUtils.getPropertyValue(gateway, "replyDestinationExpressionProcessor", ExpressionEvaluatingMessageProcessor.class);
    Expression expression = TestUtils.getPropertyValue(gateway, "replyDestinationExpressionProcessor.expression", Expression.class);
    assertEquals("@replyQueue", expression.getExpressionString());
    assertSame(context.getBean("replyQueue"), processor.processMessage(null));
    context.close();
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Expression(org.springframework.expression.Expression) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsOutboundGateway(org.springframework.integration.jms.JmsOutboundGateway) Test(org.junit.Test)

Example 8 with JmsOutboundGateway

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

the class JmsOutboundGatewayParserTests method gatewayWithDest.

@Test
public void gatewayWithDest() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundGatewayReplyDestOptions.xml", this.getClass());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("jmsGatewayDest");
    DirectFieldAccessor accessor = new DirectFieldAccessor(endpoint);
    JmsOutboundGateway gateway = (JmsOutboundGateway) accessor.getPropertyValue("handler");
    accessor = new DirectFieldAccessor(gateway);
    assertSame(context.getBean("replyQueue"), accessor.getPropertyValue("replyDestination"));
    context.close();
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsOutboundGateway(org.springframework.integration.jms.JmsOutboundGateway) Test(org.junit.Test)

Example 9 with JmsOutboundGateway

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

the class JmsOutboundGatewayParserTests method testWithDeliveryPersistentAttribute.

@Test
public void testWithDeliveryPersistentAttribute() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundGatewayWithDeliveryPersistent.xml", this.getClass());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("jmsGateway");
    DirectFieldAccessor accessor = new DirectFieldAccessor(endpoint);
    JmsOutboundGateway gateway = (JmsOutboundGateway) accessor.getPropertyValue("handler");
    accessor = new DirectFieldAccessor(gateway);
    int deliveryMode = (Integer) accessor.getPropertyValue("deliveryMode");
    assertEquals(DeliveryMode.PERSISTENT, deliveryMode);
    assertTrue(TestUtils.getPropertyValue(gateway, "async", Boolean.class));
    DefaultMessageListenerContainer container = TestUtils.getPropertyValue(gateway, "replyContainer", DefaultMessageListenerContainer.class);
    assertEquals(4, TestUtils.getPropertyValue(container, "concurrentConsumers"));
    assertEquals(5, TestUtils.getPropertyValue(container, "maxConcurrentConsumers"));
    assertEquals(10, TestUtils.getPropertyValue(container, "maxMessagesPerTask"));
    assertEquals(2000L, TestUtils.getPropertyValue(container, "receiveTimeout"));
    Object recoveryInterval;
    try {
        recoveryInterval = TestUtils.getPropertyValue(container, "recoveryInterval");
    } catch (NotReadablePropertyException e) {
        recoveryInterval = TestUtils.getPropertyValue(container, "backOff.interval");
    }
    assertEquals(10000L, recoveryInterval);
    assertEquals(7, TestUtils.getPropertyValue(container, "idleConsumerLimit"));
    assertEquals(2, TestUtils.getPropertyValue(container, "idleTaskExecutionLimit"));
    assertEquals(3, TestUtils.getPropertyValue(container, "cacheLevel"));
    assertTrue(container.isSessionTransacted());
    assertSame(context.getBean("exec"), TestUtils.getPropertyValue(container, "taskExecutor"));
    assertEquals(1234000L, TestUtils.getPropertyValue(gateway, "idleReplyContainerTimeout"));
    context.close();
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) NotReadablePropertyException(org.springframework.beans.NotReadablePropertyException) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsOutboundGateway(org.springframework.integration.jms.JmsOutboundGateway) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)9 JmsOutboundGateway (org.springframework.integration.jms.JmsOutboundGateway)9 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)7 EventDrivenConsumer (org.springframework.integration.endpoint.EventDrivenConsumer)7 Expression (org.springframework.expression.Expression)3 Method (java.lang.reflect.Method)2 Destination (javax.jms.Destination)2 Queue (javax.jms.Queue)2 Session (javax.jms.Session)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 NotReadablePropertyException (org.springframework.beans.NotReadablePropertyException)2 PollingConsumer (org.springframework.integration.endpoint.PollingConsumer)2 StubMessageConverter (org.springframework.integration.jms.StubMessageConverter)2 DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)2 MessageConverter (org.springframework.jms.support.converter.MessageConverter)2 Properties (java.util.Properties)1 DeliveryMode (javax.jms.DeliveryMode)1 Matchers.equalTo (org.hamcrest.Matchers.equalTo)1 Assert.assertEquals (org.junit.Assert.assertEquals)1