Interface DataDictionary
-
- All Known Subinterfaces:
DataTable
- All Known Implementing Classes:
EggplantVirtualUser
,EggplantVirtualUserScript
,SeleniumVirtualUser
,SeleniumVirtualUserScript
,VirtualUser
,VirtualUserScript
,WebBrowserScript
,WebBrowserVirtualUser
public interface DataDictionary
TheDataDictionary
interface is implemented by all Eggplant PerformanceVirtualUserScript
classes and theDataTable
interface.A Data Dictionary is a collection of key/value pairs where key is a keyword used to extract a value. Every
VirtualUser
in 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 22
or
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 = myPassword
add(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,VirtualUserScript
inheritsDataDictionary
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
add(DataDictionary d)
Merges the specifiedDataDictionary
into thisDataDictionary
.<T> T
get(java.lang.String key)
Returns a reference to anObject
held in the dictionary.<T> T
get(java.lang.String key, T defaultValue)
Returns anObject
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.boolean
getBoolean(java.lang.String key)
Returns aboolean
value held in the dictionary.boolean
getBoolean(java.lang.String key, boolean defaultValue)
Returns aboolean
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.double
getDouble(java.lang.String key)
Returns adouble
value held in the dictionary.double
getDouble(java.lang.String key, double defaultValue)
Returns adouble
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.float
getFloat(java.lang.String key)
Returns afloat
value held in the dictionary.float
getFloat(java.lang.String key, float defaultValue)
Returns afloat
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.int
getInt(java.lang.String key)
Returns anint
value held in the dictionary.int
getInt(java.lang.String key, int defaultValue)
Returns anint
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.java.lang.Integer
getInteger(java.lang.String key)
Returns ajava.lang.Integer
value held in the dictionary.java.lang.Integer
getInteger(java.lang.String key, java.lang.Integer defaultValue)
Returns ajava.lang.Integer
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.java.util.List
getList(java.lang.String key)
Returns aList
value held in the dictionary.java.util.List
getList(java.lang.String key, java.util.List defaultList)
Returns aList
value held in the dictionary, or thedefaultList
if thekey
cannot be found.long
getLong(java.lang.String key)
Returns along
value held in the dictionary.long
getLong(java.lang.String key, long defaultValue)
Returns along
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.java.util.Map
getMap()
Gets aMap
containing all the keys/values in this dictionary.java.lang.String
getName()
Gets the name of this dictionary.java.lang.String
getString(java.lang.String key)
Returns aString
value held in the dictionary.java.lang.String
getString(java.lang.String key, java.lang.String defaultValue)
Returns aString
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.boolean
hasKey(java.lang.String key)
Returnstrue
if the specifiedkey
is contained within the dictionary.boolean
isReadOnly()
Returnstrue
if this dictionary is read-only.java.util.Iterator
keys()
Returns anIterator
that can be used to iterate over the keys in this dictionary.<T> void
set(java.lang.String key, T o)
Sets anObject
value in the dictionary.void
setBoolean(java.lang.String key, boolean b)
Sets aboolean
value in the dictionary.void
setDouble(java.lang.String key, double i)
Sets adouble
value in the dictionary.void
setFloat(java.lang.String key, float i)
Sets afloat
value in the dictionary.void
setInt(java.lang.String key, int i)
Sets anint
value in the dictionary.void
setInteger(java.lang.String key, java.lang.Integer i)
Sets anInteger
value in the dictionary.void
setList(java.lang.String key, java.util.List list)
Sets aList
value in the dictionary.void
setLong(java.lang.String key, long i)
Sets along
value in the dictionary.void
setName(java.lang.String name)
Sets the name of this dictionary.void
setString(java.lang.String key, java.lang.String string)
Sets aString
value in the dictionary.java.lang.String
toString()
Returns aString
representation of the dictionary.
-
-
-
Method Detail
-
getMap
java.util.Map getMap()
Gets aMap
containing all the keys/values in this dictionary.- Returns:
- a
Map
containing all the keys/values in this dictionary
-
getString
java.lang.String getString(java.lang.String key) throws NoSuchValueException, BadValueException
Returns aString
value held in the dictionary.- Parameters:
key
- the key to be looked up in the dictionary- Returns:
- a
String
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
setString(String, String)
-
getString
java.lang.String getString(java.lang.String key, java.lang.String defaultValue) throws BadValueException, NoSuchValueException
Returns aString
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultValue
is 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 thekey
is not present in the dictionary- Returns:
- a
String
value held in the dictionary, or thedefaultValue
if thekey
cannot be found - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
setString(String, String)
-
getInteger
java.lang.Integer getInteger(java.lang.String key) throws NoSuchValueException, BadValueException
Returns ajava.lang.Integer
value held in the dictionary.- Parameters:
key
- the key to be looked up in the dictionary- Returns:
- a
java.lang.Integer
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
setInteger(String, Integer)
-
getInteger
java.lang.Integer getInteger(java.lang.String key, java.lang.Integer defaultValue) throws BadValueException
Returns ajava.lang.Integer
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultValue
is 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 thekey
is not present in the dictionary- Returns:
- a
java.lang.Integer
value held in the dictionary, or thedefaultValue
if thekey
cannot be found - Throws:
BadValueException
- thekey
was null- See Also:
setInteger(String, Integer)
-
getInt
int getInt(java.lang.String key) throws NoSuchValueException, BadValueException
Returns anint
value held in the dictionary.- Parameters:
key
- the key to be looked up in the dictionary- Returns:
- an
int
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
setInt(String, int)
-
getInt
int getInt(java.lang.String key, int defaultValue) throws BadValueException
Returns anint
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultValue
is 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 thekey
is not present in the dictionary- Returns:
- an
int
value held in the dictionary, or thedefaultValue
if thekey
cannot be found - Throws:
BadValueException
- thekey
was null- See Also:
setInt(String, int)
-
getLong
long getLong(java.lang.String key) throws NoSuchValueException, BadValueException
Returns along
value held in the dictionary.- Parameters:
key
- the key to be looked up in the dictionary- Returns:
- a
long
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
setLong(String, long)
-
getLong
long getLong(java.lang.String key, long defaultValue) throws BadValueException
Returns along
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultValue
is 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 thekey
is not present in the dictionary- Returns:
- a
long
value held in the dictionary, or thedefaultValue
if thekey
cannot be found - Throws:
BadValueException
- thekey
was null- See Also:
setLong(String, long)
-
getFloat
float getFloat(java.lang.String key) throws NoSuchValueException, BadValueException
Returns afloat
value held in the dictionary.- Parameters:
key
- the key to be looked up in the dictionary- Returns:
- a
float
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
setFloat(String, float)
-
getFloat
float getFloat(java.lang.String key, float defaultValue) throws BadValueException
Returns afloat
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultValue
is 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 thekey
is not present in the dictionary- Returns:
- a
float
value held in the dictionary, or thedefaultValue
if thekey
cannot be found - Throws:
BadValueException
- thekey
was null- See Also:
setFloat(String, float)
-
getDouble
double getDouble(java.lang.String key) throws NoSuchValueException, BadValueException
Returns adouble
value held in the dictionary.- Parameters:
key
- the key to be looked up in the dictionary- Returns:
- a
double
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
setDouble(String, double)
-
getDouble
double getDouble(java.lang.String key, double defaultValue) throws BadValueException
Returns adouble
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultValue
is 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 thekey
is not present in the dictionary- Returns:
- a
double
value held in the dictionary, or thedefaultValue
if thekey
cannot be found - Throws:
BadValueException
- thekey
was null- See Also:
setDouble(String, double)
-
getBoolean
boolean getBoolean(java.lang.String key) throws NoSuchValueException, BadValueException
Returns aboolean
value held in the dictionary.- Parameters:
key
- the key to be looked up in the dictionary- Returns:
- a
boolean
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
setBoolean(String, boolean)
-
getBoolean
boolean getBoolean(java.lang.String key, boolean defaultValue) throws BadValueException
Returns aboolean
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultValue
is 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 thekey
is not present in the dictionary- Returns:
- a
boolean
value held in the dictionary, or thedefaultValue
if thekey
cannot be found - Throws:
BadValueException
- thekey
was null- See Also:
setBoolean(String, boolean)
-
get
<T> T get(java.lang.String key) throws NoSuchValueException, BadValueException
Returns a reference to anObject
held 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
Object
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
set(String, Object)
-
get
<T> T get(java.lang.String key, T defaultValue) throws BadValueException
Returns anObject
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultValue
is 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 thekey
is not present in the dictionary- Returns:
- an
Object
value held in the dictionary, or thedefaultValue
if thekey
cannot be found - Throws:
BadValueException
- thekey
was null
-
keys
java.util.Iterator keys()
Returns anIterator
that can be used to iterate over the keys in this dictionary.- Returns:
- an
Iterator
that can be used to iterate over the keys in this dictionary
-
add
void add(DataDictionary d) throws NotAllowedException, BadValueException
Merges the specifiedDataDictionary
into thisDataDictionary
.All keys and values are added to this
DataDictionary
. Any keys which already exist in thisDataDictionary
will have their values replaced.- Parameters:
d
- theDataDictionary
to 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, BadValueException
Sets aString
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already 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 withstring
in the dictionarystring
- theString
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
getString(String)
-
setInteger
void setInteger(java.lang.String key, java.lang.Integer i) throws NotAllowedException, BadValueException
Sets anInteger
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already 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 withi
in the dictionaryi
- theInteger
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
getInteger(String)
-
setInt
void setInt(java.lang.String key, int i) throws NotAllowedException, BadValueException
Sets anint
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already 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 withi
in the dictionaryi
- theint
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
getInt(String)
-
setLong
void setLong(java.lang.String key, long i) throws NotAllowedException, BadValueException
Sets along
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already 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 withi
in the dictionaryi
- thelong
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
getLong(String)
-
setFloat
void setFloat(java.lang.String key, float i) throws NotAllowedException, BadValueException
Sets afloat
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already 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 withi
in the dictionaryi
- thefloat
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
getFloat(String)
-
setDouble
void setDouble(java.lang.String key, double i) throws NotAllowedException, BadValueException
Sets adouble
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already 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 withi
in the dictionaryi
- thedouble
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
getDouble(String)
-
setBoolean
void setBoolean(java.lang.String key, boolean b) throws NotAllowedException, BadValueException
Sets aboolean
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already 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 withb
in the dictionaryb
- theboolean
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
getBoolean(String)
-
set
<T> void set(java.lang.String key, T o) throws NotAllowedException, BadValueException
Sets anObject
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already 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 witho
in the dictionaryo
- theObject
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
get(String)
-
setList
void setList(java.lang.String key, java.util.List list) throws NotAllowedException, BadValueException
Sets aList
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already 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 withlist
in the dictionarylist
- theList
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
getList(String)
-
getList
java.util.List getList(java.lang.String key) throws NoSuchValueException, BadValueException
Returns aList
value held in the dictionary.- Parameters:
key
- the key to be looked up in the dictionary- Returns:
- a
List
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
setList(String, List)
-
getList
java.util.List getList(java.lang.String key, java.util.List defaultList) throws BadValueException
Returns aList
value held in the dictionary, or thedefaultList
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultList
is 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 thekey
is not present in the dictionary- Returns:
- a
List
value held in the dictionary, or thedefaultList
if thekey
cannot be found - Throws:
BadValueException
- thekey
was null- See Also:
setList(String, List)
-
isReadOnly
boolean isReadOnly()
Returnstrue
if this dictionary is read-only.- Returns:
true
if this dictionary is read-only
-
toString
java.lang.String toString()
Returns aString
representation of the dictionary.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a
String
representing 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)
Returnstrue
if the specifiedkey
is 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:
true
if the dictionary contains the specifiedkey
-
-