Skip to content

Commit 00f0113

Browse files
committed
Extract assertEmptyDirectoryExists
This is a preparatory refactoring. The method will be used by another test when we implement a `createDirectories` method.
1 parent 6b6a0f0 commit 00f0113

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</parent>
1010

1111
<artifactId>fake-sftp-server-rule</artifactId>
12-
<version>1.1.1</version>
12+
<version>1.2.0-SNAPSHOT</version>
1313
<packaging>jar</packaging>
1414

1515
<name>Fake SFTP Server Rule</name>

src/test/java/com/github/stefanbirkner/fakesftpserver/rule/FakeSftpServerRuleTest.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,7 @@ public void a_directory_that_is_created_with_the_rule_can_be_read_by_a_client()
312312
executeTestWithRule(
313313
() -> {
314314
sftpServer.createDirectory("/a/directory");
315-
Session session = connectToServer(sftpServer);
316-
ChannelSftp channel = connectSftpChannel(session);
317-
Vector entries = channel.ls("/a/directory");
318-
assertThat(entries).hasSize(2); //these are the entries . and ..
319-
channel.disconnect();
320-
session.disconnect();
315+
assertEmptyDirectory(sftpServer, "/a/directory");
321316
},
322317
sftpServer
323318
);
@@ -354,6 +349,18 @@ public void a_directory_cannot_be_created_after_the_test_is_finished() {
354349
+ " started or is already finished."
355350
);
356351
}
352+
353+
private static void assertEmptyDirectory(
354+
FakeSftpServerRule sftpServer,
355+
String directory
356+
) throws JSchException, SftpException {
357+
Session session = connectToServer(sftpServer);
358+
ChannelSftp channel = connectSftpChannel(session);
359+
Vector entries = channel.ls(directory);
360+
assertThat(entries).hasSize(2); //these are the entries . and ..
361+
channel.disconnect();
362+
session.disconnect();
363+
}
357364
}
358365

359366
@RunWith(Enclosed.class)

0 commit comments

Comments
 (0)