Search in sources :

Example 81 with EventDrivenConsumer

use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.

the class JmsOutboundChannelAdapterParserTests method adapterWithMessageConverter.

@Test
public void adapterWithMessageConverter() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundWithMessageConverter.xml", this.getClass());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("adapter");
    DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(new DirectFieldAccessor(endpoint).getPropertyValue("handler"));
    JmsTemplate jmsTemlate = (JmsTemplate) handlerAccessor.getPropertyValue("jmsTemplate");
    MessageConverter messageConverter = jmsTemlate.getMessageConverter();
    assertNotNull(messageConverter);
    assertEquals(TestMessageConverter.class, messageConverter.getClass());
    context.close();
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsTemplate(org.springframework.jms.core.JmsTemplate) MessageConverter(org.springframework.jms.support.converter.MessageConverter) Test(org.junit.Test)

Example 82 with EventDrivenConsumer

use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.

the class JmsOutboundChannelAdapterParserTests method adapterWithQosSettings.

@Test
public void adapterWithQosSettings() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundWithQos.xml", this.getClass());
    EventDrivenConsumer endpoint = context.getBean("qosAdapter", EventDrivenConsumer.class);
    DirectFieldAccessor accessor = new DirectFieldAccessor(new DirectFieldAccessor(new DirectFieldAccessor(endpoint).getPropertyValue("handler")).getPropertyValue("jmsTemplate"));
    assertEquals(true, accessor.getPropertyValue("explicitQosEnabled"));
    assertEquals(12345L, accessor.getPropertyValue("timeToLive"));
    assertEquals(7, accessor.getPropertyValue("priority"));
    assertEquals(DeliveryMode.NON_PERSISTENT, accessor.getPropertyValue("deliveryMode"));
    context.close();
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 83 with EventDrivenConsumer

use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.

the class JmsOutboundChannelAdapterParserTests method adapterWithJmsTemplate.

@Test
public void adapterWithJmsTemplate() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundWithJmsTemplate.xml", this.getClass());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("adapter");
    DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(new DirectFieldAccessor(endpoint).getPropertyValue("handler"));
    JmsTemplate jmsTemplate = (JmsTemplate) handlerAccessor.getPropertyValue("jmsTemplate");
    assertNotNull(jmsTemplate);
    assertEquals(context.getBean("template"), jmsTemplate);
    context.close();
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsTemplate(org.springframework.jms.core.JmsTemplate) Test(org.junit.Test)

Example 84 with EventDrivenConsumer

use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.

the class JmsOutboundChannelAdapterParserTests method advisedAdapter.

@Test
public void advisedAdapter() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundWithConnectionFactoryAndDestination.xml", this.getClass());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("advised");
    MessageHandler handler = TestUtils.getPropertyValue(endpoint, "handler", MessageHandler.class);
    handler.handleMessage(new GenericMessage<String>("foo"));
    assertEquals(1, adviceCalled);
    context.close();
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) MessageHandler(org.springframework.messaging.MessageHandler) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Test(org.junit.Test)

Example 85 with EventDrivenConsumer

use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.

the class JmsOutboundChannelAdapterParserTests method adapterWithOrder.

@Test
public void adapterWithOrder() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundWithOrder.xml", this.getClass());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("adapter");
    DirectFieldAccessor accessor = new DirectFieldAccessor(new DirectFieldAccessor(endpoint).getPropertyValue("handler"));
    Object order = accessor.getPropertyValue("order");
    assertEquals(123, order);
    context.close();
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Aggregations

EventDrivenConsumer (org.springframework.integration.endpoint.EventDrivenConsumer)106 Test (org.junit.Test)96 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)29 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)27 DirectChannel (org.springframework.integration.channel.DirectChannel)19 PollableChannel (org.springframework.messaging.PollableChannel)19 GenericMessage (org.springframework.messaging.support.GenericMessage)18 MessageChannel (org.springframework.messaging.MessageChannel)16 QueueChannel (org.springframework.integration.channel.QueueChannel)14 MessageHandler (org.springframework.messaging.MessageHandler)12 List (java.util.List)9 ResequencingMessageHandler (org.springframework.integration.aggregator.ResequencingMessageHandler)9 Message (org.springframework.messaging.Message)8 SmartLifecycle (org.springframework.context.SmartLifecycle)6 JmsOutboundGateway (org.springframework.integration.jms.JmsOutboundGateway)6 MongoDbAvailable (org.springframework.integration.mongodb.rules.MongoDbAvailable)6 SmartLifecycleRoleController (org.springframework.integration.support.SmartLifecycleRoleController)6 MethodInvokingReleaseStrategy (org.springframework.integration.aggregator.MethodInvokingReleaseStrategy)5 ReleaseStrategy (org.springframework.integration.aggregator.ReleaseStrategy)5 AbstractReplyProducingMessageHandler (org.springframework.integration.handler.AbstractReplyProducingMessageHandler)5