|
Key
This line was removed.
This word was removed. This word was added.
This line was added.
|
Changes (14)
View Page History{tip}If a home directory is set for the user, it will be automatically created if it does not exist.{tip}
h2. Registering a file
h2. Registering files
Use the API '{{registerFile(...)}}' or '{{registerTempFile(...)}} to mock existing file into a user home directory:
* {{registerFile(User)}}: will create a temporary file at the root of the user home directory. The filename relative to the user home directory is returned.
* {{registerFile(User, String)}}: will create a file with the given file name at the root of the user home directory,
* {{registerTempFile(User)}}: will create a file with a random file name at the root of the user home directory,
* {{registerTempFile(User, String)}}: will create a file with a random file name, except for the extension part, at the root of the user home directory,
* {{registerTempFile(User)}}: will create a file with a random file name at the root of the user home directory,
* {{registerTempFile(User, String)}}: will create a file with a random file name, except for the extension part, at the root of the user home directory,
{code}
public void testUsingFTPServer() throws IOException {
// ...
// ...
final BaseUser user1 = new BaseUser();
// ...
this.ftpServer.registerUser(user);
this.ftpServer.registerUser(user);
// An empty temporary file with a random name created at the root of a user home directory.
final String aTemporaryFileOfUser1 aFileOfUser = this.ftpServer.registerUser(user1); this.ftpServer.registerTempFile(user);
// An empty file with a random name, except the extension part, created at the root of a user home directory.
final String anotherFileOfUser = this.ftpServer.registerTempFile(user, "xml");
final String anotherFileOfUser = this.ftpServer.registerTempFile(user, "xml");
// A non-empty temporary file with a given name created at the root of a user home directory.
final String aTemporaryFileWithContentOfUser1 aFileWithContentOfUser = this.ftpServer.registerFile(user1); "my-filename.xml";
assertTrue(this.ftpServer.registerFile(user, aFileWithContentOfUser));
final FileOutputStream fos = new FileOutputStream(new File(user1.getHomeDirectory(), aTemporaryFileWithContentOfUser1)); File(user.getHomeDirectory(), aFileWithContentOfUser));
try {
fos.write("<test />".getBytes());
fos.write("<test />".getBytes());