C H A P T E R  8

Using Common Services

All tests can use services provided by the singleton class com.sun.TestBeans.Agent.TestLoader.Runner. For a complete description of this class, see devKitHome/docs/testapi/index.html.

The services are described in the following sections:


Obtaining a Property Value

To obtain the value of a property defined in the testsuite.info file or a source file, call Runner.getProperty(). For details, see the Test API documentation. For examples of usage, see the sample tests.

If a given property is defined in multiple places, the precedence rules described in Chapter 16 determine which value Runner.getProperty() returns.


Learning if a Case is Selected

To learn if a particular test case is to be run, call Runner.isSelected(), passing in the name of the case. For details, see the Test API documentation. For examples of usage, see the sample tests.


Logging

The Logger class provides multi-level log messaging, creating tagged log messages that represent a hierarchy of importance. The least important level is TRACE, and the most important level is FATAL. The importance tags in log messages enable the MicroAgent to select the messages it returns to the Relay based on the importance level set by the tester in the harness.

The Level and Logger classes define the logging facility. The Level class documentation gives guidance for choosing the level appropriate for a message.

The following sample gives one syntax for setting log message levels:

devKitHome/tests/runtime/src/client/com/sun/samples/automated/Logging.java

Given a Logger named log, you can alternatively use the methods log.trace(), log.debug(), and so on.

Other sample tests give examples of typical logging use.