You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by lq...@apache.org on 2015/11/12 14:10:45 UTC

svn commit: r1714037 - in /qpid/java/trunk/perftests/src: main/java/org/apache/qpid/disttest/client/ test/java/org/apache/qpid/disttest/client/

Author: lquack
Date: Thu Nov 12 13:10:45 2015
New Revision: 1714037

URL: http://svn.apache.org/viewvc?rev=1714037&view=rev
Log:
QPID-6804: [Java Perftests] Change ProducerParticipant to continue sending messages until test ends.

Added:
    qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ResultReporter.java
      - copied, changed from r1714011, qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/Participant.java
Modified:
    qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/Client.java
    qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ConsumerParticipant.java
    qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/Participant.java
    qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java
    qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ProducerParticipant.java
    qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ClientTest.java
    qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java
    qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java
    qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ProducerParticipantTest.java

Modified: qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/Client.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/Client.java?rev=1714037&r1=1714036&r2=1714037&view=diff
==============================================================================
--- qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/Client.java (original)
+++ qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/Client.java Thu Nov 12 13:10:45 2015
@@ -40,7 +40,7 @@ import org.apache.qpid.disttest.message.
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class Client
+public class Client implements ResultReporter
 {
     private static final Logger LOGGER = LoggerFactory.getLogger(Client.class);
 
@@ -182,7 +182,7 @@ public class Client
                 _clientJmsDelegate.startConnections();
                 for (final ParticipantExecutor executor : _participantRegistry.executors())
                 {
-                    executor.start(this);
+                    executor.start(getClientName(), this);
                 }
             }
             catch (final Exception e)
@@ -210,6 +210,10 @@ public class Client
         if (_state.compareAndSet(ClientState.RUNNING_TEST, ClientState.READY))
         {
             LOGGER.debug("Tearing down test on client: " + _clientJmsDelegate.getClientName());
+            for (Participant participant : _participants)
+            {
+                participant.stopTest();
+            }
 
             _clientJmsDelegate.tearDownTest();
         }
@@ -222,7 +226,8 @@ public class Client
         _participants.clear();
     }
 
-    public void sendResults(ParticipantResult testResult)
+    @Override
+    public void reportResult(final ParticipantResult testResult)
     {
         _clientJmsDelegate.sendResponseMessage(testResult);
         LOGGER.debug("Sent test results " + testResult);

Modified: qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ConsumerParticipant.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ConsumerParticipant.java?rev=1714037&r1=1714036&r2=1714037&view=diff
==============================================================================
--- qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ConsumerParticipant.java (original)
+++ qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ConsumerParticipant.java Thu Nov 12 13:10:45 2015
@@ -84,7 +84,7 @@ public class ConsumerParticipant impleme
     }
 
     @Override
-    public ParticipantResult doIt(String registeredClientName) throws Exception
+    public void startTest(String registeredClientName, ResultReporter resultReporter) throws Exception
     {
         final int acknowledgeMode = _jmsDelegate.getAcknowledgeMode(_command.getSessionName());
         final String providerVersion = _jmsDelegate.getProviderVersion(_command.getSessionName());
@@ -134,8 +134,7 @@ public class ConsumerParticipant impleme
                 _messageLatencies,
                 providerVersion,
                 protocolVersion);
-
-        return result;
+        resultReporter.reportResult(result);
     }
 
     @Override
@@ -144,6 +143,12 @@ public class ConsumerParticipant impleme
         _collectingData.set(true);
     }
 
+    @Override
+    public void stopTest()
+    {
+        // noop
+    }
+
     private void synchronousRun()
     {
         LOGGER.debug("Consumer {} about to consume messages", getName());
@@ -250,7 +255,7 @@ public class ConsumerParticipant impleme
 
     /**
      * Intended to be called from a {@link MessageListener}. Updates {@link #_asyncRunHasFinished} if
-     * no more messages should be processed, causing {@link #doIt(String)} to exit.
+     * no more messages should be processed, causing {@link Participant#startTest(String, ResultReporter)} to exit.
      */
     public void processAsyncMessage(Message message)
     {

Modified: qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/Participant.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/Participant.java?rev=1714037&r1=1714036&r2=1714037&view=diff
==============================================================================
--- qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/Participant.java (original)
+++ qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/Participant.java Thu Nov 12 13:10:45 2015
@@ -18,11 +18,11 @@
  */
 package org.apache.qpid.disttest.client;
 
-import org.apache.qpid.disttest.message.ParticipantResult;
 
 public interface Participant
 {
-    ParticipantResult doIt(String registeredClientName) throws Exception;
+    void startTest(String registeredClientName, ResultReporter resultReporter) throws Exception;
+    void stopTest();
 
     void releaseResources();
 

Modified: qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java?rev=1714037&r1=1714036&r2=1714037&view=diff
==============================================================================
--- qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java (original)
+++ qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java Thu Nov 12 13:10:45 2015
@@ -23,7 +23,6 @@ import java.util.concurrent.Executor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.qpid.disttest.message.ParticipantResult;
 
 public class ParticipantExecutor
 {
@@ -33,7 +32,8 @@ public class ParticipantExecutor
     private final Participant _participant;
     private final ParticipantResultFactory _factory;
 
-    private Client _client;
+    private String _clientName;
+    private ResultReporter _resultReporter;
 
     public ParticipantExecutor(Participant participant, Executor executor)
     {
@@ -44,10 +44,13 @@ public class ParticipantExecutor
 
     /**
      * Schedules the test participant to be run in a background thread.
+     * @param clientName
+     * @param resultReporter
      */
-    public void start(Client client)
+    public void start(String clientName, ResultReporter resultReporter)
     {
-        _client = client;
+        _clientName = clientName;
+        _resultReporter = resultReporter;
 
         LOGGER.debug("Starting test participant in background thread: {} ", this);
         _executor.execute(new ParticipantRunnable());
@@ -79,20 +82,19 @@ public class ParticipantExecutor
 
         private void runParticipantAndSendResults()
         {
-            ParticipantResult result = null;
             try
             {
                 if (LOGGER.isDebugEnabled())
                 {
                     LOGGER.debug("About to run participant " + _participant);
                 }
-                result = _participant.doIt(_client.getClientName());
+                _participant.startTest(_clientName, _resultReporter);
             }
             catch (Exception t)
             {
                 String errorMessage = "Unhandled error: " + t.getMessage();
                 LOGGER.error(errorMessage, t);
-                result = _factory.createForError(_participant.getName(), _client.getClientName(), errorMessage);
+                _resultReporter.reportResult(_factory.createForError(_participant.getName(), _clientName, errorMessage));
             }
             finally
             {
@@ -104,8 +106,6 @@ public class ParticipantExecutor
                 {
                     LOGGER.error("Participant " + _participant + " unable to release resources", e);
                 }
-
-                _client.sendResults(result);
             }
         }
     }
@@ -115,7 +115,7 @@ public class ParticipantExecutor
     {
         return "ParticipantExecutor[" +
                "participantName=" + _participant.getName() +
-               ", client=" + _client +
+               ", client=" + _clientName +
                ']';
     }
 }

Modified: qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ProducerParticipant.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ProducerParticipant.java?rev=1714037&r1=1714036&r2=1714037&view=diff
==============================================================================
--- qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ProducerParticipant.java (original)
+++ qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ProducerParticipant.java Thu Nov 12 13:10:45 2015
@@ -44,12 +44,14 @@ public class ProducerParticipant impleme
 
     private final ParticipantResultFactory _resultFactory;
 
-    private final CountDownLatch _collectingDataLatch = new CountDownLatch(1);
+    private final CountDownLatch _startDataCollectionLatch = new CountDownLatch(1);
+    private final CountDownLatch _stopTestLatch = new CountDownLatch(1);
     private final long _maximumDuration;
     private final long _numberOfMessages;
     private final int _batchSize;
     private final int _acknowledgeMode;
     private final RateLimiter _rateLimiter;
+    private volatile boolean _collectData = false;
 
     public ProducerParticipant(final ClientJmsDelegate jmsDelegate, final CreateProducerCommand command)
     {
@@ -65,10 +67,8 @@ public class ProducerParticipant impleme
     }
 
     @Override
-    public ParticipantResult doIt(String registeredClientName) throws Exception
+    public void startTest(String registeredClientName, ResultReporter resultReporter) throws Exception
     {
-        final String providerVersion = _jmsDelegate.getProviderVersion(_command.getSessionName());
-        final String protocolVersion = _jmsDelegate.getProtocolVersion(_command.getSessionName());
 
         long startTime = 0;
         Message lastPublishedMessage = null;
@@ -79,14 +79,14 @@ public class ProducerParticipant impleme
         LOGGER.debug("Producer {} about to send messages. Duration limit: {} ms Message Limit : {}",
                     getName(), _maximumDuration, _numberOfMessages);
 
-        while (true)
+        while (_stopTestLatch.getCount() != 0)
         {
             if (_rateLimiter != null)
             {
                 _rateLimiter.acquire();
             }
 
-            if (_collectingDataLatch.getCount() == 0)
+            if (_collectData)
             {
                 if (startTime == 0)
                 {
@@ -96,7 +96,13 @@ public class ProducerParticipant impleme
                 if ((_maximumDuration > 0 && System.currentTimeMillis() - startTime >= _maximumDuration) ||
                     (_numberOfMessages > 0 && numberOfMessagesSent >= _numberOfMessages))
                 {
-                    break;
+                    ParticipantResult result = finaliseResults(registeredClientName,
+                                                               startTime,
+                                                               numberOfMessagesSent,
+                                                               totalPayloadSizeOfAllMessagesSent,
+                                                               allProducedPayloadSizes);
+                    resultReporter.reportResult(result);
+                    _collectData = false;
                 }
 
                 lastPublishedMessage = _jmsDelegate.sendNextMessage(_command);
@@ -133,14 +139,21 @@ public class ProducerParticipant impleme
                 }
                 if (_rateLimiter == null && _maximumDuration == 0)
                 {
-                    if (!_collectingDataLatch.await(1, TimeUnit.SECONDS))
+                    if (!_startDataCollectionLatch.await(1, TimeUnit.SECONDS))
                     {
                         LOGGER.debug("Producer {} still waiting for collectingData command from coordinator", getName());
                     }
                 }
             }
         }
+    }
 
+    private ParticipantResult finaliseResults(final String registeredClientName,
+                                              final long startTime,
+                                              final int numberOfMessagesSent,
+                                              final long totalPayloadSizeOfAllMessagesSent,
+                                              final NavigableSet<Integer> allProducedPayloadSizes)
+    {
         // commit the remaining batch messages
         if (_batchSize > 0 && numberOfMessagesSent % _batchSize != 0)
         {
@@ -153,6 +166,8 @@ public class ProducerParticipant impleme
                     getName(), numberOfMessagesSent);
 
         Date start = new Date(startTime);
+        String providerVersion = _jmsDelegate.getProviderVersion(_command.getSessionName());
+        String protocolVersion = _jmsDelegate.getProtocolVersion(_command.getSessionName());
         int payloadSize = getPayloadSizeForResultIfConstantOrZeroOtherwise(allProducedPayloadSizes);
 
         return _resultFactory.createForProducer(
@@ -172,7 +187,14 @@ public class ProducerParticipant impleme
     @Override
     public void startDataCollection()
     {
-        _collectingDataLatch.countDown();
+        _collectData = true;
+        _startDataCollectionLatch.countDown();
+    }
+
+    @Override
+    public void stopTest()
+    {
+        _stopTestLatch.countDown();
     }
 
     private int getPayloadSizeForResultIfConstantOrZeroOtherwise(NavigableSet<Integer> allPayloadSizes)

Copied: qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ResultReporter.java (from r1714011, qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/Participant.java)
URL: http://svn.apache.org/viewvc/qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ResultReporter.java?p2=qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ResultReporter.java&p1=qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/Participant.java&r1=1714011&r2=1714037&rev=1714037&view=diff
==============================================================================
--- qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/Participant.java (original)
+++ qpid/java/trunk/perftests/src/main/java/org/apache/qpid/disttest/client/ResultReporter.java Thu Nov 12 13:10:45 2015
@@ -16,17 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.qpid.disttest.client;
 
 import org.apache.qpid.disttest.message.ParticipantResult;
 
-public interface Participant
+interface ResultReporter
 {
-    ParticipantResult doIt(String registeredClientName) throws Exception;
-
-    void releaseResources();
-
-    String getName();
-
-    void startDataCollection();
+    void reportResult(ParticipantResult result);
 }

Modified: qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ClientTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ClientTest.java?rev=1714037&r1=1714036&r2=1714037&view=diff
==============================================================================
--- qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ClientTest.java (original)
+++ qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ClientTest.java Thu Nov 12 13:10:45 2015
@@ -20,6 +20,7 @@
 package org.apache.qpid.disttest.client;
 
 import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
 import static org.mockito.Matchers.isA;
 import static org.mockito.Mockito.inOrder;
 import static org.mockito.Mockito.mock;
@@ -115,7 +116,7 @@ public class ClientTest extends QpidTest
 
         InOrder inOrder = Mockito.inOrder(_delegate, _participantExecutor);
         inOrder.verify(_delegate).startConnections();
-        inOrder.verify(_participantExecutor).start(_client);
+        inOrder.verify(_participantExecutor).start(eq(_client.getClientName()), any(ResultReporter.class));
     }
 
     public void testTearDownTest() throws Exception
@@ -135,7 +136,7 @@ public class ClientTest extends QpidTest
     public void testResults() throws Exception
     {
         ParticipantResult testResult = mock(ParticipantResult.class);
-        _client.sendResults(testResult);
+        _client.reportResult(testResult);
         verify(_delegate).sendResponseMessage(testResult);
     }
 

Modified: qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java?rev=1714037&r1=1714036&r2=1714037&view=diff
==============================================================================
--- qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java (original)
+++ qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java Thu Nov 12 13:10:45 2015
@@ -19,28 +19,19 @@
 package org.apache.qpid.disttest.client;
 
 import static org.apache.qpid.disttest.client.ParticipantTestHelper.assertExpectedConsumerResults;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyString;
 import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.inOrder;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import java.util.Collection;
-
 import javax.jms.Message;
 import javax.jms.Session;
 
-import org.apache.qpid.disttest.DistributedTestException;
 import org.apache.qpid.disttest.jms.ClientJmsDelegate;
-import org.apache.qpid.disttest.message.ConsumerParticipantResult;
 import org.apache.qpid.disttest.message.CreateConsumerCommand;
 import org.apache.qpid.disttest.message.ParticipantResult;
 import org.apache.qpid.test.utils.QpidTestCase;
-import org.mockito.InOrder;
+
 
 public class ConsumerParticipantTest extends QpidTestCase
 {
@@ -55,7 +46,6 @@ public class ConsumerParticipantTest ext
     private final CreateConsumerCommand _command = new CreateConsumerCommand();
     private ClientJmsDelegate _delegate;
     private ConsumerParticipant _consumerParticipant;
-    private InOrder _inOrder;
 
     /** used to check start/end time of results */
     private long _testStartTime;
@@ -65,7 +55,6 @@ public class ConsumerParticipantTest ext
     {
         super.setUp();
         _delegate = mock(ClientJmsDelegate.class);
-        _inOrder = inOrder(_delegate);
 
         _command.setSessionName(SESSION_NAME1);
         _command.setParticipantName(PARTICIPANT_NAME1);
@@ -86,9 +75,18 @@ public class ConsumerParticipantTest ext
     {
 
         _consumerParticipant.startDataCollection();
-        ParticipantResult result = _consumerParticipant.doIt(CLIENT_NAME);
+        final ParticipantResult[] result = new ParticipantResult[1];
+        _consumerParticipant.startTest(CLIENT_NAME, new ResultReporter()
+        {
+            @Override
+            public void reportResult(final ParticipantResult theResult)
+            {
+                result[0] = theResult;
+                _consumerParticipant.stopTest();
+            }
+        });
 
-        assertExpectedConsumerResults(result, PARTICIPANT_NAME1, CLIENT_NAME, _testStartTime,
+        assertExpectedConsumerResults(result[0], PARTICIPANT_NAME1, CLIENT_NAME, _testStartTime,
                                       Session.CLIENT_ACKNOWLEDGE, null, null, PAYLOAD_SIZE_PER_MESSAGE, null, MAXIMUM_DURATION);
 
         verify(_delegate, atLeastOnce()).consumeMessage(PARTICIPANT_NAME1, RECEIVE_TIMEOUT);

Modified: qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java?rev=1714037&r1=1714036&r2=1714037&view=diff
==============================================================================
--- qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java (original)
+++ qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java Thu Nov 12 13:10:45 2015
@@ -19,21 +19,21 @@
 
 package org.apache.qpid.disttest.client;
 
+import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.argThat;
+import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.inOrder;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
-import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executor;
-import java.util.concurrent.TimeUnit;
+
+import org.mockito.ArgumentMatcher;
+import org.mockito.InOrder;
 
 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 QpidTestCase
 {
@@ -41,67 +41,42 @@ public class ParticipantExecutorTest ext
     private static final String CLIENT_NAME = "CLIENT_NAME";
     private static final String PARTICIPANT_NAME = "PARTICIPANT_NAME";
     private ParticipantExecutor _participantExecutor = null;
-    private Client _client = null;
     private Participant _participant = null;
-    private ParticipantResult _mockResult;
+    private ResultReporter _resultReporter;
 
     @Override
     protected void setUp() throws Exception
     {
         super.setUp();
 
-        _client = mock(Client.class);
-        when(_client.getClientName()).thenReturn(CLIENT_NAME);
         _participant = mock(Participant.class);
 
         _participantExecutor = new ParticipantExecutor(_participant, new SynchronousExecutor());
 
-        _mockResult = mock(ParticipantResult.class);
+        _resultReporter = mock(ResultReporter.class);
     }
 
     public void testStart() throws Exception
     {
-        when(_participant.doIt(CLIENT_NAME)).thenReturn(_mockResult);
+        _participantExecutor.start(CLIENT_NAME, _resultReporter);
+        InOrder inOrder = inOrder(_participant);
 
-        _participantExecutor.start(_client);
-
-        InOrder inOrder = inOrder(_participant, _client);
-
-        inOrder.verify(_participant).doIt(CLIENT_NAME);
+        inOrder.verify(_participant).startTest(CLIENT_NAME, _resultReporter);
         inOrder.verify(_participant).releaseResources();
-        inOrder.verify(_client).sendResults(_mockResult);
     }
 
     public void testParticipantThrowsException() throws Exception
     {
-        when(_participant.doIt(CLIENT_NAME)).thenThrow(DistributedTestException.class);
+        doThrow(DistributedTestException.class).when(_participant).startTest(CLIENT_NAME, _resultReporter);
+        _participantExecutor.start(CLIENT_NAME, _resultReporter);
 
-        _participantExecutor.start(_client);
+        InOrder inOrder = inOrder(_participant, _resultReporter);
 
-        InOrder inOrder = inOrder(_participant, _client);
-
-        inOrder.verify(_participant).doIt(CLIENT_NAME);
+        inOrder.verify(_participant).startTest(CLIENT_NAME, _resultReporter);
+        inOrder.verify(_resultReporter).reportResult(argThat(HAS_ERROR));
         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);
-    }
-
-
     /** avoids our unit test needing to use multiple threads */
     private final class SynchronousExecutor implements Executor
     {

Modified: qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ProducerParticipantTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ProducerParticipantTest.java?rev=1714037&r1=1714036&r2=1714037&view=diff
==============================================================================
--- qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ProducerParticipantTest.java (original)
+++ qpid/java/trunk/perftests/src/test/java/org/apache/qpid/disttest/client/ProducerParticipantTest.java Thu Nov 12 13:10:45 2015
@@ -21,22 +21,17 @@ package org.apache.qpid.disttest.client;
 import static org.apache.qpid.disttest.client.ParticipantTestHelper.assertExpectedProducerResults;
 import static org.mockito.Matchers.isA;
 import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.inOrder;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import javax.jms.DeliveryMode;
 import javax.jms.Message;
 import javax.jms.Session;
 
-import org.apache.qpid.disttest.DistributedTestException;
 import org.apache.qpid.disttest.jms.ClientJmsDelegate;
 import org.apache.qpid.disttest.message.CreateProducerCommand;
 import org.apache.qpid.disttest.message.ParticipantResult;
 import org.apache.qpid.test.utils.QpidTestCase;
-import org.mockito.InOrder;
 
 public class ProducerParticipantTest extends QpidTestCase
 {
@@ -79,11 +74,28 @@ public class ProducerParticipantTest ext
 
     public void testSendMessagesForDuration() throws Exception
     {
-
         _producer.startDataCollection();
-        ParticipantResult result = _producer.doIt(CLIENT_NAME);
-        assertExpectedProducerResults(result, PARTICIPANT_NAME1, CLIENT_NAME, _testStartTime,
-                                      Session.AUTO_ACKNOWLEDGE, null, null, PAYLOAD_SIZE_PER_MESSAGE, null, (long) MAXIMUM_DURATION);
+        final ParticipantResult[] result = new ParticipantResult[1];
+        ResultReporter resultReporter = new ResultReporter()
+        {
+            @Override
+            public void reportResult(final ParticipantResult theResult)
+            {
+                result[0] = theResult;
+                _producer.stopTest();
+            }
+        };
+        _producer.startTest(CLIENT_NAME, resultReporter);
+        assertExpectedProducerResults(result[0],
+                                      PARTICIPANT_NAME1,
+                                      CLIENT_NAME,
+                                      _testStartTime,
+                                      Session.AUTO_ACKNOWLEDGE,
+                                      null,
+                                      null,
+                                      PAYLOAD_SIZE_PER_MESSAGE,
+                                      null,
+                                      (long) MAXIMUM_DURATION);
 
         verify(_delegate, atLeastOnce()).sendNextMessage(isA(CreateProducerCommand.class));
         verify(_delegate, atLeastOnce()).calculatePayloadSizeFrom(_mockMessage);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org