|
Java DTV API 1.3 18-Nov-2009 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.dtv.test.TestHarness
public class TestHarness
Provides an entry point and a set of tooling for test cases.
main
as follows:
import com.sun.dtv.Report; import com.sun.dtv.TestHarness; import com.sun.dtv.TestCase; public class MyTest implements TestCase { private int id = 1234; private String title = "Arithmetic Test"; public MyTest() { } public static void main(String[] args) { // Start the corresponding TestCase's main method TestHarness.start(new MyTest(), args); } public int getTestId() { // Return the id of the test (either the hardcoded one or // that passed through -testid <id>) return id; } public String getTestTitle() { // Return the title of the test (either the hardcoded one or // that passed through -testtitle <test>) return title; } public Report run(String[] args) { // 1. evaluate 'args' to particular parameter specific to this testcase and to extract the testid and/or testtitle If -testid <id>, then copy value into id If -testtitle <title>, then copy value into title ... // 2. (depending on test) synchronize with server TestHarness.sendTrigger(TestHarness.TRIGGER_SYNCHRONIZE, getTestId(), "[SYNC#2881] Switch transport stream encoding NOW!"); // 3. test code that does something with that other encoding if (1 + 1 == 2) return Report.passed(this, "OK"); else return Report.failed(this, "1 + 1 did not make 2"); } }
Field Summary | |
---|---|
static PrintStream |
log
The default output stream on a given platform to store test reports. |
static int |
TRIGGER_SYNCHRONIZE
A triggerType used to request synchronization on a given
event between the test client and the test server. |
static int |
TRIGGER_TERMINATED
A triggerType used to signal that the test identified by
testId is now considered finished. |
Constructor Summary | |
---|---|
TestHarness()
|
Method Summary | |
---|---|
static void |
sendReport(int testid,
Report report)
This alias method allows to send the report of the given testcase back to the test server. |
static void |
sendTrigger(int triggerType,
int testId,
String message)
This generic method allows to send a specific trigger to the test server. |
static void |
start(TestCase test,
String[] args)
This method is responsible for launching a given test case, handling the resulting report and ending the current test application. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int TRIGGER_SYNCHRONIZE
triggerType
used to request synchronization on a given
event between the test client and the test server.
It means that the test client has reached a specific state
required for the test and that it is awaiting acknowledgment to
continue the test. Consequently, the implementation of
sendTrigger(triggerType, testId,
message)
will wait until such a confirmation is received before
returning.
Along with the triggerType
and the
testId
, the application may
use the message
argument to specify which
synchronization milestone it has reached. It is recommended to
compose that message with a part that can be parsed (for example an
integer code) and a human readable part (i.e. a short
description) to allow both a automated (test server) and/or human
supported implementation of this feature.
sendTrigger(int,int,String)
,
Constant Field Valuespublic static final int TRIGGER_TERMINATED
triggerType
used to signal that the test identified by
testId
is now considered finished.
Along with the triggerType
and the
testId
when calling sendTrigger(triggerType, testId, message)
, the application must supply the resulting Report
in the message
argument by calling the corresponding
Report.toString()
method.
sendTrigger(int,int,String)
,
Constant Field Valuespublic static final PrintStream log
This log
must be configured
with autoFlush=true
.
java.io#PrintStream(OutputStream, boolean)
Constructor Detail |
---|
public TestHarness()
Method Detail |
---|
public static void sendTrigger(int triggerType, int testId, String message) throws UnsupportedOperationException
triggerType
, the method will
behave differently.
Currently the following two triggers must be supported by the implementation. This specification may define new triggers in subsequent versions:
It is left to the implementation how to provide the communication mean between the test client and the test server. It may use one of the following technologies: Serial, USB, Networking, ...
However, at last resort and in conjunction with any communication mean between client and server, the implementation shall display a dialog with the corresponding message to the user or test operator on the screen of the platform.
triggerType
- one of any TRIGGER_
constant defined
in this class.testId
- an integer value identifying the test. This value
can be defined by the test case itself or via arguments (see TestCase
).message
- depending on the triggerType, this string may have
different meaning. This argument may
be null
.
UnsupportedOperationException
- if triggerType
is
no supported by the platform.public static void sendReport(int testid, Report report) throws NullPointerException
TestHarness.TRIGGER_TERMINATED
,
the report string will be displayed on the screen.
This method is equivalent to calling:
TestHarness.sendTrigger(TestHarness.TRIGGER_TERMINATED, testid, report.toString());
testid
- an integer value identifying the test. This value
can be defined by the test case itself or via arguments (see TestCase
).report
- The report to be sent.
NullPointerException
- if report
is
null
public static void start(TestCase test, String[] args)
If the platform provides a return channel, it will return the
report to the test server using sendReport()
allowing thereby the server to start the next
test.
The implementation must call
at last Report.exit()
method which consequently
provokes the application to end.
An implementation is likely to be based on:
if (test != null) { Report r = test.run(args); TestHarness.sendReport(test.getTestId(), r); r.exit(); }
test
- The test case instance to be launched.args
- The list of argument that are passed to the test cases.
Usually are those from the command line.
|
Java DTV API 1.3 18-Nov-2009 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |