Package org.opennms.test
Class FileAnticipator
- java.lang.Object
-
- org.junit.Assert
-
- org.opennms.test.FileAnticipator
-
public class FileAnticipator extends org.junit.Assert
File anticipator. Example usage with late initialization:- Author:
- DJ Gregor
-
-
Constructor Summary
Constructors Constructor Description FileAnticipator()
Constructor for FileAnticipator.FileAnticipator(boolean initialize)
Constructor for FileAnticipator.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.java.io.File
expecting(java.io.File parent, java.lang.String name)
expectingjava.io.File
expecting(java.lang.String name)
expectingvoid
expectingFileWithPrefix(java.io.File parent, java.lang.String prefix, java.lang.String... suffixesToExclude)
protected void
finalize()
boolean
foundExpected()
protected static java.lang.String
generateRandomHexString(int length)
generateRandomHexStringjava.io.File
getTempDir()
getTempDirvoid
initialize()
initializeboolean
isInitialized()
isInitializedvoid
tearDown()
tearDownjava.io.File
tempDir(java.io.File parent, java.lang.String name)
tempDirjava.io.File
tempDir(java.lang.String name)
tempDirjava.io.File
tempFile(java.io.File parent, java.lang.String name)
tempFilejava.io.File
tempFile(java.io.File parent, java.lang.String name, java.lang.String contents)
tempFilejava.io.File
tempFile(java.lang.String name)
tempFilejava.io.File
tempFile(java.lang.String name, java.lang.String contents)
tempFile-
Methods inherited from class org.junit.Assert
assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertTrue, assertTrue, fail, fail
-
-
-
-
Constructor Detail
-
FileAnticipator
public FileAnticipator() throws java.io.IOException
Constructor for FileAnticipator.
- Throws:
java.io.IOException
- if any.
-
FileAnticipator
public FileAnticipator(boolean initialize) throws java.io.IOException
Constructor for FileAnticipator.
- Parameters:
initialize
- a boolean.- Throws:
java.io.IOException
- if any.
-
-
Method Detail
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
tearDown
public void tearDown()
tearDown
-
initialize
public void initialize() throws java.io.IOException
initialize
- Throws:
java.io.IOException
- if any.
-
generateRandomHexString
protected static java.lang.String generateRandomHexString(int length)
generateRandomHexString
- Parameters:
length
- a int.- Returns:
- a
String
object.
-
getTempDir
public java.io.File getTempDir()
getTempDir
- Returns:
- a
File
object.
-
tempFile
public java.io.File tempFile(java.lang.String name) throws java.io.IOException
tempFile
- Parameters:
name
- aString
object.- Returns:
- a
File
object. - Throws:
java.io.IOException
- if any.
-
tempFile
public java.io.File tempFile(java.io.File parent, java.lang.String name) throws java.io.IOException
tempFile
- Parameters:
parent
- aFile
object.name
- aString
object.- Returns:
- a
File
object. - Throws:
java.io.IOException
- if any.
-
tempFile
public java.io.File tempFile(java.lang.String name, java.lang.String contents) throws java.io.IOException
tempFile
- Parameters:
name
- aString
object.contents
- aString
object.- Returns:
- a
File
object. - Throws:
java.io.IOException
- if any.
-
tempFile
public java.io.File tempFile(java.io.File parent, java.lang.String name, java.lang.String contents) throws java.io.IOException
tempFile
- Parameters:
parent
- aFile
object.name
- aString
object.contents
- aString
object.- Returns:
- a
File
object. - Throws:
java.io.IOException
- if any.
-
tempDir
public java.io.File tempDir(java.lang.String name) throws java.io.IOException
tempDir
- Parameters:
name
- aString
object.- Returns:
- a
File
object. - Throws:
java.io.IOException
- if any.
-
tempDir
public java.io.File tempDir(java.io.File parent, java.lang.String name) throws java.io.IOException
tempDir
- Parameters:
parent
- aFile
object.name
- aString
object.- Returns:
- a
File
object. - Throws:
java.io.IOException
- if any.
-
expecting
public java.io.File expecting(java.lang.String name)
expecting
- Parameters:
name
- aString
object.- Returns:
- a
File
object.
-
expecting
public java.io.File expecting(java.io.File parent, java.lang.String name)
expecting
- Parameters:
parent
- aFile
object.name
- aString
object.- Returns:
- a
File
object.
-
expectingFileWithPrefix
public void expectingFileWithPrefix(java.io.File parent, java.lang.String prefix, java.lang.String... suffixesToExclude)
-
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.
-
foundExpected
public boolean foundExpected()
-
-