Package org.assertj.core.internal
Class Files
java.lang.Object
org.assertj.core.internal.Files
Reusable assertions for
Files.- Author:
- David DIDIER, Yvonne Wang, Alex Ruiz, Olivier Demeijer, Valeriy Vyrva, Rostyslav Ivankiv
-
Method Summary
Modifier and TypeMethodDescriptionvoidassertCanRead(AssertionInfo info, File actual) Asserts that the given file can be read by the application.voidassertCanWrite(AssertionInfo info, File actual) Asserts that the given file can be modified by the application.voidassertDoesNotExist(AssertionInfo info, File actual) Asserts that the given file does not exist.voidassertExists(AssertionInfo info, File actual) Asserts that the given file exists, regardless it's a file or directory.voidassertHasBinaryContent(AssertionInfo info, File actual, byte[] expected) Asserts that the given file has the given binary content.voidassertHasContent(AssertionInfo info, File actual, String expected, Charset charset) Asserts that the given file has the given text content.voidassertHasDigest(AssertionInfo info, File actual, String algorithm, byte[] expected) voidassertHasDigest(AssertionInfo info, File actual, String algorithm, String expected) voidassertHasDigest(AssertionInfo info, File actual, MessageDigest digest, byte[] expected) voidassertHasDigest(AssertionInfo info, File actual, MessageDigest digest, String expected) voidassertHasExtension(AssertionInfo info, File actual, String expected) Asserts that the givenFilehas the given extension.voidassertHasName(AssertionInfo info, File actual, String expected) Asserts that the givenFilehas the given name.voidassertHasNoExtension(AssertionInfo info, File actual) voidassertHasNoParent(AssertionInfo info, File actual) Asserts that the givenFiledoes not have a parent.voidassertHasParent(AssertionInfo info, File actual, File expected) Asserts that the givenFilehas the given parent.voidassertHasSizeInBytes(AssertionInfo info, File actual, long expectedSizeInBytes) Asserts that the given file has the given size in bytes.voidassertIsAbsolute(AssertionInfo info, File actual) Asserts that the given file is an absolute path.voidassertIsDirectory(AssertionInfo info, File actual) Asserts that the given file is an existing directory.voidassertIsDirectoryContaining(AssertionInfo info, File actual, String syntaxAndPattern) voidassertIsDirectoryContaining(AssertionInfo info, File actual, Predicate<File> filter) voidassertIsDirectoryNotContaining(AssertionInfo info, File actual, String syntaxAndPattern) voidassertIsDirectoryNotContaining(AssertionInfo info, File actual, Predicate<File> filter) voidassertIsDirectoryRecursivelyContaining(AssertionInfo info, File actual, String syntaxAndPattern) voidassertIsDirectoryRecursivelyContaining(AssertionInfo info, File actual, Predicate<File> filter) voidassertIsEmptyDirectory(AssertionInfo info, File actual) voidassertIsEmptyFile(AssertionInfo info, File actual) Asserts that the givenFileis empty (i.e.voidassertIsExecutable(AssertionInfo info, File actual) Asserts that the given file can be executed by the application.voidassertIsFile(AssertionInfo info, File actual) Asserts that the given file is an existing file.voidassertIsNotEmptyDirectory(AssertionInfo info, File actual) voidassertIsNotEmptyFile(AssertionInfo info, File actual) Asserts that the givenFileis not empty (i.e.voidassertIsRelative(AssertionInfo info, File actual) Asserts that the given file is a relative path.voidassertSameBinaryContentAs(AssertionInfo info, File actual, File expected) Asserts that the given files have the same binary content.voidassertSameContentAs(AssertionInfo info, File actual, Charset actualCharset, File expected, Charset expectedCharset) Asserts that the given files have same content.static Filesinstance()Returns the singleton instance of this class.
-
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-Charsetof the "actual" file.expected- the "expected" file.expectedCharset-Charsetof the "actual" file.- Throws:
NullPointerException- ifexpectedisnull.IllegalArgumentException- ifexpectedis not an existing file.AssertionError- ifactualisnull.AssertionError- ifactualis 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- ifexpectedisnull.IllegalArgumentException- ifexpectedis not an existing file.AssertionError- ifactualisnull.AssertionError- ifactualis 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- ifexpectedisnull.AssertionError- ifactualisnull.AssertionError- ifactualis 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- ifactualisnull.AssertionError- ifactualis 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- ifexpectedisnull.AssertionError- ifactualisnull.AssertionError- ifactualis 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 givenFileis empty (i.e. size is equal to zero bytes).- Parameters:
info- contains information about the assertion.actual- the given file.- Throws:
AssertionError- if the givenFileisnull.AssertionError- if the givenFiledoes not exist.AssertionError- if the givenFileis not empty.
-
assertIsNotEmptyFile
Asserts that the givenFileis 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 givenFileisnull.AssertionError- if the givenFiledoes not exist.AssertionError- if the givenFileis 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 givenFilehas the given parent.- Parameters:
info- contains information about the assertion.actual- the given file.expected- the expected parentFile.- Throws:
NullPointerException- if the expected parentFileisnull.UncheckedIOException- if an I/O error occurs.AssertionError- if the givenFileisnull.AssertionError- if the givenFiledoes not have a parent.AssertionError- if the givenFileparent is not equal to the expected one.
-
assertHasExtension
Asserts that the givenFilehas 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 actualFileisnull.AssertionError- if the actualFileis not a file (ie a directory).AssertionError- if the actualFiledoes not have the expected extension.
-
assertHasNoExtension
-
assertHasName
Asserts that the givenFilehas 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 actualFileisnull.AssertionError- if the actualFiledoes not have the expected name.
-
assertHasNoParent
Asserts that the givenFiledoes not have a parent.- Parameters:
info- contains information about the assertion.actual- the given file.- Throws:
AssertionError- if the actualFileisnull.AssertionError- if the actualFilehas 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)
-