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.File
expecting(File parent, String name)
expectingFile
expecting(String name)
expectingvoid
expectingFileWithPrefix(File parent, String prefix, String... suffixesToExclude)
protected void
finalize()
boolean
foundExpected()
protected static String
generateRandomHexString(int length)
generateRandomHexStringFile
getTempDir()
getTempDirvoid
initialize()
initializeboolean
isInitialized()
isInitializedvoid
tearDown()
tearDownFile
tempDir(File parent, String name)
tempDirFile
tempDir(String name)
tempDirFile
tempFile(File parent, String name)
tempFileFile
tempFile(File parent, String name, String contents)
tempFileFile
tempFile(String name)
tempFileFile
tempFile(String name, 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 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() throws Throwable
-
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.
-
tempFile
public File tempFile(String name) throws IOException
tempFile
- Parameters:
name
- aString
object.- Returns:
- a
File
object. - Throws:
IOException
- if any.
-
tempFile
public File tempFile(File parent, String name) throws IOException
tempFile
- Parameters:
parent
- aFile
object.name
- aString
object.- Returns:
- a
File
object. - Throws:
IOException
- if any.
-
tempFile
public File tempFile(String name, String contents) throws IOException
tempFile
- Parameters:
name
- aString
object.contents
- aString
object.- Returns:
- a
File
object. - Throws:
IOException
- if any.
-
tempFile
public File tempFile(File parent, String name, String contents) throws IOException
tempFile
- Parameters:
parent
- aFile
object.name
- aString
object.contents
- aString
object.- Returns:
- a
File
object. - Throws:
IOException
- if any.
-
tempDir
public File tempDir(String name) throws IOException
tempDir
- Parameters:
name
- aString
object.- Returns:
- a
File
object. - Throws:
IOException
- if any.
-
tempDir
public File tempDir(File parent, String name) throws IOException
tempDir
- Parameters:
parent
- aFile
object.name
- aString
object.- Returns:
- a
File
object. - Throws:
IOException
- if any.
-
expectingFileWithPrefix
public void expectingFileWithPrefix(File parent, String prefix, 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()
-
-