Package org.assertj.core.internal
Class Files
java.lang.Object
org.assertj.core.internal.Files
Reusable assertions for
File
s.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final FileFilter
(package private) BinaryDiff
(package private) Diff
(package private) Failures
private static final Files
(package private) NioFilesWrapper
private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
assertCanRead
(AssertionInfo info, File actual) Asserts that the given file can be read by the application.void
assertCanWrite
(AssertionInfo info, File actual) Asserts that the given file can be modified by the application.void
assertDoesNotExist
(AssertionInfo info, File actual) Asserts that the given file does not exist.void
assertExists
(AssertionInfo info, File actual) Asserts that the given file exists, regardless it's a file or directory.void
assertHasBinaryContent
(AssertionInfo info, File actual, byte[] expected) Asserts that the given file has the given binary content.void
assertHasContent
(AssertionInfo info, File actual, String expected, Charset charset) Asserts that the given file has the given text content.void
assertHasDigest
(AssertionInfo info, File actual, String algorithm, byte[] expected) void
assertHasDigest
(AssertionInfo info, File actual, String algorithm, String expected) void
assertHasDigest
(AssertionInfo info, File actual, MessageDigest digest, byte[] expected) void
assertHasDigest
(AssertionInfo info, File actual, MessageDigest digest, String expected) void
assertHasExtension
(AssertionInfo info, File actual, String expected) Asserts that the givenFile
has the given extension.void
assertHasName
(AssertionInfo info, File actual, String expected) Asserts that the givenFile
has the given name.void
assertHasNoExtension
(AssertionInfo info, File actual) void
assertHasNoParent
(AssertionInfo info, File actual) Asserts that the givenFile
does not have a parent.void
assertHasParent
(AssertionInfo info, File actual, File expected) Asserts that the givenFile
has the given parent.void
assertHasSizeInBytes
(AssertionInfo info, File actual, long expectedSizeInBytes) Asserts that the given file has the given size in bytes.void
assertIsAbsolute
(AssertionInfo info, File actual) Asserts that the given file is an absolute path.void
assertIsDirectory
(AssertionInfo info, File actual) Asserts that the given file is an existing directory.private void
assertIsDirectoryContaining
(AssertionInfo info, File actual, FileFilter filter, String filterPresentation) void
assertIsDirectoryContaining
(AssertionInfo info, File actual, String syntaxAndPattern) void
assertIsDirectoryContaining
(AssertionInfo info, File actual, Predicate<File> filter) private void
assertIsDirectoryNotContaining
(AssertionInfo info, File actual, FileFilter filter, String filterPresentation) void
assertIsDirectoryNotContaining
(AssertionInfo info, File actual, String syntaxAndPattern) void
assertIsDirectoryNotContaining
(AssertionInfo info, File actual, Predicate<File> filter) void
assertIsDirectoryRecursivelyContaining
(AssertionInfo info, File actual, String syntaxAndPattern) void
assertIsDirectoryRecursivelyContaining
(AssertionInfo info, File actual, Predicate<File> filter) private void
assertIsDirectoryRecursivelyContaining
(AssertionInfo info, File actual, Predicate<File> filter, String filterPresentation) void
assertIsEmptyDirectory
(AssertionInfo info, File actual) void
assertIsEmptyFile
(AssertionInfo info, File actual) Asserts that the givenFile
is empty (i.e.void
assertIsExecutable
(AssertionInfo info, File actual) Asserts that the given file can be executed by the application.void
assertIsFile
(AssertionInfo info, File actual) Asserts that the given file is an existing file.void
assertIsNotEmptyDirectory
(AssertionInfo info, File actual) void
assertIsNotEmptyFile
(AssertionInfo info, File actual) Asserts that the givenFile
is not empty (i.e.void
assertIsRelative
(AssertionInfo info, File actual) Asserts that the given file is a relative path.private static void
assertNotNull
(AssertionInfo info, File actual) void
assertSameBinaryContentAs
(AssertionInfo info, File actual, File expected) Asserts that the given files have the same binary content.void
assertSameContentAs
(AssertionInfo info, File actual, Charset actualCharset, File expected, Charset expectedCharset) Asserts that the given files have same content.directoryContent
(AssertionInfo info, File actual) private static FileFilter
fileFilter
(AssertionInfo info, File actual, String syntaxAndPattern) filterDirectory
(AssertionInfo info, File actual, FileFilter filter) getFileExtension
(File file) static Files
instance()
Returns the singleton instance of this class.private boolean
isAbsolutePath
(AssertionInfo info, File actual) private boolean
isDirectoryRecursivelyContaining
(AssertionInfo info, File actual, Predicate<File> filter) recursiveContentOf
(File directory) sortedRecursiveContent
(File directory) private void
verifyIsFile
(File expected)
-
Field Details
-
UNABLE_TO_COMPARE_FILE_CONTENTS
- See Also:
-
INSTANCE
-
ANY
-
diff
Diff diff -
binaryDiff
BinaryDiff binaryDiff -
failures
Failures failures -
nioFilesWrapper
NioFilesWrapper nioFilesWrapper
-
-
Constructor Details
-
Files
Files()
-
-
Method Details
-
instance
Returns the singleton instance of this class.- Returns:
- the singleton instance of this class.
-
assertSameContentAs
public void assertSameContentAs(AssertionInfo info, File actual, Charset actualCharset, File expected, Charset expectedCharset) Asserts that the given files have same content. Adapted from FileAssert (from JUnit-addons.)- Parameters:
info
- contains information about the assertion.actual
- the "actual" file.actualCharset
-Charset
of the "actual" file.expected
- the "expected" file.expectedCharset
-Charset
of the "actual" file.- Throws:
NullPointerException
- ifexpected
isnull
.IllegalArgumentException
- ifexpected
is not an existing file.AssertionError
- ifactual
isnull
.AssertionError
- ifactual
is not an existing file.UncheckedIOException
- if an I/O error occurs.AssertionError
- if the given files do not have same content.
-
assertSameBinaryContentAs
Asserts that the given files have the same binary content.- Parameters:
info
- contains information about the assertion.actual
- the "actual" file.expected
- the "expected" file.- Throws:
NullPointerException
- ifexpected
isnull
.IllegalArgumentException
- ifexpected
is not an existing file.AssertionError
- ifactual
isnull
.AssertionError
- ifactual
is not an existing file.UncheckedIOException
- if an I/O error occurs.AssertionError
- if the given files do not have same content.
-
assertHasBinaryContent
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:
NullPointerException
- ifexpected
isnull
.AssertionError
- ifactual
isnull
.AssertionError
- ifactual
is not an existing file.UncheckedIOException
- if an I/O error occurs.AssertionError
- if the file does not have the binary content.
-
assertHasSizeInBytes
Asserts that the given file has the given size in bytes.- Parameters:
info
- contains information about the assertion.actual
- the "actual" file.expectedSizeInBytes
- the "expected" file size.- Throws:
AssertionError
- ifactual
isnull
.AssertionError
- ifactual
is not an existing file.
-
assertHasContent
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:
NullPointerException
- ifexpected
isnull
.AssertionError
- ifactual
isnull
.AssertionError
- ifactual
is not an existing file.UncheckedIOException
- if an I/O error occurs.AssertionError
- if the file does not have the text content.
-
assertIsFile
Asserts that the given file is an existing file.- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
AssertionError
- if the given file isnull
.AssertionError
- if the given file is not an existing file.
-
assertIsDirectory
Asserts that the given file is an existing directory.- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
AssertionError
- if the given file isnull
.AssertionError
- if the given file is not an existing directory.
-
assertIsAbsolute
Asserts that the given file is an absolute path.- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
AssertionError
- if the given file isnull
.AssertionError
- if the given file is not an absolute path.
-
assertIsRelative
Asserts that the given file is a relative path.- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
AssertionError
- if the given file isnull
.AssertionError
- if the given file is not a relative path.
-
assertExists
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:
AssertionError
- if the given file isnull
.AssertionError
- if the given file does not exist.
-
assertDoesNotExist
Asserts that the given file does not exist.- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
AssertionError
- if the given file isnull
.AssertionError
- if the given file exists.
-
assertCanWrite
Asserts that the given file can be modified by the application.- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
AssertionError
- if the given file isnull
.AssertionError
- if the given file can not be modified.
-
assertIsEmptyFile
Asserts that the givenFile
is empty (i.e. size is equal to zero bytes).- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
AssertionError
- if the givenFile
isnull
.AssertionError
- if the givenFile
does not exist.AssertionError
- if the givenFile
is not empty.
-
assertIsNotEmptyFile
Asserts that the givenFile
is not empty (i.e. size is greater than zero bytes).- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
AssertionError
- if the givenFile
isnull
.AssertionError
- if the givenFile
does not exist.AssertionError
- if the givenFile
is empty.
-
assertCanRead
Asserts that the given file can be read by the application.- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
AssertionError
- if the given file isnull
.AssertionError
- if the given file can not be modified.
-
assertIsExecutable
Asserts that the given file can be executed by the application.- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
AssertionError
- if the given file isnull
.AssertionError
- if the given file can not be executed.
-
assertHasParent
Asserts that the givenFile
has the given parent.- Parameters:
info
- contains information about the assertion.actual
- the given file.expected
- the expected parentFile
.- Throws:
NullPointerException
- if the expected parentFile
isnull
.UncheckedIOException
- if an I/O error occurs.AssertionError
- if the givenFile
isnull
.AssertionError
- if the givenFile
does not have a parent.AssertionError
- if the givenFile
parent is not equal to the expected one.
-
assertHasExtension
Asserts that the givenFile
has the given extension.- Parameters:
info
- contains information about the assertion.actual
- the given file.expected
- the expected extension, it does not contains the'.'
- Throws:
NullPointerException
- if the expected extension isnull
.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not a file (ie a directory).AssertionError
- if the actualFile
does not have the expected extension.
-
assertHasNoExtension
-
assertHasName
Asserts that the givenFile
has the given name.- Parameters:
info
- contains information about the assertion.actual
- the given file.expected
- the expected file name.- Throws:
NullPointerException
- if the expected name isnull
.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
does not have the expected name.
-
assertHasNoParent
Asserts that the givenFile
does not have a parent.- Parameters:
info
- contains information about the assertion.actual
- the given file.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
has a parent.
-
assertHasDigest
-
assertHasDigest
-
assertHasDigest
-
assertHasDigest
-
assertIsEmptyDirectory
-
assertIsNotEmptyDirectory
-
assertIsDirectoryContaining
-
assertIsDirectoryContaining
-
assertIsDirectoryRecursivelyContaining
public void assertIsDirectoryRecursivelyContaining(AssertionInfo info, File actual, String syntaxAndPattern) -
assertIsDirectoryRecursivelyContaining
public void assertIsDirectoryRecursivelyContaining(AssertionInfo info, File actual, Predicate<File> filter) -
assertIsDirectoryNotContaining
-
assertIsDirectoryNotContaining
public void assertIsDirectoryNotContaining(AssertionInfo info, File actual, String syntaxAndPattern) -
filterDirectory
-
directoryContent
-
assertIsDirectoryContaining
private void assertIsDirectoryContaining(AssertionInfo info, File actual, FileFilter filter, String filterPresentation) -
assertIsDirectoryNotContaining
private void assertIsDirectoryNotContaining(AssertionInfo info, File actual, FileFilter filter, String filterPresentation) -
isDirectoryRecursivelyContaining
private boolean isDirectoryRecursivelyContaining(AssertionInfo info, File actual, Predicate<File> filter) -
sortedRecursiveContent
-
recursiveContentOf
-
assertIsDirectoryRecursivelyContaining
private void assertIsDirectoryRecursivelyContaining(AssertionInfo info, File actual, Predicate<File> filter, String filterPresentation) -
fileFilter
-
assertNotNull
-
getFileExtension
-
verifyIsFile
-
isAbsolutePath
-