@@ -164,6 +164,8 @@ public boolean isSatisified() throws Exception {
164164 assertTrue (receivedExceptions .isEmpty ());
165165 assertEquals (Integer .valueOf (MESSAGE_COUNT ), Integer .valueOf (receivedMessages .size ()));
166166
167+ waitForIncludedStatsToUpdate ();
168+
167169 //Make sure stats are correct for local -> remote
168170 assertEquals (MESSAGE_COUNT , localBroker .getDestination (includedDestination ).getDestinationStatistics ().getEnqueues ().getCount ());
169171 assertEquals (MESSAGE_COUNT , localBroker .getDestination (includedDestination ).getDestinationStatistics ().getDequeues ().getCount ());
@@ -249,6 +251,24 @@ public boolean isSatisified() throws Exception {
249251 remoteConsumer .close ();
250252 }
251253
254+ private void waitForIncludedStatsToUpdate () throws Exception {
255+ assertTrue ("Included destination stats did not reach expected counts" ,
256+ Wait .waitFor (new Condition () {
257+ @ Override
258+ public boolean isSatisified () throws Exception {
259+ return MESSAGE_COUNT == localBroker .getDestination (includedDestination ).getDestinationStatistics ().getEnqueues ().getCount ()
260+ && MESSAGE_COUNT == localBroker .getDestination (includedDestination ).getDestinationStatistics ().getDequeues ().getCount ()
261+ && MESSAGE_COUNT == localBroker .getDestination (includedDestination ).getDestinationStatistics ().getForwards ().getCount ()
262+ && MESSAGE_COUNT == localBroker .getDestination (includedDestination ).getDestinationStatistics ().getNetworkDequeues ().getCount ()
263+ && 0 == localBroker .getDestination (includedDestination ).getDestinationStatistics ().getNetworkEnqueues ().getCount ()
264+ && MESSAGE_COUNT == remoteBroker .getDestination (includedDestination ).getDestinationStatistics ().getEnqueues ().getCount ()
265+ && 0 == remoteBroker .getDestination (includedDestination ).getDestinationStatistics ().getForwards ().getCount ()
266+ && MESSAGE_COUNT == remoteBroker .getDestination (includedDestination ).getDestinationStatistics ().getNetworkEnqueues ().getCount ()
267+ && 0 == remoteBroker .getDestination (includedDestination ).getDestinationStatistics ().getNetworkDequeues ().getCount ();
268+ }
269+ }, 20000 , 500 ));
270+ }
271+
252272 protected void assertNetworkBridgeStatistics (final long expectedLocalSent , final long expectedRemoteSent ) throws Exception {
253273
254274 final NetworkBridge localBridge = localBroker .getNetworkConnectors ().get (0 ).activeBridges ().iterator ().next ();
0 commit comments