org.aludratest.service.file
Interface FileInteraction

All Superinterfaces:
Action, Interaction
All Known Implementing Classes:
FileActionImpl

public interface FileInteraction
extends Interaction

Interaction interface of the FileService.

Author:
Volker Bergmann

Method Summary
 boolean copy(String fromPath, String toPath, boolean overwrite)
          Copies a file or folder.
 void createDirectory(String directoryPath)
          Creates a directory.
 void delete(String filePath)
          Deletes a file or folder.
 List<String> getChildren(String filePath)
          Lists all child elements of the given folder.
 List<String> getChildren(String filePath, FileFilter filter)
          Lists all child elements of the given folder which match the filter.
 List<String> getChildren(String filePath, String filterRegex)
          Lists all child elements of the given folder which match the given regular expression.
 InputStream getInputStreamForFile(String filePath)
          Creates an InputStream for accessing the content of a file.
 BufferedReader getReaderForTextFile(String filePath)
          Creates a Reader for accessing the content of a text file.
 String getRootFolder()
          Provides the root folder of the service instance.
 boolean move(String fromPath, String toPath, boolean overwrite)
          Renames or moves a file or folder.
 byte[] readBinaryFile(String filePath)
          Reads a binary file and provides its content as an array of bytes.
 String readTextFile(String filePath)
          Reads a text file and provides its content as String.
 String waitForFirstMatch(String parentPath, FileFilter filter)
          Polls the given directory until the filter finds a match or a timeout is exceeded.
 void waitUntilExists(String elementType, String filePath)
          Polls the file system for a given file until it is found or a timeout is exceeded.
 void waitUntilNotExists(String filePath)
          Polls the file system for a given file until it has disappeared or a timeout is exceeded.
 boolean writeBinaryFile(String filePath, byte[] bytes, boolean overwrite)
          Creates a binary file with the provided content.
 boolean writeBinaryFile(String filePath, InputStream source, boolean overwrite)
          Creates a binary file and writes to it all content provided by the source InputStream.
 boolean writeTextFile(String filePath, Reader source, boolean overwrite)
          Creates a text file and writes to it all content provided by the source Reader.
 boolean writeTextFile(String filePath, String text, boolean overwrite)
          Creates a text file with the provided content.
 
Methods inherited from interface org.aludratest.service.Action
createAttachments, createDebugAttachments, setSystemConnector
 

Method Detail

getRootFolder

String getRootFolder()
Provides the root folder of the service instance.

Returns:
the root folder of the FileService.

getChildren

List<String> getChildren(String filePath)
Lists all child elements of the given folder.

Parameters:
filePath - the path of the file of which to get children
Returns:
a List of the child objects of the given file

getChildren

List<String> getChildren(String filePath,
                         String filterRegex)
Lists all child elements of the given folder which match the given regular expression.

Parameters:
filePath - the path of the file of which to get the children
filterRegex -
Returns:
a List of the child objects of the given file

getChildren

List<String> getChildren(String filePath,
                         FileFilter filter)
Lists all child elements of the given folder which match the filter.

Parameters:
filePath - the path of the file of which to get the children
filter -
Returns:
a List of the child objects of the given file

createDirectory

void createDirectory(String directoryPath)
Creates a directory.

Parameters:
directoryPath - the path of the directory to create

move

boolean move(String fromPath,
             String toPath,
             boolean overwrite)
Renames or moves a file or folder.

Parameters:
fromPath - the file/folder to rename/move
toPath - the new name/location of the file/folder
overwrite - flag which indicates if an existing file may be overwritten by the operation
Returns:
true if a formerly existing file was overwritten.
Throws:
org.aludratest.service.file.exception.FilePresentException - if a file was already present and overwriting was disabled.

copy

boolean copy(String fromPath,
             String toPath,
             boolean overwrite)
Copies a file or folder.

Parameters:
fromPath - the file/folder to copy
toPath - the name/location of the copy
overwrite - flag which indicates if an existing file may be overwritten by the operation
Returns:
true if a formerly existing file was overwritten.
Throws:
org.aludratest.service.file.exception.FilePresentException - if a file was already present and overwriting was disabled.

delete

void delete(String filePath)
Deletes a file or folder.

Parameters:
filePath - the path of the file to delete

writeTextFile

boolean writeTextFile(String filePath,
                      String text,
                      boolean overwrite)
Creates a text file with the provided content.

Parameters:
filePath - the path of the file to save
text - the text to save as file content
overwrite - flag which indicates if an existing file may be overwritten by the operation
Returns:
true if a formerly existing file was overwritten.
Throws:
org.aludratest.service.file.exception.FilePresentException - if a file was already present and overwriting was disabled.

writeTextFile

boolean writeTextFile(String filePath,
                      Reader source,
                      boolean overwrite)
Creates a text file and writes to it all content provided by the source Reader.

Parameters:
filePath - the path of the file to save
source - a Reader which provides the file content
overwrite - flag which indicates if an existing file may be overwritten by the operation
Returns:
true if a formerly existing file was overwritten.
Throws:
org.aludratest.service.file.exception.FilePresentException - if a file was already present and overwriting was disabled.

writeBinaryFile

boolean writeBinaryFile(String filePath,
                        byte[] bytes,
                        boolean overwrite)
Creates a binary file with the provided content.

Parameters:
filePath - the path of the file to save
bytes - the file content to write
overwrite - flag which indicates if an existing file may be overwritten by the operation
Returns:
true if a formerly existing file was overwritten.
Throws:
org.aludratest.service.file.exception.FilePresentException - if a file was already present and overwriting was disabled.

writeBinaryFile

boolean writeBinaryFile(String filePath,
                        InputStream source,
                        boolean overwrite)
Creates a binary file and writes to it all content provided by the source InputStream.

Parameters:
filePath - the path of the file to save
source - an InputStream which provides the content to write to the file
overwrite - flag which indicates if an existing file may be overwritten by the operation
Returns:
true if a formerly existing file was overwritten.
Throws:
org.aludratest.service.file.exception.FilePresentException - if a file was already present and overwriting was disabled.

readTextFile

String readTextFile(String filePath)
Reads a text file and provides its content as String.

Parameters:
filePath - the path of the file to read
Returns:
the content of the file

getReaderForTextFile

BufferedReader getReaderForTextFile(String filePath)
Creates a Reader for accessing the content of a text file.

Parameters:
filePath - the path of the file to read
Returns:
a reader for the text file

readBinaryFile

byte[] readBinaryFile(String filePath)
Reads a binary file and provides its content as an array of bytes.

Parameters:
filePath - the path of the file to read
Returns:
the file content as byte array

getInputStreamForFile

InputStream getInputStreamForFile(String filePath)
Creates an InputStream for accessing the content of a file.

Parameters:
filePath - the path of the file for which to get an input stream
Returns:
an InputStream for accessing the file

waitUntilExists

void waitUntilExists(String elementType,
                     String filePath)
Polls the file system for a given file until it is found or a timeout is exceeded. Timeout and the maximum number of polls are retrieved from the FileServiceConfiguration.

Parameters:
elementType -
filePath - the path of the file for which to wait
Throws:
AutomationException - if the file was not found within the timeout

waitUntilNotExists

void waitUntilNotExists(String filePath)
Polls the file system for a given file until it has disappeared or a timeout is exceeded. Timeout and the maximum number of polls are retrieved from the FileServiceConfiguration.

Parameters:
filePath - the path of the file for which to wait until absence
Throws:
AutomationException - if the file was not found within the timeout

waitForFirstMatch

String waitForFirstMatch(String parentPath,
                         FileFilter filter)
Polls the given directory until the filter finds a match or a timeout is exceeded. Timeout and the maximum number of polls are retrieved from the FileServiceConfiguration.

Parameters:
parentPath - the path of the directory in which to search for the file
filter - a filter object that decides which file is to be accepted
Returns:
the file path of the first file that was accepted by the filter
Throws:
AutomationException - if the file was not found within the timeout


Copyright © 2015 aludratest.org. All rights reserved.