Search in sources :

Example 86 with EventDrivenConsumer

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

the class RedisOutboundChannelAdapterParserTests method validateConfiguration.

@Test
@RedisAvailable
public void validateConfiguration() {
    EventDrivenConsumer adapter = context.getBean("outboundAdapter", EventDrivenConsumer.class);
    Object handler = context.getBean("outboundAdapter.handler");
    assertEquals("outboundAdapter", adapter.getComponentName());
    DirectFieldAccessor accessor = new DirectFieldAccessor(handler);
    Object topicExpression = accessor.getPropertyValue("topicExpression");
    assertNotNull(topicExpression);
    assertEquals("headers['topic'] ?: 'foo'", ((Expression) topicExpression).getExpressionString());
    Object converterBean = context.getBean("testConverter");
    assertEquals(converterBean, accessor.getPropertyValue("messageConverter"));
    assertEquals(context.getBean("serializer"), accessor.getPropertyValue("serializer"));
    Object endpointHandler = TestUtils.getPropertyValue(adapter, "handler");
    assertTrue(AopUtils.isAopProxy(endpointHandler));
    assertThat(TestUtils.getPropertyValue(endpointHandler, "h.advised.advisors.first.item.advice"), Matchers.instanceOf(RequestHandlerRetryAdvice.class));
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) RequestHandlerRetryAdvice(org.springframework.integration.handler.advice.RequestHandlerRetryAdvice) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) RedisAvailable(org.springframework.integration.redis.rules.RedisAvailable) Test(org.junit.Test)

Example 87 with EventDrivenConsumer

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

the class OutboundChannelAdapterParserTests method testOutboundChannelAdapterWithId.

@Test
public void testOutboundChannelAdapterWithId() {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("OutboundChannelAdapterParserTests-context.xml", this.getClass());
    Object consumer = context.getBean("sftpOutboundAdapter");
    assertTrue(consumer instanceof EventDrivenConsumer);
    PublishSubscribeChannel channel = context.getBean("inputChannel", PublishSubscribeChannel.class);
    assertEquals(channel, TestUtils.getPropertyValue(consumer, "inputChannel"));
    assertEquals("sftpOutboundAdapter", ((EventDrivenConsumer) consumer).getComponentName());
    FileTransferringMessageHandler<?> handler = TestUtils.getPropertyValue(consumer, "handler", FileTransferringMessageHandler.class);
    String remoteFileSeparator = (String) TestUtils.getPropertyValue(handler, "remoteFileTemplate.remoteFileSeparator");
    assertNotNull(remoteFileSeparator);
    assertEquals(".", remoteFileSeparator);
    assertEquals(".bar", TestUtils.getPropertyValue(handler, "remoteFileTemplate.temporaryFileSuffix", String.class));
    Expression remoteDirectoryExpression = (Expression) TestUtils.getPropertyValue(handler, "remoteFileTemplate.directoryExpressionProcessor.expression");
    assertNotNull(remoteDirectoryExpression);
    assertTrue(remoteDirectoryExpression instanceof LiteralExpression);
    assertNotNull(TestUtils.getPropertyValue(handler, "remoteFileTemplate.temporaryDirectoryExpressionProcessor"));
    assertEquals(context.getBean("fileNameGenerator"), TestUtils.getPropertyValue(handler, "remoteFileTemplate.fileNameGenerator"));
    assertEquals("UTF-8", TestUtils.getPropertyValue(handler, "remoteFileTemplate.charset"));
    CachingSessionFactory<?> sessionFactory = TestUtils.getPropertyValue(handler, "remoteFileTemplate.sessionFactory", CachingSessionFactory.class);
    DefaultSftpSessionFactory clientFactory = TestUtils.getPropertyValue(sessionFactory, "sessionFactory", DefaultSftpSessionFactory.class);
    assertEquals("localhost", TestUtils.getPropertyValue(clientFactory, "host"));
    assertEquals(2222, TestUtils.getPropertyValue(clientFactory, "port"));
    assertEquals(23, TestUtils.getPropertyValue(handler, "order"));
    // verify subscription order
    @SuppressWarnings("unchecked") Set<MessageHandler> handlers = (Set<MessageHandler>) TestUtils.getPropertyValue(TestUtils.getPropertyValue(channel, "dispatcher"), "handlers");
    Iterator<MessageHandler> iterator = handlers.iterator();
    assertSame(TestUtils.getPropertyValue(context.getBean("sftpOutboundAdapterWithExpression"), "handler"), iterator.next());
    assertSame(handler, iterator.next());
    assertEquals(384, TestUtils.getPropertyValue(handler, "chmod"));
    context.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) Set(java.util.Set) PublishSubscribeChannel(org.springframework.integration.channel.PublishSubscribeChannel) MessageHandler(org.springframework.messaging.MessageHandler) FileTransferringMessageHandler(org.springframework.integration.file.remote.handler.FileTransferringMessageHandler) LiteralExpression(org.springframework.expression.common.LiteralExpression) DefaultSftpSessionFactory(org.springframework.integration.sftp.session.DefaultSftpSessionFactory) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) LiteralExpression(org.springframework.expression.common.LiteralExpression) SpelExpression(org.springframework.expression.spel.standard.SpelExpression) Expression(org.springframework.expression.Expression) Test(org.junit.Test)

Example 88 with EventDrivenConsumer

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

the class FtpsOutboundChannelAdapterParserTests method testFtpsOutboundChannelAdapterComplete.

@Test
public void testFtpsOutboundChannelAdapterComplete() throws Exception {
    assertTrue(ftpOutbound instanceof EventDrivenConsumer);
    assertEquals(this.ftpChannel, TestUtils.getPropertyValue(ftpOutbound, "inputChannel"));
    assertEquals("ftpOutbound", ftpOutbound.getComponentName());
    FileTransferringMessageHandler<?> handler = TestUtils.getPropertyValue(ftpOutbound, "handler", FileTransferringMessageHandler.class);
    assertEquals(this.fileNameGenerator, TestUtils.getPropertyValue(handler, "remoteFileTemplate.fileNameGenerator"));
    assertEquals("UTF-8", TestUtils.getPropertyValue(handler, "remoteFileTemplate.charset"));
    DefaultFtpsSessionFactory sf = TestUtils.getPropertyValue(handler, "remoteFileTemplate.sessionFactory", DefaultFtpsSessionFactory.class);
    assertEquals("localhost", TestUtils.getPropertyValue(sf, "host"));
    assertEquals(22, TestUtils.getPropertyValue(sf, "port"));
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) DefaultFtpsSessionFactory(org.springframework.integration.ftp.session.DefaultFtpsSessionFactory) Test(org.junit.Test)

Example 89 with EventDrivenConsumer

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

the class JmsOutboundGatewayParserTests method gatewayWithExplicitPubSubDomainTrue.

@Test
public void gatewayWithExplicitPubSubDomainTrue() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundGatewayWithPubSubSettings.xml", this.getClass());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("pubSubDomainGateway");
    DirectFieldAccessor accessor = new DirectFieldAccessor(new DirectFieldAccessor(endpoint).getPropertyValue("handler"));
    assertTrue((Boolean) accessor.getPropertyValue("requestPubSubDomain"));
    assertTrue((Boolean) accessor.getPropertyValue("replyPubSubDomain"));
    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 90 with EventDrivenConsumer

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

the class JmsOutboundGatewayParserTests method gatewayWithOrder.

@Test
public void gatewayWithOrder() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundGatewayWithOrder.xml", this.getClass());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("jmsGateway");
    DirectFieldAccessor accessor = new DirectFieldAccessor(new DirectFieldAccessor(endpoint).getPropertyValue("handler"));
    Object order = accessor.getPropertyValue("order");
    assertEquals(99, order);
    assertEquals(Boolean.TRUE, accessor.getPropertyValue("requiresReply"));
    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