Search in sources :

Example 6 with JmsMessageDrivenEndpoint

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

the class JmsInboundGatewayParserTests method testTransactionManager.

@Test
public void testTransactionManager() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsGatewayTransactionManagerTests.xml", this.getClass());
    JmsMessageDrivenEndpoint gateway = (JmsMessageDrivenEndpoint) context.getBean("gatewayWithoutTransactionManager");
    DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
    accessor = new DirectFieldAccessor(accessor.getPropertyValue("listenerContainer"));
    assertNull(accessor.getPropertyValue("transactionManager"));
    gateway = (JmsMessageDrivenEndpoint) context.getBean("gatewayWithTransactionManager");
    accessor = new DirectFieldAccessor(gateway);
    accessor = new DirectFieldAccessor(accessor.getPropertyValue("listenerContainer"));
    Object txManager = accessor.getPropertyValue("transactionManager");
    assertEquals(JmsTransactionManager.class, txManager.getClass());
    assertEquals(context.getBean("txManager"), txManager);
    assertEquals(context.getBean("testConnectionFactory"), ((JmsTransactionManager) txManager).getConnectionFactory());
    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)

Example 7 with JmsMessageDrivenEndpoint

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

the class JmsInboundGatewayParserTests method testGatewayWithContainerReference.

@Test
public void testGatewayWithContainerReference() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("inboundGatewayWithContainerReference.xml", this.getClass());
    JmsMessageDrivenEndpoint gateway = context.getBean("gatewayWithContainerReference", JmsMessageDrivenEndpoint.class);
    AbstractMessageListenerContainer messageListenerContainer = context.getBean("messageListenerContainer", AbstractMessageListenerContainer.class);
    assertFalse(gateway.isRunning());
    assertFalse(messageListenerContainer.isRunning());
    SmartLifecycleRoleController roleController = context.getBean(SmartLifecycleRoleController.class);
    @SuppressWarnings("unchecked") MultiValueMap<String, SmartLifecycle> lifecycles = TestUtils.getPropertyValue(roleController, "lifecycles", MultiValueMap.class);
    assertTrue(lifecycles.containsKey("foo"));
    assertSame(gateway, lifecycles.getFirst("foo"));
    gateway.start();
    AbstractMessageListenerContainer container = (AbstractMessageListenerContainer) new DirectFieldAccessor(gateway).getPropertyValue("listenerContainer");
    assertEquals(messageListenerContainer, container);
    assertTrue(gateway.isRunning());
    assertTrue(messageListenerContainer.isRunning());
    gateway.stop();
    context.close();
}
Also used : SmartLifecycleRoleController(org.springframework.integration.support.SmartLifecycleRoleController) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) SmartLifecycle(org.springframework.context.SmartLifecycle) JmsMessageDrivenEndpoint(org.springframework.integration.jms.JmsMessageDrivenEndpoint) AbstractMessageListenerContainer(org.springframework.jms.listener.AbstractMessageListenerContainer) Test(org.junit.Test)

Example 8 with JmsMessageDrivenEndpoint

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

the class JmsInboundGatewayParserTests method testGatewayWithConnectionFactoryAndDestinationName.

@Test
public void testGatewayWithConnectionFactoryAndDestinationName() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsGatewayWithConnectionFactoryAndDestinationName.xml", this.getClass());
    PollableChannel channel = (PollableChannel) context.getBean("requestChannel");
    JmsMessageDrivenEndpoint gateway = (JmsMessageDrivenEndpoint) context.getBean("jmsGateway");
    assertEquals(JmsMessageDrivenEndpoint.class, gateway.getClass());
    context.start();
    Message<?> message = channel.receive(10000);
    assertNotNull("message should not be null", message);
    assertEquals("message-driven-test", message.getPayload());
    context.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PollableChannel(org.springframework.messaging.PollableChannel) JmsMessageDrivenEndpoint(org.springframework.integration.jms.JmsMessageDrivenEndpoint) Test(org.junit.Test)

Example 9 with JmsMessageDrivenEndpoint

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

the class JmsInboundGatewayParserTests method testGatewayWithReplyQosProperties.

@Test
public void testGatewayWithReplyQosProperties() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("inboundGatewayWithReplyQos.xml", this.getClass());
    JmsMessageDrivenEndpoint gateway = context.getBean("gatewayWithReplyQos", JmsMessageDrivenEndpoint.class);
    DirectFieldAccessor accessor = new DirectFieldAccessor(new DirectFieldAccessor(gateway).getPropertyValue("listener"));
    assertEquals(12345L, accessor.getPropertyValue("replyTimeToLive"));
    assertEquals(7, accessor.getPropertyValue("replyPriority"));
    assertEquals(DeliveryMode.NON_PERSISTENT, accessor.getPropertyValue("replyDeliveryMode"));
    assertEquals(true, accessor.getPropertyValue("explicitQosEnabledForReplies"));
    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)

Example 10 with JmsMessageDrivenEndpoint

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

the class JmsInboundGatewayParserTests method gatewayWithReplyChannel.

@Test
public void gatewayWithReplyChannel() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsGatewayWithReplyChannel.xml", this.getClass());
    JmsTemplate template = new JmsTemplate(context.getBean(ConnectionFactory.class));
    template.convertAndSend("testDestination", "Hello");
    JmsMessageDrivenEndpoint gateway = (JmsMessageDrivenEndpoint) context.getBean("gateway");
    Object replyChannel = TestUtils.getPropertyValue(gateway, "listener.gatewayDelegate.replyChannel");
    assertEquals(context.getBean("replies"), replyChannel);
    assertNotNull(template.receive("testReplyDestination"));
    context.close();
}
Also used : ConnectionFactory(javax.jms.ConnectionFactory) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) JmsTemplate(org.springframework.jms.core.JmsTemplate) 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