Top Description Constructors Methods
org.testng

public Class FileAssert

extends Object
Class Inheritance
Imports
java.io.File, .IOException, java.util.Optional

Assertion tool for File centric assertions. Conceptually, this is an extension of Assert. Presents assertion methods with a more natural parameter order. The order is always actualValue, expectedValue [, message].
Author
Paul Mendelon
Since
5.6

Constructor Summary

AccessConstructor and Description
private
FileAssert()

Protect this constructor since it is a static only class.

Method Summary

Modifier and TypeMethod and Description
public static void
assertDirectory(File
the file to evaluate
tstvalue
,
String
the assertion error message
message
)

Asserts that a tstvalue is a proper directory.

public static void
public static void
assertFile(File
the file to evaluate
tstvalue
,
String
the assertion error message
message
)

Asserts that a tstvalue is a proper file.

public static void
assertFile(File
The actual file
tstvalue
)

public static void
assertLength(File
the file to evaluate
tstvalue
,
long
the expected value
expected
,
String
the assertion error message
message
)

Asserts that a tstvalue is a file of exactly expected characters or a directory of exactly expected entries.

public static void
assertLength(File
The actual file
tstvalue
,
long
The expected length
expected
)

public static void
assertMaxLength(File
the file to evaluate
tstvalue
,
long
The expected max length
expected
,
String
the assertion error message
message
)

Asserts that a tstvalue is a file of at most expected characters or a directory of at most expected entries.

public static void
assertMaxLength(File
The actual file
tstvalue
,
long
The expected length
expected
)

public static void
assertMinLength(File
the file to evaluate
tstvalue
,
long
the expected value
expected
,
String
the assertion error message
message
)

Asserts that a tstvalue is a file of at least expected characters or a directory of at least expected entries.

public static void
assertMinLength(File
The actual file
tstvalue
,
long
The expected min length
expected
)

public static void
assertReadable(File
the file to evaluate
tstvalue
,
String
the assertion error message
message
)

Asserts that a tstvalue is readable.

public static void
assertReadable(File
The actual file
tstvalue
)

public static void
assertReadWrite(File
the file to evaluate
tstvalue
,
String
the assertion error message
message
)

Asserts that a tstvalue is readable and writeable.

public static void
assertReadWrite(File
The actual file
tstvalue
)

public static void
assertWriteable(File
the file to evaluate
tstvalue
,
String
the assertion error message
message
)

Asserts that a tstvalue is writeable.

public static void
assertWriteable(File
The actual file
tstvalue
)

public static void
fail(String
the assertion error message
message
,
Throwable
the original exception
realCause
)

Fails a test with the given message and wrapping the original exception.

public static void
fail(String
the assertion error message
message
)

Fails a test with the given message.

public static void
fail()

Fails a test with no message.

private static void
failFile(File path, String actual, String expected, String message)

Formats failure for file assertions.

private static void
failSecurity(Exception e, File path, String actual, String expected, String message)

private static String
fileAccess(File path)

String representation of read and write permissions of path.

private static String
fileType(File path)

String representation of what sort of file path is.

private static String
toString(File path)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

FileAssertback to summary
private FileAssert()

Protect this constructor since it is a static only class.

Method Detail

assertDirectoryback to summary
public static void assertDirectory(File tstvalue, String message)

Asserts that a tstvalue is a proper directory. If it isn't, an AssertionError with the given message is thrown.

Parameters
tstvalue:File

the file to evaluate

message:String

the assertion error message

assertDirectoryback to summary
public static void assertDirectory(File tstvalue)
assertFileback to summary
public static void assertFile(File tstvalue, String message)

Asserts that a tstvalue is a proper file. If it isn't, an AssertionError with the given message is thrown.

Parameters
tstvalue:File

the file to evaluate

message:String

the assertion error message

assertFileback to summary
public static void assertFile(File tstvalue)
Parameters
tstvalue:File

The actual file

See Also
assertFile(File, String)
assertLengthback to summary
public static void assertLength(File tstvalue, long expected, String message)

Asserts that a tstvalue is a file of exactly expected characters or a directory of exactly expected entries. If it isn't, an AssertionError with the given message is thrown.

Parameters
tstvalue:File

the file to evaluate

expected:long

the expected value

message:String

the assertion error message

assertLengthback to summary
public static void assertLength(File tstvalue, long expected)
Parameters
tstvalue:File

The actual file

expected:long

The expected length

See Also
assertLength(File, long, String)
assertMaxLengthback to summary
public static void assertMaxLength(File tstvalue, long expected, String message)

Asserts that a tstvalue is a file of at most expected characters or a directory of at most expected entries. If it isn't, an AssertionError with the given message is thrown.

Parameters
tstvalue:File

the file to evaluate

expected:long

The expected max length

message:String

the assertion error message

assertMaxLengthback to summary
public static void assertMaxLength(File tstvalue, long expected)
Parameters
tstvalue:File

The actual file

expected:long

The expected length

See Also
assertMaxLength(File, long, String)
assertMinLengthback to summary
public static void assertMinLength(File tstvalue, long expected, String message)

Asserts that a tstvalue is a file of at least expected characters or a directory of at least expected entries. If it isn't, an AssertionError with the given message is thrown.

Parameters
tstvalue:File

the file to evaluate

expected:long

the expected value

message:String

the assertion error message

assertMinLengthback to summary
public static void assertMinLength(File tstvalue, long expected)
Parameters
tstvalue:File

The actual file

expected:long

The expected min length

See Also
assertMinLength(File, long, String)
assertReadableback to summary
public static void assertReadable(File tstvalue, String message)

Asserts that a tstvalue is readable. If it isn't, an AssertionError with the given message is thrown.

Parameters
tstvalue:File

the file to evaluate

message:String

the assertion error message

assertReadableback to summary
public static void assertReadable(File tstvalue)
Parameters
tstvalue:File

The actual file

See Also
assertReadable(File, String)
assertReadWriteback to summary
public static void assertReadWrite(File tstvalue, String message)

Asserts that a tstvalue is readable and writeable. If it isn't, an AssertionError with the given message is thrown.

Parameters
tstvalue:File

the file to evaluate

message:String

the assertion error message

assertReadWriteback to summary
public static void assertReadWrite(File tstvalue)
Parameters
tstvalue:File

The actual file

See Also
assertReadWrite(File, String)
assertWriteableback to summary
public static void assertWriteable(File tstvalue, String message)

Asserts that a tstvalue is writeable. If it isn't, an AssertionError with the given message is thrown.

Parameters
tstvalue:File

the file to evaluate

message:String

the assertion error message

assertWriteableback to summary
public static void assertWriteable(File tstvalue)
Parameters
tstvalue:File

The actual file

See Also
assertWriteable(File, String)
failback to summary
public static void fail(String message, Throwable realCause)

Fails a test with the given message and wrapping the original exception.

Parameters
message:String

the assertion error message

realCause:Throwable

the original exception

failback to summary
public static void fail(String message)

Fails a test with the given message.

Parameters
message:String

the assertion error message

failback to summary
public static void fail()

Fails a test with no message.

failFileback to summary
private static void failFile(File path, String actual, String expected, String message)

Formats failure for file assertions.

failSecurityback to summary
private static void failSecurity(Exception e, File path, String actual, String expected, String message)
fileAccessback to summary
private static String fileAccess(File path)

String representation of read and write permissions of path.

fileTypeback to summary
private static String fileType(File path)

String representation of what sort of file path is.

toStringback to summary
private static String toString(File path)