Package org.testng
Class FileAssert
- java.lang.Object
-
- org.testng.FileAssert
-
public class FileAssert extends java.lang.ObjectAssertion tool for File centric assertions. Conceptually, this is an extension ofAssert. Presents assertion methods with a more natural parameter order. The order is always actualValue, expectedValue [, message].- Since:
- 5.6
-
-
Constructor Summary
Constructors Modifier Constructor Description privateFileAssert()Protect this constructor since it is a static only class.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertDirectory(java.io.File tstvalue)static voidassertDirectory(java.io.File tstvalue, java.lang.String message)Asserts that atstvalueis a proper directory.static voidassertFile(java.io.File tstvalue)static voidassertFile(java.io.File tstvalue, java.lang.String message)Asserts that atstvalueis a proper file.static voidassertLength(java.io.File tstvalue, long expected)static voidassertLength(java.io.File tstvalue, long expected, java.lang.String message)Asserts that atstvalueis a file of exactlyexpectedcharacters or a directory of exactlyexpectedentries.static voidassertMaxLength(java.io.File tstvalue, long expected)static voidassertMaxLength(java.io.File tstvalue, long expected, java.lang.String message)Asserts that atstvalueis a file of at mostexpectedcharacters or a directory of at mostexpectedentries.static voidassertMinLength(java.io.File tstvalue, long expected)static voidassertMinLength(java.io.File tstvalue, long expected, java.lang.String message)Asserts that atstvalueis a file of at leastexpectedcharacters or a directory of at leastexpectedentries.static voidassertReadable(java.io.File tstvalue)static voidassertReadable(java.io.File tstvalue, java.lang.String message)Asserts that atstvalueis readable.static voidassertReadWrite(java.io.File tstvalue)static voidassertReadWrite(java.io.File tstvalue, java.lang.String message)Asserts that atstvalueis readable and writeable.static voidassertWriteable(java.io.File tstvalue)static voidassertWriteable(java.io.File tstvalue, java.lang.String message)Asserts that atstvalueis writeable.static voidfail()Fails a test with no message.static voidfail(java.lang.String message)Fails a test with the given message.static voidfail(java.lang.String message, java.lang.Throwable realCause)Fails a test with the given message and wrapping the original exception.private static voidfailFile(java.io.File path, java.lang.String actual, java.lang.String expected, java.lang.String message)Formats failure for file assertions.private static voidfailSecurity(java.lang.Exception e, java.io.File path, java.lang.String actual, java.lang.String expected, java.lang.String message)private static java.lang.StringfileAccess(java.io.File path)String representation of read and write permissions ofpath.private static java.lang.StringfileType(java.io.File path)String representation of what sort of filepathis.private static java.lang.StringtoString(java.io.File path)
-
-
-
Method Detail
-
assertDirectory
public static void assertDirectory(java.io.File tstvalue, java.lang.String message)Asserts that atstvalueis a proper directory. If it isn't, an AssertionError with the given message is thrown.- Parameters:
tstvalue- the file to evaluatemessage- the assertion error message
-
assertDirectory
public static void assertDirectory(java.io.File tstvalue)
-
assertFile
public static void assertFile(java.io.File tstvalue, java.lang.String message)Asserts that atstvalueis a proper file. If it isn't, an AssertionError with the given message is thrown.- Parameters:
tstvalue- the file to evaluatemessage- the assertion error message
-
assertFile
public static void assertFile(java.io.File tstvalue)
- Parameters:
tstvalue- The actual file- See Also:
assertFile(File, String)
-
assertLength
public static void assertLength(java.io.File tstvalue, long expected, java.lang.String message)Asserts that atstvalueis a file of exactlyexpectedcharacters or a directory of exactlyexpectedentries. If it isn't, an AssertionError with the given message is thrown.- Parameters:
tstvalue- the file to evaluateexpected- the expected valuemessage- the assertion error message
-
assertLength
public static void assertLength(java.io.File tstvalue, long expected)- Parameters:
tstvalue- The actual fileexpected- The expected length- See Also:
assertLength(File, long, String)
-
assertMinLength
public static void assertMinLength(java.io.File tstvalue, long expected, java.lang.String message)Asserts that atstvalueis a file of at leastexpectedcharacters or a directory of at leastexpectedentries. If it isn't, an AssertionError with the given message is thrown.- Parameters:
tstvalue- the file to evaluateexpected- the expected valuemessage- the assertion error message
-
assertMinLength
public static void assertMinLength(java.io.File tstvalue, long expected)- Parameters:
tstvalue- The actual fileexpected- The expected min length- See Also:
assertMinLength(File, long, String)
-
assertMaxLength
public static void assertMaxLength(java.io.File tstvalue, long expected, java.lang.String message)Asserts that atstvalueis a file of at mostexpectedcharacters or a directory of at mostexpectedentries. If it isn't, an AssertionError with the given message is thrown.- Parameters:
tstvalue- the file to evaluateexpected- The expected max lengthmessage- the assertion error message
-
assertMaxLength
public static void assertMaxLength(java.io.File tstvalue, long expected)- Parameters:
tstvalue- The actual fileexpected- The expected length- See Also:
assertMaxLength(File, long, String)
-
assertReadable
public static void assertReadable(java.io.File tstvalue, java.lang.String message)Asserts that atstvalueis readable. If it isn't, an AssertionError with the given message is thrown.- Parameters:
tstvalue- the file to evaluatemessage- the assertion error message
-
assertReadable
public static void assertReadable(java.io.File tstvalue)
- Parameters:
tstvalue- The actual file- See Also:
assertReadable(File, String)
-
assertWriteable
public static void assertWriteable(java.io.File tstvalue, java.lang.String message)Asserts that atstvalueis writeable. If it isn't, an AssertionError with the given message is thrown.- Parameters:
tstvalue- the file to evaluatemessage- the assertion error message
-
assertWriteable
public static void assertWriteable(java.io.File tstvalue)
- Parameters:
tstvalue- The actual file- See Also:
assertWriteable(File, String)
-
assertReadWrite
public static void assertReadWrite(java.io.File tstvalue, java.lang.String message)Asserts that atstvalueis readable and writeable. If it isn't, an AssertionError with the given message is thrown.- Parameters:
tstvalue- the file to evaluatemessage- the assertion error message
-
assertReadWrite
public static void assertReadWrite(java.io.File tstvalue)
- Parameters:
tstvalue- The actual file- See Also:
assertReadWrite(File, String)
-
fail
public static void fail(java.lang.String message, java.lang.Throwable realCause)Fails a test with the given message and wrapping the original exception.- Parameters:
message- the assertion error messagerealCause- the original exception
-
fail
public static void fail(java.lang.String message)
Fails a test with the given message.- Parameters:
message- the assertion error message
-
fail
public static void fail()
Fails a test with no message.
-
failFile
private static void failFile(java.io.File path, java.lang.String actual, java.lang.String expected, java.lang.String message)Formats failure for file assertions.
-
failSecurity
private static void failSecurity(java.lang.Exception e, java.io.File path, java.lang.String actual, java.lang.String expected, java.lang.String message)- Parameters:
tstvalue-string-string2-message-
-
fileType
private static java.lang.String fileType(java.io.File path)
String representation of what sort of filepathis.
-
fileAccess
private static java.lang.String fileAccess(java.io.File path)
String representation of read and write permissions ofpath.
-
toString
private static java.lang.String toString(java.io.File path)
-
-