Package org.assertj.core.internal
Class Files
- java.lang.Object
-
- org.assertj.core.internal.Files
-
-
Field Summary
Fields Modifier and Type Field Description private static Predicate<File>ANY(package private) BinaryDiffbinaryDiff(package private) Diffdiff(package private) Failuresfailuresprivate static FilesINSTANCE(package private) NioFilesWrappernioFilesWrapperprivate static StringUNABLE_TO_COMPARE_FILE_CONTENTS
-
Constructor Summary
Constructors Constructor Description Files()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertCanRead(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.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.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)private voidassertIsDirectoryContaining(AssertionInfo info, File actual, Predicate<File> filter, String filterPresentation)voidassertIsDirectoryNotContaining(AssertionInfo info, File actual, String syntaxAndPattern)voidassertIsDirectoryNotContaining(AssertionInfo info, File actual, Predicate<File> filter)private voidassertIsDirectoryNotContaining(AssertionInfo info, File actual, Predicate<File> filter, String filterPresentation)voidassertIsEmptyDirectory(AssertionInfo info, File actual)voidassertIsFile(AssertionInfo info, File actual)Asserts that the given file is an existing file.voidassertIsNotEmptyDirectory(AssertionInfo info, File actual)voidassertIsRelative(AssertionInfo info, File actual)Asserts that the given file is a relative path.private static voidassertNotNull(AssertionInfo info, File actual)voidassertSameContentAs(AssertionInfo info, File actual, Charset actualCharset, File expected, Charset expectedCharset)Asserts that the given files have same content.private List<File>directoryContent(AssertionInfo info, File actual)private List<String>directoryContentDescription(AssertionInfo info, File actual)private List<File>filterDirectory(AssertionInfo info, File actual, Predicate<File> filter)private StringgetFileExtension(File file)static Filesinstance()Returns the singleton instance of this class.private booleanisAbsolutePath(AssertionInfo info, File actual)private Predicate<File>pathMatcher(AssertionInfo info, File actual, String syntaxAndPattern)static List<String>toFileNames(List<File> files)private voidverifyIsFile(File expected)
-
-
-
Field Detail
-
UNABLE_TO_COMPARE_FILE_CONTENTS
private static final String UNABLE_TO_COMPARE_FILE_CONTENTS
- See Also:
- Constant Field Values
-
INSTANCE
private static final Files INSTANCE
-
diff
Diff diff
-
binaryDiff
BinaryDiff binaryDiff
-
failures
Failures failures
-
nioFilesWrapper
NioFilesWrapper nioFilesWrapper
-
-
Method Detail
-
instance
public static Files 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.
-
assertHasBinaryContent
public void assertHasBinaryContent(AssertionInfo info, 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:
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.
-
assertHasContent
public void assertHasContent(AssertionInfo info, File actual, String expected, 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:
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
public void assertIsFile(AssertionInfo info, File actual)
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
public void assertIsDirectory(AssertionInfo info, File actual)
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
public void assertIsAbsolute(AssertionInfo info, File actual)
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
public void assertIsRelative(AssertionInfo info, File actual)
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
public void assertExists(AssertionInfo info, 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:
AssertionError- if the given file isnull.AssertionError- if the given file does not exist.
-
assertDoesNotExist
public void assertDoesNotExist(AssertionInfo info, File actual)
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
public void assertCanWrite(AssertionInfo info, 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:
AssertionError- if the given file isnull.AssertionError- if the given file can not be modified.
-
assertCanRead
public void assertCanRead(AssertionInfo info, 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:
AssertionError- if the given file isnull.AssertionError- if the given file can not be modified.
-
assertHasParent
public void assertHasParent(AssertionInfo info, File actual, File expected)
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
public void assertHasExtension(AssertionInfo info, File actual, String expected)
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.
-
assertHasName
public void assertHasName(AssertionInfo info, File actual, String expected)
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
public void assertHasNoParent(AssertionInfo info, File actual)
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
public void assertHasDigest(AssertionInfo info, File actual, MessageDigest digest, byte[] expected)
-
assertHasDigest
public void assertHasDigest(AssertionInfo info, File actual, MessageDigest digest, String expected)
-
assertHasDigest
public void assertHasDigest(AssertionInfo info, File actual, String algorithm, byte[] expected)
-
assertHasDigest
public void assertHasDigest(AssertionInfo info, File actual, String algorithm, String expected)
-
assertIsEmptyDirectory
public void assertIsEmptyDirectory(AssertionInfo info, File actual)
-
assertIsNotEmptyDirectory
public void assertIsNotEmptyDirectory(AssertionInfo info, File actual)
-
assertIsDirectoryContaining
public void assertIsDirectoryContaining(AssertionInfo info, File actual, Predicate<File> filter)
-
assertIsDirectoryContaining
public void assertIsDirectoryContaining(AssertionInfo info, File actual, String syntaxAndPattern)
-
assertIsDirectoryNotContaining
public void assertIsDirectoryNotContaining(AssertionInfo info, File actual, Predicate<File> filter)
-
assertIsDirectoryNotContaining
public void assertIsDirectoryNotContaining(AssertionInfo info, File actual, String syntaxAndPattern)
-
filterDirectory
private List<File> filterDirectory(AssertionInfo info, File actual, Predicate<File> filter)
-
directoryContent
private List<File> directoryContent(AssertionInfo info, File actual)
-
assertIsDirectoryContaining
private void assertIsDirectoryContaining(AssertionInfo info, File actual, Predicate<File> filter, String filterPresentation)
-
assertIsDirectoryNotContaining
private void assertIsDirectoryNotContaining(AssertionInfo info, File actual, Predicate<File> filter, String filterPresentation)
-
directoryContentDescription
private List<String> directoryContentDescription(AssertionInfo info, File actual)
-
pathMatcher
private Predicate<File> pathMatcher(AssertionInfo info, File actual, String syntaxAndPattern)
-
assertNotNull
private static void assertNotNull(AssertionInfo info, File actual)
-
verifyIsFile
private void verifyIsFile(File expected)
-
isAbsolutePath
private boolean isAbsolutePath(AssertionInfo info, File actual)
-
-