org.fest.assertions
Class FileAssert

java.lang.Object
  extended by org.fest.assertions.Assert
      extended by org.fest.assertions.GenericAssert<FileAssert,File>
          extended by org.fest.assertions.FileAssert

public class FileAssert
extends GenericAssert<FileAssert,File>

Assertions for File.

To create a new instance of this class invoke Assertions.assertThat(File).

Author:
David DIDIER, Yvonne Wang, Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.assertions.GenericAssert
actual, myself
 
Constructor Summary
protected FileAssert(File actual)
          Creates a new FileAssert.
 
Method Summary
 FileAssert doesNotExist()
          Verifies that the actual File does not exist.
 FileAssert exists()
          Verifies that the actual File does exist.
 FileAssert hasSameContentAs(File expected)
          Verifies that the content of the actual File is equal to the content of the given one.
 FileAssert hasSize(long expected)
          Verifies that the size of the actual File is equal to the given one.
 FileAssert isAbsolute()
          Verifies that the actual File is an absolute path.
 FileAssert isDirectory()
          Verifies that the actual File is a directory.
 FileAssert isFile()
          Verifies that the actual File is a regular file.
 FileAssert isRelative()
          Verifies that the actual File is a relative path.
 
Methods inherited from class org.fest.assertions.GenericAssert
as, as, describedAs, describedAs, doesNotSatisfy, is, isEqualTo, isIn, isIn, isNot, isNotEqualTo, isNotIn, isNotIn, isNotNull, isNotSameAs, isNull, isSameAs, overridingErrorMessage, satisfies
 
Methods inherited from class org.fest.assertions.Assert
customErrorMessage, description, description, description, equals, fail, fail, failIfCustomMessageIsSet, failIfCustomMessageIsSet, failure, formattedErrorMessage, hashCode, rawDescription, replaceDefaultErrorMessagesWith
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileAssert

protected FileAssert(File actual)
Creates a new FileAssert.

Parameters:
actual - the target to verify.
Method Detail

doesNotExist

public FileAssert doesNotExist()
Verifies that the actual File does not exist.

Returns:
this assertion object.
Throws:
AssertionError - if the the actual File is null.
AssertionError - if the actual File exists.

exists

public FileAssert exists()
Verifies that the actual File does exist.

Returns:
this assertion object.
Throws:
AssertionError - if the the actual File is null.
AssertionError - if the actual File does not exist.

hasSize

public FileAssert hasSize(long expected)
Verifies that the size of the actual File is equal to the given one.

Parameters:
expected - the expected size of the actual File.
Returns:
this assertion object.
Throws:
AssertionError - if the the actual File is null.
AssertionError - if the size of the actual File is not equal to the given one.

isDirectory

public FileAssert isDirectory()
Verifies that the actual File is a directory.

Returns:
this assertion object.
Throws:
AssertionError - if the the actual File is null.
AssertionError - if the actual File is not a directory.

isFile

public FileAssert isFile()
Verifies that the actual File is a regular file.

Returns:
this assertion object.
Throws:
AssertionError - if the the actual File is null.
AssertionError - if the actual File is not a regular file.

hasSameContentAs

public FileAssert hasSameContentAs(File expected)
Verifies that the content of the actual File is equal to the content of the given one. Adapted from FileAssert (from JUnit-addons.)

Parameters:
expected - the given File to compare the actual File to.
Returns:
this assertion object.
Throws:
NullPointerException - if the file to compare to is null.
AssertionError - if the the actual File is null.
AssertionError - if the content of the actual File is not equal to the content of the given one.

isRelative

public FileAssert isRelative()
Verifies that the actual File is a relative path.

Returns:
this assertion object.
Throws:
AssertionError - if the actual File is not a relative path.

isAbsolute

public FileAssert isAbsolute()
Verifies that the actual File is an absolute path.

Returns:
this assertion object.
Throws:
AssertionError - if the actual File is not an absolute path.


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.