Interface DataDictionary
-
- All Known Subinterfaces:
DataTable
- All Known Implementing Classes:
EggplantVirtualUser,EggplantVirtualUserScript,SeleniumVirtualUser,SeleniumVirtualUserScript,VirtualUser,VirtualUserScript,WebBrowserScript,WebBrowserVirtualUser
public interface DataDictionaryTheDataDictionaryinterface is implemented by all Eggplant PerformanceVirtualUserScriptclasses and theDataTableinterface.A Data Dictionary is a collection of key/value pairs where key is a keyword used to extract a value. Every
VirtualUserin a running test has a Data Dictionary. Suppose a Data Dictionary contains a key"counter"whose value is22. To extract the value from the dictionary use the following code:int count = getInt("counter"); // count is now set to 22or
String count = getString("counter"); // count is now set to "22"A DataDictionary can be populated from a Data Dictionary File. This is a text file containing lines of text in the form
key=value.e.g.
eggPlant Performance Studio enables you to associate Data Dictionary files with a test and multiple VU Groups. The key/value pairs in the files are loaded into each VU's data dictionary when the test is initialized. Studio also allows you to add values using the inline-data form of a test's Data properties. You may also add values within your script code using thehost = 192.168.2.7 port = 1245 user = Jane Smith password = myPasswordadd(DataDictionary)orset(String, Object)methods described in this reference. The methods and properties described in this reference can all be accessed directly from within the code of any script class because the base script class,VirtualUserScriptinheritsDataDictionary.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidadd(DataDictionary d)Merges the specifiedDataDictionaryinto thisDataDictionary.<T> Tget(java.lang.String key)Returns a reference to anObjectheld in the dictionary.<T> Tget(java.lang.String key, T defaultValue)Returns anObjectvalue held in the dictionary, or thedefaultValueif thekeycannot be found.booleangetBoolean(java.lang.String key)Returns abooleanvalue held in the dictionary.booleangetBoolean(java.lang.String key, boolean defaultValue)Returns abooleanvalue held in the dictionary, or thedefaultValueif thekeycannot be found.doublegetDouble(java.lang.String key)Returns adoublevalue held in the dictionary.doublegetDouble(java.lang.String key, double defaultValue)Returns adoublevalue held in the dictionary, or thedefaultValueif thekeycannot be found.floatgetFloat(java.lang.String key)Returns afloatvalue held in the dictionary.floatgetFloat(java.lang.String key, float defaultValue)Returns afloatvalue held in the dictionary, or thedefaultValueif thekeycannot be found.intgetInt(java.lang.String key)Returns anintvalue held in the dictionary.intgetInt(java.lang.String key, int defaultValue)Returns anintvalue held in the dictionary, or thedefaultValueif thekeycannot be found.java.lang.IntegergetInteger(java.lang.String key)Returns ajava.lang.Integervalue held in the dictionary.java.lang.IntegergetInteger(java.lang.String key, java.lang.Integer defaultValue)Returns ajava.lang.Integervalue held in the dictionary, or thedefaultValueif thekeycannot be found.java.util.ListgetList(java.lang.String key)Returns aListvalue held in the dictionary.java.util.ListgetList(java.lang.String key, java.util.List defaultList)Returns aListvalue held in the dictionary, or thedefaultListif thekeycannot be found.longgetLong(java.lang.String key)Returns alongvalue held in the dictionary.longgetLong(java.lang.String key, long defaultValue)Returns alongvalue held in the dictionary, or thedefaultValueif thekeycannot be found.java.util.MapgetMap()Gets aMapcontaining all the keys/values in this dictionary.java.lang.StringgetName()Gets the name of this dictionary.java.lang.StringgetString(java.lang.String key)Returns aStringvalue held in the dictionary.java.lang.StringgetString(java.lang.String key, java.lang.String defaultValue)Returns aStringvalue held in the dictionary, or thedefaultValueif thekeycannot be found.booleanhasKey(java.lang.String key)Returnstrueif the specifiedkeyis contained within the dictionary.booleanisReadOnly()Returnstrueif this dictionary is read-only.java.util.Iteratorkeys()Returns anIteratorthat can be used to iterate over the keys in this dictionary.<T> voidset(java.lang.String key, T o)Sets anObjectvalue in the dictionary.voidsetBoolean(java.lang.String key, boolean b)Sets abooleanvalue in the dictionary.voidsetDouble(java.lang.String key, double i)Sets adoublevalue in the dictionary.voidsetFloat(java.lang.String key, float i)Sets afloatvalue in the dictionary.voidsetInt(java.lang.String key, int i)Sets anintvalue in the dictionary.voidsetInteger(java.lang.String key, java.lang.Integer i)Sets anIntegervalue in the dictionary.voidsetList(java.lang.String key, java.util.List list)Sets aListvalue in the dictionary.voidsetLong(java.lang.String key, long i)Sets alongvalue in the dictionary.voidsetName(java.lang.String name)Sets the name of this dictionary.voidsetString(java.lang.String key, java.lang.String string)Sets aStringvalue in the dictionary.java.lang.StringtoString()Returns aStringrepresentation of the dictionary.
-
-
-
Method Detail
-
getMap
java.util.Map getMap()
Gets aMapcontaining all the keys/values in this dictionary.- Returns:
- a
Mapcontaining all the keys/values in this dictionary
-
getString
java.lang.String getString(java.lang.String key) throws NoSuchValueException, BadValueExceptionReturns aStringvalue held in the dictionary.- Parameters:
key- the key to be looked up in the dictionary- Returns:
- a
Stringvalue held in the dictionary - Throws:
NoSuchValueException- thekeydoes not exist in the dictionaryBadValueException- thekeywas null- See Also:
setString(String, String)
-
getString
java.lang.String getString(java.lang.String key, java.lang.String defaultValue) throws BadValueException, NoSuchValueExceptionReturns aStringvalue held in the dictionary, or thedefaultValueif thekeycannot be found.Default data warning:
When called from a VU script, if thedefaultValueis returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myString, using default value instead: abcd To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Parameters:
key- the key to be looked up in the dictionarydefaultValue- the value to return if thekeyis not present in the dictionary- Returns:
- a
Stringvalue held in the dictionary, or thedefaultValueif thekeycannot be found - Throws:
NoSuchValueException- thekeydoes not exist in the dictionaryBadValueException- thekeywas null- See Also:
setString(String, String)
-
getInteger
java.lang.Integer getInteger(java.lang.String key) throws NoSuchValueException, BadValueExceptionReturns ajava.lang.Integervalue held in the dictionary.- Parameters:
key- the key to be looked up in the dictionary- Returns:
- a
java.lang.Integervalue held in the dictionary - Throws:
NoSuchValueException- thekeydoes not exist in the dictionaryBadValueException- thekeywas null- See Also:
setInteger(String, Integer)
-
getInteger
java.lang.Integer getInteger(java.lang.String key, java.lang.Integer defaultValue) throws BadValueExceptionReturns ajava.lang.Integervalue held in the dictionary, or thedefaultValueif thekeycannot be found.Default data warning:
When called from a VU script, if thedefaultValueis returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myInteger, using default value instead: 1234 To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Parameters:
key- the key to be looked up in the dictionarydefaultValue- the value to return if thekeyis not present in the dictionary- Returns:
- a
java.lang.Integervalue held in the dictionary, or thedefaultValueif thekeycannot be found - Throws:
BadValueException- thekeywas null- See Also:
setInteger(String, Integer)
-
getInt
int getInt(java.lang.String key) throws NoSuchValueException, BadValueExceptionReturns anintvalue held in the dictionary.- Parameters:
key- the key to be looked up in the dictionary- Returns:
- an
intvalue held in the dictionary - Throws:
NoSuchValueException- thekeydoes not exist in the dictionaryBadValueException- thekeywas null- See Also:
setInt(String, int)
-
getInt
int getInt(java.lang.String key, int defaultValue) throws BadValueExceptionReturns anintvalue held in the dictionary, or thedefaultValueif thekeycannot be found.Default data warning:
When called from a VU script, if thedefaultValueis returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myInt, using default value instead: 1234 To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Parameters:
key- the key to be looked up in the dictionarydefaultValue- the value to return if thekeyis not present in the dictionary- Returns:
- an
intvalue held in the dictionary, or thedefaultValueif thekeycannot be found - Throws:
BadValueException- thekeywas null- See Also:
setInt(String, int)
-
getLong
long getLong(java.lang.String key) throws NoSuchValueException, BadValueExceptionReturns alongvalue held in the dictionary.- Parameters:
key- the key to be looked up in the dictionary- Returns:
- a
longvalue held in the dictionary - Throws:
NoSuchValueException- thekeydoes not exist in the dictionaryBadValueException- thekeywas null- See Also:
setLong(String, long)
-
getLong
long getLong(java.lang.String key, long defaultValue) throws BadValueExceptionReturns alongvalue held in the dictionary, or thedefaultValueif thekeycannot be found.Default data warning:
When called from a VU script, if thedefaultValueis returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myLong, using default value instead: 1234567890L To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Parameters:
key- the key to be looked up in the dictionarydefaultValue- the value to return if thekeyis not present in the dictionary- Returns:
- a
longvalue held in the dictionary, or thedefaultValueif thekeycannot be found - Throws:
BadValueException- thekeywas null- See Also:
setLong(String, long)
-
getFloat
float getFloat(java.lang.String key) throws NoSuchValueException, BadValueExceptionReturns afloatvalue held in the dictionary.- Parameters:
key- the key to be looked up in the dictionary- Returns:
- a
floatvalue held in the dictionary - Throws:
NoSuchValueException- thekeydoes not exist in the dictionaryBadValueException- thekeywas null- See Also:
setFloat(String, float)
-
getFloat
float getFloat(java.lang.String key, float defaultValue) throws BadValueExceptionReturns afloatvalue held in the dictionary, or thedefaultValueif thekeycannot be found.Default data warning:
When called from a VU script, if thedefaultValueis returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myFloat, using default value instead: 3.142F To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Parameters:
key- the key to be looked up in the dictionarydefaultValue- the value to return if thekeyis not present in the dictionary- Returns:
- a
floatvalue held in the dictionary, or thedefaultValueif thekeycannot be found - Throws:
BadValueException- thekeywas null- See Also:
setFloat(String, float)
-
getDouble
double getDouble(java.lang.String key) throws NoSuchValueException, BadValueExceptionReturns adoublevalue held in the dictionary.- Parameters:
key- the key to be looked up in the dictionary- Returns:
- a
doublevalue held in the dictionary - Throws:
NoSuchValueException- thekeydoes not exist in the dictionaryBadValueException- thekeywas null- See Also:
setDouble(String, double)
-
getDouble
double getDouble(java.lang.String key, double defaultValue) throws BadValueExceptionReturns adoublevalue held in the dictionary, or thedefaultValueif thekeycannot be found.Default data warning:
When called from a VU script, if thedefaultValueis returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myDouble, using default value instead: 1.234 To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Parameters:
key- the key to be looked up in the dictionarydefaultValue- the value to return if thekeyis not present in the dictionary- Returns:
- a
doublevalue held in the dictionary, or thedefaultValueif thekeycannot be found - Throws:
BadValueException- thekeywas null- See Also:
setDouble(String, double)
-
getBoolean
boolean getBoolean(java.lang.String key) throws NoSuchValueException, BadValueExceptionReturns abooleanvalue held in the dictionary.- Parameters:
key- the key to be looked up in the dictionary- Returns:
- a
booleanvalue held in the dictionary - Throws:
NoSuchValueException- thekeydoes not exist in the dictionaryBadValueException- thekeywas null- See Also:
setBoolean(String, boolean)
-
getBoolean
boolean getBoolean(java.lang.String key, boolean defaultValue) throws BadValueExceptionReturns abooleanvalue held in the dictionary, or thedefaultValueif thekeycannot be found.Default data warning:
When called from a VU script, if thedefaultValueis returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myBoolean, using default value instead: true To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Parameters:
key- the key to be looked up in the dictionarydefaultValue- the value to return if thekeyis not present in the dictionary- Returns:
- a
booleanvalue held in the dictionary, or thedefaultValueif thekeycannot be found - Throws:
BadValueException- thekeywas null- See Also:
setBoolean(String, boolean)
-
get
<T> T get(java.lang.String key) throws NoSuchValueException, BadValueException
Returns a reference to anObjectheld in the dictionary.- Type Parameters:
T- The type of object to retrieve from the dictionary- Parameters:
key- the key to be looked up in the dictionary- Returns:
- an
Objectvalue held in the dictionary - Throws:
NoSuchValueException- thekeydoes not exist in the dictionaryBadValueException- thekeywas null- See Also:
set(String, Object)
-
get
<T> T get(java.lang.String key, T defaultValue) throws BadValueExceptionReturns anObjectvalue held in the dictionary, or thedefaultValueif thekeycannot be found.Default data warning:
When called from a VU script, if thedefaultValueis returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myObject, using default value instead: abcd1234 To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Type Parameters:
T- The type of object to retrieve from the dictionary- Parameters:
key- the key to be looked up in the dictionarydefaultValue- the value to return if thekeyis not present in the dictionary- Returns:
- an
Objectvalue held in the dictionary, or thedefaultValueif thekeycannot be found - Throws:
BadValueException- thekeywas null
-
keys
java.util.Iterator keys()
Returns anIteratorthat can be used to iterate over the keys in this dictionary.- Returns:
- an
Iteratorthat can be used to iterate over the keys in this dictionary
-
add
void add(DataDictionary d) throws NotAllowedException, BadValueException
Merges the specifiedDataDictionaryinto thisDataDictionary.All keys and values are added to this
DataDictionary. Any keys which already exist in thisDataDictionarywill have their values replaced.- Parameters:
d- theDataDictionaryto be merged- Throws:
NotAllowedException- This dictionary is read onlyBadValueException- Tried to a dd a null value to the dictionary
-
setString
void setString(java.lang.String key, java.lang.String string) throws NotAllowedException, BadValueExceptionSets aStringvalue in the dictionary.keyis associated with the value in the dictionary. If thekeyalready exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
setString("hostName", "www.testplant.com");- Parameters:
key- the key to associate withstringin the dictionarystring- theStringto be associated with thekeyin the dictionary- Throws:
NotAllowedException- This dictionary is read onlyBadValueException- thekeywas null- See Also:
getString(String)
-
setInteger
void setInteger(java.lang.String key, java.lang.Integer i) throws NotAllowedException, BadValueExceptionSets anIntegervalue in the dictionary.keyis associated with the value in the dictionary. If thekeyalready exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
setInteger("port", 8080);- Parameters:
key- the key to associate withiin the dictionaryi- theIntegerto be associated with thekeyin the dictionary- Throws:
NotAllowedException- This dictionary is read onlyBadValueException- thekeywas null- See Also:
getInteger(String)
-
setInt
void setInt(java.lang.String key, int i) throws NotAllowedException, BadValueExceptionSets anintvalue in the dictionary.keyis associated with the value in the dictionary. If thekeyalready exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
setInt("port", 8080);- Parameters:
key- the key to associate withiin the dictionaryi- theintto be associated with thekeyin the dictionary- Throws:
NotAllowedException- This dictionary is read onlyBadValueException- thekeywas null- See Also:
getInt(String)
-
setLong
void setLong(java.lang.String key, long i) throws NotAllowedException, BadValueExceptionSets alongvalue in the dictionary.keyis associated with the value in the dictionary. If thekeyalready exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
setLong("amount", 9156598231230);- Parameters:
key- the key to associate withiin the dictionaryi- thelongto be associated with thekeyin the dictionary- Throws:
NotAllowedException- This dictionary is read onlyBadValueException- thekeywas null- See Also:
getLong(String)
-
setFloat
void setFloat(java.lang.String key, float i) throws NotAllowedException, BadValueExceptionSets afloatvalue in the dictionary.keyis associated with the value in the dictionary. If thekeyalready exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
setFloat("amount", 123.45);- Parameters:
key- the key to associate withiin the dictionaryi- thefloatto be associated with thekeyin the dictionary- Throws:
NotAllowedException- This dictionary is read onlyBadValueException- thekeywas null- See Also:
getFloat(String)
-
setDouble
void setDouble(java.lang.String key, double i) throws NotAllowedException, BadValueExceptionSets adoublevalue in the dictionary.keyis associated with the value in the dictionary. If thekeyalready exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
setDouble("amount", 123.45);- Parameters:
key- the key to associate withiin the dictionaryi- thedoubleto be associated with thekeyin the dictionary- Throws:
NotAllowedException- This dictionary is read onlyBadValueException- thekeywas null- See Also:
getDouble(String)
-
setBoolean
void setBoolean(java.lang.String key, boolean b) throws NotAllowedException, BadValueExceptionSets abooleanvalue in the dictionary.keyis associated with the value in the dictionary. If thekeyalready exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
setBoolean("retryLogon", false);- Parameters:
key- the key to associate withbin the dictionaryb- thebooleanto be associated with thekeyin the dictionary- Throws:
NotAllowedException- This dictionary is read onlyBadValueException- thekeywas null- See Also:
getBoolean(String)
-
set
<T> void set(java.lang.String key, T o) throws NotAllowedException, BadValueExceptionSets anObjectvalue in the dictionary.keyis associated with the value in the dictionary. If thekeyalready exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
set("today", new Date());- Type Parameters:
T- The type of object to add to the dictionary- Parameters:
key- the key to associate withoin the dictionaryo- theObjectto be associated with thekeyin the dictionary- Throws:
NotAllowedException- This dictionary is read onlyBadValueException- thekeywas null- See Also:
get(String)
-
setList
void setList(java.lang.String key, java.util.List list) throws NotAllowedException, BadValueExceptionSets aListvalue in the dictionary.keyis associated with the value in the dictionary. If thekeyalready exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
List<String> hostList = new ArrayList<String>(); hostList.add("www.testplant.com"); setList("hosts", hostList);- Parameters:
key- the key to associate withlistin the dictionarylist- theListto be associated with thekeyin the dictionary- Throws:
NotAllowedException- This dictionary is read onlyBadValueException- thekeywas null- See Also:
getList(String)
-
getList
java.util.List getList(java.lang.String key) throws NoSuchValueException, BadValueExceptionReturns aListvalue held in the dictionary.- Parameters:
key- the key to be looked up in the dictionary- Returns:
- a
Listvalue held in the dictionary - Throws:
NoSuchValueException- thekeydoes not exist in the dictionaryBadValueException- thekeywas null- See Also:
setList(String, List)
-
getList
java.util.List getList(java.lang.String key, java.util.List defaultList) throws BadValueExceptionReturns aListvalue held in the dictionary, or thedefaultListif thekeycannot be found.Default data warning:
When called from a VU script, if thedefaultListis returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myList, using default value instead: List with first item: Item01 To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Parameters:
key- the key to be looked up in the dictionarydefaultList- the value to return if thekeyis not present in the dictionary- Returns:
- a
Listvalue held in the dictionary, or thedefaultListif thekeycannot be found - Throws:
BadValueException- thekeywas null- See Also:
setList(String, List)
-
isReadOnly
boolean isReadOnly()
Returnstrueif this dictionary is read-only.- Returns:
trueif this dictionary is read-only
-
toString
java.lang.String toString()
Returns aStringrepresentation of the dictionary.- Overrides:
toStringin classjava.lang.Object- Returns:
- a
Stringrepresenting the key/value pairs in the dictionary
-
getName
java.lang.String getName()
Gets the name of this dictionary.- Returns:
- the name of the Data Dictionary
-
setName
void setName(java.lang.String name)
Sets the name of this dictionary.- Parameters:
name- the name of the Data Dictionary
-
hasKey
boolean hasKey(java.lang.String key)
Returnstrueif the specifiedkeyis contained within the dictionary.e.g.
if (myDictionary.HasKey("newHostName")) { // do something } else { // do something else }- Parameters:
key- the key to be looked up in the dictionary- Returns:
trueif the dictionary contains the specifiedkey
-
-