Java DTV API 1.3
18-Nov-2009

com.sun.dtv.test
Class Report

java.lang.Object
  extended by com.sun.dtv.test.Report

public class Report
extends Object

Embodies the result of a test: a code, a reference to the test and a related reason.


Field Summary
static int ERROR
          A report type indicating that the test was not run because some error occurred before the test could even be attempted.
static int FAILED
          A report type indicating that the test was executed but the test reported that it failed.
static int NOT_RUN
          A report type indicating that the test has not yet been run in this context.
protected static int NUM_STATES
          Number of report types which are predefined as "constants".
static int PASSED
          A report type indicating that the test was executed and was successful.
static int UNRESOLVED
          A report type indicating that the test has produced indecisive results.
 
Constructor Summary
Report(int type, TestCase test, String reason)
          Create a Report object.
 
Method Summary
static Report error(TestCase test, String reason)
          Create a Report to indicate that an error occurred while trying to run a test: i.e. the test did not complete for some reason, and so it could not determine whether what was being tested passed or failed.
 void exit()
          Convenience exit() function for the main() of tests to exit in such a way that the report passes up across process boundaries without losing information, that is: exit codes don't give the associated text of the report and return codes when exceptions are thrown could cause unintended results.
static Report failed(TestCase test, String reason)
          Create a Report to indicate the unsuccessful outcome of a test: i.e. the test completed, but the test determined that what was being tested did not pass the test.
 int getType()
          Get the type code indicating the type of this Report object.
 boolean isError()
          Check if the type code of the report is ERROR.
 boolean isFailed()
          Check if the type code of the report is FAILED.
 boolean isNotRun()
          Check if the type code of the report is NOT_RUN.
 boolean isPassed()
          Check if the type code of the report is PASSED.
 boolean isUnresolved()
          Check if the type code of the report is UNRESOLVED.
static Report notRun(TestCase test, String reason)
          Create a Report to indicate that the test has not yet been run.
static Report passed(TestCase test, String reason)
          Create a Report to indicate the successful outcome of a test.
 String toString()
          Convert a Report to a string.
static Report unresolved(TestCase test, String reason)
          Create a Report to indicate that the test has produced indecisive results.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PASSED

public static final int PASSED
A report type indicating that the test was executed and was successful.

See Also:
passed(com.sun.dtv.test.TestCase, java.lang.String), getType(), Constant Field Values

FAILED

public static final int FAILED
A report type indicating that the test was executed but the test reported that it failed.

See Also:
failed(com.sun.dtv.test.TestCase, java.lang.String), getType(), Constant Field Values

ERROR

public static final int ERROR
A report type indicating that the test was not run because some error occurred before the test could even be attempted. This is generally a more serious error than FAILED.

See Also:
getType(), Constant Field Values

NOT_RUN

public static final int NOT_RUN
A report type indicating that the test has not yet been run in this context. More specifically, no status file has been recorded for this test in the current work directory.

See Also:
getType(), Constant Field Values

UNRESOLVED

public static final int UNRESOLVED
A report type indicating that the test has produced indecisive results. They may happen if the execution of the test was interrupted unexpectedly, there were too many warnings or the test was incorrectly configured. This usually means that the test operator need to analyze the test log as well as probably improve the test case.

See Also:
getType(), Constant Field Values

NUM_STATES

protected static final int NUM_STATES
Number of report types which are predefined as "constants".

See Also:
Constant Field Values
Constructor Detail

Report

public Report(int type,
              TestCase test,
              String reason)
       throws NullPointerException,
              IllegalArgumentException
Create a Report object. See passed(TestCase, String), failed(TestCase, String), error(TestCase, String) etc. for more convenient factory methods to create Report objects. Every time a new report is created, it must be automatically logged in the output stream defined to by TestHarness.log. The format is defined to be the return value of toString() appended with a carriage return (CR) character.

Parameters:
type - The type code for the Report object.
test - The corresponding test TestCase object.
reason - A short string to store in the report. Unprintable characters (i.e. outside the range 040C to 177C) in the string are replaced by a space.
Throws:
NullPointerException - if test or reason is null.
IllegalArgumentException - if the specified type is invalid.
Method Detail

getType

public int getType()
Get the type code indicating the type of this Report object.

Returns:
the type code indicating the type of this Report object.
See Also:
PASSED, FAILED, ERROR, NOT_RUN, UNRESOLVED

isPassed

public boolean isPassed()
Check if the type code of the report is PASSED.

Returns:
true if the type code is PASSED.
See Also:
passed(com.sun.dtv.test.TestCase, java.lang.String), getType(), PASSED

isFailed

public boolean isFailed()
Check if the type code of the report is FAILED.

Returns:
true if the type code is FAILED.
See Also:
failed(com.sun.dtv.test.TestCase, java.lang.String), getType(), FAILED

isError

public boolean isError()
Check if the type code of the report is ERROR.

Returns:
true if the type code is ERROR.
See Also:
error(com.sun.dtv.test.TestCase, java.lang.String), getType(), ERROR

isNotRun

public boolean isNotRun()
Check if the type code of the report is NOT_RUN.

Returns:
true if the type code is NOT_RUN.
See Also:
notRun(com.sun.dtv.test.TestCase, java.lang.String), getType(), NOT_RUN

isUnresolved

public boolean isUnresolved()
Check if the type code of the report is UNRESOLVED.

Returns:
true if the type code is UNRESOLVED.
See Also:
unresolved(com.sun.dtv.test.TestCase, java.lang.String), getType(), UNRESOLVED

passed

public static Report passed(TestCase test,
                            String reason)
Create a Report to indicate the successful outcome of a test.

Parameters:
test - The test TestCase object that passed.
reason - A short string describing why the test passed.
Returns:
a Report to indicate the successful outcome of a test.

failed

public static Report failed(TestCase test,
                            String reason)
Create a Report to indicate the unsuccessful outcome of a test: i.e. the test completed, but the test determined that what was being tested did not pass the test.

Parameters:
test - The test TestCase object that failed.
reason - A short string describing why the test failed.
Returns:
a Report to indicate the unsuccessful outcome of a test.

error

public static Report error(TestCase test,
                           String reason)
Create a Report to indicate that an error occurred while trying to run a test: i.e. the test did not complete for some reason, and so it could not determine whether what was being tested passed or failed.

Parameters:
test - The test TestCase object that had an error.
reason - A short string describing the error that occurred.
Returns:
a Report to indicate the error outcome of a test.

notRun

public static Report notRun(TestCase test,
                            String reason)
Create a Report to indicate that the test has not yet been run.

Parameters:
test - The test TestCase object that did not run.
reason - A short string indicating why the test has not yet been run.
Returns:
a Report to indicate the notRun outcome of a test.

unresolved

public static Report unresolved(TestCase test,
                                String reason)
Create a Report to indicate that the test has produced indecisive results.

Parameters:
test - The test TestCase object.
reason - A short string indicating why the test has not yet been run.
Returns:
a Report to indicate the UNRESOLVED outcome of a test.

toString

public String toString()
Convert a Report to a string. The convention is to specify the type of the report, the test id (as returned by TestCase.getTestId()) and the reason on a space separated line.

Overrides:
toString in class Object
Returns:
The complete report in a string.

exit

public void exit()
Convenience exit() function for the main() of tests to exit in such a way that the report passes up across process boundaries without losing information, that is: exit codes don't give the associated text of the report and return codes when exceptions are thrown could cause unintended results.

An identifying marker is written to the error stream, which the script running the test watches for as the last output before returning, followed by the type and reason.

The method does not return. Typically this method would call System.exit with a value dependent on the type.


Java DTV API 1.3
18-Nov-2009

Copyright © 2008-2009 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.

DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Use of this document is subject to license terms.