public abstract class DiffTestCase extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected File |
logFile
Name of current .log file.
|
protected OutputStream |
logOutputStream
OutputStream for current test log.
|
protected File |
refFile
Name of current .ref file.
|
| 限定符 | 构造器和说明 |
|---|---|
protected |
DiffTestCase(String testCaseName)
Initializes a new DiffTestCase.
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
addDiffMask(String mask)
Adds a diff mask.
|
protected void |
addIgnorePattern(String javaPattern) |
static String |
diff(File file1,
File file2)
Returns a string containing the difference between the contents of two
files.
|
protected void |
diffFile(File logFile,
File refFile)
Compares a log file with its reference log.
|
static String |
diffLines(List<String> lines1,
List<String> lines2)
Returns a string containing the difference between the two sets of lines.
|
protected void |
diffTestLog()
Finishes a diff-based test.
|
protected static String |
fileContents(File file)
Returns the contents of a file as a string.
|
protected abstract File |
getTestlogRoot()
Returns the root directory under which testlogs should be written.
|
protected Writer |
openTestLog()
Initializes a diff-based test.
|
protected OutputStream |
openTestLogOutputStream(File testFileSansExt)
Initializes a diff-based test, overriding the default log file naming
scheme altogether.
|
protected void |
setRefFileDiffMasks()
Sets the diff masks that are common to .REF files
|
protected void |
setUp() |
protected void |
setVerbose(boolean verbose)
Sets whether to give verbose message if diff fails.
|
protected void |
tearDown() |
protected File logFile
protected File refFile
protected OutputStream logOutputStream
@BeforeEach protected void setUp()
@AfterEach
protected void tearDown()
throws IOException
IOExceptionprotected Writer openTestLog() throws Exception
Exceptionprotected abstract File getTestlogRoot() throws Exception
Exceptionprotected OutputStream openTestLogOutputStream(File testFileSansExt) throws IOException
testFileSansExt - full path to log filename, without .log/.ref
extensionIOExceptionprotected void diffTestLog()
throws IOException
NOTE: if you wrap the Writer returned by openTestLog() (e.g. with a PrintWriter), be sure to flush the wrapping Writer before calling this method.
IOExceptiondiffFile(File, File)protected void diffFile(File logFile, File refFile) throws IOException
Usually, the log file and the reference log are in the same directory, one ending with '.log' and the other with '.ref'.
If the files are identical, removes logFile.
logFile - Log filerefFile - Reference logIOExceptionprotected void addDiffMask(String mask)
mask - a regular expression, as per String.replaceAllprotected void addIgnorePattern(String javaPattern)
public static String diff(File file1, File file2)
public static String diffLines(List<String> lines1, List<String> lines2)
protected static String fileContents(File file)
file - Fileprotected void setVerbose(boolean verbose)
protected void setRefFileDiffMasks()
Copyright © 2012-2023 Apache Software Foundation. All Rights Reserved.