Interface ITestAgent


public interface ITestAgent
This interface exposes services provided directly by the Agent that may assist in test execution.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    createZipFile(File zipFile, File dir, FileFilter filter, boolean overwriteExisting)
    Create a zip file of the contents of an existing directory tree.
    void
    deleteDirTree(File topDir, boolean deleteTopDir, boolean errorOnMissingDir)
    Deletes an existing directory tree.
    Get the temporary directory on the agent for this test case, this directory falls under the temporary directory for the containing test session for the provided test case.
    getTempDir(ITestSession testSession)
    Get the temporary directory on the agent for this test session.
    void
    Log an exception to the agent.log file.
    void
    logMessage(String message)
    Log a message to the agent.log file with the provided message.
    void
    sendMail(String fromUser, List<String> toUserList, String subject, String body)
    Connects to the default host and sends the specified piece of mail to the list of recipients.
  • Method Details

    • logMessage

      void logMessage(String message)
      Log a message to the agent.log file with the provided message. The message will be under the 'TMAdapter' category.
      Parameters:
      message - The message to log.
    • logException

      void logException(Throwable t)
      Log an exception to the agent.log file. The exception will be under the 'ERROR' category.
      Parameters:
      t - The exception to log.
    • sendMail

      void sendMail(String fromUser, List<String> toUserList, String subject, String body) throws TMAPIException
      Connects to the default host and sends the specified piece of mail to the list of recipients. It uses the mail server specified in the agent.properties file.
      Parameters:
      fromUser - the mail address of the sender
      toUserList - a list of email addresses of the recipients. Each address should be of the form <mailbox>&<hostname>.
      subject - the subject of the message
      body - the body of the message It is the responsibility of the caller to ensure that the message body corresponds to RFC821. This means that appropriate line endings should be present; and lines should be limited to 998 bytes. Some mail servers will are very lenient in what they accept; others will enforce the letter of the standard.
      Throws:
      TMAPIException - If there is an error in sending the SMTP message.
    • getTempDir

      File getTempDir(ITestSession testSession) throws TMAPIException
      Get the temporary directory on the agent for this test session. Note that this directory will be deleted on restart of the Agent and after the ITestSessionAdapter.uninitialize method is called.
      Parameters:
      testSession - The test session to get a temporary directory for.
      Returns:
      The temporary directory.
      Throws:
      TMAPIException - Reserved exception.
    • getTempDir

      File getTempDir(ITestCase testCase) throws TMAPIException
      Get the temporary directory on the agent for this test case, this directory falls under the temporary directory for the containing test session for the provided test case. Note that this directory will be deleted on restart of the Agent and after the ITestSessionAdapter.uninitialize method is called.
      Parameters:
      testCase - The test case to get a temporary directory for.
      Returns:
      The temporary directory.
      Throws:
      TMAPIException - Reserved exception.
    • deleteDirTree

      void deleteDirTree(File topDir, boolean deleteTopDir, boolean errorOnMissingDir) throws TMAPIException
      Deletes an existing directory tree.
      Parameters:
      topDir - The root of the directory tree to delete.
      deleteTopDir - Delete the provided topDir if set to true, otherwise make topDir an empty directory.
      errorOnMissingDir - If the provided directory does not exist and this parameter is set to true, then an exception will be thrown, otherwise the method will return after performing no deletion.
      Throws:
      TMAPIException - If the directory doesn't exist and the errorOnMissingDir parameter has a value of true, or there was an error in deleting the directory tree.
    • createZipFile

      void createZipFile(File zipFile, File dir, FileFilter filter, boolean overwriteExisting) throws TMAPIException
      Create a zip file of the contents of an existing directory tree. The entries in the zip file will have relative paths to the directory provided.
      Parameters:
      zipFile - The zip file to create.
      dir - The directory that contains all the files and subdirectories that should be added to the zip file.
      filter - The optional file filter to apply.
      overwriteExisting - If true then creation of the zip file is permitted to overwrite an existing file, otherwise it will be considered an error to create a zip file over an existing file.
      Throws:
      TMAPIException - If the zip file can not be created.