use of org.springframework.integration.dsl.StandardIntegrationFlow in project spring-integration by spring-projects.
the class ManualFlowTests method testRegistrationDuplicationRejected.
@Test
public void testRegistrationDuplicationRejected() {
String testId = "testId";
StandardIntegrationFlow testFlow = IntegrationFlows.from(Supplier.class).get();
this.integrationFlowContext.registration(testFlow).id(testId).register();
try {
this.integrationFlowContext.registration(testFlow).id(testId).register();
} catch (Exception e) {
assertThat(e, instanceOf(IllegalArgumentException.class));
assertThat(e.getMessage(), containsString("with flowId '" + testId + "' is already registered."));
}
}
use of org.springframework.integration.dsl.StandardIntegrationFlow in project spring-integration by spring-projects.
the class MockMessageSourceTests method testMockMessageSourceDynamicFlow.
@Test
public void testMockMessageSourceDynamicFlow() {
QueueChannel out = new QueueChannel();
StandardIntegrationFlow flow = IntegrationFlows.from(MockIntegration.mockMessageSource("foo", "bar", "baz")).<String, String>transform(String::toUpperCase).channel(out).get();
IntegrationFlowRegistration registration = this.integrationFlowContext.registration(flow).register();
Message<?> receive = out.receive(10_000);
assertNotNull(receive);
assertEquals("FOO", receive.getPayload());
receive = out.receive(10_000);
assertNotNull(receive);
assertEquals("BAR", receive.getPayload());
for (int i = 0; i < 10; i++) {
receive = out.receive(10_000);
assertNotNull(receive);
assertEquals("BAZ", receive.getPayload());
}
registration.destroy();
}
use of org.springframework.integration.dsl.StandardIntegrationFlow in project spring-integration by spring-projects.
the class FtpTests method testFtpInboundStreamFlow.
@Test
public void testFtpInboundStreamFlow() throws Exception {
QueueChannel out = new QueueChannel();
StandardIntegrationFlow flow = IntegrationFlows.from(Ftp.inboundStreamingAdapter(new FtpRemoteFileTemplate(sessionFactory())).remoteDirectory("ftpSource").maxFetchSize(11).regexFilter(".*\\.txt$"), e -> e.id("ftpInboundAdapter").poller(Pollers.fixedDelay(100))).channel(out).get();
IntegrationFlowRegistration registration = this.flowContext.registration(flow).register();
Message<?> message = out.receive(10_000);
assertNotNull(message);
assertThat(message.getPayload(), instanceOf(InputStream.class));
assertThat(message.getHeaders().get(FileHeaders.REMOTE_FILE), isOneOf(" ftpSource1.txt", "ftpSource2.txt"));
new IntegrationMessageHeaderAccessor(message).getCloseableResource().close();
message = out.receive(10_000);
assertNotNull(message);
assertThat(message.getPayload(), instanceOf(InputStream.class));
assertThat(message.getHeaders().get(FileHeaders.REMOTE_FILE), isOneOf(" ftpSource1.txt", "ftpSource2.txt"));
new IntegrationMessageHeaderAccessor(message).getCloseableResource().close();
MessageSource<?> source = context.getBean(FtpStreamingMessageSource.class);
assertThat(TestUtils.getPropertyValue(source, "maxFetchSize"), equalTo(11));
registration.destroy();
}
use of org.springframework.integration.dsl.StandardIntegrationFlow in project spring-integration by spring-projects.
the class SftpTests method testSftpInboundStreamFlow.
@Test
public void testSftpInboundStreamFlow() throws Exception {
QueueChannel out = new QueueChannel();
StandardIntegrationFlow flow = IntegrationFlows.from(Sftp.inboundStreamingAdapter(new SftpRemoteFileTemplate(sessionFactory())).remoteDirectory("sftpSource").regexFilter(".*\\.txt$"), e -> e.id("sftpInboundAdapter").poller(Pollers.fixedDelay(100))).channel(out).get();
IntegrationFlowRegistration registration = this.flowContext.registration(flow).register();
Message<?> message = out.receive(10_000);
assertNotNull(message);
assertThat(message.getPayload(), instanceOf(InputStream.class));
assertThat(message.getHeaders().get(FileHeaders.REMOTE_FILE), isOneOf(" sftpSource1.txt", "sftpSource2.txt"));
((InputStream) message.getPayload()).close();
new IntegrationMessageHeaderAccessor(message).getCloseableResource().close();
message = out.receive(10_000);
assertNotNull(message);
assertThat(message.getPayload(), instanceOf(InputStream.class));
assertThat(message.getHeaders().get(FileHeaders.REMOTE_FILE), isOneOf(" sftpSource1.txt", "sftpSource2.txt"));
((InputStream) message.getPayload()).close();
new IntegrationMessageHeaderAccessor(message).getCloseableResource().close();
registration.destroy();
}
Aggregations