summaryrefslogtreecommitdiff
path: root/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java')
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java25
1 files changed, 20 insertions, 5 deletions
diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java
index f30e4664ff..6720047cd1 100644
--- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java
+++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java
@@ -20,6 +20,7 @@
package org.apache.qpid.disttest.client;
import static org.mockito.Matchers.argThat;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -28,14 +29,13 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
-import junit.framework.TestCase;
-
import org.apache.qpid.disttest.DistributedTestException;
import org.apache.qpid.disttest.message.ParticipantResult;
+import org.apache.qpid.test.utils.QpidTestCase;
import org.mockito.ArgumentMatcher;
import org.mockito.InOrder;
-public class ParticipantExecutorTest extends TestCase
+public class ParticipantExecutorTest extends QpidTestCase
{
private static final ResultHasError HAS_ERROR = new ResultHasError();
private static final String CLIENT_NAME = "CLIENT_NAME";
@@ -69,8 +69,8 @@ public class ParticipantExecutorTest extends TestCase
InOrder inOrder = inOrder(_participant, _client);
inOrder.verify(_participant).doIt(CLIENT_NAME);
- inOrder.verify(_client).sendResults(_mockResult);
inOrder.verify(_participant).releaseResources();
+ inOrder.verify(_client).sendResults(_mockResult);
}
public void testParticipantThrowsException() throws Exception
@@ -82,13 +82,28 @@ public class ParticipantExecutorTest extends TestCase
InOrder inOrder = inOrder(_participant, _client);
inOrder.verify(_participant).doIt(CLIENT_NAME);
+ inOrder.verify(_participant).releaseResources();
inOrder.verify(_client).sendResults(argThat(HAS_ERROR));
+ }
+
+ public void testReleaseResourcesThrowsException() throws Exception
+ {
+ when(_participant.doIt(CLIENT_NAME)).thenReturn(_mockResult);
+ doThrow(DistributedTestException.class).when(_participant).releaseResources();
+
+ _participantExecutor.start(_client);
+
+ InOrder inOrder = inOrder(_participant, _client);
+
+ inOrder.verify(_participant).doIt(CLIENT_NAME);
inOrder.verify(_participant).releaseResources();
+
+ // check that sendResults is called even though releaseResources threw an exception
+ inOrder.verify(_client).sendResults(_mockResult);
}
public void testThreadNameAndDaemonness() throws Exception
{
-
ThreadPropertyReportingParticipant participant = new ThreadPropertyReportingParticipant(PARTICIPANT_NAME);
_participantExecutor = new ParticipantExecutor(participant);