org.apache.commons
Class AbstractVfsTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.commons.AbstractVfsTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AbstractProviderTestCase, DefaultFileMonitorTests, FileSystemManagerFactoryTestCase, GenericFileNameTestCase

public abstract class AbstractVfsTestCase
extends junit.framework.TestCase

A base class for VFS tests. Provides utility methods for locating test resources.

Author:
Adam Murdoch

Constructor Summary
AbstractVfsTestCase()
           
 
Method Summary
static void assertSameMessage(String[] messages, Throwable throwable)
          Asserts that an exception chain contains the expected messages.
static void assertSameMessage(String code, Object[] params, Throwable throwable)
          Asserts that an exception contains the expected message.
static void assertSameMessage(String code, Object param, Throwable throwable)
          Asserts that an exception contains the expected message.
static void assertSameMessage(String code, Throwable throwable)
          Asserts that an exception contains the expected message.
static boolean equals(Object o1, Object o2)
          Compares 2 objects for equality, nulls are equal.
static File getCanonicalFile(File file)
          Makes a file canonical
static Throwable getCause(Throwable throwable)
          Returns the cause of an exception.
static String getPackageName(Class<?> clazz)
          Returns the name of the package containing a class.
static String getResourceTestDirectory()
           
static String getTestDirectory()
           
static File getTestDirectory(String name)
          Locates a test directory, creating it if it does not exist.
static File getTestDirectoryFile()
          Locates the base directory for this test.
static File getTestResource(String name)
          Locates a test resource, and asserts that the resource exists
static File getTestResource(String name, boolean mustExist)
          Locates a test resource.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractVfsTestCase

public AbstractVfsTestCase()
Method Detail

getPackageName

public static String getPackageName(Class<?> clazz)
Returns the name of the package containing a class.

Returns:
The . delimited package name, or an empty string if the class is in the default package.

getTestResource

public static File getTestResource(String name)
Locates a test resource, and asserts that the resource exists

Parameters:
name - path of the resource, relative to this test's base directory.

getTestResource

public static File getTestResource(String name,
                                   boolean mustExist)
Locates a test resource.

Parameters:
name - path of the resource, relative to this test's base directory.

getTestDirectoryFile

public static File getTestDirectoryFile()
Locates the base directory for this test.


getTestDirectory

public static String getTestDirectory()

getResourceTestDirectory

public static String getResourceTestDirectory()

getTestDirectory

public static File getTestDirectory(String name)
Locates a test directory, creating it if it does not exist.

Parameters:
name - path of the directory, relative to this test's base directory.

getCanonicalFile

public static File getCanonicalFile(File file)
Makes a file canonical


assertSameMessage

public static void assertSameMessage(String[] messages,
                                     Throwable throwable)
Asserts that an exception chain contains the expected messages.

Parameters:
messages - The messages, in order. A null entry in this array indicates that the message should be ignored.

getCause

public static Throwable getCause(Throwable throwable)
Returns the cause of an exception.


assertSameMessage

public static void assertSameMessage(String code,
                                     Throwable throwable)
Asserts that an exception contains the expected message.


assertSameMessage

public static void assertSameMessage(String code,
                                     Object[] params,
                                     Throwable throwable)
Asserts that an exception contains the expected message.


assertSameMessage

public static void assertSameMessage(String code,
                                     Object param,
                                     Throwable throwable)
Asserts that an exception contains the expected message.


equals

public static boolean equals(Object o1,
                             Object o2)
Compares 2 objects for equality, nulls are equal. Used by the test classes' equals() methods.



Copyright © 2002-2011 The Apache Software Foundation. All Rights Reserved.