org.h2.test
Class TestBase

java.lang.Object
  extended by org.h2.test.TestBase
Direct Known Subclasses:
Test, TestAlter, TestAlterSchemaRename, TestAutoRecompile, TestAutoReconnect, TestAutoServer, TestBackup, TestBatchUpdates, TestBenchmark, TestBigDb, TestBigResult, TestBitField, TestBnf, TestBtreeIndex, TestCache, TestCacheConcurrentLIRS, TestCacheLIRS, TestCacheLongKeyLIRS, TestCallableStatement, TestCancel, TestCases, TestCheckpoint, TestClassLoaderLeak, TestClearReferences, TestCluster, TestCollation, TestCompatibility, TestCompatibilityOracle, TestCompress, TestConcurrent, TestConcurrentUpdate, TestConnectionInfo, TestConnectionPool, TestCrashAPI, TestCsv, TestDatabaseEventListener, TestDataPage, TestDataSource, TestDataUtils, TestDate, TestDateIso8601, TestDateStorage, TestDeadlock, TestDiskFull, TestDriver, TestDrop, TestDuplicateKeyUpdate, TestEncryptedDb, TestExclusive, TestExit, TestFile, TestFileLock, TestFileLockProcess, TestFileLockSerialized, TestFileSystem, TestFreeSpace, TestFtp, TestFullText, TestFunctionOverload, TestFunctions, TestFuzzOptimizations, TestHalt, TestIndex, TestInit, TestIntArray, TestIntIntHashMap, TestJavaObject, TestJavaObjectSerializer, TestJmx, TestJoin, TestKill, TestKillProcessWhileWriting, TestKillRestart, TestKillRestartMulti, TestLargeBlob, TestLimit, TestLimitUpdates, TestLinkedTable, TestListener, TestLob, TestLobApi, TestManyJdbcObjects, TestMathUtils, TestMemoryUsage, TestMetaData, TestModifyOnWrite, TestMulti, TestMultiConn, TestMultiDimension, TestMultiThread, TestMultiThreaded, TestMultiThreadedKernel, TestMultiThreadedKernel, TestMvcc1, TestMvcc2, TestMvcc3, TestMvccMultiThreaded, TestMVStore, TestMVStoreBenchmark, TestMVTableEngine, TestNativeSQL, TestNestedJoins, TestNestedLoop, TestNetUtils, TestObjectDataType, TestObjectDeserialization, TestOldVersion, TestOpenClose, TestOptimizations, TestOuterJoins, TestOutOfMemory, TestOverflow, TestPageStore, TestPageStoreCoverage, TestPattern, TestPgServer, TestPowerOff, TestPowerOffFs, TestPowerOffFs2, TestPreparedStatement, TestQueryCache, TestRandomCompare, TestRandomMapOps, TestRandomSQL, TestReader, TestReadOnly, TestRecoverKillLoop, TestRecovery, TestRecursiveQueries, TestReopen, TestReplace, TestResultSet, TestRights, TestRowLocks, TestRunscript, TestSampleApps, TestScript, TestScriptReader, TestScriptSimple, TestSecurity, TestSelectCountNonNullColumn, TestSequence, TestServlet, TestSessionsLocks, TestShardedMap, TestShell, TestShow, TestSimpleIndex, TestSort, TestSpaceReuse, TestSpatial, TestSpeed, TestSpinLock, TestSQLInjection, TestStatement, TestStreams, TestStreamStore, TestStringCache, TestStringUtils, TestSynth, TestTableEngines, TestTempTables, TestThreads, TestTimer, TestTools, TestTraceSystem, TestTransaction, TestTransactionIsolation, TestTransactionStore, TestTriggersConstraints, TestTwoPhaseCommit, TestUpdatableResultSet, TestUpgrade, TestUrlJavaObjectSerializer, TestUtils, TestValue, TestValueHashMap, TestValueMemory, TestView, TestViewAlterTable, TestViewDropView, TestWeb, TestXA, TestXASimple, TestZloty

public abstract class TestBase
extends java.lang.Object

The base class for all tests.


Field Summary
static java.lang.String BASE_TEST_DIR
          The base directory.
 TestAll config
          The test configuration.
protected  long start
          The time when the test was started.
protected static java.lang.String TEMP_DIR
          The temporary directory.
protected static int uniqueId
          An id used to create unique file names.
 
Constructor Summary
TestBase()
           
 
Method Summary
protected  void assertContains(java.lang.String result, java.lang.String contains)
          Check that a result contains the given substring.
protected  void assertEqualDatabases(java.sql.Statement stat1, java.sql.Statement stat2)
          Check if two databases contain the same met data.
protected  void assertEqualReaders(java.io.Reader expected, java.io.Reader actual, int len)
          Check if two readers are equal, and if not throw an exception.
protected  void assertEquals(boolean expected, boolean actual)
          Check if two values are equal, and if not throw an exception.
 void assertEquals(byte[] expected, byte[] actual)
          Check if two values are equal, and if not throw an exception.
 void assertEquals(java.util.Date expected, java.util.Date actual)
          Check if two values are equal, and if not throw an exception.
protected  void assertEquals(double expected, double actual)
          Check if two values are equal, and if not throw an exception.
protected  void assertEquals(float expected, float actual)
          Check if two values are equal, and if not throw an exception.
protected  void assertEquals(java.lang.Integer expected, java.lang.Integer actual)
          Check if two values are equal, and if not throw an exception.
 void assertEquals(int expected, int actual)
          Check if two values are equal, and if not throw an exception.
protected  void assertEquals(long expected, long actual)
          Check if two values are equal, and if not throw an exception.
 void assertEquals(java.lang.Object[] expected, java.lang.Object[] actual)
          Check if two values are equal, and if not throw an exception.
 void assertEquals(java.lang.String message, int expected, int actual)
          Check if two values are equal, and if not throw an exception.
protected  void assertEquals(java.lang.String message, java.sql.ResultSet rs0, java.sql.ResultSet rs1)
          Check if two result sets are equal, and if not throw an exception.
protected  void assertEquals(java.lang.String expected, java.lang.String actual)
          Check if two values are equal, and if not throw an exception.
protected  void assertEquals(java.lang.String message, java.lang.String expected, java.lang.String actual)
          Check if two values are equal, and if not throw an exception.
protected  void assertEqualStreams(java.io.InputStream expected, java.io.InputStream actual, int len)
          Check if two streams are equal, and if not throw an exception.
protected  void assertFalse(boolean value)
          Check that the passed boolean is false.
protected  void assertFalse(java.lang.String message, boolean value)
          Check that the passed boolean is false.
 void assertKnownException(java.sql.SQLException e)
          Check that a given exception is not an unexpected 'general error' exception.
protected  void assertKnownException(java.lang.String message, java.sql.SQLException e)
          Check that a given exception is not an unexpected 'general error' exception.
 void assertNull(java.lang.Object obj)
          Check that the passed object is null.
protected  void assertResult(java.lang.String expected, java.sql.Statement stat, java.lang.String sql)
          Check that the result set of a query is exactly this value.
protected  void assertResultRowCount(int expected, java.sql.ResultSet rs)
          Check that the result set row count matches.
protected  void assertResultSetMeta(java.sql.ResultSet rs, int columnCount, java.lang.String[] labels, int[] datatypes, int[] precision, int[] scale)
          Check if the result set meta data is correct.
protected  void assertResultSetOrdered(java.sql.ResultSet rs, java.lang.String[][] data)
          Check if a result set contains the expected data.
protected  void assertSingleValue(java.sql.Statement stat, java.lang.String sql, int expected)
          Check that the result set of a query is exactly this value.
protected  void assertSmaller(long a, long b)
          Check if the first value is larger or equal than the second value, and if not throw an exception.
protected  void assertStartsWith(java.lang.String text, java.lang.String expectedStart)
          Check that a text starts with the expected characters..
protected
<T> T
assertThrows(java.lang.Class<?> expectedExceptionClass, T obj)
          Verify the next method call on the object will throw an exception.
protected
<T> T
assertThrows(int expectedErrorCode, T obj)
          Verify the next method call on the object will throw an exception.
protected
<T> T
assertThrows(ResultVerifier verifier, T obj)
          Verify the next method call on the object will throw an exception.
protected  void assertThrows(java.lang.String expectedErrorMessage, java.sql.Statement stat, java.lang.String sql)
          Check that executing the specified query results in the specified error.
 void assertTrue(boolean condition)
          Check that the passed boolean is true.
protected  void assertTrue(java.lang.String message, boolean condition)
          Check that the passed boolean is true.
protected  void crash(java.sql.Connection conn)
          Simulate a database crash.
static TestBase createCaller()
          Create a new object of the calling class.
protected  void createClassProxy(java.lang.Class<?> clazz)
          Create a proxy class that extends the given class.
static java.io.ByteArrayInputStream createFailingStream(java.lang.Exception e)
          Construct a stream of 20 KB that fails while reading with the provided exception.
protected  void deleteDb(java.lang.String name)
          Delete all database files for this database.
protected  void deleteDb(java.lang.String dir, java.lang.String name)
          Delete all database files for a database.
protected  void eatMemory(int remainingKB)
          Use up almost all memory.
 void fail()
          Called if the test reached a point that was not expected.
protected  void fail(java.lang.String string)
          Called if the test reached a point that was not expected.
protected  void freeMemory()
          Remove the hard reference to the memory.
 java.lang.String getBaseDir()
          Get the base directory for tests.
protected  java.lang.String getClassPath()
          Get the classpath list used to execute java -cp ...
 java.sql.Connection getConnection(java.lang.String name)
          Open a database connection in admin mode.
 java.sql.Connection getConnection(java.lang.String name, java.lang.String user, java.lang.String password)
          Open a database connection.
protected  java.lang.String getFilePassword()
          Get the file password (only required if file encryption is used).
static int getMemoryUsed()
          Get the number of megabytes heap memory in use.
static long getMemoryUsedBytes()
          Get the number of bytes heap memory in use.
protected  java.lang.String getPassword()
          Get the login password.
protected  java.lang.String getPassword(java.lang.String userPassword)
          Get the password to use to login for the given user password.
protected  int getSize(int small, int big)
          Get the small or the big value depending on the configuration.
static java.lang.String getTestDir(java.lang.String name)
          Get the test directory for this test.
protected  java.lang.String getURL(java.lang.String name, boolean admin)
          Get the database URL for the given database name using the current configuration options.
protected  java.lang.String getUser()
           
 TestBase init()
          Initialize the test configuration using the default settings.
 TestBase init(TestAll conf)
          Initialize the test configuration.
static void logError(java.lang.String s, java.lang.Throwable e)
          Log an error message.
 void println(java.lang.String s)
          Print a message to system out.
protected  void printTime(java.lang.String s)
          Print the current time and a message to system out.
 void printTimeMemory(java.lang.String s, long time)
          Print the currently used memory, the message and the given time in milliseconds.
protected  java.lang.String readString(java.io.Reader reader)
          Read a string from the reader.
 void runTest(TestAll conf)
          This method is initializes the test, runs the test by calling the test() method, and prints status information.
protected  void startServerIfRequired()
          Start the TCP server if enabled in the configuration.
abstract  void test()
          This method will be called by the test framework.
 void testCase(int seed)
          Run a test case using the given seed value.
static void throwException(java.lang.Throwable e)
          Throw a checked exception, without having to declare the method as throwing a checked exception.
protected  void trace(int x)
          Write a message to system out if trace is enabled.
 void trace(java.lang.String s)
          Write a message to system out if trace is enabled.
protected  void traceMemory()
          Print how much memory is currently used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASE_TEST_DIR

public static final java.lang.String BASE_TEST_DIR
The base directory.

See Also:
Constant Field Values

TEMP_DIR

protected static final java.lang.String TEMP_DIR
The temporary directory.

See Also:
Constant Field Values

uniqueId

protected static int uniqueId
An id used to create unique file names.


config

public TestAll config
The test configuration.


start

protected long start
The time when the test was started.

Constructor Detail

TestBase

public TestBase()
Method Detail

getTestDir

public static java.lang.String getTestDir(java.lang.String name)
Get the test directory for this test.

Parameters:
name - the directory name suffix
Returns:
the test directory

startServerIfRequired

protected void startServerIfRequired()
                              throws java.sql.SQLException
Start the TCP server if enabled in the configuration.

Throws:
java.sql.SQLException

init

public TestBase init()
              throws java.lang.Exception
Initialize the test configuration using the default settings.

Returns:
itself
Throws:
java.lang.Exception

init

public TestBase init(TestAll conf)
              throws java.lang.Exception
Initialize the test configuration.

Parameters:
conf - the configuration
Returns:
itself
Throws:
java.lang.Exception

testCase

public void testCase(int seed)
              throws java.lang.Exception
Run a test case using the given seed value.

Parameters:
seed - the random seed value
Throws:
java.lang.Exception

runTest

public void runTest(TestAll conf)
This method is initializes the test, runs the test by calling the test() method, and prints status information. It also catches exceptions so that the tests can continue.

Parameters:
conf - the test configuration

getConnection

public java.sql.Connection getConnection(java.lang.String name)
                                  throws java.sql.SQLException
Open a database connection in admin mode. The default user name and password is used.

Parameters:
name - the database name
Returns:
the connection
Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection(java.lang.String name,
                                         java.lang.String user,
                                         java.lang.String password)
                                  throws java.sql.SQLException
Open a database connection.

Parameters:
name - the database name
user - the user name to use
password - the password to use
Returns:
the connection
Throws:
java.sql.SQLException

getPassword

protected java.lang.String getPassword(java.lang.String userPassword)
Get the password to use to login for the given user password. The file password is added if required.

Parameters:
userPassword - the password of this user
Returns:
the login password

getFilePassword

protected java.lang.String getFilePassword()
Get the file password (only required if file encryption is used).

Returns:
the file password

getPassword

protected java.lang.String getPassword()
Get the login password. This is usually the user password. If file encryption is used it is combined with the file password.

Returns:
the login password

getBaseDir

public java.lang.String getBaseDir()
Get the base directory for tests. If a special file system is used, the prefix is prepended.

Returns:
the directory, possibly including file system prefix

getURL

protected java.lang.String getURL(java.lang.String name,
                                  boolean admin)
Get the database URL for the given database name using the current configuration options.

Parameters:
name - the database name
admin - true if the current user is an admin
Returns:
the database URL

getSize

protected int getSize(int small,
                      int big)
Get the small or the big value depending on the configuration.

Parameters:
small - the value to return if the current test mode is 'small'
big - the value to return if the current test mode is 'big'
Returns:
small or big, depending on the configuration

getUser

protected java.lang.String getUser()

trace

protected void trace(int x)
Write a message to system out if trace is enabled.

Parameters:
x - the value to write

trace

public void trace(java.lang.String s)
Write a message to system out if trace is enabled.

Parameters:
s - the message to write

traceMemory

protected void traceMemory()
Print how much memory is currently used.


printTimeMemory

public void printTimeMemory(java.lang.String s,
                            long time)
Print the currently used memory, the message and the given time in milliseconds.

Parameters:
s - the message
time - the time in millis

getMemoryUsed

public static int getMemoryUsed()
Get the number of megabytes heap memory in use.

Returns:
the used megabytes

getMemoryUsedBytes

public static long getMemoryUsedBytes()
Get the number of bytes heap memory in use.

Returns:
the used bytes

fail

public void fail()
Called if the test reached a point that was not expected.

Throws:
java.lang.AssertionError - always throws an AssertionError

fail

protected void fail(java.lang.String string)
Called if the test reached a point that was not expected.

Parameters:
string - the error message
Throws:
java.lang.AssertionError - always throws an AssertionError

logError

public static void logError(java.lang.String s,
                            java.lang.Throwable e)
Log an error message.

Parameters:
s - the message
e - the exception

println

public void println(java.lang.String s)
Print a message to system out.

Parameters:
s - the message

printTime

protected void printTime(java.lang.String s)
Print the current time and a message to system out.

Parameters:
s - the message

deleteDb

protected void deleteDb(java.lang.String name)
Delete all database files for this database.

Parameters:
name - the database name

deleteDb

protected void deleteDb(java.lang.String dir,
                        java.lang.String name)
Delete all database files for a database.

Parameters:
dir - the directory where the database files are located
name - the database name

test

public abstract void test()
                   throws java.lang.Exception
This method will be called by the test framework.

Throws:
java.lang.Exception - if an exception in the test occurs

assertEquals

public void assertEquals(java.lang.String message,
                         int expected,
                         int actual)
Check if two values are equal, and if not throw an exception.

Parameters:
message - the message to print in case of error
expected - the expected value
actual - the actual value
Throws:
java.lang.AssertionError - if the values are not equal

assertEquals

public void assertEquals(int expected,
                         int actual)
Check if two values are equal, and if not throw an exception.

Parameters:
expected - the expected value
actual - the actual value
Throws:
java.lang.AssertionError - if the values are not equal

assertEquals

public void assertEquals(byte[] expected,
                         byte[] actual)
Check if two values are equal, and if not throw an exception.

Parameters:
expected - the expected value
actual - the actual value
Throws:
java.lang.AssertionError - if the values are not equal

assertEquals

public void assertEquals(java.util.Date expected,
                         java.util.Date actual)
Check if two values are equal, and if not throw an exception.

Parameters:
expected - the expected value
actual - the actual value
Throws:
java.lang.AssertionError - if the values are not equal

assertEquals

public void assertEquals(java.lang.Object[] expected,
                         java.lang.Object[] actual)
Check if two values are equal, and if not throw an exception.

Parameters:
expected - the expected value
actual - the actual value
Throws:
java.lang.AssertionError - if the values are not equal

assertEqualReaders

protected void assertEqualReaders(java.io.Reader expected,
                                  java.io.Reader actual,
                                  int len)
                           throws java.io.IOException
Check if two readers are equal, and if not throw an exception.

Parameters:
expected - the expected value
actual - the actual value
len - the maximum length, or -1
Throws:
java.lang.AssertionError - if the values are not equal
java.io.IOException

assertEqualStreams

protected void assertEqualStreams(java.io.InputStream expected,
                                  java.io.InputStream actual,
                                  int len)
                           throws java.io.IOException
Check if two streams are equal, and if not throw an exception.

Parameters:
expected - the expected value
actual - the actual value
len - the maximum length, or -1
Throws:
java.lang.AssertionError - if the values are not equal
java.io.IOException

assertEquals

protected void assertEquals(java.lang.String message,
                            java.lang.String expected,
                            java.lang.String actual)
Check if two values are equal, and if not throw an exception.

Parameters:
message - the message to use if the check fails
expected - the expected value
actual - the actual value
Throws:
java.lang.AssertionError - if the values are not equal

assertEquals

protected void assertEquals(java.lang.String expected,
                            java.lang.String actual)
Check if two values are equal, and if not throw an exception.

Parameters:
expected - the expected value
actual - the actual value
Throws:
java.lang.AssertionError - if the values are not equal

assertEquals

protected void assertEquals(java.lang.String message,
                            java.sql.ResultSet rs0,
                            java.sql.ResultSet rs1)
                     throws java.sql.SQLException
Check if two result sets are equal, and if not throw an exception.

Parameters:
message - the message to use if the check fails
rs0 - the first result set
rs1 - the second result set
Throws:
java.lang.AssertionError - if the values are not equal
java.sql.SQLException

assertSmaller

protected void assertSmaller(long a,
                             long b)
Check if the first value is larger or equal than the second value, and if not throw an exception.

Parameters:
a - the first value
b - the second value (must be smaller than the first value)
Throws:
java.lang.AssertionError - if the first value is smaller

assertContains

protected void assertContains(java.lang.String result,
                              java.lang.String contains)
Check that a result contains the given substring.

Parameters:
result - the result value
contains - the term that should appear in the result
Throws:
java.lang.AssertionError - if the term was not found

assertStartsWith

protected void assertStartsWith(java.lang.String text,
                                java.lang.String expectedStart)
Check that a text starts with the expected characters..

Parameters:
text - the text
expectedStart - the expected prefix
Throws:
java.lang.AssertionError - if the text does not start with the expected characters

assertEquals

protected void assertEquals(long expected,
                            long actual)
Check if two values are equal, and if not throw an exception.

Parameters:
expected - the expected value
actual - the actual value
Throws:
java.lang.AssertionError - if the values are not equal

assertEquals

protected void assertEquals(double expected,
                            double actual)
Check if two values are equal, and if not throw an exception.

Parameters:
expected - the expected value
actual - the actual value
Throws:
java.lang.AssertionError - if the values are not equal

assertEquals

protected void assertEquals(float expected,
                            float actual)
Check if two values are equal, and if not throw an exception.

Parameters:
expected - the expected value
actual - the actual value
Throws:
java.lang.AssertionError - if the values are not equal

assertEquals

protected void assertEquals(boolean expected,
                            boolean actual)
Check if two values are equal, and if not throw an exception.

Parameters:
expected - the expected value
actual - the actual value
Throws:
java.lang.AssertionError - if the values are not equal

assertTrue

public void assertTrue(boolean condition)
Check that the passed boolean is true.

Parameters:
condition - the condition
Throws:
java.lang.AssertionError - if the condition is false

assertNull

public void assertNull(java.lang.Object obj)
Check that the passed object is null.

Parameters:
obj - the object
Throws:
java.lang.AssertionError - if the condition is false

assertTrue

protected void assertTrue(java.lang.String message,
                          boolean condition)
Check that the passed boolean is true.

Parameters:
message - the message to print if the condition is false
condition - the condition
Throws:
java.lang.AssertionError - if the condition is false

assertFalse

protected void assertFalse(boolean value)
Check that the passed boolean is false.

Parameters:
value - the condition
Throws:
java.lang.AssertionError - if the condition is true

assertFalse

protected void assertFalse(java.lang.String message,
                           boolean value)
Check that the passed boolean is false.

Parameters:
message - the message to print if the condition is false
value - the condition
Throws:
java.lang.AssertionError - if the condition is true

assertResultRowCount

protected void assertResultRowCount(int expected,
                                    java.sql.ResultSet rs)
                             throws java.sql.SQLException
Check that the result set row count matches.

Parameters:
expected - the number of expected rows
rs - the result set
Throws:
java.lang.AssertionError - if a different number of rows have been found
java.sql.SQLException

assertSingleValue

protected void assertSingleValue(java.sql.Statement stat,
                                 java.lang.String sql,
                                 int expected)
                          throws java.sql.SQLException
Check that the result set of a query is exactly this value.

Parameters:
stat - the statement
sql - the SQL statement to execute
expected - the expected result value
Throws:
java.lang.AssertionError - if a different result value was returned
java.sql.SQLException

assertResult

protected void assertResult(java.lang.String expected,
                            java.sql.Statement stat,
                            java.lang.String sql)
                     throws java.sql.SQLException
Check that the result set of a query is exactly this value.

Parameters:
expected - the expected result value
stat - the statement
sql - the SQL statement to execute
Throws:
java.lang.AssertionError - if a different result value was returned
java.sql.SQLException

assertThrows

protected void assertThrows(java.lang.String expectedErrorMessage,
                            java.sql.Statement stat,
                            java.lang.String sql)
Check that executing the specified query results in the specified error.

Parameters:
expectedErrorMessage - the expected error message
stat - the statement
sql - the SQL statement to execute

assertResultSetMeta

protected void assertResultSetMeta(java.sql.ResultSet rs,
                                   int columnCount,
                                   java.lang.String[] labels,
                                   int[] datatypes,
                                   int[] precision,
                                   int[] scale)
                            throws java.sql.SQLException
Check if the result set meta data is correct.

Parameters:
rs - the result set
columnCount - the expected column count
labels - the expected column labels
datatypes - the expected data types
precision - the expected precisions
scale - the expected scales
Throws:
java.sql.SQLException

assertResultSetOrdered

protected void assertResultSetOrdered(java.sql.ResultSet rs,
                                      java.lang.String[][] data)
                               throws java.sql.SQLException
Check if a result set contains the expected data. The sort order is significant

Parameters:
rs - the result set
data - the expected data
Throws:
java.lang.AssertionError - if there is a mismatch
java.sql.SQLException

crash

protected void crash(java.sql.Connection conn)
Simulate a database crash. This method will also close the database files, but the files are in a state as the power was switched off. It doesn't throw an exception.

Parameters:
conn - the database connection

readString

protected java.lang.String readString(java.io.Reader reader)
Read a string from the reader. This method reads until end of file.

Parameters:
reader - the reader
Returns:
the string read

assertKnownException

public void assertKnownException(java.sql.SQLException e)
Check that a given exception is not an unexpected 'general error' exception.

Parameters:
e - the error

assertKnownException

protected void assertKnownException(java.lang.String message,
                                    java.sql.SQLException e)
Check that a given exception is not an unexpected 'general error' exception.

Parameters:
message - the message
e - the exception

assertEquals

protected void assertEquals(java.lang.Integer expected,
                            java.lang.Integer actual)
Check if two values are equal, and if not throw an exception.

Parameters:
expected - the expected value
actual - the actual value
Throws:
java.lang.AssertionError - if the values are not equal

assertEqualDatabases

protected void assertEqualDatabases(java.sql.Statement stat1,
                                    java.sql.Statement stat2)
                             throws java.sql.SQLException
Check if two databases contain the same met data.

Parameters:
stat1 - the connection to the first database
stat2 - the connection to the second database
Throws:
java.lang.AssertionError - if the databases don't match
java.sql.SQLException

createCaller

public static TestBase createCaller()
Create a new object of the calling class.

Returns:
the new test

getClassPath

protected java.lang.String getClassPath()
Get the classpath list used to execute java -cp ...

Returns:
the classpath list

eatMemory

protected void eatMemory(int remainingKB)
Use up almost all memory.

Parameters:
remainingKB - the number of kilobytes that are not referenced

freeMemory

protected void freeMemory()
Remove the hard reference to the memory.


assertThrows

protected <T> T assertThrows(java.lang.Class<?> expectedExceptionClass,
                             T obj)
Verify the next method call on the object will throw an exception.

Type Parameters:
T - the class of the object
Parameters:
expectedExceptionClass - the expected exception class to be thrown
obj - the object to wrap
Returns:
a proxy for the object

assertThrows

protected <T> T assertThrows(int expectedErrorCode,
                             T obj)
Verify the next method call on the object will throw an exception.

Type Parameters:
T - the class of the object
Parameters:
expectedErrorCode - the expected error code
obj - the object to wrap
Returns:
a proxy for the object

assertThrows

protected <T> T assertThrows(ResultVerifier verifier,
                             T obj)
Verify the next method call on the object will throw an exception.

Type Parameters:
T - the class of the object
Parameters:
verifier - the result verifier to call
obj - the object to wrap
Returns:
a proxy for the object

createClassProxy

protected void createClassProxy(java.lang.Class<?> clazz)
Create a proxy class that extends the given class.

Parameters:
clazz - the class

createFailingStream

public static java.io.ByteArrayInputStream createFailingStream(java.lang.Exception e)
Construct a stream of 20 KB that fails while reading with the provided exception.

Parameters:
e - the exception
Returns:
the stream

throwException

public static void throwException(java.lang.Throwable e)
Throw a checked exception, without having to declare the method as throwing a checked exception.

Parameters:
e - the exception to throw