org.opennms.test
Class FileAnticipator

java.lang.Object
  extended by junit.framework.Assert
      extended by org.opennms.test.FileAnticipator

public class FileAnticipator
extends junit.framework.Assert

File anticipator. Example usage with late initialization:

 private FileAnticipator m_fileAnticipator;

Version:
$Id: $
Author:
DJ Gregor

Constructor Summary
FileAnticipator()
          Constructor for FileAnticipator.
FileAnticipator(boolean initialize)
          Constructor for FileAnticipator.
 
Method Summary
 void deleteExpected()
          Delete expected files, throwing an AssertionFailedError if any of the expected files don't exist.
 void deleteExpected(boolean ignoreNonExistantFiles)
          Delete expected files, throwing an AssertionFailedError if any of the expected files don't exist.
 File expecting(File parent, String name)
          expecting
 File expecting(String name)
          expecting
protected  void finalize()
          
protected static String generateRandomHexString(int length)
          generateRandomHexString
 File getTempDir()
          getTempDir
 void initialize()
          initialize
 boolean isInitialized()
          isInitialized
 void tearDown()
          tearDown
 File tempDir(File parent, String name)
          tempDir
 File tempDir(String name)
          tempDir
 File tempFile(File parent, String name)
          tempFile
 File tempFile(File parent, String name, String contents)
          tempFile
 File tempFile(String name)
          tempFile
 File tempFile(String name, String contents)
          tempFile
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileAnticipator

public FileAnticipator()
                throws IOException

Constructor for FileAnticipator.

Throws:
IOException - if any.

FileAnticipator

public FileAnticipator(boolean initialize)
                throws IOException

Constructor for FileAnticipator.

Parameters:
initialize - a boolean.
Throws:
IOException - if any.
Method Detail

finalize

protected void finalize()

Overrides:
finalize in class Object

tearDown

public void tearDown()

tearDown


initialize

public void initialize()
                throws IOException

initialize

Throws:
IOException - if any.

generateRandomHexString

protected static String generateRandomHexString(int length)

generateRandomHexString

Parameters:
length - a int.
Returns:
a String object.

getTempDir

public File getTempDir()

getTempDir

Returns:
a File object.

tempFile

public File tempFile(String name)
              throws IOException

tempFile

Parameters:
name - a String object.
Returns:
a File object.
Throws:
IOException - if any.

tempFile

public File tempFile(File parent,
                     String name)
              throws IOException

tempFile

Parameters:
parent - a File object.
name - a String object.
Returns:
a File object.
Throws:
IOException - if any.

tempFile

public File tempFile(String name,
                     String contents)
              throws IOException

tempFile

Parameters:
name - a String object.
contents - a String object.
Returns:
a File object.
Throws:
IOException - if any.

tempFile

public File tempFile(File parent,
                     String name,
                     String contents)
              throws IOException

tempFile

Parameters:
parent - a File object.
name - a String object.
contents - a String object.
Returns:
a File object.
Throws:
IOException - if any.

tempDir

public File tempDir(String name)
             throws IOException

tempDir

Parameters:
name - a String object.
Returns:
a File object.
Throws:
IOException - if any.

tempDir

public File tempDir(File parent,
                    String name)
             throws IOException

tempDir

Parameters:
parent - a File object.
name - a String object.
Returns:
a File object.
Throws:
IOException - if any.

expecting

public File expecting(String name)

expecting

Parameters:
name - a String object.
Returns:
a File object.

expecting

public File expecting(File parent,
                      String name)

expecting

Parameters:
parent - a File object.
name - a String object.
Returns:
a File object.

deleteExpected

public void deleteExpected()
Delete expected files, throwing an AssertionFailedError if any of the expected files don't exist.


deleteExpected

public void deleteExpected(boolean ignoreNonExistantFiles)
Delete expected files, throwing an AssertionFailedError if any of the expected files don't exist.

Parameters:
ignoreNonExistantFiles - if true, non-existant files will be ignored and will not throw an AssertionFailedError
Throws:
junit.framework.AssertionFailedError - if ignoreNonExistantFiles is false and an expected file does not exist, or if a file cannot be deleted

isInitialized

public boolean isInitialized()

isInitialized

Returns:
a boolean.


Copyright © 2011. All Rights Reserved.