Package com.xceptance.xlt.api.util
Class XltProperties
java.lang.Object
com.xceptance.xlt.api.util.XltProperties
The property keeper. Loads and stores the properties of the entire tool. Single instance implementation.
 
The process of looking up a property uses multiple fall-backs. When resolving the value for the key "foo.bar", for instance, the following effective keys are tried, in this order:
- the test user name plus simple key, e.g. "TOrder.foo.bar"
- the test class name plus simple key, e.g. "posters.loadtest.tests.TOrder.foo.bar"
- the simple key, i.e. "foo.bar"
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionabstract XltPropertiesclear()Clears all properties but does not do anything else.abstract booleancontainsKey(String key) Checks whether there is a mapping for the specified key in this property list.abstract PathReturns the test suite's config directory.abstract PropertiesReturns a copy of all the internally stored properties, with any placeholder resolved.abstract PathReturns the test suite's data directory.abstract StringgetEffectiveKey(Session session, String bareKey) Returns the effective key to be used for property lookup via one of the getProperty(...) methods.abstract StringgetEffectiveKey(String testCaseClassName, String userName, String bareKey) Behaves likegetEffectiveKey(Session, String)but without the session dependencystatic XltPropertiesReturns the one and only XltProperties instance.abstract PropertiesReturns a reference to the properties.getPropertiesForKey(String domainKey) Returns all properties whose name starts with the given domain key.getProperty(Session session, String key) Searches for the property with the specified key in this property list.abstract StringgetProperty(String key) Searches for the property with the specified key in this property list.abstract booleangetProperty(String key, boolean defaultValue) Searches for the property with the specified key in this property list.abstract intgetProperty(String key, int defaultValue) Searches for the property with the specified key in this property list.abstract longgetProperty(String key, long defaultValue) Searches for the property with the specified key in this property list.abstract StringgetProperty(String key, String defaultValue) Searches for the property with the specified key in this property list.abstract LinkedHashMap<String, Properties> Returns an ordered list of property sources.abstract StringgetPropertyRandomValue(String key, String defaultValue) Returns one value of the given multi-value property.abstract longReturns the start time of the test in milliseconds since 1970.abstract StringReturns the product version.abstract booleanDo we run in dev mode such as Maven or Eclipse or similar?abstract booleanDo we run in load test mode?abstract voidremoveProperty(String key) Removes the property with the given key from the internal properties store.abstract voidsetProperties(Properties newProperties) Method for changing the properties during runtime.abstract voidsetProperty(String key, String value) Sets a property during runtime.
- 
Field Details- 
DEFAULT_PROPERTIESConstants to indicate the name of the base properties- See Also:
 
- 
PROJECT_PROPERTIES- See Also:
 
- 
TEST_PROPERTIES- See Also:
 
- 
DEVELOPMENT_PROPERTIES- See Also:
 
- 
SECRET_PROPERTIES- See Also:
 
- 
SYSTEM_PROPERTIES- See Also:
 
 
- 
- 
Constructor Details- 
XltPropertiespublic XltProperties()
 
- 
- 
Method Details- 
getInstanceReturns the one and only XltProperties instance.- Returns:
- the XltProperties singleton
 
- 
containsKeyChecks whether there is a mapping for the specified key in this property list.- Parameters:
- key- the property key
- Returns:
- trueif there is a mapping,- falseotherwise
 
- 
getCopyOfPropertiesReturns a copy of all the internally stored properties, with any placeholder resolved.- Returns:
- the properties
 
- 
getPropertiesReturns a reference to the properties. This is mainly here for speed. Deal with it at your own discretion. You are not supposed to modify these!- Returns:
- the properties
 
- 
getPropertyBucketsReturns an ordered list of property sources. This allows a more tailored access if needed. Don't write to these properties, because XLT will not pay any attention. This is mainly meant when you want to extend the property concept in a test suite for your own pleasure. Please keep in mind that this is all shared across test threads, hence it is read-only which is also in parts enforced.
- 
getPropertiesForKeyReturns all properties whose name starts with the given domain key. The domain is stripped from the resulting property names.- Parameters:
- domainKey- domain for the properties
- Returns:
- a map with all matching properties
 
- 
getPropertySearches for the property with the specified key in this property list. The method returns null if the property is not found. This method will lookup the session from the context automatically!- Parameters:
- key- the property key
- Returns:
- the value of the key
 
- 
getPropertySearches for the property with the specified key in this property list. The method returns null if the property is not found. In most cases,getProperty(String)} will be sufficient. For testing and more advanced use cases, a session context can be passed in.- Parameters:
- session- the session information to use to enhance the lookup
- key- the property key
- Returns:
- the value of the key
- Since:
- 7.0.0
 
- 
getPropertySearches for the property with the specified key in this property list. The method returns the default value argument if the property is not found.- Parameters:
- key- the property key
- defaultValue- the defaultValue if key not found
- Returns:
- the value of the key as a boolean
 
- 
getPropertySearches for the property with the specified key in this property list. The method returns the default value argument if the property is not found.- Parameters:
- key- the property key
- defaultValue- the defaultValue if key not found
- Returns:
- the value of the key as an int
 
- 
getPropertySearches for the property with the specified key in this property list. The method returns the default value argument if the property is not found.- Parameters:
- key- the property key
- defaultValue- the defaultValue if key not found
- Returns:
- the value of the key as a long
 
- 
getPropertySearches for the property with the specified key in this property list. The method returns the default value argument if the property is not found. The key is upper-cased before the property will be searched.- Parameters:
- key- the property key
- defaultValue- the defaultValue if key not found
- Returns:
- the value of the key
 
- 
getPropertyRandomValueReturns one value of the given multi-value property. Multiple values are separated by comma, semicolon, or space. The returned value is chosen randomly from the set of values.- Parameters:
- key- the name of the property
- defaultValue- the default property value (a multi-value)
- Returns:
- one of the values, chosen randomly
 
- 
getStartTimepublic abstract long getStartTime()Returns the start time of the test in milliseconds since 1970.- Returns:
- the start time of the test in milliseconds
 
- 
getEffectiveKeyReturns the effective key to be used for property lookup via one of the getProperty(...) methods.When looking up a key, "password" for example, the following effective keys are tried, in this order: - the prefix "secret." plus the simple key to ensure precedence of secret properties over public ones
- the test user name plus simple key, e.g. "TAuthor.password"
- the test class name plus simple key, e.g. "com.xceptance.xlt.samples.tests.TAuthor.password"
- the simple key, e.g. "password"
 - Parameters:
- session- the session to get utility data from
- bareKey- the bare property key, i.e. without any prefixes
- Returns:
- the first key that produces a result
- Since:
- 7.0.0
 
- 
getEffectiveKeyBehaves likegetEffectiveKey(Session, String)but without the session dependency- Parameters:
- testCaseClassName- the classname the property might have been extended with
- userName- the current username which might be in the property name
- bareKey- the key without any prefixes
- Returns:
- Since:
- 7.0.0
 
- 
getVersionReturns the product version.- Returns:
- the version string, e.g. "1.1.0"
 
- 
getConfigDirectoryReturns the test suite's config directory.- Returns:
- the config directory path
 
- 
getDataDirectoryReturns the test suite's data directory.- Returns:
- the data directory path
 
- 
removePropertyRemoves the property with the given key from the internal properties store.- Parameters:
- key- the property key
 
- 
setPropertiesMethod for changing the properties during runtime. Can be called multiple times to add additional properties. It does not apply System properties automatically anymore!!! If you need that in your logic, simply run#setProperties(System.getProperties()- Parameters:
- newProperties- complete new set of properties, will be added to existing properties and overwrites already defined properties with new values. None existing properties will be added.
 
- 
setPropertySets a property during runtime. Overwrites an existing property with the same name. Does not re-apply any java system settings.- Parameters:
- key- new property key
- value- new property value
 
- 
clearClears all properties but does not do anything else. This is a dangerous operation!- Returns:
- the cleared instance
 
- 
isLoadTestpublic abstract boolean isLoadTest()Do we run in load test mode?- Returns:
- true if this instance is running a load test aka this is executed by an agent
 
- 
isDevModepublic abstract boolean isDevMode()Do we run in dev mode such as Maven or Eclipse or similar?- Returns:
- true if this instance is running a dev mode, false otherwise
 
 
-