C H A P T E R 16 |
Properties and Parameter Expansion |
This chapter describes properties in an abstract way, independent of the notation used to specify them in source file comments (see Chapter 4), card files (see Chapter 25), or a test pack’s testsuite.info file (see Chapter 6).
It also describes parameter expansion, which is similar to the like-named mechanism provided by shell programming languages such as BASH. Parameter expansion can be used with property definitions. @card.requires comments, and, in OTA test packs, with strings in HTML, WML, and JAD files. Briefly, a string whose value is coded as ${NAME} is replaced by the run-time value of the property NAME.
This chapter has these sections:
If you define the same property name in a source file or card file or testsuite.info file, the property takes its default value from the most local definition. Thus, if defined in a case and a class, the value is taken from the definition in test case, not from the test class. If defined in a class and in testsuite.info, the value is taken from the class. In other words, a property value comes from testsuite.info only if it is overridden nowhere else. A property value specified by a user in a template, configuration, or the test tree’s Configure Test pop-up overrides the default value.
CODE EXAMPLE 16-1 is a fragment that shows the property MaxDistance defined in a class and a case of that class.
* @testclass * @card.property MaxDistance=10 ... * @testcase * @card.property MaxDistance=100 ... * @testcase * (MaxDistance not defined) |
In this example, assuming that the tester has not set the value of MaxDistance, the first test case has the value 100 because its default has precedence over the class default. The second test case has the value 10 from the test class’s definition of MaxDistance.
You can code default property values symbolically by naming other properties. At runtime, the system expands the symbolic values into actual values. CODE EXAMPLE 16-2 shows the expansion of the value of ${MaxDistance}.
Note - Symbolic property values displayed to testers and administrators are not expanded. Continuing with CODE EXAMPLE 16-2, the default value displayed in the Configure Test pop-up window is ${MaxDistance}. |
In an OTA test pack, you use the ${...} notation to can define parameters in the HTML, WML, and JAD files associated with test MIDlets. To enable expansion of such parameters, you must enable the OTA version of property expansion by setting the PropertyExpansionProcessing property to 2.0. To enable it for a test pack, add the following lines to the testsuite.info file:
PropertyExpansionProcessing=2.0 PropertyExpansionProcessing.scope=hidden
You can also set PropertyExpansionProcessing in a source or card file. It is an ordinary property subject to the OTA precedence rules. Accordingly, you can enable or disable expansion class by class or case by case.
To see the effect of PropertyExpansionProcessing, consider this example:
Multi-level expansion is supported, that is, nested ${...} values are permitted. For example, if the property ac has the value x and b=c, then the value ${a${b}} is expanded to x.
For a more realistic example of OTA parameter expansion, see the test case t06multilayerPropertyExpansion in devKitHome/tests/ota/src/client/com/sun/samples.interactive/Interactive.java. In this example, PropertyExpansionProcessing is set to 2.0 in the testsuite.info file.
For OTA test packs, you can use the following predefined parameters to set the values of properties in source, card, and testsuite.info files. You can use them to set the values of parameters in HTML, WML, and JAD files if PropertyExpansionProcessing=2.0.
Do not define a property that has the same name as a predefined parameter.