Class GeneralDataProvider

java.lang.Object
com.xceptance.xlt.api.data.GeneralDataProvider

public class GeneralDataProvider extends Object
The GeneralDataProvider class is a general data provider for commonly needed test data objects that comes in handy all the time. It provides access to several fixed sets of data objects, which are backed by special predefined data files in the "default" subdirectory of the test suite's data directory (e.g. "[testsuite]/config/data/default"):
  • first names (firstnames.txt)
  • last names (lastnames.txt)
  • company names (companies.txt)
  • streets (streets.txt)
  • towns (towns.txt)
  • countries (countries.txt)
Each time this data provider is asked for data, a data object is chosen randomly from the respective data set. Note: If the default data sets do not meet your needs, you may simply modify the data files.

This provider is also able to generate random data in special formats, such as:

  • phone numbers
  • domain names
  • email addresses
This data is not served from a data file, but generated on the fly.

Since this provider is implemented as a singleton, you first have to obtain the singleton instance via getInstance() before you can use this provider.

See Also:
  • Method Details

    • getCompany

      public String getCompany(boolean removeWhitespace)
      Returns a company name randomly chosen from the pool of company names.
      Parameters:
      removeWhitespace - whether or not any whitespace is to be removed from the string
      Returns:
      a company name
    • getCountry

      public String getCountry(boolean removeWhitespace)
      Returns a country name randomly chosen from the pool of country names.
      Parameters:
      removeWhitespace - whether or not any whitespace is to be removed from the string
      Returns:
      a country name
    • getFirstName

      public String getFirstName(boolean removeWhitespace)
      Returns a first name randomly chosen from the pool of first names.
      Parameters:
      removeWhitespace - whether or not any whitespace is to be removed from the string
      Returns:
      a first name
    • getTown

      public String getTown(boolean removeWhitespace)
      Returns a town randomly chosen from the pool of towns.
      Parameters:
      removeWhitespace - whether or not any whitespace is to be removed from the string
      Returns:
      a town
    • getLastName

      public String getLastName(boolean removeWhitespace)
      Returns a last name randomly chosen from the pool of last names.
      Parameters:
      removeWhitespace - whether or not any whitespace is to be removed from the string
      Returns:
      a last name
    • getSentence

      public String getSentence(boolean removeWhitespace)
      Returns a sentence.
      Parameters:
      removeWhitespace - whether or not any whitespace is to be removed from the string
      Returns:
      a sentence
    • getText

      public String getText(int sentenceCount, boolean removeWhitespace)
      Returns a text composed of several sentences.
      Parameters:
      sentenceCount - the number of sentences to use
      removeWhitespace - whether or not any whitespace is to be removed from the string
      Returns:
      a text
    • getText

      public String getText(int minSentenceCount, int maxSentenceCount, boolean removeWhitespace)
      Returns a text composed of several sentences.
      Parameters:
      minSentenceCount - the minimum number of sentences to return
      maxSentenceCount - the maximum number of sentences to return
      removeWhitespace - whether or not any whitespace is to be removed from the string
      Returns:
      a text
    • getEmail

      public String getEmail()
      Returns a randomly generated email address. This email address does not necessarily exists. This email address is not guaranteed to be unique.
      Returns:
      an email address
    • getPredefinedEmail

      public String getPredefinedEmail()
      Returns an email from the provided list without modifications. This functionality is needed, when the software under test requires real email addresses to function or to prevent clogging of email systems under test.
      Returns:
      an existing email address from the file, it returns null if no such email is available
    • getEmail

      @Deprecated public String getEmail(String name, boolean removeWhitespace)
      Deprecated.
      since 4.3.0, replaced by getEmail(String) because parameter 'removeWhitespace' is not evaluated at all.
      Returns a random email with the given user name.
      Parameters:
      name - local part of email address
      removeWhitespace - whether or not any whitespace is to be removed from the string.
      Returns:
      an email address
    • getEmail

      public String getEmail(String name)
      Returns a random email with the given user name. Whitespaces get removed (if any).
      Parameters:
      name - local part of email address
      Returns:
      an email address
    • getUniqueEmail

      public String getUniqueEmail(String prefix, String domain, int length)
      Returns a truly unique email address by generating a globally unique local part for a given domain. The local part is created by utilizing the java.util.UUID method to get an immutable universally unique identifier. The - characters form the UUID are stripped. The max length of the uuid part is 32 characters (example: fd385d38126145948983629bc63f46d2). The format of email addresses is local-part@domain where the local-part may be up to 64 characters long and the domain name may have a maximum of 253 characters ? but the maximum 256 characters length of a forward or reverse path restricts the entire email address to be no more than 254 characters. (Source: http://en.wikipedia.org/wiki/Email_address)
      Parameters:
      prefix - a prefix to be used for the local part. This should be short to avoid real long emails. This should be mostly be something like an r or s to avoid email starting with numbers.
      domain - the domain part of the email address. Should not contain the '@' sign.
      length - the max length of the local part. Please be advised that too short local parts will render this method useless. At least 12 characters are recommended.
      Returns:
      a truly globally unique email address
      Since:
      4.3.0
      See Also:
    • getUniqueEmail

      public String getUniqueEmail(String domain)
      Convenience method for getting a truly unique email with a local part length of 20 characters. Only the domain part is required. Example: xfd385d3812614594898@varmail.de
      Parameters:
      domain - the domain part of the email address. Should not contain the '@' sign.
      Returns:
      a truly globally unique email address
      Since:
      4.3.0
      See Also:
    • getStreet

      public String getStreet(boolean removeWhitespace)
      Returns a street name randomly chosen from the pool of street names.
      Parameters:
      removeWhitespace - whether or not any whitespace is to be removed from the string
      Returns:
      a street name
    • getZip

      public String getZip(int length)
      Returns a random zip code.
      Parameters:
      length - length of the zip code
      Returns:
      the zip code
    • getUniqueUserName

      public String getUniqueUserName()
      Returns a random user name for login purposes. Should be unique in time and space.
      Returns:
      a unique user name
    • getUSPhoneNumber

      public String getUSPhoneNumber()
      Returns a random US phone number in the format "1-xxx-yyy-zzzz".
      Returns:
      a random US number
    • getDEPhoneNumber

      public String getDEPhoneNumber()
      Returns a random DE phone number in the format "0xxx-yyyyyy".
      Returns:
      a random DE number
    • getInstance

      public static GeneralDataProvider getInstance()
      Returns the one and only GeneralDataProvider instance.
      Returns:
      the GeneralDataProvider singleton