public class FileAssert extends AbstractAssert<FileAssert,File>
File
s.
To create a new instance of this class, invoke
.
Assertions.assertThat(File)
actual, info, myself
Modifier | Constructor and Description |
---|---|
protected |
FileAssert(File actual) |
Modifier and Type | Method and Description |
---|---|
FileAssert |
canRead()
Verifies that the actual
File can be read by the application. |
FileAssert |
canWrite()
Verifies that the actual
File can be modified by the application. |
FileAssert |
doesNotExist()
Verifies that the actual
File does not exist. |
FileAssert |
exists()
Verifies that the actual
File exists, regardless it's a file or directory. |
FileAssert |
hasBinaryContent(byte[] expected)
Verifies that the binary content of the actual
File is exactly equal to the given one. |
FileAssert |
hasContent(String expected)
Verifies that the text content of the actual
File is exactly equal to the given one.The charset to use when reading the file should be provided with usingCharset(Charset) or
usingCharset(String) prior to calling this method; if not, the platform's default charset (as returned by
Charset.defaultCharset() ) will be used. |
FileAssert |
hasContentEqualTo(File expected)
Verifies that the content of the actual
File is equal to the content of the given one. |
FileAssert |
isAbsolute()
Verifies that the actual
File is an absolute path. |
FileAssert |
isDirectory()
Verifies that the actual
File is an existing directory. |
FileAssert |
isFile()
Verifies that the actual
File is an existing file. |
FileAssert |
isRelative()
Verifies that the actual
File is a relative path. |
FileAssert |
usingCharset(Charset charset)
Specifies the charset to use for text-based assertions on the file's contents.
|
FileAssert |
usingCharset(String charsetName)
Specifies the name of the charset to use for text-based assertions on the file's contents.
|
as, as, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, 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
protected FileAssert(File actual)
public FileAssert exists()
File
exists, regardless it's a file or directory.this
assertion object.AssertionError
- if the actual File
is null
.AssertionError
- if the actual File
does not exist.public FileAssert doesNotExist()
File
does not exist.this
assertion object.AssertionError
- if the actual File
is null
.AssertionError
- if the actual File
exists.public FileAssert isFile()
File
is an existing file.this
assertion object.AssertionError
- if the actual File
is null
.AssertionError
- if the actual File
is not an existing file.public FileAssert isDirectory()
File
is an existing directory.this
assertion object.AssertionError
- if the actual File
is null
.AssertionError
- if the actual File
is not an existing file.public FileAssert isAbsolute()
File
is an absolute path.this
assertion object.AssertionError
- if the actual File
is null
.AssertionError
- if the actual File
is not an absolute path.public FileAssert isRelative()
File
is a relative path.this
assertion object.AssertionError
- if the actual File
is null
.AssertionError
- if the actual File
is not a relative path.public FileAssert hasContentEqualTo(File expected)
File
is equal to the content of the given one.expected
- the given File
to compare the actual File
to.this
assertion object.NullPointerException
- if the given File
is null
.IllegalArgumentException
- if the given File
is not an existing file.AssertionError
- if the actual File
is null
.AssertionError
- if the actual File
is not an existing file.FilesException
- if an I/O error occurs.AssertionError
- if the content of the actual File
is not equal to the content of the given one.public FileAssert hasBinaryContent(byte[] expected)
File
is exactly equal to the given one.expected
- the expected binary content to compare the actual File
's content to.this
assertion object.NullPointerException
- if the given content is null
.AssertionError
- if the actual File
is null
.AssertionError
- if the actual File
is not an existing file.FilesException
- if an I/O error occurs.AssertionError
- if the content of the actual File
is not equal to the given binary content.public FileAssert usingCharset(String charsetName)
charsetName
- the name of the charset to use.this
assertion object.IllegalArgumentException
- if the given encoding is not supported on this platform.public FileAssert usingCharset(Charset charset)
charset
- the charset to use.this
assertion object.NullPointerException
- if the given charset is null
.public FileAssert hasContent(String expected)
File
is exactly equal to the given one.usingCharset(Charset)
or
usingCharset(String)
prior to calling this method; if not, the platform's default charset (as returned by
Charset.defaultCharset()
) will be used.expected
- the expected text content to compare the actual File
's content to.this
assertion object.NullPointerException
- if the given content is null
.AssertionError
- if the actual File
is null
.AssertionError
- if the actual File
is not an existing file.FilesException
- if an I/O error occurs.AssertionError
- if the content of the actual File
is not equal to the given binary content.public FileAssert canWrite()
File
can be modified by the application.this
assertion object.AssertionError
- if the actual File
is null
.AssertionError
- if the actual File
can not be modified by the application.public FileAssert canRead()
File
can be read by the application.this
assertion object.AssertionError
- if the actual File
is null
.AssertionError
- if the actual File
can not be read by the application.Copyright © 2013 AssertJ. All Rights Reserved.