For example, the following test requires a Duke.png to create the Image object for successful execution.

CODE EXAMPLE 4-22Test That Requires an Image Resource

Public class Test2 {

public Status testImage() {

Image imgI = null;

String imageDir = "/shared/sample/pkg3/"; try {

imgI = Image.createImage(imageDir+"Duke.png"); } catch (IOException e) {

....

}

if (imgI == null) {

return Status.failed("Failed: no image is created.");

}

return Status.passed("OKAY");

}

}

For this test example, the following is a resources entry that might be added to the test description file.

CODE EXAMPLE 4-23resources Attribute in the Test Description

<TR>

<TD SCOPE="row"> <B>resources</B> </TD> <TD>shared/sample/pkg3/Duke.png</TD> </TR>

In the resources entry, the value of the resource

(shared/sample/pkg3/Duke.png) is the qualified name of the resource file. If multiple resources are added to the test description file, separate them with white space. If the resource file is a class file, the file name must include the .class extension.

During build time, the Duke.png image file is copied into the specified destination directory (../shared/sample/pkg3/Duke.png). During test execution, the execution framework checks the testClasses.lst file and the test URL. During the test execution, the framework bundles the resource files specified in the resource entry (../shared/sample/pkg3/Duke.png) and the class files listed in testClasses.lst into a test JAR file.

68 Java ME TCK Framework Developer’s Guide • July 2007

Page 88
Image 88
Sun Microsystems 1.2 manual Code Example 4-22Test That Requires an Image Resource