This shows you the differences between two versions of the page.
es:en:text_files_adaptor [2018/09/19 11:22] tast created |
es:en:text_files_adaptor [2025/03/31 13:34] (current) ale |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Adaptador Ficheros de Texto ===== | + | Text Files Adaptor |
+ | Introduction | ||
+ | Through the Text Files Adaptor, TAST can manage plain text files and use them in testing. It’s possible to perform single tests with this adaptor or End to end tests connecting with other adaptors either. | ||
- | {{:TAST-icon.png?nolink&70|}} | + | Initialization Parameters |
+ | FilePath: the complete path, including the name of the file, of the file represented by the adapter in the diagram. | ||
+ | CharSet: the charset used to create the file. For example, if you are using files for Webservice testing, charset must be UTF-8. If you are using files from Windows to one FTP/SFTP server charset must be CP1252. | ||
+ | It is really important to select properly the charset of the file, the return carriage character is handled in a different way depending on it. It can impact in all the predefine functions managing the file in H-TEST. | ||
+ | To select the proper charset you, it is possible to identify it using the text editor in the following way: | ||
- | ==== Inicialización de parámetros ==== | ||
- | * **FilePath:** La ruta completa, incluido el nombre del archivo representado por el adaptador en el diagrama | ||
- | * **CharSet:** El conjunto de caracteres usados en el archivo a tratar. | + | Charset.png |
- | ==== Funciones ==== | + | Create/Overwrite: when the checkbox is marked, H-TEST will create a new file or overwrite it if the file already exists. |
+ | Functions | ||
+ | closeFile(): closes the file and release the associated resources. Returns true if the file could be closed correctly or false otherwise. Input parameters are not required. | ||
+ | containsText(SearchString): returns true if the text string entered in the searchString parameter exists in the file, false otherwise. | ||
+ | countFileLine(): returns the number of lines in the file. Input parameters are not required. | ||
+ | countTextFile(): this function counts the number of times a string appears in a file. The input parameter searchString allow the user to search and execute the comparison. | ||
+ | deleteFtpFile(): this function deletes a file from the FTP server. Returns if the operation was successful or it was not. The parameters that function needs are: | ||
+ | The Host parameter represents the address of the remote machine where the file resides. | ||
+ | The User parameter represents the user of connection to the remote system. | ||
+ | The Password parameter represents the user's password on the remote system. | ||
+ | The RemotePath parameter represents the path of the file on the remote system. | ||
+ | The Port parameter represents the port number of the server. | ||
+ | deleteSftpFile(): this function deletes a file from the SFTP server. Returns if the operation was successful or it was not. The parameters that function needs are: | ||
+ | The Host parameter represents the address of the remote machine where the file resides. | ||
+ | The User parameter represents the user of connection to the remote system. | ||
+ | The Password parameter represents the user's password on the remote system. | ||
+ | The RemotePath parameter represents the path of the file on the remote system. | ||
+ | The Port parameter represents the port number of the server. | ||
+ | generateFileAsEvidence(): the function generates a copy of the file in it's current state to add as evidence. | ||
+ | getFileText(): reads the content of the file and it returns as a TastDataString variable. It does not require input parameters. | ||
+ | getFtpFile(Host, User, Password, RemotePath, LocalPath): allows transferring a file via the FTP protocol of a remote system to the local system in which the diagram is executed. | ||
+ | Returns true if the operation is successful, false otherwise. | ||
+ | The Host parameter represents the address of the remote machine where the file resides. | ||
+ | The User parameter represents the user of connection to the remote system. | ||
+ | The Password parameter represents the user's password on the remote system. | ||
+ | The RemotePath parameter represents the path on the remote system to the file that we want to transfer. | ||
+ | The LocalPath parameter represents the path, in the local file system, where we want to transfer the file. | ||
+ | getLineLength(lineNum): returns the length of the file line indicated by the lineNum parameter. | ||
+ | getNumColumns(): returns the number of columns contained in the TastTableData that was generated by the execution of the loadCsvFile function. | ||
+ | It requires the execution of the loadCsvFile function in previous steps of the diagram. | ||
- | * **closeFile():** Cierra el archivo y libere los recursos asociados. Devuelve true si el archivo puede cerrarse correctamente o falso de lo contrario. | + | getOwner(): return file 's owner in the filesystem. Input parameters are not required. |
+ | getReadLine(lineNum): returns a variable of type String to the executor with the content of the number of line indicated by the lineNum parameter. | ||
+ | getSftpFile(Host, Port, User, Password, RemotePath, LocalPath): allows transferring a file via the SFTP protocol of a remote system to the local system in which the diagram is executed. | ||
+ | Returns true if the operation is successful, false otherwise. | ||
+ | The Host parameter represents the address of the remote machine where the file resides. | ||
+ | The Port parameter represents the port number on which the SFTP server listens for incoming connections. The Sftp takes port 22 by default. | ||
+ | The User parameter represents the user of connection to the remote system. | ||
+ | The Password parameter represents the user's password on the remote system. | ||
+ | The RemotePath parameter represents the path on the remote system to the file that we want to transfer. | ||
+ | The LocalPath parameter represents the path, in the local file system, where we want to transfer the file. | ||
+ | getSize(): returns the file size in KiloBytes. Input parameters are not required. | ||
+ | getTableValue(RowNum, ColNum): returns the contained value of the cell indicated by the RowNum and ColNum parameters. | ||
+ | It requires the execution of the loadCsvFile function in previous steps of the diagram. | ||
- | * **ContainsText(searchString):** Devuelve verdadero si el valor de la cadena de texto del parámetro searchString existe en el archivo, de lo contrario es falso. | + | getTextFileData(): keeps all the content of the file in an array and another file for futures operations. It does not require input parameters. |
- | + | lineContainsText(lineNum, StringToSearch): returns true if the text string entered in the StringToSearch parameter exists in the line of the file indicated by the lineNum parameter, and false otherwise. | |
- | * **CountFileLine():** Devuelve el número de líneas del fichero. | + | loadCsvFile(Separator): reads the contents of a csv-type file, and transforms it into a TastTableData variable that is returned to the executor so that we can operate on the data in the next steps of the diagram. The separator parameter indicates the separator character of fields in the file. |
- | + | newFile(FilePath): creates or overrides a file, with the path and the name indicated by the parameter “filePath”. | |
- | * **getFtpFile(Host, User, Password, remotePath, localPath):** Permite transferir un archivo a través del protocolo Ftp de un sistema remoto al sistema local en el que se ejecuta el diagrama. | + | If the file doesn´t exist, TAST will create it, as an empty file. |
- | * Devuelve verdadero si la operación finaliza con éxito, de lo contrario, falso. | + | If the file exist, TAST will delete the current file, and it will create a new empty one. |
- | * El parámetro Host indica la dirección de la máquina remota donde reside el archivo. | + | openFile(): checks the existence of the file in the file system, and the reads / writes permissions on it. Returns true if the file could be accessed correctly or false otherwise. Input parameters are not required. |
- | * El parámetro User indica el usuario de la conexión al sistema remoto. | + | openNewFile(): resets the content of the configured file to empty. This file must exist. Input parameters are not required. |
- | * El parámetro Password indica la contraseña del usuario en el sistema remoto. | + | putFtpFile(Host, User, Pasword, LocalFileName, RemoteFileName, HostDirectory): allows to transfer a file, by the Ftp protocol, of the local system in which the diagram is executed to the remote system. |
- | * El parámetro remotePath indica la ruta en el sistema remoto del archivo que queremos transferir. | + | Returns true if the operation is successful, false otherwise. |
- | * El parámetro localPath representa la ruta donde queremos transferir el archivo. | + | The Host parameter represents the address of the remote machine where the file resides. |
- | + | The User parameter represents the user of connection to the remote system. | |
- | * **GetLineLength(numLine):** Devuelve la longitud de la línea de archivo indicada por el parámetro numLine. | + | The Password parameter represents the user's password on the remote system. |
- | + | The LocalFileName parameter represents the full path to the file on the local system. | |
- | * **GetNumColumns():** Devuelve el número de columnas contenidas en TastTableData que se generó mediante la ejecución de la función dBGetQueryData. Requiere la ejecución de la función dBGetQueryData en los pasos anteriores del diagrama. | + | The RemoteFileName parameter represents the name of the file on the remote system. |
- | + | The HostDirectory parameter represents the directory, in the remote file system, where we want to transfer the file. | |
- | * **GetOwner():** Devuelve el propietario del fichero. | + | putSftpFile(Host, Port, User, Password, LocalPath, RemotePathFormed): allows to transfer a file, by the Sftp protocol, of the local system in which the diagram is executed to the remote system. |
- | + | Returns true if the operation is successful, false otherwise. | |
- | * **GetReadLine(numLine):** Devuelve en una variable de tipo String el contenido de la línea indicado por el parámetro numLine. | + | The Host parameter represents the address of the remote machine where the file resides. |
- | + | The Port parameter represents the port number on which the file server waits for incoming connections.The SFTP takes port 22 by default. | |
- | * **getSFtpFile(Host, Port, User, Password, remotePath, localPath):** Permite transferir un archivo a través del protocolo SFtp de un sistema remoto al sistema en el que se ejecuta el diagrama. | + | The User parameter represents the user of connection to the remote system. |
- | * Devuelve verdadero si la operación finaliza con éxito, de lo contrario, falso. | + | The Password parameter represents the user's password on the remote system. |
- | * El parámetro Host indica la dirección de la máquina remota donde reside el archivo. | + | The LocalPath parameter represents the complete path and the name of the file in the local system. |
- | * El parámetro Port representa el número de puerto en el que el servidor SFTP escucha las conexiones entrantes. | + | The RemotePathFormed parameter represents the full path and the name of the file on the remote system. |
- | * El parámetro User indica el usuario de la conexión al sistema remoto. | + | replaceText(From_Str, To_Str): allows to replace all the occurrences of the string “From_Str” by the string “To_Str”, and will save the file again. |
- | * El parámetro Password indica la contraseña del usuario en el sistema remotoem. | + | writeEnter: the function append a carriage return to the file. Input parameters are not required. |
- | * El parámetro remotePath indica la ruta en el sistema remoto del archivo que queremos transferir. | + | writeTo(StringToWrite): writes the text string in the file, in append mode. |
- | * El parámetro localPath representa la ruta donde queremos transferir el archivo. | + | Returns true if the write operation was successful, false otherwise. The input parameters are StringToWrite to receive the text string and addBreakLine to skip the line (this parameter is a Boolean). |
- | + | ||
- | * **GetSize():** Devuelve el tamaño del fichero en KiloBytes. | + | |
- | + | ||
- | * **GetTableValue(RowNum, ColNum):** Devuelve el valor contenido de la celda indicada por los parámetros RowNum y ColNum. Requiere la ejecución de la función dBGetQueryData en los pasos anteriores del diagrama. | + | |
- | + | ||
- | * **LineContainsText(numLine, searchString):** Devuelve verdadero si el valor de la cadena de texto del parámetro searchString existe en la línea del archivo indicado por el parámetro numLine, y falso en caso contrarioo. | + | |
- | + | ||
- | * **LoadCsvFile(separator):** Lee el contenido de un archivo de tipo csv y lo transforma en una variable TastTableData con la que podamos operar sobre los datos en los siguientes pasos del diagrama. El parámetro separator indica el carácter separador de los campos en el archivo. | + | |
- | + | ||
- | * **openFile():** Verifica la existencia del archivo y los permisos de lectura / escritura en él. Devuelve verdadero si el archivo se puede acceder correctamente o falso en caso contrario. | + | |
- | + | ||
- | * **putFtpFile(Host, User, Pasword, LocalFileName, remoteFileName, hostDirectory):** Permite transferir un archivo, mediante el protocolo Ftp, del sistema local en el que se ejecuta el diagrama al sistema remoto. | + | |
- | * Devuelve verdadero si la operación finaliza con éxito, de lo contrario, falso. | + | |
- | * El parámetro Host indica la dirección de la máquina remota donde reside el archivo. | + | |
- | * El parámetro Port representa el número de puerto en el que el servidor SFTP escucha las conexiones entrantes. | + | |
- | * El parámetro User indica el usuario de la conexión al sistema remoto. | + | |
- | * El parámetro Password indica la contraseña del usuario en el sistema remoto. | + | |
- | * El parámetro localFileName representa la ruta completa al archivo en el sistema local. | + | |
- | * El parámetro remoteFileName representa el nombre del archivo en el sistema remoto. | + | |
- | * El parámetro hostDirectory representa el directorio, en el sistema de archivos remoto, donde queremos transferir el archivo. | + | |
- | + | ||
- | * **putSFtpFile(Host, Port, User, Password, LocalPath, remotePathFormed):** Permite transferir un archivo, mediante el protocolo SFtp, del sistema local en el que se ejecuta el diagrama al sistema remoto. | + | |
- | * Devuelve verdadero si la operación finaliza con éxito, de lo contrario, falso. | + | |
- | * El parámetro Host indica la dirección de la máquina remota donde reside el archivo. | + | |
- | * El parámetro Port representa el número de puerto en el que el servidor SFTP escucha las conexiones entrantes. | + | |
- | * El parámetro User indica el usuario de la conexión al sistema remoto. | + | |
- | * El parámetro Password indica la contraseña del usuario en el sistema remoto. | + | |
- | * El parámetro localPath representa la ruta completa y el nombre del archivo en el sistema local. | + | |
- | * El parámetro remotePathFormed representa la ruta completa y el nombre del archivo en el sistema remoto. | + | |
- | + | ||
- | * **WriteTo(writeString):** Escriba la cadena de texto en el archivo, al final del mismo. | + | |
- | * Devuelve verdadero si la operación de escritura fue exitosa, de lo contrario, falsa. | + |