Package org.fest.assertions.internal
Class Files
- java.lang.Object
-
- org.fest.assertions.internal.Files
-
public class Files extends java.lang.Object
Reusable assertions for
s.File
- Author:
- David DIDIER, Yvonne Wang, Alex Ruiz, Olivier Demeijer
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assertCanRead(AssertionInfo info, java.io.File actual)
Asserts that the given file can be read by the application.void
assertCanWrite(AssertionInfo info, java.io.File actual)
Asserts that the given file can be modified by the application.void
assertDoesNotExist(AssertionInfo info, java.io.File actual)
Asserts that the given file does not exist.void
assertEqualContent(AssertionInfo info, java.io.File actual, java.io.File expected)
Asserts that the given files have equal content.void
assertExists(AssertionInfo info, java.io.File actual)
Asserts that the given file exists, regardless it's a file or directory.void
assertHasBinaryContent(AssertionInfo info, java.io.File actual, byte[] expected)
Asserts that the given file has the given binary content.void
assertHasContent(AssertionInfo info, java.io.File actual, java.lang.String expected, java.nio.charset.Charset charset)
Asserts that the given file has the given text content.void
assertIsAbsolute(AssertionInfo info, java.io.File actual)
Asserts that the given file is an absolute path.void
assertIsDirectory(AssertionInfo info, java.io.File actual)
Asserts that the given file is an existing directory.void
assertIsFile(AssertionInfo info, java.io.File actual)
Asserts that the given file is an existing file.void
assertIsRelative(AssertionInfo info, java.io.File actual)
Asserts that the given file is a relative path.static Files
instance()
Returns the singleton instance of this class.
-
-
-
Method Detail
-
instance
public static Files instance()
Returns the singleton instance of this class.- Returns:
- the singleton instance of this class.
-
assertEqualContent
public void assertEqualContent(AssertionInfo info, java.io.File actual, java.io.File expected)
Asserts that the given files have equal content. Adapted from FileAssert (from JUnit-addons.)- Parameters:
info
- contains information about the assertion.actual
- the "actual" file.expected
- the "expected" file.- Throws:
java.lang.NullPointerException
- ifexpected
isnull
.java.lang.IllegalArgumentException
- ifexpected
is not an existing file.java.lang.AssertionError
- ifactual
isnull
.java.lang.AssertionError
- ifactual
is not an existing file.org.fest.util.FilesException
- if an I/O error occurs.java.lang.AssertionError
- if the given files do not have equal content.
-
assertHasBinaryContent
public void assertHasBinaryContent(AssertionInfo info, java.io.File actual, byte[] expected)
Asserts that the given file has the given binary content.- Parameters:
info
- contains information about the assertion.actual
- the "actual" file.expected
- the "expected" binary content.- Throws:
java.lang.NullPointerException
- ifexpected
isnull
.java.lang.AssertionError
- ifactual
isnull
.java.lang.AssertionError
- ifactual
is not an existing file.org.fest.util.FilesException
- if an I/O error occurs.java.lang.AssertionError
- if the file does not have the binary content.
-
assertHasContent
public void assertHasContent(AssertionInfo info, java.io.File actual, java.lang.String expected, java.nio.charset.Charset charset)
Asserts that the given file has the given text content.- Parameters:
info
- contains information about the assertion.actual
- the "actual" file.expected
- the "expected" text content.charset
- the charset to use to read the file.- Throws:
java.lang.NullPointerException
- ifexpected
isnull
.java.lang.AssertionError
- ifactual
isnull
.java.lang.AssertionError
- ifactual
is not an existing file.org.fest.util.FilesException
- if an I/O error occurs.java.lang.AssertionError
- if the file does not have the text content.
-
assertIsFile
public void assertIsFile(AssertionInfo info, java.io.File actual)
Asserts that the given file is an existing file.- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
java.lang.AssertionError
- if the given file isnull
.java.lang.AssertionError
- if the given file is not an existing file.
-
assertIsDirectory
public void assertIsDirectory(AssertionInfo info, java.io.File actual)
Asserts that the given file is an existing directory.- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
java.lang.AssertionError
- if the given file isnull
.java.lang.AssertionError
- if the given file is not an existing directory.
-
assertIsAbsolute
public void assertIsAbsolute(AssertionInfo info, java.io.File actual)
Asserts that the given file is an absolute path.- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
java.lang.AssertionError
- if the given file isnull
.java.lang.AssertionError
- if the given file is not an absolute path.
-
assertIsRelative
public void assertIsRelative(AssertionInfo info, java.io.File actual)
Asserts that the given file is a relative path.- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
java.lang.AssertionError
- if the given file isnull
.java.lang.AssertionError
- if the given file is not a relative path.
-
assertExists
public void assertExists(AssertionInfo info, java.io.File actual)
Asserts that the given file exists, regardless it's a file or directory.- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
java.lang.AssertionError
- if the given file isnull
.java.lang.AssertionError
- if the given file does not exist.
-
assertDoesNotExist
public void assertDoesNotExist(AssertionInfo info, java.io.File actual)
Asserts that the given file does not exist.- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
java.lang.AssertionError
- if the given file isnull
.java.lang.AssertionError
- if the given file exists.
-
assertCanWrite
public void assertCanWrite(AssertionInfo info, java.io.File actual)
Asserts that the given file can be modified by the application.- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
java.lang.AssertionError
- if the given file isnull
.java.lang.AssertionError
- if the given file can not be modified.
-
assertCanRead
public void assertCanRead(AssertionInfo info, java.io.File actual)
Asserts that the given file can be read by the application.- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
java.lang.AssertionError
- if the given file isnull
.java.lang.AssertionError
- if the given file can not be modified.
-
-