Package com.sun.javatest.finder
Class TagTestFinder
- java.lang.Object
-
- com.sun.javatest.TestFinder
-
- com.sun.javatest.finder.TagTestFinder
-
- Direct Known Subclasses:
ExpandTestFinder
public class TagTestFinder extends TestFinder
This class searches out test descriptions found in a file system tree. Each attribute of the test description consists of JavaDoc-like tags which provide an tag-name and associated value. The associated test script for the test suite will interpret the values. All tags for a given test description must be within the same block comment. A file may contain multiple test descriptions.- See Also:
TestFinder
-
-
Nested Class Summary
-
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 TagTestFinder()
Constructs the list of file names to exclude for pruning in the search for files to examine for test descriptions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addExtension(java.lang.String extn, java.lang.Class<? extends CommentStream> commentStreamClass)
Nominate a class to read files that have a particular extension.protected int
decodeArg(java.lang.String[] args, int i)
Decode the arg at a specified position in the arg array.void
exclude(java.lang.String name)
Exclude all files with a particular name from being scanned.void
exclude(java.lang.String... names)
Exclude all files with particular names from being scanned.java.lang.Class<? extends CommentStream>
getClassForExtension(java.lang.String extn)
Get the class used to handle an extension.protected java.io.File
getCurrentFile()
Get the name of the file currently being scanned.java.lang.String
getInitialTag()
Get the current value of the initial tag that is checked for in a test description.boolean
isExcluded(java.lang.String s)
Determine if the given extension is excluded from scanning.protected java.util.Map<java.lang.String,java.lang.String>
parseComment(java.lang.String comment, java.io.File currFile)
Given a comment, find all tags of interest.void
scan(java.io.File file)
Scan a file, looking for test descriptions and/or more files to scan.protected void
scanFile(java.io.File file)
Scan a file, looking for comments and in the comments, for test description data.void
setInitialTag(java.lang.String tag)
Set the initial tag to be checked for in a test description.void
unexclude(java.lang.String name)
Undo an exclude operation.-
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, init, isFolder, lastModified, localizedError, normalize, processEntry, read, setComparator, setErrorHandler, setRoot, totalNumberOfTestsInTheSuite
-
-
-
-
Method Detail
-
decodeArg
protected int decodeArg(java.lang.String[] args, int i) throws TestFinder.Fault
Decode the arg at a specified position in the arg array. If overridden by a subtype, the subtype should try and decode any arg it recognizes, and then call super.decodeArg to give the superclass(es) a chance to recognize any arguments.- Overrides:
decodeArg
in classTestFinder
- Parameters:
args
- The array of argumentsi
- The next argument to be decoded.- Returns:
- The number of elements consumed in the array; for example, for a simple option like "-v" the result should be 1; for an option with an argument like "-f file" the result should be 2, etc.
- Throws:
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.
-
scan
public void scan(java.io.File file)
Scan a file, looking for test descriptions and/or more files to scan.- Specified by:
scan
in classTestFinder
- Parameters:
file
- The file to scan
-
getCurrentFile
protected java.io.File getCurrentFile()
Get the name of the file currently being scanned.- Returns:
- the name of the file currently being scanned.
-
exclude
public void exclude(java.lang.String name)
Exclude all files with a particular name from being scanned. This will typically be for directories like SCCS, Codemgr_wsdata, etc- Parameters:
name
- The name of files to be excluded.
-
exclude
public void exclude(java.lang.String... names)
Exclude all files with particular names from being scanned. This will typically be for directories like SCCS, Codemgr_wsdata, etc- Parameters:
names
- The names of files to be excluded.
-
unexclude
public void unexclude(java.lang.String name)
Undo an exclude operation.- Parameters:
name
- The filename to stop ignoring, should never be null.- See Also:
exclude(java.lang.String)
,isExcluded(String)
-
isExcluded
public boolean isExcluded(java.lang.String s)
Determine if the given extension is excluded from scanning.- Parameters:
s
- The extension to check for (should not contain the leading dot)- Returns:
- True if it is excluded, false otherwise.
- See Also:
exclude(java.lang.String)
,exclude(java.lang.String[])
,unexclude(String)
-
addExtension
public void addExtension(java.lang.String extn, java.lang.Class<? extends CommentStream> commentStreamClass)
Nominate a class to read files that have a particular extension.- Parameters:
extn
- The extension for which this class is to be usedcommentStreamClass
- A class to read files of a particular extension. The class must be a subtype of CommentStream
-
getClassForExtension
public java.lang.Class<? extends CommentStream> getClassForExtension(java.lang.String extn)
Get the class used to handle an extension.- Parameters:
extn
- The extension in question- Returns:
- the class previously registered with addExtension
-
getInitialTag
public java.lang.String getInitialTag()
Get the current value of the initial tag that is checked for in a test description. If null, no tag is required.- Returns:
- the value of the required initial tag, or null if none required.
- See Also:
setInitialTag(java.lang.String)
-
setInitialTag
public void setInitialTag(java.lang.String tag)
Set the initial tag to be checked for in a test description. If set to null, no initial tag is required. The default value for the initial tag is "test". (i.e. @test must appear in the test description.)- Parameters:
tag
- The tag to be checked for.- See Also:
getInitialTag()
-
scanFile
protected void scanFile(java.io.File file)
Scan a file, looking for comments and in the comments, for test description data.- Parameters:
file
- The file to scan
-
parseComment
protected java.util.Map<java.lang.String,java.lang.String> parseComment(java.lang.String comment, java.io.File currFile)
Given a comment, find all tags of interest. Return a map containing the name-value pairs for those tags. If a duplicate name is found, the last name-value will be returned.- Parameters:
comment
- The comment to be parsed.currFile
- The name of the file currently being read.- Returns:
- A map containing the name-value pairs read from the comment.
-
-