| java.lang.Object com.sleepycat.je.util.TestUtils
TestUtils | public class TestUtils (Code) | | |
Method Summary | |
public static int | alphaKey(int i) Generate a synthetic base 26 four byte alpha key from an int.
The bytes of the key are between 'A' and 'Z', inclusive. | public static byte[] | byteArrayCopy(byte[] ba) | public static void | checkLatchCount() | public static boolean | checkTreeDepth(Database db, int desiredDepth) Assert if the tree is not this deep. | public static void | clearIsolationLevel(EnvironmentConfig config) If a unit test needs to override the isolation level, it should call
this method after calling initEnvConfig. | public static void | copyFiles(File fromDir, File toDir) Copies all files in fromDir to toDir. | public void | debugMsg(String message) | public static String | dumpByteArray(byte[] b) | public static void | generateRandomAlphaBytes(byte[] bytes) | public static BIN | getBIN(Cursor cursor) Returns the target BIN for the given cursor. | public static IN | getIN(BIN bin) Returns the parent IN of the given BIN. | public static byte[] | getTestArray(int val) Useful utility for generating byte arrays with a known order. | public static int | getTestVal(byte[] testArray) | public static EnvironmentConfig | initEnvConfig() Called by each unit test to enforce isolation level settings specified
in the isolationLevel system property. | public static void | loadLog(Class cls, String resourceName, File envHome) Loads the given resource relative to the given class, and copies it to
log file zero in the given directory. | public static void | logBINAndIN(Environment env, Cursor cursor) Logs the BIN at the cursor provisionally and the parent IN
non-provisionally. | public static long | logIN(Environment env, IN in, boolean provisional, IN parent) Logs the given IN. | public static void | printLatchCount(String msg) | public static void | printLatches(String msg) | public static void | putUnsignedInt(byte[] buf, long value) Marshall an unsigned int (long) into a four byte buffer. | public static void | removeFiles(String msg, File envFile, String suffix) | public static void | removeFiles(String msg, File envFile, String suffix, boolean checkRemove) | public static void | removeFiles(File envFile, FilenameFilter filter) Remove files with the pattern indicated by the filename filter from the
environment home directory. | public static void | removeLogFiles(String msg, File envFile, boolean checkRemove) Remove je log files from the home directory. | public static boolean | runLongTests() | public static void | setRandomSeed(int seed) | public static String | skipVersion(Exception e) Skip over the JE version number at the start of the exception
message for tests which are looking for a specific message. | public static long | tallyNodeMemUsage(EnvironmentImpl envImpl) | public static long | validateNodeMemUsage(EnvironmentImpl envImpl, boolean assertOnError) |
alphaKey | public static int alphaKey(int i)(Code) | | Generate a synthetic base 26 four byte alpha key from an int.
The bytes of the key are between 'A' and 'Z', inclusive. 0 maps
to 'AAAA', 1 to 'AAAB', etc.
|
byteArrayCopy | public static byte[] byteArrayCopy(byte[] ba)(Code) | | a copy of the passed in byte array |
checkLatchCount | public static void checkLatchCount()(Code) | | |
checkTreeDepth | public static boolean checkTreeDepth(Database db, int desiredDepth) throws DatabaseException(Code) | | Assert if the tree is not this deep. Use to ensure that data setups
are as expected.
|
clearIsolationLevel | public static void clearIsolationLevel(EnvironmentConfig config)(Code) | | If a unit test needs to override the isolation level, it should call
this method after calling initEnvConfig.
|
copyFiles | public static void copyFiles(File fromDir, File toDir) throws IOException(Code) | | Copies all files in fromDir to toDir. Does not copy subdirectories.
|
dumpByteArray | public static String dumpByteArray(byte[] b)(Code) | | length and data of a byte array, printed as decimal numbers |
generateRandomAlphaBytes | public static void generateRandomAlphaBytes(byte[] bytes)(Code) | | |
getTestArray | public static byte[] getTestArray(int val)(Code) | | Useful utility for generating byte arrays with a known order.
Vary the length just to introduce more variability.
a byte array of length val % 100 with the value of "val" |
getTestVal | public static int getTestVal(byte[] testArray)(Code) | | Return the value of a test data array generated with getTestArray
as an int
|
initEnvConfig | public static EnvironmentConfig initEnvConfig()(Code) | | Called by each unit test to enforce isolation level settings specified
in the isolationLevel system property. Other system properties or
default settings may be applied in the future.
|
loadLog | public static void loadLog(Class cls, String resourceName, File envHome) throws IOException(Code) | | Loads the given resource relative to the given class, and copies it to
log file zero in the given directory.
|
logBINAndIN | public static void logBINAndIN(Environment env, Cursor cursor) throws DatabaseException(Code) | | Logs the BIN at the cursor provisionally and the parent IN
non-provisionally. Used to simulate a partial checkpoint or eviction.
|
printLatchCount | public static void printLatchCount(String msg)(Code) | | |
printLatches | public static void printLatches(String msg)(Code) | | |
putUnsignedInt | public static void putUnsignedInt(byte[] buf, long value)(Code) | | Marshall an unsigned int (long) into a four byte buffer.
|
removeFiles | public static void removeFiles(String msg, File envFile, String suffix) throws IOException(Code) | | Remove files with this suffix from the je home directory
Parameters: msg - prefix to append to error messages Parameters: envFile - environment directory Parameters: suffix - files with this suffix will be removed |
removeFiles | public static void removeFiles(String msg, File envFile, String suffix, boolean checkRemove) throws IOException(Code) | | Remove files with this suffix from the je home directory
Parameters: msg - prefix to append to error messages Parameters: envFile - environment directory Parameters: suffix - files with this suffix will be removed Parameters: checkRemove - if true, check the -DremoveLogFiles systemproperty before removing. |
removeFiles | public static void removeFiles(File envFile, FilenameFilter filter) throws IOException(Code) | | Remove files with the pattern indicated by the filename filter from the
environment home directory.
Note that BadFileFilter looks for this pattern: NNNNNNNN.bad.#
InfoFileFilter looks for this pattern: je.info.#
Parameters: envFile - environment directory |
removeLogFiles | public static void removeLogFiles(String msg, File envFile, boolean checkRemove) throws IOException(Code) | | Remove je log files from the home directory. Will be disabled
if the unit test is run with -DremoveLogFiles=false
Parameters: msg - prefix to append to error messages Parameters: envFile - environment directory |
runLongTests | public static boolean runLongTests()(Code) | | true if long running tests are enabled. |
setRandomSeed | public static void setRandomSeed(int seed)(Code) | | |
skipVersion | public static String skipVersion(Exception e)(Code) | | Skip over the JE version number at the start of the exception
message for tests which are looking for a specific message.
|
|
|