Package com.xceptance.xlt.api.data
Class GeneralDataProvider
- java.lang.Object
-
- com.xceptance.xlt.api.data.GeneralDataProvider
-
public class GeneralDataProvider extends java.lang.Object
TheGeneralDataProvider
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 XLT data directory ("[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:
DataProvider
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.String
getCompany(boolean removeWhitespace)
Returns a company name randomly chosen from the pool of company names.java.lang.String
getCountry(boolean removeWhitespace)
Returns a country name randomly chosen from the pool of country names.java.lang.String
getDEPhoneNumber()
Returns a random DE phone number in the format "0xxx-yyyyyy".java.lang.String
getEmail()
Returns a randomly generated email address.java.lang.String
getEmail(java.lang.String name)
Returns a random email with the given user name.java.lang.String
getEmail(java.lang.String name, boolean removeWhitespace)
Deprecated.since 4.3.0, replaced bygetEmail(String)
because parameter 'removeWhitespace' is not evaluated at all.java.lang.String
getFirstName(boolean removeWhitespace)
Returns a first name randomly chosen from the pool of first names.static GeneralDataProvider
getInstance()
Returns the one and only GeneralDataProvider instance.java.lang.String
getLastName(boolean removeWhitespace)
Returns a last name randomly chosen from the pool of last names.java.lang.String
getPredefinedEmail()
Returns an email from the provided list without modifications.java.lang.String
getSentence(boolean removeWhitespace)
Returns a sentence.java.lang.String
getStreet(boolean removeWhitespace)
Returns a street name randomly chosen from the pool of street names.java.lang.String
getText(int sentenceCount, boolean removeWhitespace)
Returns a text composed of several sentences.java.lang.String
getText(int minSentenceCount, int maxSentenceCount, boolean removeWhitespace)
Returns a text composed of several sentences.java.lang.String
getTown(boolean removeWhitespace)
Returns a town randomly chosen from the pool of towns.java.lang.String
getUniqueEmail(java.lang.String domain)
Convenience method for getting a truly unique email with a local part length of 20 characters.java.lang.String
getUniqueEmail(java.lang.String prefix, java.lang.String domain, int length)
Returns a truly unique email address by generating a globally unique local part for a given domain.java.lang.String
getUniqueUserName()
Returns a random user name for login purposes.java.lang.String
getUSPhoneNumber()
Returns a random US phone number in the format "1-xxx-yyy-zzzz".java.lang.String
getZip(int length)
Returns a random zip code.
-
-
-
Method Detail
-
getCompany
public java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.String getText(int sentenceCount, boolean removeWhitespace)
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
public java.lang.String getText(int minSentenceCount, int maxSentenceCount, boolean removeWhitespace)
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
public java.lang.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 java.lang.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 java.lang.String getEmail(java.lang.String name, boolean removeWhitespace)
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
public java.lang.String getEmail(java.lang.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 java.lang.String getUniqueEmail(java.lang.String prefix, java.lang.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:
UUID.randomUUID()
-
getUniqueEmail
public java.lang.String getUniqueEmail(java.lang.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:
getUniqueEmail(String, String, int)
-
getStreet
public java.lang.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 java.lang.String getZip(int length)
Returns a random zip code.- Parameters:
length
- length of the zip code- Returns:
- the zip code
-
getUniqueUserName
public java.lang.String getUniqueUserName()
Returns a random user name for login purposes. Should be unique in time and space.- Returns:
- a unique user name
-
getUSPhoneNumber
public java.lang.String getUSPhoneNumber()
Returns a random US phone number in the format "1-xxx-yyy-zzzz".- Returns:
- a random US number
-
getDEPhoneNumber
public java.lang.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
-
-