Sun Microsystems 1.2 Telephone Accessories User Manual


 
74 Java ME TCK Framework Developer’s Guide July 2007
2. Write an interview question that obtains the value of the environment variable
from the user.
To obtain the value of environment variables from users, test developers must
write an interview class and create the required interview questions. If an
interview class already exists in the test source, the developer can either add new
questions to the existing interview or create a new sub-interview class containing
the required questions and link it to the existing interview class.
For this example, we will assume that we have an existing interview class
(SampleInterview.java) in the Simple Test Suite source and that we are
adding a new question about whether the target implementation supports a
specific feature.
For an example of linking a new interview class to an existing interview, see
Chapter 3 “Creating a Test Suite Configuration Interview” on page 28.
The following is an example of question code that can be added to an interview.
In the question code, the isFeatureSupported environment variable name
must be consistent with the name used in Step 1 for selectIf (in the test
description file). Also in the question code, featureSupport is the unique
question name that becomes part of the question key created in Step 3 for use in
both the map and the properties files.
The following example is a complete configuration interview
(SampleInterview.java) that contains the added question code.
// The added question:Does the implementation support the feature?
private YesNoQuestion qFeatureSupport = new YesNoQuestion(this,
"featureSupport") {
public void clear() {
setValue(YesNoQuestion.NO);
}
protected void export(Map data) {
boolean b = (value == YES);
data.put("isFeatureSupported", String.valueOf(b));
}
public class SampleInterview extends Interview {
/**
* @param parent
* @throws Fault
*/
public SampleInterview(MidpTckBaseInterview parent)
throws Fault {
super(parent, "sample");
init();
}