Sun Microsystems 1.2 Telephone Accessories User Manual


 
Chapter 4 Writing Tests 59
Example of OTA Test
The following is an example of an OTA server component. In the example, the
source of the MIDlet suite is named Test_MIDlet.java and the JAD file is
Test_MIDlet.jad. The JAD file contains the manifest file and the
Test_MIDlet.class.
CODE EXAMPLE 4-12 Server Test Component Example
public class OTATest1 extends OTATest {
public static final String NAME = "Test_MIDlet";
public static final String testCaseID = "OTA_Sample";
public Status OTA_Sample() {
Attributes attr = new Attributes();
attr.putValue("reportURL", address + "/TestResult/");
attr.putValue("testCaseID", testCaseID);
String jadURL = address + "/" + NAME + ".jad";
log.println("Installing " + NAME + ".jad\n");
Status s = installWithNotification(attr, NAME, null);
if (s == null || !s.isPassed()) {
log.println("Could not install the application.");
return s;
}
try {
log.println("Running " + NAME + ".jar" + "\n");
String[] cmt = new String[]{"Some comments"};
String qn = "Some Questions";
s = handler.run(jadURL, NAME, cmt, qn);
if (s == null || !s.isPassed()) {
log.println("Could not run midlet suite");
return s;
}
return otaServer.getStatus(testCaseID);
} finally {
if (!handler.removeAll(null).isPassed()) {
ref.println("Could not remove midlet suites");