Package com.sun.javatest.finder
Class BinaryTestFinder
- java.lang.Object
-
- com.sun.javatest.TestFinder
-
- com.sun.javatest.finder.BinaryTestFinder
-
public class BinaryTestFinder extends TestFinder
A TestFinder to read a compressed binary file containing the previously "compiled" results of some other test finder.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BinaryTestFinder.TestTable
A TestTable is a collection of TestDescriptions.static class
BinaryTestFinder.TestTree
A TestTree represents a tree of test descriptions; the data of the individual descriptions is stored in a test table.-
Nested classes/interfaces inherited from class com.sun.javatest.TestFinder
TestFinder.ErrorHandler, TestFinder.Fault
-
-
Field Summary
-
Fields inherited from class com.sun.javatest.TestFinder
debug, env
-
-
Constructor Summary
Constructors Constructor Description BinaryTestFinder()
Create an uninitialized binary test finder.BinaryTestFinder(java.io.File jtdFile)
Deprecated.Use BinaryTestFinder(File testSuiteRoot, File jtdFile) insteadBinaryTestFinder(java.io.File testSuiteRoot, java.io.File jtdFile)
Deprecated.Use BinaryTestFinder(File, File, TestEnvironment) with null as the last argument.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected int
decodeArg(java.lang.String[] args, int i)
Decodes any args needed by BinaryTestFinder.com.sun.javatest.finder.BinaryTestFinder.StringTable
getStringTable()
BinaryTestFinder.TestTable
getTestTable()
BinaryTestFinder.TestTree
getTestTree()
void
init(java.io.File testSuiteRoot, java.io.File jtdFile)
Deprecated.Use init(File, File TestEnvironment) with null args as needed.void
init(java.lang.String[] args, java.io.File testSuiteRoot, TestEnvironment env)
Initialize a new BinaryTestFinder.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.void
readBinaryFile()
Read the binary file.protected void
scan(java.io.File file)
Given a File, scan to look for other files or tests.java.util.Optional<java.lang.Integer>
totalNumberOfTestsInTheSuite()
Returns the total number of tests in the inspected suite if it is known.-
Methods inherited from class com.sun.javatest.TestFinder
clearErrors, decodeAllArgs, error, error, error, foundFile, foundTestDescription, foundTestDescription, getComparator, getDefaultComparator, getErrorCount, getErrorHandler, getErrors, getFiles, getRoot, getRootDir, getTests, init, localizedError, normalize, processEntry, read, setComparator, setErrorHandler, setRoot
-
-
-
-
Constructor Detail
-
BinaryTestFinder
public BinaryTestFinder()
Create an uninitialized binary test finder. Use one of the init methods to initialize it.
-
BinaryTestFinder
@Deprecated public BinaryTestFinder(java.io.File jtdFile) throws TestFinder.Fault
Deprecated.Use BinaryTestFinder(File testSuiteRoot, File jtdFile) insteadCreate and initialize a binary test finder.- Parameters:
jtdFile
- The binary file containing the precompiled test descriptions. The file should be an absolute file.- Throws:
TestFinder.Fault
- if there is a problem while reading the data file.- See Also:
BinaryTestFinder(File, File)
-
BinaryTestFinder
@Deprecated public BinaryTestFinder(java.io.File testSuiteRoot, java.io.File jtdFile) throws TestFinder.Fault
Deprecated.Use BinaryTestFinder(File, File, TestEnvironment) with null as the last argument.Create and initialize a binary test finder.- Parameters:
jtdFile
- The binary file containing the precompiled test descriptions. If the file is relative, it will be evaluated relative to testSuiteRoot.testSuiteRoot
- The root file of the Test Suite. This is usually a file called testsuite.html- Throws:
TestFinder.Fault
- if there is a problem while reading the data file.
-
-
Method Detail
-
init
public void init(java.lang.String[] args, java.io.File testSuiteRoot, TestEnvironment env) throws TestFinder.Fault
Initialize a new BinaryTestFinder. This method opens the binary file to read from, calls methods to read the data, and initializes other variables.- Overrides:
init
in classTestFinder
- Parameters:
args
- Any arguments needed by the TestFinder. You must pass "-binary" followed by the path to the binary file. If the file is relative, it will be evaluated relative to testSuiteRoot.testSuiteRoot
- The root file of the Test Suite. This is usually a file called testsuite.htmlenv
- Environment file for the TestFinder. Not used by BinaryTestFinder.- Throws:
TestFinder.Fault
- if there is a problem while reading the data file.
-
init
@Deprecated public void init(java.io.File testSuiteRoot, java.io.File jtdFile) throws TestFinder.Fault
Deprecated.Use init(File, File TestEnvironment) with null args as needed.Initialize a new BinaryTestFinder. This method opens the binary file to read from, calls methods to read the data, and initializes other variables.- Parameters:
testSuiteRoot
- The root file of the Test Suite. This is usually a file called testsuite.htmljtdFile
- The file containing the binary data for the test descriptions. If the file is relative, it will be evaluated relative to testSuiteRoot.- Throws:
TestFinder.Fault
- if there is a problem while reading the data file.
-
decodeArg
protected int decodeArg(java.lang.String[] args, int i) throws TestFinder.Fault
Decodes any args needed by BinaryTestFinder. The only supported args are "-binary" or "-jtd" followed by the name of the binary file, or the name of the binary file as the last argument.- Overrides:
decodeArg
in classTestFinder
- Parameters:
args
- An array of arguments, containing the next argument to be decoded.i
- The position in the args array of the next argument to be decoded.- Returns:
- The number of entries in the args array that were taken as part of the next argument.
- Throws:
TestFinder.Fault
- if any problems occur while decoding the next argument
-
lastModified
public long lastModified(java.io.File f)
Description copied from class:TestFinder
Determine when the last time this path was modified. This is used to decide whether to rescan that location or not. The default implementation defers the choice to the java.- Overrides:
lastModified
in classTestFinder
- Parameters:
f
- The location in question.
-
isFolder
public boolean isFolder(java.io.File path)
Description copied from class:TestFinder
Determine whether a location corresponds to a directory (folder) or an actual file. If the finder implementation chooses, the locations used in read() and scan() may be real or virtual. This method will be queried to determine if a location is a container or something that should be scanned for tests. If it is both...- Overrides:
isFolder
in classTestFinder
- Parameters:
path
- The location in question.
-
scan
protected void scan(java.io.File file)
Given a File, scan to look for other files or tests. These can then be used through getTests() and getFiles().This method first takes the file path and makes it relative to the testsuite root. It then finds the corresponding node in the test tree, and calls foundFile and foundTestDescription based on the info in that node, thereby recreating the effect of the original read of this file by the original test finder.
- Specified by:
scan
in classTestFinder
- Parameters:
file
- The file to scan
-
readBinaryFile
public void readBinaryFile()
Read the binary file. The input file should be a zip file as written by BinaryTestWriter. All three sections are read, but only the string table and test tree are parsed at this point. The test table is read from an internal byte array as required.
-
getStringTable
public com.sun.javatest.finder.BinaryTestFinder.StringTable getStringTable()
-
getTestTable
public BinaryTestFinder.TestTable getTestTable()
-
getTestTree
public BinaryTestFinder.TestTree getTestTree()
-
totalNumberOfTestsInTheSuite
public java.util.Optional<java.lang.Integer> totalNumberOfTestsInTheSuite()
Description copied from class:TestFinder
Returns the total number of tests in the inspected suite if it is known. (For example if preliminary quick scan of the suite was done). Default implementation returns empty Optional.- Overrides:
totalNumberOfTestsInTheSuite
in classTestFinder
- Returns:
- total number of tests or empty optional if there's no info available
-
-