|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Dictionary<K,V>
java.util.Hashtable<Object,Object>
java.util.Properties
org.apache.qpid.junit.extensions.util.ParsedProperties
org.apache.qpid.junit.extensions.util.TestContextProperties
public class TestContextProperties
TestContextProperties is an extension of ParsedProperties
that keeps track of property key/value pairs
that are used by tests being run under the TKTestRunner
. To keep the
test runner notified of configurable test parameters, tests should establish their required property values by
initiliazing fields or statics or in the constructor, through this class. The tk test runner automatically places
any additional properties specified on the command line into the this class, and these are held statically.
public class MyTestClass extends TestCase { ParsedProperties testProps = TestContextProperties.getInstance(); private int testParam = testProps.setPropertyIfNull("testParam", 1); ...This has the effect of setting up the field testParam with the default value of 1, unless it is overridden by values passed to the tk test runner. It also notifies the tk test runner of the name and value of the test parameter actually used for the test, so that this can be logged in the test output file.
Responsibilities | Collaborations |
---|---|
Log all name/value pairs read or written. |
Field Summary |
---|
Fields inherited from class java.util.Properties |
---|
defaults |
Method Summary | |
---|---|
static Properties |
getAccessedProps()
Gets all of the properties (with their most recent values) that have been set or read through this class. |
static ParsedProperties |
getInstance()
Gets the singleton instance of the test context properties. |
static ParsedProperties |
getInstance(Properties defaults)
Gets the singleton instance of the test context properties, applying a specified set of default properties to it, if they are not already set. |
String |
getProperty(String key)
Looks up a property value relative to the environment, callers class and method. |
Object |
setProperty(String key,
String value)
Calls the Hashtable method put . |
String |
setPropertyIfNull(String key,
String value)
Helper method for setting properties to defaults when they are not already set. |
Methods inherited from class org.apache.qpid.junit.extensions.util.ParsedProperties |
---|
getPropertyAsBoolean, getPropertyAsInteger, getPropertyAsLong, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setPropertyIfNull, setPropertyIfNull, setPropertyIfNull, setPropertyIfNull, setPropertyIfNull, setPropertyIfNull, setSysPropertyIfNull, setSysPropertyIfNull, setSysPropertyIfNull, setSysPropertyIfNull, setSysPropertyIfNull, setSysPropertyIfNull, setSysPropertyIfNull |
Methods inherited from class java.util.Properties |
---|
getProperty, list, list, load, load, loadFromXML, propertyNames, save, store, store, storeToXML, storeToXML, stringPropertyNames |
Methods inherited from class java.util.Hashtable |
---|
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static ParsedProperties getInstance()
public static ParsedProperties getInstance(Properties defaults)
defaults
- The defaults to apply for properties not already set.
public static Properties getAccessedProps()
public String getProperty(String key)
TKTestRunner
.
getProperty
in class Properties
key
- The property key.
public Object setProperty(String key, String value)
put
. Provided for parallelism with the getProperty
method. Enforces use of strings for property keys and values. The value returned is the result of the
Hashtable call to put
. The property key/value pair is remembered and made
available to TKTestRunner
.
setProperty
in class Properties
key
- The key to be placed into this property list.value
- The value corresponding to key.
null
if it did not have one.public String setPropertyIfNull(String key, String value)
TKTestRunner
.
setPropertyIfNull
in class ParsedProperties
key
- The name of the system property to set.value
- The value to set it to.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |