com.sun.javatest
public class Status extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
ERROR
A return code indicating that the test was not run because some error
occurred before the test could even be attempted.
|
static java.lang.String |
EXIT_PREFIX
A string used to prefix the status when it is written to System.err
by
exit() . |
static int[] |
exitCodes
Exit codes used by Status.exit corresponding to
PASSED, FAILED, ERROR, NOT_RUN.
|
static int |
FAILED
A return code indicating that the test was executed but the test
reported that it failed.
|
static int |
NOT_RUN
A return code indicating that the test has not yet been run in this context.
|
static int |
NUM_STATES
Number of states which are predefined as "constants".
|
static int |
PASSED
A return code indicating that the test was executed and was successful.
|
Constructor and Description |
---|
Status(int type,
java.lang.String reason)
Create a Status object.
|
Modifier and Type | Method and Description |
---|---|
Status |
augment(Status aux)
Return a new Status object with a possibly augmented reason field.
|
Status |
augment(java.lang.String aux)
Return a new Status object with a possibly augmented reason field.
|
static java.lang.String |
decode(java.lang.String str)
Decodes string encoded by encode(String) method.
|
static java.lang.String |
encode(java.lang.String str)
Encodes strings containing non-ascii characters, where all characters
are replaced with with their Unicode code.
|
static Status |
error(java.lang.String reason)
Create a Status to indicate that an error occurred while trying to run a test:
i.e.
|
void |
exit()
Convenience exit() function for the main() of tests to exit in such a
way that the status passes up across process boundaries without losing
information (ie exit codes don't give the associated text of the status
and return codes when exceptions are thrown could cause unintended
results).
|
static Status |
failed(java.lang.String reason)
Create a Status to indicate the unsuccessful outcome of a test:
i.e.
|
java.lang.String |
getReason()
Get the message given when the status was created.
|
int |
getType()
Get the type code indicating the type of this Status object.
|
boolean |
isError()
Check if the type code of the status is ERROR.
|
boolean |
isFailed()
Check if the type code of the status is FAILED.
|
boolean |
isNotRun()
Check if the type code of the status is NOT_RUN.
|
boolean |
isPassed()
Check if the type code of the status is PASSED.
|
static Status |
notApplicable(java.lang.String reason)
Deprecated.
|
static Status |
parse(java.lang.String s)
Parse a string-form of a Status.
|
static Status |
passed(java.lang.String reason)
Create a Status to indicate the successful outcome of a test.
|
java.lang.String |
toString()
Convert a Status to a string.
|
static java.lang.String |
typeToString(int typeNum)
Translate the type number to a descriptive string.
|
public static final int PASSED
public static final int FAILED
public static final int ERROR
getType()
,
Constant Field Valuespublic static final int NOT_RUN
getType()
,
Constant Field Valuespublic static final int NUM_STATES
public static final java.lang.String EXIT_PREFIX
exit()
.public static final int[] exitCodes
public Status(int type, java.lang.String reason) throws java.lang.IllegalArgumentException
passed(java.lang.String)
, failed(java.lang.String)
, error(java.lang.String)
etc. for more convenient factory methods to create Status objects.type
- The type code for the Status object.reason
- A short string to store in the status. Unprintable characters
(i.e. outside the range 040C to 177C) in the string are replaced by a space.java.lang.IllegalArgumentException
- if the specified type is invalid.public static Status passed(java.lang.String reason)
reason
- A short string describing why the test passed.public static Status failed(java.lang.String reason)
reason
- A short string describing why the test failed.public static Status error(java.lang.String reason)
reason
- A short string describing the error that occurred.public static Status notApplicable(java.lang.String reason)
reason
- A short string describing why the test was not applicable.public boolean isPassed()
passed(java.lang.String)
,
getType()
,
PASSED
public boolean isFailed()
failed(java.lang.String)
,
getType()
,
FAILED
public boolean isError()
error(java.lang.String)
,
getType()
,
ERROR
public boolean isNotRun()
public int getType()
public java.lang.String getReason()
public Status augment(java.lang.String aux)
aux
- if not null and not empty, it will be combined with the original reason.public Status augment(Status aux)
aux
- a Status to combine with this objectpublic static Status parse(java.lang.String s)
s
- a string containing the string form of a Status
as generated by toString()
exit()
public java.lang.String toString()
toString
in class java.lang.Object
parse(java.lang.String)
public static java.lang.String typeToString(int typeNum)
typeNum
- A number between zero and NUM_STATESpublic void exit()
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. It calls System.exit with a value dependent on the type.
public static java.lang.String encode(java.lang.String str)
System.out.println(Status.encode("X ?")); //58 20 1AB System.out.println(Status.encode("Abc1")); // Abc1
str
- - string to encodedecode(java.lang.String)
public static java.lang.String decode(java.lang.String str)
str
- - string to decodeencode(java.lang.String)
Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.