Skip to main content

Samba DSL

Architecture

The Samba DSL is based on the possibility to inject a Samba proxy client into the main test code with just a few annotations. This opens the possibility to use a set of predefined actions on the proxy client that are optimised for the need of testing.

To have the Samba proxy client injected in the test the only required step is to include an argument of type SambaApplication in the list of arguments of the test and to annotate it with the minimum required annotations. The respective object is initialised automatically and allows to be readily used in the test.

Method reference

SambaApplication::createFolder

ParameterTypeDescription
folderStringThe path to the folder to be created

Creates a folder with the specified path. Returns a SambaWriteResponse containing information about the created folder in the Samba server.

SambaApplication::deleteFolder

ParameterTypeDescription
folderStringThe path to the folder to be deleted

Deletes a folder with the specified path.

SambaApplication::listFiles

ParameterTypeDescription
folderStringThe path to the folder from which you want the contents to be listed

Returns a SambaListResponse containing a list of files and folders currently sitting in the folder you passed as parameter. You can assert if a file or folder is present in this directory, or not.

SambaApplication::writeFile

ParameterTypeDescription
fileFileThe file, copied from the local file system, that should be uploaded to the Samba server
fileNameStringFile name to be used for this file in the Samba server

Copies a file from the current file system to the Samba server, using the name provided. Returns a SambaWriteResponse containing the uploaded file name, size and time-related attributes (creation time, modification time, last access time and last write time)

SambaApplication::writeFile

ParameterTypeDescription
fileStreamInputStreamAn input stream from which the file contents are read
fileNameStringFile name to be used for this file in the Samba server

Uploads a file to the Samba server reading bytes from an InputStream, using the name provided. Returns a SambaWriteResponse containing the uploaded file name, size and time-related attributes (creation time, modification time, last access time and last write time)

SambaApplication::readFile

ParameterTypeDescription
fileStringThe path to the file to be read, in the Samba server

Reads a file, at the provided path, from the Samba server. Returns a SambaReadResponse containing file attributes like name and size, and a byte array with the file content itself.

SambaApplication::moveFile

ParameterTypeDescription
oldFileStringThe path to the file that should be moved or renamed, in the Samba server
newFileStringThe path to the new folder where the file should be moved to, together with a possible new name for the file

Moves and/or renames a file, in the Samba server. Returns a SambaWriteResponse containing file attributes after the write operation succeeded.

SambaApplication::deleteFile

ParameterTypeDescription
fileStringThe path to the file that should be deleted, in the Samba server

Deletes a file, at the provided path, in the Samba server.

SambaReadResponse::printFileInformation

Logs information about the file that has been retrieved from the Samba server. Information includes file name, file size in bytes, creation time, modification time, last access time and last write time.

SambaReadResponse::assertFileSizeInBytes

ParameterTypeDescription
fileSizeInByteslongThe expected size, in bytes, for the file retrieved from the Samba server

Asserts that the file retrieved from the Samba server has an expected size, in bytes. Useful to double-check if the correct file was retrieved.

SambaReadResponse::getFileContent

Returns a byte array containing the file retrieved from the Samba server.

SambaWriteResponse::printFileInformation

Logs information about the file that has been uploaded to the Samba server. Information includes file name, file size in bytes, creation time, modification time, last access time and last write time.

SambaWriteResponse::assertFileSizeInBytes

ParameterTypeDescription
fileSizeInByteslongThe expected size, in bytes, for the file uploaded to the Samba server

Asserts that the file uploaded from the Samba server has an expected size, in bytes. Useful to double-check if the write operation succeeded in creating the exact same file as the one intended to be uploaded.

SambaListResponse::printFilesInformation

Logs information regarding all files and folders returned. Information includes name, size in bytes, creation time, modification time, last access time and last write time.

SambaListResponse::getFilesAndFolders

Returns a java.util.Collection object containing information about all files and folders found in the listFiles operation.

SambaListResponse::assertThatContainsFileOrFolderNamed

ParameterTypeDescription
fileOrFolderStringThe name of the file or folder that needs to be present in order to pass the assertion.

Asserts that the list of elements returned contains the specified file or folder. It uses basic string comparison.

SambaListResponse::assertThatDoesNotContainFileOrFolderNamed

ParameterTypeDescription
fileOrFolderStringThe name of the file or folder that needs to be present in order to pass the assertion.

Asserts that the list of elements returned does not contain the specified file or folder. It uses basic string comparison.

Any SambaResponse::andThen

Returns the initial SambaApplication to be able to continue the flow. Typically, after a set of assertions this method can be used to re-query the Samba server for something else to run additional assertions.