sofya.apps.dejavu
Class TestSelectionHandler

java.lang.Object
  extended by sofya.base.Handler
      extended by sofya.apps.dejavu.TestSelectionHandler
All Implemented Interfaces:
SConstants

public class TestSelectionHandler
extends Handler
implements SConstants

The TestSelectionHandler provides methods to manipulate Sofya test selection files and manage test selection information for methods obtained from running the DejaVu tool.

Version:
09/21/2004
Author:
Alex Kinneer

Nested Class Summary
 
Nested classes/interfaces inherited from interface sofya.base.SConstants
SConstants.BlockLabel, SConstants.BlockObjectType, SConstants.BlockSubType, SConstants.BlockType, SConstants.BranchObjectType, SConstants.BranchType, SConstants.EDObjectType, SConstants.TraceObjectType
 
Field Summary
 
Fields inherited from class sofya.base.Handler
HANDLER_EXTENSIONS, LINE_SEP
 
Fields inherited from interface sofya.base.SConstants
DEFAULT_PORT, INST_COMPATIBLE, INST_OLD_UNSUPPORTED, INST_OPT_NORMAL, INST_OPT_SEQUENCE, SIG_CHKALIVE, SIG_ECHO
 
Constructor Summary
TestSelectionHandler()
          Default constructor, creates a test selection handler with no test selections yet registered and no test count set.
TestSelectionHandler(int numTests)
          Default constructor, creates a test selection handler with no test selections yet registered and the specified number of tests from which selection may occur.
 
Method Summary
 boolean containsMethod(java.lang.String methodName)
          Reports whether test selection data exists for a given method.
 java.lang.String[] getMethodList()
          Gets the list of methods names for which test selections are currently registered with the handler.
 int getNumberOfTests()
          Gets the number of tests.
 int[] getSelectedTests(java.lang.String methodName)
          Gets the tests selected for a given method.
static void main(java.lang.String[] argv)
          Test driver for TestSelectionHandler.
 void readTestSelectionFile(java.lang.String fileName)
          Reads a test selection file making the information available for request from the handler.
 void setSelectedTests(java.lang.String methodName, int[] selectedTests)
          Records the tests selected for a given method.
 void writeTestSelectionFile(java.lang.String fileName, java.lang.String tag)
          Writes a test selection file from the test selection information currently registered with the handler.
 
Methods inherited from class sofya.base.Handler
copyFile, createCacheFile, disableParseNumbers, ensureTagExists, formatSignature, isIntAvailable, isStringAvailable, newCache, openCacheFile, openInputFile, openInputFile, openOutputFile, openOutputFile, parseClass, prepareTokenizer, readInt, readIntIgnoreEOL, readJarClasses, readNextLine, readProgFile, readString, readStringIgnoreEOL, readToEOL, readToNextDataLine, toBinary, toHex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestSelectionHandler

public TestSelectionHandler()
Default constructor, creates a test selection handler with no test selections yet registered and no test count set.

Note: A handler created with this constructor should only be used to read an existing test selection file. Any attempt to add test selection information for a method or write a test selection file prior to calling readTestSelectionFile(java.lang.String) will result in an IllegalStateException being thrown. To create a new test selection file, TestSelectionHandler(int) should be used.


TestSelectionHandler

public TestSelectionHandler(int numTests)
Default constructor, creates a test selection handler with no test selections yet registered and the specified number of tests from which selection may occur.

Parameters:
numTests - Number of tests from which selection may occur.
Method Detail

writeTestSelectionFile

public void writeTestSelectionFile(java.lang.String fileName,
                                   java.lang.String tag)
                            throws java.lang.IllegalStateException,
                                   java.io.IOException
Writes a test selection file from the test selection information currently registered with the handler.

Parameters:
fileName - Name of the test selection file to be written.
Throws:
java.lang.IllegalStateException - If the number of tests has not yet been set, either in the constructor or by readTestSelectionFile(java.lang.String).
java.io.IOException - If there is an I/O error creating or writing the file.

readTestSelectionFile

public void readTestSelectionFile(java.lang.String fileName)
                           throws java.io.FileNotFoundException,
                                  BadFileFormatException,
                                  java.io.IOException
Reads a test selection file making the information available for request from the handler. The getSelectedTests(java.lang.String) method can be used to retrieve information loaded by this method.

If the handler was created using the no-argument constructor, this method will set the number of tests, enabling the ability to add new test selection information and write a modified test selection file.

Parameters:
fileName - Name of the test selection file to be read.
Throws:
java.io.FileNotFoundException - If the specified file doesn't exist.
BadFileFormatException - If the specified file is not a test selection file, or is otherwise malformed or corrupted.
java.io.IOException - If there is an I/O error reading the file.

getMethodList

public java.lang.String[] getMethodList()
Gets the list of methods names for which test selections are currently registered with the handler.

Returns:
A list of the method names for which test selections can be retrieved from this handler.

containsMethod

public boolean containsMethod(java.lang.String methodName)
Reports whether test selection data exists for a given method.

Parameters:
methodName - Name of the method which the handler should check for test selection data.
Returns:
true if test selection data is available for the given method, false otherwise.

getSelectedTests

public int[] getSelectedTests(java.lang.String methodName)
                       throws MethodNotFoundException
Gets the tests selected for a given method.

Parameters:
methodName - Name of the method for which the selected tests are to be retrieved.
Returns:
The list of tests selected for the given method.
Throws:
MethodNotFoundException - If the handler has no test selection information associated with a method of the specified name.

setSelectedTests

public void setSelectedTests(java.lang.String methodName,
                             int[] selectedTests)
                      throws java.lang.IllegalStateException
Records the tests selected for a given method.

If test selection information already exists for the specified method, it is overwritten. Otherwise the method and test selection information are added to the set of methods registered with the handler.

Parameters:
methodName - Name of the method for which test selection information is being recorded.
selectedTests - The selected tests to be associated with the method.
Throws:
java.lang.IllegalStateException - If the number of tests has not yet been set, either in the constructor or by readTestSelectionFile(java.lang.String).

getNumberOfTests

public int getNumberOfTests()
Gets the number of tests.

Returns:
The number of tests from which selection can occur. A value of -1 indicates that the number of tests has not yet been set.

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Test driver for TestSelectionHandler.

Throws:
java.lang.Exception