com.sun.javatest.finder
Class TagTestFinder

java.lang.Object
  extended by com.sun.javatest.TestFinder
      extended by 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
TagTestFinder()
          Constructs the list of file names to exclude for pruning in the search for files to examine for test descriptions.
 
Method Summary
 void addExtension(java.lang.String extn, java.lang.Class 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 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.
protected  java.util.Map 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.
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 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 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(java.io.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 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.

addExtension

public void addExtension(java.lang.String extn,
                         java.lang.Class 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 java.lang.Class 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

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()

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)

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 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.


Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.