Add SFTP remote copy test-case

This commit is contained in:
Artem Bilan
2021-02-18 11:31:08 -05:00
parent ee3ccc4493
commit e2e01db9a2

View File

@@ -390,6 +390,30 @@ public class SftpServerOutboundTests extends SftpTestSupport {
session.close();
}
@Test
public void testSftpCopy() throws Exception {
this.template.execute(session -> {
PipedInputStream in = new PipedInputStream();
PipedOutputStream out = new PipedOutputStream(in);
session.read("sftpSource/sftpSource2.txt", out);
session.write(in, "sftpTarget/sftpTarget2.txt");
return null;
});
Session<?> session = this.sessionFactory.getSession();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FileCopyUtils.copy(session.readRaw("sftpTarget/sftpTarget2.txt"), baos);
assertThat(session.finalizeRaw()).isTrue();
assertThat(new String(baos.toByteArray())).isEqualTo("source2");
baos = new ByteArrayOutputStream();
FileCopyUtils.copy(session.readRaw("sftpSource/sftpSource2.txt"), baos);
assertThat(session.finalizeRaw()).isTrue();
assertThat(new String(baos.toByteArray())).isEqualTo("source2");
session.close();
}
@Test
public void testInt3047ConcurrentSharedSession() throws Exception {
final Session<?> session1 = this.sessionFactory.getSession();