Class LatchCountDownAndCallRealMethodAnswer
- java.lang.Object
-
- org.mockito.internal.stubbing.defaultanswers.ForwardsInvocations
-
- org.springframework.amqp.rabbit.test.mockito.LatchCountDownAndCallRealMethodAnswer
-
- All Implemented Interfaces:
Serializable
,org.mockito.stubbing.Answer<Object>
public class LatchCountDownAndCallRealMethodAnswer extends org.mockito.internal.stubbing.defaultanswers.ForwardsInvocations
AnAnswer
for void returning methods that calls the real method and counts down a latch. Captures any exceptions thrown.- Since:
- 1.6
- Author:
- Gary Russell
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LatchCountDownAndCallRealMethodAnswer(int count)
Deprecated.in favor ofLatchCountDownAndCallRealMethodAnswer(int, Object)
.LatchCountDownAndCallRealMethodAnswer(int count, Object delegate)
Get an instance with the provided properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
answer(org.mockito.invocation.InvocationOnMock invocation)
boolean
await(int timeout)
Wait for the latch to count down.Collection<Exception>
getExceptions()
Return the exceptions thrown.CountDownLatch
getLatch()
-
-
-
Constructor Detail
-
LatchCountDownAndCallRealMethodAnswer
@Deprecated public LatchCountDownAndCallRealMethodAnswer(int count)
Deprecated.in favor ofLatchCountDownAndCallRealMethodAnswer(int, Object)
.Get an instance with no delegate.- Parameters:
count
- to set in aCountDownLatch
.
-
LatchCountDownAndCallRealMethodAnswer
public LatchCountDownAndCallRealMethodAnswer(int count, @Nullable Object delegate)
Get an instance with the provided properties. Use the test harness to get an instance with the proper delegate.- Parameters:
count
- the count.delegate
- the delegate.- Since:
- 2.1.16
-
-
Method Detail
-
await
public boolean await(int timeout) throws InterruptedException
Wait for the latch to count down.- Parameters:
timeout
- the timeout in seconds.- Returns:
- the result of awaiting on the latch; true if counted down.
- Throws:
InterruptedException
- if the thread is interrupted.- Since:
- 2.1.16
-
getLatch
public CountDownLatch getLatch()
-
getExceptions
@Nullable public Collection<Exception> getExceptions()
Return the exceptions thrown.- Returns:
- the exceptions.
- Since:
- 2.2.3
-
-