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:
  • Constructor Details

    • TagTestFinder

      public TagTestFinder()
      Constructs the list of file names to exclude for pruning in the search for files to examine for test descriptions. This constructor also sets the allowable comment formats.
  • Method Details

    • decodeArg

      protected int decodeArg(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 class TestFinder
      Parameters:
      args - The array of arguments
      i - 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(File file)
      Scan a file, looking for test descriptions and/or more files to scan.
      Specified by:
      scan in class TestFinder
      Parameters:
      file - The file to scan
    • getCurrentFile

      protected File getCurrentFile()
      Get the name of the file currently being scanned.
      Returns:
      the name of the file currently being scanned.
    • exclude

      public void exclude(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(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(String name)
      Undo an exclude operation.
      Parameters:
      name - The filename to stop ignoring, should never be null.
      See Also:
    • isExcluded

      public boolean isExcluded(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:
    • addExtension

      public void addExtension(String extn, 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 used
      commentStreamClass - A class to read files of a particular extension. The class must be a subtype of CommentStream
    • getClassForExtension

      public Class<? extends CommentStream> getClassForExtension(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 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

      public void setInitialTag(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:
    • scanFile

      protected void scanFile(File file)
      Scan a file, looking for comments and in the comments, for test description data.
      Parameters:
      file - The file to scan
    • parseComment

      protected Map<String,String> parseComment(String comment, 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.