Search in sources :

Example 1 with JmsMessageDrivenEndpoint

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

the class JmsMessageDrivenChannelAdapterParserTests method testAdapterWithIdleTaskExecutionLimit.

@Test
public void testAdapterWithIdleTaskExecutionLimit() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsInboundWithContainerSettings.xml", this.getClass());
    JmsMessageDrivenEndpoint adapter = (JmsMessageDrivenEndpoint) context.getBean("adapterWithIdleTaskExecutionLimit.adapter");
    adapter.start();
    AbstractMessageListenerContainer container = (AbstractMessageListenerContainer) new DirectFieldAccessor(adapter).getPropertyValue("listenerContainer");
    assertEquals(7, new DirectFieldAccessor(container).getPropertyValue("idleTaskExecutionLimit"));
    adapter.stop();
    context.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsMessageDrivenEndpoint(org.springframework.integration.jms.JmsMessageDrivenEndpoint) AbstractMessageListenerContainer(org.springframework.jms.listener.AbstractMessageListenerContainer) Test(org.junit.Test)

Example 2 with JmsMessageDrivenEndpoint

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

the class JmsMessageDrivenChannelAdapterParserTests method adapterWithPubSubDomain.

@Test
public void adapterWithPubSubDomain() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsInboundWithPubSubDomain.xml", this.getClass());
    JmsMessageDrivenEndpoint endpoint = context.getBean("messageDrivenAdapter", JmsMessageDrivenEndpoint.class);
    AbstractMessageListenerContainer container = (AbstractMessageListenerContainer) new DirectFieldAccessor(endpoint).getPropertyValue("listenerContainer");
    assertEquals(Boolean.TRUE, container.isPubSubDomain());
    // INT-3680
    assertFalse(container.isSubscriptionDurable());
    assertNull(container.getDurableSubscriptionName());
    endpoint.stop();
    context.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsMessageDrivenEndpoint(org.springframework.integration.jms.JmsMessageDrivenEndpoint) AbstractMessageListenerContainer(org.springframework.jms.listener.AbstractMessageListenerContainer) Test(org.junit.Test)

Example 3 with JmsMessageDrivenEndpoint

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

the class JmsMessageDrivenChannelAdapterParserTests method testAdapterWithReceiveTimeout.

@Test
public void testAdapterWithReceiveTimeout() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsInboundWithContainerSettings.xml", this.getClass());
    JmsMessageDrivenEndpoint adapter = (JmsMessageDrivenEndpoint) context.getBean("adapterWithReceiveTimeout.adapter");
    adapter.start();
    AbstractMessageListenerContainer container = (AbstractMessageListenerContainer) new DirectFieldAccessor(adapter).getPropertyValue("listenerContainer");
    assertEquals(1111L, new DirectFieldAccessor(container).getPropertyValue("receiveTimeout"));
    adapter.stop();
    context.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsMessageDrivenEndpoint(org.springframework.integration.jms.JmsMessageDrivenEndpoint) AbstractMessageListenerContainer(org.springframework.jms.listener.AbstractMessageListenerContainer) Test(org.junit.Test)

Example 4 with JmsMessageDrivenEndpoint

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

the class JmsMessageDrivenChannelAdapterParserTests method adapterWithMessageSelector.

@Test
public void adapterWithMessageSelector() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsInboundWithMessageSelector.xml", this.getClass());
    PollableChannel output = (PollableChannel) context.getBean("output2");
    Message<?> message = output.receive(timeoutOnReceive);
    MessageHistory history = MessageHistory.read(message);
    assertNotNull(history);
    Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "messageDrivenAdapter", 0);
    assertNotNull(componentHistoryRecord);
    JmsMessageDrivenEndpoint endpoint = context.getBean("messageDrivenAdapter", JmsMessageDrivenEndpoint.class);
    assertEquals("jms:message-driven-channel-adapter", componentHistoryRecord.get("type"));
    assertNotNull("message should not be null", message);
    assertEquals("test [with selector: TestProperty = 'foo']", message.getPayload());
    endpoint.stop();
    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 5 with JmsMessageDrivenEndpoint

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

the class JmsInboundGatewayParserTests method gatewayWithPubSubDomain.

@Test
public void gatewayWithPubSubDomain() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsGatewayWithPubSubDomain.xml", this.getClass());
    JmsMessageDrivenEndpoint endpoint = context.getBean("gateway", JmsMessageDrivenEndpoint.class);
    JmsDestinationAccessor container = (JmsDestinationAccessor) new DirectFieldAccessor(endpoint).getPropertyValue("listenerContainer");
    assertEquals(Boolean.TRUE, container.isPubSubDomain());
    context.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsMessageDrivenEndpoint(org.springframework.integration.jms.JmsMessageDrivenEndpoint) JmsDestinationAccessor(org.springframework.jms.support.destination.JmsDestinationAccessor) 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