Package com.xceptance.xlt.api.data
Class GeneralDataProvider
java.lang.Object
com.xceptance.xlt.api.data.GeneralDataProvider
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)
This provider is also able to generate random data in special formats, such as:
- phone numbers
- domain names
- email addresses
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 Summary
Modifier and TypeMethodDescriptiongetCompany
(boolean removeWhitespace) Returns a company name randomly chosen from the pool of company names.getCountry
(boolean removeWhitespace) Returns a country name randomly chosen from the pool of country names.Returns a random DE phone number in the format "0xxx-yyyyyy".getEmail()
Returns a randomly generated email address.Returns a random email with the given user name.Deprecated.getFirstName
(boolean removeWhitespace) Returns a first name randomly chosen from the pool of first names.static GeneralDataProvider
Returns the one and only GeneralDataProvider instance.getLastName
(boolean removeWhitespace) Returns a last name randomly chosen from the pool of last names.Returns an email from the provided list without modifications.getSentence
(boolean removeWhitespace) Returns a sentence.getStreet
(boolean removeWhitespace) Returns a street name randomly chosen from the pool of street names.getText
(int sentenceCount, boolean removeWhitespace) Returns a text composed of several sentences.getText
(int minSentenceCount, int maxSentenceCount, boolean removeWhitespace) Returns a text composed of several sentences.getTown
(boolean removeWhitespace) Returns a town randomly chosen from the pool of towns.getUniqueEmail
(String domain) Convenience method for getting a truly unique email with a local part length of 20 characters.getUniqueEmail
(String prefix, String domain, int length) Returns a truly unique email address by generating a globally unique local part for a given domain.Returns a random user name for login purposes.Returns a random US phone number in the format "1-xxx-yyy-zzzz".getZip
(int length) Returns a random zip code.
-
Method Details
-
getCompany
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
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
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
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
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
Returns a sentence.- Parameters:
removeWhitespace
- whether or not any whitespace is to be removed from the string- Returns:
- a sentence
-
getText
Returns a text composed of several sentences.- Parameters:
sentenceCount
- the number of sentences to useremoveWhitespace
- whether or not any whitespace is to be removed from the string- Returns:
- a text
-
getText
Returns a text composed of several sentences.- Parameters:
minSentenceCount
- the minimum number of sentences to returnmaxSentenceCount
- the maximum number of sentences to returnremoveWhitespace
- whether or not any whitespace is to be removed from the string- Returns:
- a text
-
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
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.since 4.3.0, replaced bygetEmail(String)
because parameter 'removeWhitespace' is not evaluated at all.Returns a random email with the given user name.- Parameters:
name
- local part of email addressremoveWhitespace
- whether or not any whitespace is to be removed from the string.- Returns:
- an email address
-
getEmail
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
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
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
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
Returns a random zip code.- Parameters:
length
- length of the zip code- Returns:
- the zip code
-
getUniqueUserName
Returns a random user name for login purposes. Should be unique in time and space.- Returns:
- a unique user name
-
getUSPhoneNumber
Returns a random US phone number in the format "1-xxx-yyy-zzzz".- Returns:
- a random US number
-
getDEPhoneNumber
Returns a random DE phone number in the format "0xxx-yyyyyy".- Returns:
- a random DE number
-
getInstance
Returns the one and only GeneralDataProvider instance.- Returns:
- the GeneralDataProvider singleton
-
getEmail(String)
because parameter 'removeWhitespace' is not evaluated at all.