Search in sources :

Example 11 with JmsMessageDrivenEndpoint

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

the class JmsInboundGatewayParserTests method gatewayWithDurableSubscription.

@Test
public void gatewayWithDurableSubscription() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("inboundGatewayWithDurableSubscription.xml", this.getClass());
    JmsMessageDrivenEndpoint endpoint = context.getBean("gateway", JmsMessageDrivenEndpoint.class);
    DefaultMessageListenerContainer container = (DefaultMessageListenerContainer) new DirectFieldAccessor(endpoint).getPropertyValue("listenerContainer");
    assertEquals(Boolean.TRUE, container.isPubSubDomain());
    assertEquals(Boolean.TRUE, container.isSubscriptionDurable());
    assertEquals("testDurableSubscriptionName", container.getDurableSubscriptionName());
    assertEquals("testClientId", container.getClientId());
    assertTrue(container.isSubscriptionShared());
    context.close();
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsMessageDrivenEndpoint(org.springframework.integration.jms.JmsMessageDrivenEndpoint) Test(org.junit.Test)

Example 12 with JmsMessageDrivenEndpoint

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

the class JmsInboundGatewayParserTests method replyQosPropertiesDisabledByDefault.

@Test
public void replyQosPropertiesDisabledByDefault() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("inboundGatewayDefault.xml", this.getClass());
    JmsMessageDrivenEndpoint gateway = context.getBean("gateway", JmsMessageDrivenEndpoint.class);
    DirectFieldAccessor accessor = new DirectFieldAccessor(new DirectFieldAccessor(gateway).getPropertyValue("listener"));
    assertEquals(false, 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 13 with JmsMessageDrivenEndpoint

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

the class JmsInboundGatewayParserTests method testGatewayWithConnectionFactoryAndDestination.

@Test
public void testGatewayWithConnectionFactoryAndDestination() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsGatewayWithConnectionFactoryAndDestination.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);
    MessageHistory history = MessageHistory.read(message);
    assertNotNull(history);
    Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "jmsGateway", 0);
    assertNotNull(componentHistoryRecord);
    assertEquals("jms:inbound-gateway", componentHistoryRecord.get("type"));
    assertNotNull("message should not be null", message);
    assertEquals("message-driven-test", message.getPayload());
    context.close();
}
Also used : MessageHistory(org.springframework.integration.history.MessageHistory) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PollableChannel(org.springframework.messaging.PollableChannel) Properties(java.util.Properties) JmsMessageDrivenEndpoint(org.springframework.integration.jms.JmsMessageDrivenEndpoint) Test(org.junit.Test)

Example 14 with JmsMessageDrivenEndpoint

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

the class JmsInboundGatewayParserTests method testGatewayWithDefaultConnectionFactory.

@Test
public void testGatewayWithDefaultConnectionFactory() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsGatewayWithDefaultConnectionFactory.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 15 with JmsMessageDrivenEndpoint

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

the class JmsMessageDrivenChannelAdapterParserTests method adapterWithTaskExecutor.

@Test
public void adapterWithTaskExecutor() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsInboundWithTaskExecutor.xml", this.getClass());
    JmsMessageDrivenEndpoint endpoint = context.getBean("messageDrivenAdapter.adapter", JmsMessageDrivenEndpoint.class);
    DefaultMessageListenerContainer container = TestUtils.getPropertyValue(endpoint, "listenerContainer", DefaultMessageListenerContainer.class);
    assertSame(context.getBean("exec"), TestUtils.getPropertyValue(container, "taskExecutor"));
    endpoint.stop();
    context.close();
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) 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