JBoss Test 1.2.0.Final

org.jboss.test
Class AbstractTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.jboss.test.AbstractTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AbstractTestCaseWithSetup, BaseTestCase

public abstract class AbstractTestCase
extends junit.framework.TestCase

An abstract Test Case.

Version:
$Revision: 71003 $
Author:
Adrian Brock

Constructor Summary
AbstractTestCase(String name)
          Create a new abstract test case
 
Method Summary
protected  void assertEmpty(Collection c)
          Asserts a collection is empty
protected static void assertEmpty(Object[] array)
          Assert an array is empty or null
protected  void assertEmpty(String context, Collection c)
          Asserts a collection is empty
protected  void assertEquals(double one, double two)
          Assert two double values are equal
protected  void assertEquals(float one, float two)
          Assert two float values are equal
protected  void assertEquals(Object[] expected, Object[] actual)
          Assert two arrays are equal
protected  void assertEquals(String context, Object[] expected, Object[] actual)
          Assert two arrays are equal
protected
<T> T
assertInstanceOf(Object o, Class<T> expectedType)
          Check we have the expected type
protected
<T> T
assertInstanceOf(Object o, Class<T> expectedType, boolean allowNull)
          Check we have the expected type
static void checkDeepThrowable(Class<? extends Throwable> expected, Throwable throwable)
          Check we have the expected deep exception
static void checkDeepThrowableRethrow(Class<? extends Throwable> expected, Throwable throwable)
          Check a deep throwable and rethrow if it doesn't match
static void checkThrowable(Class<? extends Throwable> expected, Throwable throwable)
          Check we have the expected exception
static void checkThrowableRethrow(Class<? extends Throwable> expected, Throwable throwable)
          Check a throwable and rethrow if it doesn't match
protected  void configureLogging()
          Callback for configuring logging at the start of the test
protected  Object deserialize(byte[] bytes)
          Serialize an object
protected abstract  void enableTrace(String name)
          Enable trace for a logging category
protected  void failure(String reason, Throwable cause)
          Raise an assertion failed error for an error
static URL findResource(Class clazz, String name)
           
abstract  org.jboss.logging.Logger getLog()
          Get the log for this test
 URL getResource(String name)
           
protected  byte[] serialize(Serializable object)
          Serialize an object
protected
<T> T
serializeDeserialize(Serializable value, Class<T> expected)
          Serialize/deserialize
protected  void setUp()
           
protected  void tearDown()
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, 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

AbstractTestCase

public AbstractTestCase(String name)
Create a new abstract test case

Parameters:
name - the test name
Method Detail

getLog

public abstract org.jboss.logging.Logger getLog()
Get the log for this test

Returns:
the log

getResource

public URL getResource(String name)

findResource

public static URL findResource(Class clazz,
                               String name)

setUp

protected void setUp()
              throws Exception
Overrides:
setUp in class junit.framework.TestCase
Throws:
Exception

tearDown

protected void tearDown()
                 throws Exception
Overrides:
tearDown in class junit.framework.TestCase
Throws:
Exception

configureLogging

protected void configureLogging()
Callback for configuring logging at the start of the test


enableTrace

protected abstract void enableTrace(String name)
Enable trace for a logging category

Parameters:
name - the logging category

assertEquals

protected void assertEquals(float one,
                            float two)
Assert two float values are equal

Parameters:
one - the expected value
two - the actual value

assertEquals

protected void assertEquals(double one,
                            double two)
Assert two double values are equal

Parameters:
one - the expected value
two - the actual value

assertEquals

protected void assertEquals(Object[] expected,
                            Object[] actual)
Assert two arrays are equal

Parameters:
expected - the expected array
actual - the actual array

assertEquals

protected void assertEquals(String context,
                            Object[] expected,
                            Object[] actual)
Assert two arrays are equal

Parameters:
context - the context
expected - the expected array
actual - the actual array

assertEmpty

protected void assertEmpty(Collection c)
Asserts a collection is empty

Parameters:
c - the collection

assertEmpty

protected void assertEmpty(String context,
                           Collection c)
Asserts a collection is empty

Parameters:
context - the context
c - the collection

assertEmpty

protected static void assertEmpty(Object[] array)
Assert an array is empty or null

Parameters:
array - the array

checkThrowable

public static void checkThrowable(Class<? extends Throwable> expected,
                                  Throwable throwable)
Check we have the expected exception

Parameters:
expected - the excepted class of the exception
throwable - the real exception

checkThrowableRethrow

public static void checkThrowableRethrow(Class<? extends Throwable> expected,
                                         Throwable throwable)
                                  throws Exception
Check a throwable and rethrow if it doesn't match

Parameters:
expected - the expected throwable
throwable - the throwable
Throws:
Exception - the thrown exception

checkDeepThrowable

public static void checkDeepThrowable(Class<? extends Throwable> expected,
                                      Throwable throwable)
Check we have the expected deep exception

Parameters:
expected - the excepted class of the exception
throwable - the real exception

checkDeepThrowableRethrow

public static void checkDeepThrowableRethrow(Class<? extends Throwable> expected,
                                             Throwable throwable)
                                      throws Exception
Check a deep throwable and rethrow if it doesn't match

Parameters:
expected - the expected throwable
throwable - the throwable
Throws:
Exception - the thrown exception

serialize

protected byte[] serialize(Serializable object)
                    throws Exception
Serialize an object

Parameters:
object - the object
Returns:
the bytes
Throws:
Exception - for any error

deserialize

protected Object deserialize(byte[] bytes)
                      throws Exception
Serialize an object

Parameters:
bytes - - the raw serialzied object data
Returns:
the bytes
Throws:
Exception - for any error

serializeDeserialize

protected <T> T serializeDeserialize(Serializable value,
                                     Class<T> expected)
                          throws Exception
Serialize/deserialize

Type Parameters:
T - the expected type
Parameters:
value - the value
expected - the expected type
Returns:
the result
Throws:
Exception - for any problem

assertInstanceOf

protected <T> T assertInstanceOf(Object o,
                                 Class<T> expectedType)
Check we have the expected type

Type Parameters:
T - the expected type
Parameters:
o - the object
expectedType - the excepted class of the exception
Returns:
the expected type

assertInstanceOf

protected <T> T assertInstanceOf(Object o,
                                 Class<T> expectedType,
                                 boolean allowNull)
Check we have the expected type

Type Parameters:
T - the expected type
Parameters:
o - the object
expectedType - the excepted class of the exception
allowNull - whether the object can be null
Returns:
the expected type

failure

protected void failure(String reason,
                       Throwable cause)
Raise an assertion failed error for an error

Parameters:
reason - the reason
cause - the cause

JBoss Test 1.2.0.Final

Copyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.