|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.javatest.TestFinder
public abstract class TestFinder
Base implementation for test finders which search for test descriptions given a starting location. When creating instances of TestFinder for use, the creator should be sure to call the init() method before use.
| Nested Class Summary | |
|---|---|
static interface |
TestFinder.ErrorHandler
This interface is used to report significant errors found while reading files, but which are not of themselves serious enough to stop reading further. |
static class |
TestFinder.Fault
This exception is to report serious problems that occur while finding tests. |
| Field Summary | |
|---|---|
protected static boolean |
debug
A boolean to enable trace output while debugging test finders. |
protected TestEnvironment |
env
Deprecated. This feature was available in earlier versions of JT Harness but does not interact well with JT Harness 3.0's GUI features. Use with discretion, if at all. |
| Constructor Summary | |
|---|---|
TestFinder()
|
|
| Method Summary | |
|---|---|
void |
clearErrors()
Clear outstanding errors found by the test finder, so that until a new error is reported, getErrorCount will return 0 and getErrors will return an empty array. |
protected void |
decodeAllArgs(java.lang.String[] args)
Perform argument decoding, calling decodeArg for successive args until exhausted. |
protected int |
decodeArg(java.lang.String[] args,
int i)
Decode the arg at a specified position in the arg array. |
protected void |
error(I18NResourceBundle i18n,
java.lang.String key)
Report an error to the error handler. |
protected void |
error(I18NResourceBundle i18n,
java.lang.String key,
java.lang.Object arg)
Report an error to the error handler. |
protected void |
error(I18NResourceBundle i18n,
java.lang.String key,
java.lang.Object[] args)
Report an error to the error handler. |
protected void |
foundFile(java.io.File newFile)
Report that another file that needs to be read has been found. |
protected void |
foundTestDescription(java.util.Map entries,
java.io.File file,
int line)
Report that data for a test description has been found. |
protected void |
foundTestDescription(TestDescription td)
Report that a test description has been found. |
java.util.Comparator |
getComparator()
Get the current comparator being used. |
protected java.util.Comparator |
getDefaultComparator()
Get the default to be used when the user does not want to specify their own. |
int |
getErrorCount()
Get an count of the number of errors found by this test finder, as recorded by calls to the error handler via error and localizedError. |
TestFinder.ErrorHandler |
getErrorHandler()
Get the registered error handler. |
java.lang.String[] |
getErrors()
Get the errors recorded by the test finder, as recorded by calls to the error handler via error and localizedError. |
java.io.File[] |
getFiles()
Get the files that were found by the most recent call of read. |
java.io.File |
getRoot()
Get the root file of the test suite, as passed in to the init method. |
java.io.File |
getRootDir()
Get the root directory of the test suite; this is either the root passed in to the init method or if that is a file, it is the directory containing the file. |
TestDescription[] |
getTests()
Get the test descriptions that were found by the most recent call of read. |
void |
init(java.lang.String[] args,
java.io.File testSuiteRoot,
java.io.File[] tests,
TestFilter[] filters,
TestEnvironment env)
Deprecated. Use one of the other init() methods. This functionality is no longer supported. Methods on TestResultTable should yield similar results. |
void |
init(java.lang.String[] args,
java.io.File testSuiteRoot,
TestEnvironment env)
Initialize the data required by the finder. |
boolean |
isFolder(java.io.File path)
Determine whether a location corresponds to a directory (folder) or an actual file. |
long |
lastModified(java.io.File f)
Determine when the last time this path was modified. |
protected void |
localizedError(java.lang.String msg)
Report a message to the error handler, without additional processing. |
protected java.util.Map |
normalize(java.util.Map entries)
"normalize" the test description entries read from a file. |
protected void |
processEntry(java.util.Map entries,
java.lang.String name,
java.lang.String value)
Handle a test description entry read from a file. |
void |
read(java.io.File file)
Read a file, looking for test descriptions and other files that might need to be read. |
protected abstract void |
scan(java.io.File file)
Scan a file, looking for test descriptions and other files that might need to be scanned. |
void |
setComparator(java.util.Comparator c)
Incoming files and test descriptions are sorted by their name during processing, this method allows adjustment of the comparison method to be used during this sorting. |
void |
setErrorHandler(TestFinder.ErrorHandler h)
Set an error handler to be informed of errors that may arise while reading tests. |
protected void |
setRoot(java.io.File testSuiteRoot)
Set the test suite root file or directory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected TestEnvironment env
protected static boolean debug
| Constructor Detail |
|---|
public TestFinder()
| Method Detail |
|---|
public void init(java.lang.String[] args,
java.io.File testSuiteRoot,
TestEnvironment env)
throws TestFinder.Fault
args - An array of strings specified as arguments in the environment. Null
indicates no args.testSuiteRoot - The root file that will be passed to test descriptions read
by the finder.env - The environment being used to run the test. May be null.
TestFinder.Fault - if there is a problem interpreting any of args.
public void init(java.lang.String[] args,
java.io.File testSuiteRoot,
java.io.File[] tests,
TestFilter[] filters,
TestEnvironment env)
throws TestFinder.Fault
args - An array of strings specified as arguments in the environment. Null
indicates no args.testSuiteRoot - The root file that will be passed to test descriptions read
by the finder.tests - The tests to be read by the finder. (ignored)filters - An optional array of filters to filter the tests read by the finder.env - The environment being used to run the test. May be null.
TestFinder.Fault - if there is a problem interpreting any of args.init(String[],File,TestEnvironment)
protected void decodeAllArgs(java.lang.String[] args)
throws TestFinder.Fault
args - The arguments to be decoded
TestFinder.Fault - if decodeArg throws the exception
while decoding one of the arguments, or if decodeArg does
not recognize an argument.
protected int decodeArg(java.lang.String[] args,
int i)
throws TestFinder.Fault
args - The array of argumentsi - The next argument to be decoded
TestFinder.Fault - If there is a problem with the value of the current
arg, such as a bad value to an option, the Fault
exception can be thrown. The exception should NOT be
thrown if the current arg is unrecognized: in that case,
an implementation should delegate the call to the
supertype.
protected void setRoot(java.io.File testSuiteRoot)
throws java.lang.IllegalStateException,
TestFinder.Fault
testSuiteRoot - The path to be set as the root of the
test suite in which files will be read.
java.lang.IllegalStateException - if already set
TestFinder.Fault - if there is some test-finder-specific
problem with the specified file.getRoot()public java.io.File getRoot()
init method.
setRoot(java.io.File)public java.io.File getRootDir()
public void setComparator(java.util.Comparator c)
null parameter. By default, this class will
do US Locale sorting.
c - The comparison operator to be used. Null indicates no sorting (old behavior).getComparator(),
foundTestDescription(TestDescription),
foundFile(File)public java.util.Comparator getComparator()
setComparator(java.util.Comparator)protected java.util.Comparator getDefaultComparator()
public TestFinder.ErrorHandler getErrorHandler()
setErrorHandler(com.sun.javatest.TestFinder.ErrorHandler)public void setErrorHandler(TestFinder.ErrorHandler h)
h - The error handler that will be informed of non-fatal
errors that occur while reading the test suitegetErrorHandler()
protected void error(I18NResourceBundle i18n,
java.lang.String key)
i18n - A resource bundle containing the localized error messageskey - The name of the entry in the resource bundle containing
the appropriate error message.
The message should not need any arguments.
protected void error(I18NResourceBundle i18n,
java.lang.String key,
java.lang.Object arg)
i18n - A resource bundle containing the localized error messageskey - The name of the entry in the resource bundle containing
the appropriate error message.
The message will be formatted with a single argument, using
MessageFormat.format.arg - The argument to be formatted in the message found in the
resource bundle
protected void error(I18NResourceBundle i18n,
java.lang.String key,
java.lang.Object[] args)
i18n - A resource bundle containing the localized error messageskey - The name of the entry in the resource bundle containing
the appropriate error message.
The message will be formatted with an array of arguments, using
MessageFormat.format.args - The arguments to be formatted in the message found in the
resource bundleprotected void localizedError(java.lang.String msg)
msg - The message to be reportederror(com.sun.javatest.util.I18NResourceBundle, java.lang.String)public int getErrorCount()
getErrors(),
clearErrors()public java.lang.String[] getErrors()
public void clearErrors()
public boolean isFolder(java.io.File path)
path - The location in question.public long lastModified(java.io.File f)
f - The location in question.public void read(java.io.File file)
file - The file to be read.protected abstract void scan(java.io.File file)
file - The file to scan
protected void processEntry(java.util.Map entries,
java.lang.String name,
java.lang.String value)
entries - The dictionary of the entries being readname - The name of the entry that has been readvalue - The value of the entry that has been readprotected java.util.Map normalize(java.util.Map entries)
entries - A set of tag values read from a test description in a file
protected void foundTestDescription(java.util.Map entries,
java.io.File file,
int line)
entries - The data for the test descriptionfile - The file being readline - The line number within the file (used for error messages)protected void foundTestDescription(TestDescription td)
td - The data for the test description. May never be null.foundTestDescription(java.util.Map, java.io.File, int)public TestDescription[] getTests()
read(java.io.File),
foundTestDescription(java.util.Map, java.io.File, int)protected void foundFile(java.io.File newFile)
newFile - the file that has been found that needs to be read.read(java.io.File),
getFiles()public java.io.File[] getFiles()
read(java.io.File),
foundFile(java.io.File)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||