Class LatchCountDownAndCallRealMethodAnswer
- java.lang.Object
-
- org.mockito.internal.stubbing.defaultanswers.ForwardsInvocations
-
- org.springframework.amqp.rabbit.test.mockito.LatchCountDownAndCallRealMethodAnswer
-
- All Implemented Interfaces:
java.io.Serializable
,org.mockito.stubbing.Answer<java.lang.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, java.lang.Object delegate)
Get an instance with the provided properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
answer(org.mockito.invocation.InvocationOnMock invocation)
boolean
await(int timeout)
Wait for the latch to count down.java.util.Collection<java.lang.Exception>
getExceptions()
Return the exceptions thrown.java.util.concurrent.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 java.lang.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
-
answer
public java.lang.Object answer(org.mockito.invocation.InvocationOnMock invocation) throws java.lang.Throwable
- Specified by:
answer
in interfaceorg.mockito.stubbing.Answer<java.lang.Object>
- Overrides:
answer
in classorg.mockito.internal.stubbing.defaultanswers.ForwardsInvocations
- Throws:
java.lang.Throwable
-
await
public boolean await(int timeout) throws java.lang.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:
java.lang.InterruptedException
- if the thread is interrupted.- Since:
- 2.1.16
-
getLatch
public java.util.concurrent.CountDownLatch getLatch()
-
getExceptions
@Nullable public java.util.Collection<java.lang.Exception> getExceptions()
Return the exceptions thrown.- Returns:
- the exceptions.
- Since:
- 2.2.3
-
-