use of org.springframework.integration.file.remote.SessionCallback in project spring-integration-samples by spring-projects.
the class SftpTestUtils method createTestFiles.
public static void createTestFiles(RemoteFileTemplate<LsEntry> template, final String... fileNames) {
if (template != null) {
final ByteArrayInputStream stream = new ByteArrayInputStream("foo".getBytes());
template.execute((SessionCallback<LsEntry, Void>) session -> {
try {
session.mkdir("si.sftp.sample");
} catch (Exception e) {
assertThat(e.getMessage(), containsString("failed to create"));
}
for (int i = 0; i < fileNames.length; i++) {
stream.reset();
session.write(stream, "si.sftp.sample/" + fileNames[i]);
}
return null;
});
}
}
Aggregations