Sun Microsystems 1.2 manual Example of OTA Test, Code Example 4-12Server Test Component Example

Models: 1.2

1 130
Download 130 pages 63.94 Kb
Page 79
Image 79

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-12Server 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");

Chapter 4 Writing Tests 59

Page 79
Image 79
Sun Microsystems 1.2 manual Example of OTA Test, Code Example 4-12Server Test Component Example