Example usage for org.springframework.integration.file FileHeaders REMOTE_FILE_INFO

List of usage examples for org.springframework.integration.file FileHeaders REMOTE_FILE_INFO

Introduction

In this page you can find the example usage for org.springframework.integration.file FileHeaders REMOTE_FILE_INFO.

Prototype

String REMOTE_FILE_INFO

To view the source code for org.springframework.integration.file FileHeaders REMOTE_FILE_INFO.

Click Source Link

Document

A remote file information representation

Usage

From source file:org.springframework.integration.ftp.inbound.FtpStreamingMessageSourceTests.java

@SuppressWarnings("unchecked")
@Test/*from  w  ww.j ava 2 s .  co m*/
public void testAllContents() {
    Message<byte[]> received = (Message<byte[]>) this.data.receive(10000);
    assertNotNull(received);
    assertThat(new String(received.getPayload()), equalTo("source1"));
    String fileInfo = (String) received.getHeaders().get(FileHeaders.REMOTE_FILE_INFO);
    assertThat(fileInfo, containsString("remoteDirectory\":\"ftpSource"));
    assertThat(fileInfo, containsString("permissions\":\"-rw-------"));
    assertThat(fileInfo, containsString("size\":7"));
    assertThat(fileInfo, containsString("directory\":false"));
    assertThat(fileInfo, containsString("filename\":\" ftpSource1.txt"));
    assertThat(fileInfo, containsString("modified\":"));
    assertThat(fileInfo, containsString("link\":false"));
    received = (Message<byte[]>) this.data.receive(10000);
    assertNotNull(received);
    assertThat(new String(received.getPayload()), equalTo("source2"));
    fileInfo = (String) received.getHeaders().get(FileHeaders.REMOTE_FILE_INFO);
    assertThat(fileInfo, containsString("remoteDirectory\":\"ftpSource"));
    assertThat(fileInfo, containsString("permissions\":\"-rw-------"));
    assertThat(fileInfo, containsString("size\":7"));
    assertThat(fileInfo, containsString("directory\":false"));
    assertThat(fileInfo, containsString("filename\":\"ftpSource2.txt"));
    assertThat(fileInfo, containsString("modified\":"));
    assertThat(fileInfo, containsString("link\":false"));

    this.adapter.stop();
    this.source.setFileInfoJson(false);
    this.data.purge(null);
    this.adapter.start();
    received = (Message<byte[]>) this.data.receive(10000);
    assertNotNull(received);
    assertThat(received.getHeaders().get(FileHeaders.REMOTE_FILE_INFO), instanceOf(FtpFileInfo.class));
    this.adapter.stop();
}