public class MatsTestLatch
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
MatsTestLatch.Result<S,I> |
Modifier and Type | Field and Description |
---|---|
static int |
WAIT_MILLIS_FOR_NON_OCCURRENCE
Some tests needs to assert that something does not happen, i.e.
|
Constructor and Description |
---|
MatsTestLatch() |
Modifier and Type | Method and Description |
---|---|
void |
resolve(MatsEndpoint.DetachedProcessContext context,
java.lang.Object sto,
java.lang.Object dto)
When this method is invoked, the waiting threads will be released.
|
void |
resolve(java.lang.Object sto,
java.lang.Object dto)
When this method is invoked, the waiting threads will be released - this variant does not take the
ProcessContext, use
the other one ! |
<S,I> MatsTestLatch.Result<S,I> |
waitForResult()
Convenience method of
waitForResult(long) meant for waiting for something that is expected to happen:
Waits for 30 seconds for the test-latch to be resolved . |
<S,I> MatsTestLatch.Result<S,I> |
waitForResult(long timeout)
Waits for the specified time for
#resolve(DetachedProcessContext, Object, Object) resolve(..)} to be
invoked by some other thread, returning the result. |
public static final int WAIT_MILLIS_FOR_NON_OCCURRENCE
public <S,I> MatsTestLatch.Result<S,I> waitForResult()
waitForResult(long)
meant for waiting for something that is expected to happen:
Waits for 30 seconds for the test-latch to be resolved
.
Since tests employing this method should resolve as fast as possible, it makes little sense to limit this
waiting time to "a short time", as either the test works, and it resolves literally as fast as possible, or the
test is broken, and then it doesn't really matter that you have to wait 30 seconds to find out. What we don't
want is a test that fails due to e.g. garbage collection kicking in, or some other infrastructural matters that
do not relate to the test.waitForResult(long)
.public <S,I> MatsTestLatch.Result<S,I> waitForResult(long timeout)
#resolve(DetachedProcessContext, Object, Object)
resolve(..)} to be
invoked by some other thread, returning the result. If the result is already in, it immediately returns. If the
result does not come within timeout, an AssertionError
is raised.
Notice: If you wait for something that should happen, you should rather use the non-arg method
waitForResult()
.timeout
- the max time to wait.MatsTestLatch.Result
. Throws AssertionError
if not gotten within timeout.public void resolve(java.lang.Object sto, java.lang.Object dto)
the other one
!sto
- State object.dto
- the incoming state object that the Mats processor initially received.#resolve(DetachedProcessContext, Object, Object)
public void resolve(MatsEndpoint.DetachedProcessContext context, java.lang.Object sto, java.lang.Object dto)
context
- (Detached)ProcessContextsto
- State object.dto
- the incoming state object that the Mats processor initially received.