use of org.springframework.integration.file.splitter.FileSplitter.FileMarker in project spring-integration by spring-projects.
the class FileSplitterTests method testFirstLineAsHeader.
@Test
public void testFirstLineAsHeader() {
QueueChannel outputChannel = new QueueChannel();
FileSplitter splitter = new FileSplitter(true, true);
splitter.setFirstLineAsHeader("firstLine");
splitter.setOutputChannel(outputChannel);
splitter.handleMessage(new GenericMessage<>(file));
Message<?> received = outputChannel.receive(0);
assertNotNull(received);
assertNull(received.getHeaders().get(IntegrationMessageHeaderAccessor.SEQUENCE_SIZE));
assertNull(received.getHeaders().get("firstLine"));
assertEquals("START", received.getHeaders().get(FileHeaders.MARKER));
assertThat(received.getPayload(), instanceOf(FileSplitter.FileMarker.class));
FileMarker fileMarker = (FileSplitter.FileMarker) received.getPayload();
assertEquals(FileSplitter.FileMarker.Mark.START, fileMarker.getMark());
assertEquals(file.getAbsolutePath(), fileMarker.getFilePath());
received = outputChannel.receive(0);
assertEquals("HelloWorld", received.getHeaders().get("firstLine"));
assertNotNull(received);
received = outputChannel.receive(0);
assertNotNull(received);
assertEquals("END", received.getHeaders().get(FileHeaders.MARKER));
assertNull(received.getHeaders().get("firstLine"));
assertThat(received.getPayload(), instanceOf(FileSplitter.FileMarker.class));
fileMarker = (FileSplitter.FileMarker) received.getPayload();
assertEquals(FileSplitter.FileMarker.Mark.END, fileMarker.getMark());
assertEquals(file.getAbsolutePath(), fileMarker.getFilePath());
assertEquals(1, fileMarker.getLineCount());
}
Aggregations