org.fhcrc.cpl.toolbox.test
Class TestUtilities

java.lang.Object
  extended by org.fhcrc.cpl.toolbox.test.TestUtilities

public class TestUtilities
extends java.lang.Object

Abstract base class for all msInspect tests. Lots of utility methods


Field Summary
protected static java.io.File mLogFile
           
protected static java.io.PrintWriter mLogPrintWriter
           
protected static java.lang.String mRootTestDirName
           
protected static java.lang.String mRootTestTempfileDirName
           
protected static java.lang.String mSampleDataDirName
           
protected static java.lang.String mTestLogDirName
           
protected static boolean mTriedToOpenLog
           
protected static java.lang.String mViewerRootDirName
           
 
Constructor Summary
TestUtilities()
           
 
Method Summary
static java.lang.String calculateHexMD5SumNoWhiteSpace(java.io.File file)
          Calculate an MD5 sum for a file, first stripping out all whitespace, then convert it to hex
static java.lang.String calculateHexMD5SumNoWhiteSpaceNoComments(java.io.File file)
           
static void closeLog()
          Close the PrintWriter on the log file, if it's open
static boolean compareHexMD5SumsNoWhiteSpace(java.io.File file, java.lang.String targetSum)
          Compare the MD5 sum of a file with a previously stored sum
static boolean compareHexMD5SumsNoWhiteSpaceNoComments(java.io.File file, java.lang.String targetSum)
           
static java.lang.String constructTempFilePath(java.lang.String className, java.lang.String relativeFilePath)
          Convenience method to construct a filepath in the temp file dir
static boolean createTestTempDir(java.lang.String className)
          Create a temp dir for this test
static java.lang.String getCurrentTestTempDirName(java.lang.String className)
           
static java.io.File getLogFile()
          Manage the log file
static java.lang.String getRootTestDirName()
          webapps/tools/test.
static java.lang.String getRootTestTempfileDirName()
           
static java.lang.String getSampleDataDirFilePath(java.lang.String fileName)
          Convenience method to get the filepath of a named file in the sampledata dir
static java.lang.String getSampleDataDirName()
          Get the directory name of the sampledata directory, where all files that the test might need to work with should live
static java.lang.String getTestLogDirName()
           
static java.lang.String getViewerRootDirName()
          Get the viewer root directory (webapps/tools)
static void log(java.lang.String mesg)
          Write a lot message to System.err and also to a log file
static void openLogPrintWriter()
          Open a PrintWriter on the log file
static void recursiveFileDelete(java.io.File file)
          Recursively delete a file and any children from the filesystem
static void removeHashCommentLinesFromFile(java.io.File file)
          Strip # style comments from a file.
static java.lang.String toHexString(byte[] v)
          Convert a byte array to a hex string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mViewerRootDirName

protected static java.lang.String mViewerRootDirName

mSampleDataDirName

protected static java.lang.String mSampleDataDirName

mRootTestTempfileDirName

protected static java.lang.String mRootTestTempfileDirName

mRootTestDirName

protected static java.lang.String mRootTestDirName

mTestLogDirName

protected static java.lang.String mTestLogDirName

mLogFile

protected static java.io.File mLogFile

mLogPrintWriter

protected static java.io.PrintWriter mLogPrintWriter

mTriedToOpenLog

protected static boolean mTriedToOpenLog
Constructor Detail

TestUtilities

public TestUtilities()
Method Detail

recursiveFileDelete

public static void recursiveFileDelete(java.io.File file)
Recursively delete a file and any children from the filesystem

Parameters:
file -

createTestTempDir

public static boolean createTestTempDir(java.lang.String className)
Create a temp dir for this test

Returns:

getSampleDataDirName

public static java.lang.String getSampleDataDirName()
Get the directory name of the sampledata directory, where all files that the test might need to work with should live

Returns:

getSampleDataDirFilePath

public static java.lang.String getSampleDataDirFilePath(java.lang.String fileName)
Convenience method to get the filepath of a named file in the sampledata dir

Parameters:
fileName -
Returns:

getViewerRootDirName

public static java.lang.String getViewerRootDirName()
Get the viewer root directory (webapps/tools)

Returns:

getRootTestDirName

public static java.lang.String getRootTestDirName()
webapps/tools/test. Contains logs and temp_files subdirs

Returns:

getTestLogDirName

public static java.lang.String getTestLogDirName()
Returns:
directory name of the test log directory

getRootTestTempfileDirName

public static java.lang.String getRootTestTempfileDirName()
Returns:
dir name of the root test temp file directory

getCurrentTestTempDirName

public static java.lang.String getCurrentTestTempDirName(java.lang.String className)
Returns:
dir name of the temp file dir for this test

constructTempFilePath

public static java.lang.String constructTempFilePath(java.lang.String className,
                                                     java.lang.String relativeFilePath)
Convenience method to construct a filepath in the temp file dir

Parameters:
relativeFilePath -
Returns:

toHexString

public static java.lang.String toHexString(byte[] v)
Convert a byte array to a hex string

Parameters:
v -
Returns:

removeHashCommentLinesFromFile

public static void removeHashCommentLinesFromFile(java.io.File file)
                                           throws java.lang.Exception
Strip # style comments from a file. Useful for creating md5 sums for files in which the comments might vary but everything else must be the same

Parameters:
file -
Throws:
java.lang.Exception

calculateHexMD5SumNoWhiteSpaceNoComments

public static java.lang.String calculateHexMD5SumNoWhiteSpaceNoComments(java.io.File file)
                                                                 throws java.lang.Exception
Throws:
java.lang.Exception

calculateHexMD5SumNoWhiteSpace

public static java.lang.String calculateHexMD5SumNoWhiteSpace(java.io.File file)
                                                       throws java.lang.Exception
Calculate an MD5 sum for a file, first stripping out all whitespace, then convert it to hex

Parameters:
file -
Returns:
Throws:
java.lang.Exception

compareHexMD5SumsNoWhiteSpace

public static boolean compareHexMD5SumsNoWhiteSpace(java.io.File file,
                                                    java.lang.String targetSum)
                                             throws java.lang.Exception
Compare the MD5 sum of a file with a previously stored sum

Parameters:
file -
targetSum -
Returns:
Throws:
java.lang.Exception

compareHexMD5SumsNoWhiteSpaceNoComments

public static boolean compareHexMD5SumsNoWhiteSpaceNoComments(java.io.File file,
                                                              java.lang.String targetSum)
                                                       throws java.lang.Exception
Throws:
java.lang.Exception

log

public static void log(java.lang.String mesg)
Write a lot message to System.err and also to a log file

Parameters:
mesg -

getLogFile

public static java.io.File getLogFile()
Manage the log file

Returns:

openLogPrintWriter

public static void openLogPrintWriter()
Open a PrintWriter on the log file


closeLog

public static void closeLog()
Close the PrintWriter on the log file, if it's open



Fred Hutchinson Cancer Research Center