The following tables document the helper methods available in Hazelcast. Member methods are available only when the test class inherits the respective support class, hence only in JUnit 4. Static methods can also be used in other frameworks.
Configuration helpers
Method | Static? | Origin | Description |
---|---|---|---|
|
yes |
HazelcastTestSupport |
Returns a compact Config with reduced threads but with Jet and metrics enabled. |
|
yes |
HazelcastTestSupport |
Returns a compact Config with Jet and metrics disabled and minimal threads. |
|
yes |
HazelcastTestSupport |
Applies minimal threads, with Jet and metrics enabled, to a given Config. |
|
yes |
HazelcastTestSupport |
Returns a default Config with Jet enabled. |
|
yes |
HazelcastTestSupport |
Modifies a given Config to disable all network join mechanisms (TCP/IP and autodetection). |
Threading and concurrency utilities
Method | Static? | Origin | Description |
---|---|---|---|
|
yes |
HazelcastTestSupport |
Runs a RunnableEx, Runnable, or Callable in a new thread, returning a Future. |
|
yes |
HazelcastTestSupport |
Schedules an interrupt of the current thread after a specified delay. |
Sleep and timing helpers
Method | Static? | Origin | Description |
---|---|---|---|
|
yes |
HazelcastTestSupport |
Sleeps for the specified number of milliseconds, swallowing interruptions. |
|
yes |
HazelcastTestSupport |
Sleeps for the specified number of seconds. |
|
yes |
HazelcastTestSupport |
Sleeps up to a target end time, warning if already past. |
|
yes |
HazelcastTestSupport |
Sleeps up to a duration unless an AtomicBoolean flag is set, then sets it. |
|
yes |
HazelcastTestSupport |
Guarantees sleeping at least the given milliseconds, even across interrupts. |
|
yes |
HazelcastTestSupport |
Alias in seconds for sleepAtLeastMillis. |
Random data and names
Method | Static? | Origin | Description |
---|---|---|---|
|
yes |
HazelcastTestSupport |
Builds a random lowercase ASCII string of given length. |
|
yes |
HazelcastTestSupport |
Returns a new unsecure UUID string. |
|
yes |
HazelcastTestSupport |
Returns a random UUID string as a map name (with optional prefix). |
|
yes |
HazelcastTestSupport |
Alias for |
Partition and key generation
Method | Static? | Origin | Description |
---|---|---|---|
|
yes |
HazelcastTestSupport |
Generates a random key whose partition is owned by the local member (with optional prefix). |
|
yes |
HazelcastTestSupport |
Picks a random partition that is locally owned by a given instance. |
|
yes |
HazelcastTestSupport |
Generates a key owned (or not) by the local member. |
|
yes |
HazelcastTestSupport |
Generates a key mapping to a specific partition ID (with optional prefix). |
|
no |
HazelcastTestSupport |
Generates multiple keys all belonging to the same owned partition. |
Partition table and safe-state
Method | Static? | Origin | Description |
---|---|---|---|
|
yes |
HazelcastTestSupport |
Forces partition table initialization on instances. |
|
yes |
HazelcastTestSupport |
Checks whether a single instance’s partition state is safe. |
|
yes |
HazelcastTestSupport |
Checks whether the entire cluster is in a safe partition state. |
|
yes |
HazelcastTestSupport |
Verifies that all instances in a collection are safe. |
|
yes |
HazelcastTestSupport |
Blocks until instance(s) reach safe state, with retry assertions. |
|
yes |
HazelcastTestSupport |
Asserts (throws) if any instance is not in safe state. |
Cluster assertions
Method | Static? | Origin | Description |
---|---|---|---|
|
yes |
HazelcastTestSupport |
Asserts that no Hazelcast server instances remain. |
|
yes |
HazelcastTestSupport |
Asserts that no Hazelcast client instances remain. |
|
yes |
HazelcastTestSupport |
Asserts cluster size immediately or eventually within timeout. |
|
yes |
HazelcastTestSupport |
Asserts that all instances agree on the master address. |
|
yes |
HazelcastTestSupport |
Asserts the cluster state immediately or eventually. |
General assertions
Method | Static? | Origin | Description |
---|---|---|---|
|
yes |
HazelcastTestSupport |
Collection- and string-based containment assertions. |
|
yes |
HazelcastTestSupport |
Asserts that one string starts with another (ComparisonFailure on fail). |
|
yes |
HazelcastTestSupport |
Asserts two Properties objects have identical keys and values. |
|
yes |
HazelcastTestSupport |
Asserts and casts an object to a given class. |
|
yes |
HazelcastTestSupport |
Asserts an Iterable yields exactly the expected elements in order. |
Time-bound assertions
Method | Static? | Origin | Description |
---|---|---|---|
|
yes |
HazelcastTestSupport |
Waits for a Future/FutureTask to complete within timeout. |
|
yes |
HazelcastTestSupport |
Waits until collections, maps, or values reach expected state. |
|
yes |
HazelcastTestSupport |
Retries assertions until success or failure within timeout. |
|
yes |
HazelcastTestSupport |
Delays for a fixed period, then asserts. |
|
yes |
HazelcastTestSupport |
Continuously asserts a predicate over a duration. |
|
yes |
HazelcastTestSupport |
Waits for latch or atomic to reach an expected value. |
Specialized assertions
Method | Static? | Origin | Description |
---|---|---|---|
|
yes |
HazelcastTestSupport |
Verifies a utility class has exactly one private constructor. |
|
yes |
HazelcastTestSupport |
Asserts all enum values are handled via valueOf. |
|
yes |
HazelcastTestSupport |
Asserts that a given runnable throws a specific exception type. |
|
yes |
HazelcastTestSupport |
Numeric-range assertions. |
|
yes |
HazelcastTestSupport |
Retries a task until exactly one run succeeds or times out. |
|
yes |
HazelcastTestSupport |
Waits until the parked operation count reaches an expected value. |
Connection and membership
Method | Static? | Origin | Description |
---|---|---|---|
|
yes |
HazelcastTestSupport |
Simulates network failure by closing connections between two instances. |
|
yes |
HazelcastTestSupport |
Marks one node as suspected by another, optionally with a reason. |
Reflection and cleanup
Method | Static? | Origin | Description |
---|---|---|---|
|
yes |
HazelcastTestSupport |
Reflectively retrieves a private field’s value from an object or class. |
|
yes |
HazelcastTestSupport |
Iterates over and destroys every DistributedObject on a given instance. |
JUnit assumptions
Method | Static? | Origin | Description |
---|---|---|---|
|
yes |
HazelcastTestSupport |
Assumes the test is not running on Windows. |
|
yes |
HazelcastTestSupport |
Assumes Linux platform. |
|
yes |
HazelcastTestSupport |
Assumes non-ARM64 architecture. |
File and directory utilities
Method | Static? | Origin | Description |
---|---|---|---|
|
yes |
JetTestSupport |
Appends one or more lines to an existing file, creating it if needed. |
|
yes |
JetTestSupport |
Creates a temporary directory (deleted on JVM exit) and returns its File. |
Jet configuration helpers
Method | Static? | Origin | Description |
---|---|---|---|
|
yes |
JetTestSupport |
Returns a small default Config with Jet resource-upload enabled. |
|
yes |
JetTestSupport |
Returns a default Config with Jet enabled (no thread reduction). |
Cluster cleanup and job teardown
Method | Static? | Origin | Description |
---|---|---|---|
|
yes |
JetTestSupport |
Cancels a job and waits until it is no longer running on any member. |
|
yes |
JetTestSupport |
Cancels a job and asserts that its |
Pipeline utilities
Method | Static? | Origin | Description |
---|---|---|---|
|
yes |
JetTestSupport |
Extracts the internal ProcessorMetaSupplier from a BatchSource pipeline stage. |
|
yes |
JetTestSupport |
Waits until exactly one Jet job is in RUNNING state and returns it. |
TestHazelcastFactory utilities
Method | Static? | Origin | Description |
---|---|---|---|
|
no |
TestHazelcastInstanceFactory |
Returns the configured number of nodes/addresses. |
|
no |
TestHazelcastInstanceFactory |
Creates a new server instance using default or mock-network context. Various overloads available. |
|
yes |
TestHazelcastInstanceFactory |
Attempts to build an |
|
no |
TestHazelcastInstanceFactory |
Returns the next pre-allocated or newly minted |
|
no |
TestHazelcastInstanceFactory |
Returns the next |
|
no |
TestHazelcastInstanceFactory |
Creates as many instances as |
|
no |
TestHazelcastInstanceFactory |
Creates |
|
no |
TestHazelcastInstanceFactory |
Returns all live instances, mock-network or real. |
|
no |
TestHazelcastInstanceFactory |
Returns the unmodifiable list of all addresses this factory manages. |
|
no |
TestHazelcastInstanceFactory |
Terminates one instance and removes it from registry if mock-network. |
|
no |
TestHazelcastInstanceFactory |
Shuts down all instances; clears registry or calls |
|
no |
TestHazelcastInstanceFactory |
Terminates all instances; stops registry or calls |
|
no |
TestHazelcastFactory |
Creates a new client in the mock-network setup. Various overloads available. |
|
no |
TestHazelcastFactory |
Retrieves a previously created client proxy by its name. |
|
no |
TestHazelcastFactory |
Shuts down all server members via parent |
|
no |
TestHazelcastFactory |
Shuts down all clients (mock-network or real) then all members. |
|
no |
TestHazelcastFactory |
Terminates all clients then all members. |