Package org.apache.hadoop.hbase
Class GenericTestUtils
java.lang.Object
org.apache.hadoop.hbase.GenericTestUtils
Test provides some very generic helpers which might be used across the tests
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Mockito answer helper that triggers one latch as soon as the method is called, then waits on another before continuing.static class
An Answer implementation that simply forwards all calls through to a delegate.static class
An Answer implementation which sleeps for a random number of milliseconds between 0 and a configurable value before delegating to the real implementation of the method. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertExists
(File f) Assert that a given file exists.static void
assertGlobEquals
(File dir, String pattern, String... expectedMatches) List all of the files in 'dir' that match the regex 'pattern'.static void
assertMatches
(String output, String pattern) static void
assertNoThreadsMatching
(String regex) Assert that there are no threads running whose name matches the given regular expression.static void
assertValueNear
(long expected, long actual, long allowedError) static void
assertValueWithinRange
(long expectedMin, long expectedMax, long actual) static String
Extracts the name of the method where the invocation has happenedstatic int
Generates a process-wide unique sequence number.static void
waitFor
(org.apache.hbase.thirdparty.com.google.common.base.Supplier<Boolean> check, int checkEveryMillis, int waitForMillis)
-
Field Details
-
sequence
-
-
Constructor Details
-
GenericTestUtils
public GenericTestUtils()
-
-
Method Details
-
getMethodName
Extracts the name of the method where the invocation has happened- Returns:
- String name of the invoking method
-
uniqueSequenceId
Generates a process-wide unique sequence number.- Returns:
- a unique sequence number
-
assertExists
Assert that a given file exists. -
assertGlobEquals
public static void assertGlobEquals(File dir, String pattern, String... expectedMatches) throws IOException List all of the files in 'dir' that match the regex 'pattern'. Then check that this list is identical to 'expectedMatches'.- Throws:
IOException
- if the dir is inaccessible
-
waitFor
public static void waitFor(org.apache.hbase.thirdparty.com.google.common.base.Supplier<Boolean> check, int checkEveryMillis, int waitForMillis) throws TimeoutException, InterruptedException - Throws:
TimeoutException
InterruptedException
-
assertMatches
-
assertValueNear
-
assertValueWithinRange
-
assertNoThreadsMatching
Assert that there are no threads running whose name matches the given regular expression.- Parameters:
regex
- the regex to match against
-