Package org.fest.assertions.api
Class FileAssert
- All Implemented Interfaces:
Assert<FileAssert,
,File> Descriptable<FileAssert>
,ExtensionPoints<FileAssert,
File>
Assertion methods for
File
s.
To create a new instance of this class, invoke
.
Assertions.assertThat(File)
- Author:
- David DIDIER, Yvonne Wang, Alex Ruiz, Olivier Michallat, Olivier Demeijer
-
Field Summary
Fields inherited from class org.fest.assertions.api.AbstractAssert
actual, myself
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncanRead()
Verifies that the actualFile
can be read by the application.canWrite()
Verifies that the actualFile
can be modified by the application.Verifies that the actualFile
does not exist.exists()
Verifies that the actualFile
exists, regardless it's a file or directory.hasBinaryContent
(byte[] expected) Verifies that the binary content of the actualFile
is exactly equal to the given one.hasContent
(String expected) Verifies that the text content of the actualFile
is exactly equal to the given one.
The charset to use when reading the file should be provided withusingCharset(Charset)
orusingCharset(String)
prior to calling this method; if not, the platform's default charset (as returned byCharset.defaultCharset()
) will be used.hasContentEqualTo
(File expected) Verifies that the content of the actualFile
is equal to the content of the given one.Verifies that the actualFile
is an absolute path.Verifies that the actualFile
is an existing directory.isFile()
Verifies that the actualFile
is an existing file.Verifies that the actualFile
is a relative path.usingCharset
(String charsetName) Specifies the name of the charset to use for text-based assertions on the file's contents.usingCharset
(Charset charset) Specifies the charset to use for text-based assertions on the file's contents.Methods inherited from class org.fest.assertions.api.AbstractAssert
as, as, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, getWritableAssertionInfo, has, hashCode, hasSameClassAs, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, overridingErrorMessage, usingComparator, usingDefaultComparator
-
Constructor Details
-
FileAssert
-
-
Method Details
-
exists
Verifies that the actualFile
exists, regardless it's a file or directory.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
does not exist.
-
doesNotExist
Verifies that the actualFile
does not exist.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
exists.
-
isFile
Verifies that the actualFile
is an existing file.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an existing file.
-
isDirectory
Verifies that the actualFile
is an existing directory.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an existing file.
-
isAbsolute
Verifies that the actualFile
is an absolute path.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an absolute path.
-
isRelative
Verifies that the actualFile
is a relative path.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not a relative path.
-
hasContentEqualTo
Verifies that the content of the actualFile
is equal to the content of the given one.- Parameters:
expected
- the givenFile
to compare the actualFile
to.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the givenFile
isnull
.IllegalArgumentException
- if the givenFile
is not an existing file.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an existing file.org.fest.util.FilesException
- if an I/O error occurs.AssertionError
- if the content of the actualFile
is not equal to the content of the given one.
-
hasBinaryContent
Verifies that the binary content of the actualFile
is exactly equal to the given one.- Parameters:
expected
- the expected binary content to compare the actualFile
's content to.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given content isnull
.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an existing file.org.fest.util.FilesException
- if an I/O error occurs.AssertionError
- if the content of the actualFile
is not equal to the given binary content.
-
usingCharset
Specifies the name of the charset to use for text-based assertions on the file's contents.- Parameters:
charsetName
- the name of the charset to use.- Returns:
this
assertion object.- Throws:
IllegalArgumentException
- if the given encoding is not supported on this platform.
-
usingCharset
Specifies the charset to use for text-based assertions on the file's contents.- Parameters:
charset
- the charset to use.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given charset isnull
.
-
hasContent
Verifies that the text content of the actualFile
is exactly equal to the given one.
The charset to use when reading the file should be provided withusingCharset(Charset)
orusingCharset(String)
prior to calling this method; if not, the platform's default charset (as returned byCharset.defaultCharset()
) will be used.- Parameters:
expected
- the expected text content to compare the actualFile
's content to.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given content isnull
.AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
is not an existing file.org.fest.util.FilesException
- if an I/O error occurs.AssertionError
- if the content of the actualFile
is not equal to the given binary content.
-
canWrite
Verifies that the actualFile
can be modified by the application.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
can not be modified by the application.
-
canRead
Verifies that the actualFile
can be read by the application.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualFile
isnull
.AssertionError
- if the actualFile
can not be read by the application.
-