Skip to content

Commit 07a1d27

Browse files
committed
Move documentation about port up
While reading the README I very often expect documentation about the port immediately after introducing the rule because the port number is essential for running a test that connects to an SFTP server.
1 parent 1775220 commit 07a1d27

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,34 +45,34 @@ The Fake SFTP Server Rule is used by adding it to your test class.
4545

4646
This rule starts a server before your test and stops it afterwards.
4747

48-
You can interact with the SFTP server by using the SFTP protocol with password
49-
authentication. By default the server accepts every pair of username and
50-
password, but you can restrict it to specific pairs.
48+
By default the SFTP server listens on an auto-allocated port. During the test
49+
this port can be obtained by `sftpServer.getPort()`. It can be changed
50+
by calling `setPort(int)`. If you do this from within a test then the server
51+
gets restarted. The time-consuming restart can be avoided by setting the port
52+
immediately after creating the rule.
5153

5254
public class TestClass {
5355
@Rule
5456
public final FakeSftpServerRule sftpServer = new FakeSftpServerRule()
55-
.addUser("username", "password");
57+
.setPort(1234);
5658

5759
...
5860
}
5961

60-
It is also possible to do this during the test using the same method.
61-
62-
By default the SFTP server listens on an auto-allocated port. During the test
63-
this port can be obtained by `sftpServer.getPort()`. It can be changed
64-
by calling `setPort(int)`. If you do this from within a test then the server
65-
gets restarted. The time-consuming restart can be avoided by setting the port
66-
immediately after creating the rule.
62+
You can interact with the SFTP server by using the SFTP protocol with password
63+
authentication. By default the server accepts every pair of username and
64+
password, but you can restrict it to specific pairs.
6765

6866
public class TestClass {
6967
@Rule
7068
public final FakeSftpServerRule sftpServer = new FakeSftpServerRule()
71-
.setPort(1234);
69+
.addUser("username", "password");
7270

7371
...
7472
}
7573

74+
It is also possible to do this during the test using the same method.
75+
7676
### Testing code that reads files
7777

7878
If you test code that reads files from an SFTP server then you need a server

src/main/java/com/github/stefanbirkner/fakesftpserver/rule/FakeSftpServerRule.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,33 +38,33 @@
3838
* }
3939
* </pre>
4040
* <p>This rule starts a server before your test and stops it afterwards.
41-
* <p>You can interact with the SFTP server by using the SFTP protocol with
42-
* password authentication. By default the server accepts every pair of
43-
* username and password, buy you can restrict it to specific pairs.
41+
* <p>By default the SFTP server listens on an auto-allocated port. During the
42+
* test this port can be obtained by {@link #getPort() sftpServer.getPort()}. It
43+
* can be changed by calling {@link #setPort(int)}. If you do this from within a
44+
* test then the server gets restarted. The time-consuming restart can be
45+
* avoided by setting the port immediately after creating the rule.
4446
* <pre>
4547
* public class TestClass {
4648
* &#064;Rule
4749
* public final FakeSftpServerRule sftpServer = new FakeSftpServerRule()
48-
* .{@link #addUser(String, String) addUser}("username", "password");
50+
* .setPort(1234);
4951
*
5052
* ...
5153
* }
5254
* </pre>
53-
* <p>It is also possible to do this during the test using the same method.
54-
* <p>By default the SFTP server listens on an auto-allocated port. During the
55-
* test this port can be obtained by {@link #getPort() sftpServer.getPort()}. It
56-
* can be changed by calling {@link #setPort(int)}. If you do this from within a
57-
* test then the server gets restarted. The time-consuming restart can be
58-
* avoided by setting the port immediately after creating the rule.
55+
* <p>You can interact with the SFTP server by using the SFTP protocol with
56+
* password authentication. By default the server accepts every pair of
57+
* username and password, buy you can restrict it to specific pairs.
5958
* <pre>
6059
* public class TestClass {
6160
* &#064;Rule
6261
* public final FakeSftpServerRule sftpServer = new FakeSftpServerRule()
63-
* .setPort(1234);
62+
* .{@link #addUser(String, String) addUser}("username", "password");
6463
*
6564
* ...
6665
* }
6766
* </pre>
67+
* <p>It is also possible to do this during the test using the same method.
6868
*
6969
* <h2>Testing code that reads files</h2>
7070
* <p>If you test code that reads files from an SFTP server then you need the

0 commit comments

Comments
 (0)