com.sun.javatest.finder
Class ChameleonTestFinder

java.lang.Object
  extended by com.sun.javatest.TestFinder
      extended by com.sun.javatest.finder.ChameleonTestFinder

public class ChameleonTestFinder
extends TestFinder

A TestFinder that delegates to different test finders in different areas of the test suite, as described by a special "map" file.


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
ChameleonTestFinder()
          Create an uninitialized ChameleonTestFinder.
 
Method Summary
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.io.File[] getFiles()
          Get the files that were found by the most recent call of read.
 boolean getIgnoreCase()
          Check whether or not to ignore case when matching files against entries.
 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, TestEnvironment env)
          Generic initialization routine.
 void readEntries(java.io.File file)
          Read the entries in a file which describe which test finder to use in which part of the test suite.
protected  void scan(java.io.File file)
          Scan a file, looking for test descriptions and other files that might need to be scanned.
 void setIgnoreCase(boolean b)
          Set whether or not to ignore case when matching files against entries.
 
Methods inherited from class com.sun.javatest.TestFinder
clearErrors, decodeAllArgs, error, error, error, foundFile, foundTestDescription, foundTestDescription, getComparator, getDefaultComparator, getErrorCount, getErrorHandler, getErrors, getRoot, getRootDir, 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

ChameleonTestFinder

public ChameleonTestFinder()
Create an uninitialized ChameleonTestFinder.

Method Detail

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

getIgnoreCase

public boolean getIgnoreCase()
Check whether or not to ignore case when matching files against entries. By default, case will be ignored on Windows platforms. (System.getProperty("os.name").startsWith("Windows")) This can be overridden by setting the following system property:
    -Djavatest.chameleon.ignoreCase=true|false
 
This in turn can be overridden by using -ignoreCase or -dontIgnoreCase in the args to init.

Returns:
whether or not to ignore case when matching files against entries.
See Also:
setIgnoreCase(boolean)

setIgnoreCase

public void setIgnoreCase(boolean b)
Set whether or not to ignore case when matching files against entries.

Parameters:
b - whether or not to ignore case when matching files against entries.
See Also:
getIgnoreCase()

init

public void init(java.lang.String[] args,
                 java.io.File testSuiteRoot,
                 TestEnvironment env)
          throws TestFinder.Fault
Generic initialization routine. You can also initialize the test finder directly, with exclude(java.lang.String), readEntries(java.io.File), etc.

Overrides:
init in class TestFinder
Parameters:
args - An array of strings giving initialization data. The primary option is "-f file" to specify the name of the file describing which test finder to use in which section of the test suite.
testSuiteRoot - The root file of the test suite.
env - This argument is not required by this test finder.
Throws:
TestFinder.Fault - if an error is found during initialization.

readEntries

public void readEntries(java.io.File file)
                 throws TestFinder.Fault
Read the entries in a file which describe which test finder to use in which part of the test suite. The file is read line by line. If a line is empty or begins with a '#' character, the line is ignored. Otherwise the line is broken up as follows:
directory-or-file finder-class-name finder-args ...
Then, when a file is to be read by the test finder, the entries above are checked in the order they were read for an entry whose first word matches the beginning of the nameo of the file to be read. If and when a match is found, the test finder delegates the request to the test finder specified in the rest of the entry that provided the match.

Parameters:
file - The file containing the entries to be read.
Throws:
TestFinder.Fault - if a problem occurs while reading the file.

decodeArg

protected int decodeArg(java.lang.String[] args,
                        int i)
                 throws TestFinder.Fault
Description copied from class: TestFinder
Decode the arg at a specified position in the arg array. If overridden by a subtype, the subtype should try and decode any args 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

protected void scan(java.io.File file)
Scan a file, looking for test descriptions and other files that might need to be scanned. The implementation depends on the type of test finder.

Specified by:
scan in class TestFinder
Parameters:
file - The file to scan

getFiles

public java.io.File[] getFiles()
Description copied from class: TestFinder
Get the files that were found by the most recent call of read.

Overrides:
getFiles in class TestFinder
Returns:
the files that were found by the most recent call of read.
See Also:
TestFinder.read(java.io.File), TestFinder.foundFile(java.io.File)

getTests

public TestDescription[] getTests()
Description copied from class: TestFinder
Get the test descriptions that were found by the most recent call of read.

Overrides:
getTests in class TestFinder
Returns:
the test descriptions that were found by the most recent call of read.
See Also:
TestFinder.read(java.io.File), TestFinder.foundTestDescription(java.util.Map, java.io.File, int)


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