Package org.opentest4j
Class FileInfo
java.lang.Object
org.opentest4j.FileInfo
- All Implemented Interfaces:
Serializable
FileInfo
is a pair of a file path and the contents of the file.
Its main use case is for actual
and expected
values in
AssertionFailedError
.
The semantics of the path
can be defined by the users of this
class.
- Since:
- 1.3
- Author:
- Marc Philipp, Reinhold Degenfellner
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Determines if the supplied object is an instance ofFileInfo
with the same path and contents as thisFileInfo
.byte[]
Returns the contents of the file.getContentsAsString
(Charset charset) Returns the contents of the file as aString
.getPath()
Returns the path to the file.int
hashCode()
Generates a unique hash code for thisFileInfo
based on itspath
.toString()
-
Constructor Details
-
FileInfo
Constructs aFileInfo
with a path to a file and the contents of the file.Be cautious with large files (limiting the size may be a good idea).
The supplied byte array is not copied to avoid unnecessary memory allocations. However, callers of this constructors should not modify the byte array after calling this constructor. This behavior may change in a future release without prior notice.
- Parameters:
path
- the path to the file; must not benull
contents
- the contents of the file; must not benull
;
-
-
Method Details
-
getPath
Returns the path to the file.- Returns:
- the path to the file; never
null
-
getContents
public byte[] getContents()Returns the contents of the file.This method does currently not return a defensive copy of the contained byte array to avoid unnecessary memory allocations. However, callers of this method should not modify the returned byte array. This behavior may change in a future release without prior notice.
- Returns:
- the contents of the file; never
null
-
getContentsAsString
Returns the contents of the file as aString
.- Returns:
- the contents of the file as a
String
; nevernull
-
equals
Determines if the supplied object is an instance ofFileInfo
with the same path and contents as thisFileInfo
. -
hashCode
public int hashCode()Generates a unique hash code for thisFileInfo
based on itspath
. -
toString
-