TUM CCSM Commons

edu.tum.cs.commons.test
Class CCSMTestCaseBase

java.lang.Object
  extended by TestCase
      extended by edu.tum.cs.commons.test.CCSMTestCaseBase
Direct Known Subclasses:
TestletBase

public abstract class CCSMTestCaseBase
extends TestCase

Base class for test cases that access test data files. This class provides a simple mechanism for accessing test data files in a specified directory and provides statistics on test file usage and non-usage.

The test files a test case accesses must reside in the following location:

        test-data/<Name of the package the test case resides in>
 
For example if a test case is defined in package demo.test the test files it accesses must be located in directory test-data/demo.test.

Version:
$Rev: 28629 $
Author:
Florian Deissenboeck, $Author: deissenb $
Rating:
GREEN Hash: AEAC92C20B9EDCFB4A8E5E0A2C9E844A

Constructor Summary
CCSMTestCaseBase()
          Default constructor
CCSMTestCaseBase(java.lang.String name)
          Constructs a test case with the given name.
 
Method Summary
protected  CanonicalFile canonize(java.io.File file)
          Canonize file.
protected  CanonicalFile createCanonicalTmpFile(java.lang.String filename, java.lang.String content)
          Same as createTmpFile(String, String) but returns a CanonicalFile.
protected  java.io.File createTmpFile(java.lang.String filename, java.lang.String content)
          Create a temporary file in a subdirectory of the test temp directory.
protected  void deleteTmpDirectory()
          Delete temporary directory.
protected  java.io.File getTmpDirectory()
          Get temporary directory.
static boolean is64BitVM()
          Checks if we run on a 64 bit VM
protected  void printStatistics()
          Print report about used and unused test files.
protected  void printUnusedFiles()
          Print report about unused test files.
protected  void printUsedFiles()
          Print report about used test files.
protected  CanonicalFile useCanonicalTestFile(java.lang.String filename)
          Same as useTestFile(String) but returns a CanonicalFile.
protected  java.io.File useTestFile(java.lang.String filename)
          Use test file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CCSMTestCaseBase

public CCSMTestCaseBase()
Default constructor


CCSMTestCaseBase

public CCSMTestCaseBase(java.lang.String name)
Constructs a test case with the given name.

Parameters:
name - Name of the test method that gets called
Method Detail

useTestFile

protected java.io.File useTestFile(java.lang.String filename)
Use test file. This method does not actually access the file, so no IO exception can be raised. This method uses a TestDataManager to log access to test data files.

Parameters:
filename - Name of the file
Returns:
the file.

createTmpFile

protected java.io.File createTmpFile(java.lang.String filename,
                                     java.lang.String content)
                              throws java.io.IOException
Create a temporary file in a subdirectory of the test temp directory. Directories are created as needed.

Parameters:
filename - name of the file
content - content
Returns:
the file
Throws:
java.io.IOException - if an IO exception occurrs

getTmpDirectory

protected java.io.File getTmpDirectory()
Get temporary directory.


deleteTmpDirectory

protected void deleteTmpDirectory()
Delete temporary directory.


printUsedFiles

protected void printUsedFiles()
Print report about used test files.


printUnusedFiles

protected void printUnusedFiles()
Print report about unused test files.


printStatistics

protected void printStatistics()
Print report about used and unused test files.


useCanonicalTestFile

protected CanonicalFile useCanonicalTestFile(java.lang.String filename)
Same as useTestFile(String) but returns a CanonicalFile. If canonization fails, this makes the current test fail.


createCanonicalTmpFile

protected CanonicalFile createCanonicalTmpFile(java.lang.String filename,
                                               java.lang.String content)
                                        throws java.io.IOException
Same as createTmpFile(String, String) but returns a CanonicalFile. If canonization fails, this makes the current test fail.

Throws:
java.io.IOException

canonize

protected CanonicalFile canonize(java.io.File file)
Canonize file. If canonization fails, this makes the current test fail.


is64BitVM

public static boolean is64BitVM()
Checks if we run on a 64 bit VM


TUM CCSM Commons

TUM CCSM Commons - 2.7