From 5fbe2f7032d3113bff70dd775555967c992964e5 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 24 Aug 2015 10:53:01 +0000
Subject: [PATCH] AssuredReplicationPluginTest.java: Used ReplicationTestCase.waitForSpecificMsg*(). Code cleanup

---
 opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java |   31 ++++++++++++++-----------------
 1 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
index 7a56c7d..9ee3a1b 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
@@ -832,7 +832,8 @@
    * @param msgType Class of the message we are waiting for.
    * @return The expected message if it comes in time or fails (assertion).
    */
-  protected static <T extends ReplicationMsg> T waitForSpecificMsg(Session session, Class<T> msgType) {
+  protected static <T extends ReplicationMsg> T waitForSpecificMsg(Session session, Class<T> msgType) throws Exception
+  {
     return (T) waitForSpecificMsgs(session, (ReplicationBroker) null, msgType);
   }
 
@@ -843,19 +844,24 @@
    * @param msgType Class of the message we are waiting for.
    * @return The expected message if it comes in time or fails (assertion).
    */
-  protected static <T extends ReplicationMsg> T waitForSpecificMsg(ReplicationBroker broker, Class<T> msgType) {
+  protected static <T extends ReplicationMsg> T waitForSpecificMsg(ReplicationBroker broker, Class<T> msgType)
+      throws Exception
+  {
     return (T) waitForSpecificMsgs(null, broker, msgType);
   }
 
-  protected static ReplicationMsg waitForSpecificMsgs(Session session, Class<?>... msgTypes) {
+  protected static ReplicationMsg waitForSpecificMsgs(Session session, Class<?>... msgTypes) throws Exception
+  {
     return waitForSpecificMsgs(session, null, msgTypes);
   }
 
-  protected static ReplicationMsg waitForSpecificMsgs(ReplicationBroker broker, Class<?>... msgTypes) {
+  protected static ReplicationMsg waitForSpecificMsgs(ReplicationBroker broker, Class<?>... msgTypes) throws Exception
+  {
     return waitForSpecificMsgs(null, broker, msgTypes);
   }
 
   private static ReplicationMsg waitForSpecificMsgs(Session session, ReplicationBroker broker, Class<?>... msgTypes)
+      throws Exception
   {
     assertTrue(session != null || broker != null, "One of Session or ReplicationBroker parameter must not be null");
     assertTrue(session == null || broker == null, "Only one of Session or ReplicationBroker parameter must not be null");
@@ -869,22 +875,13 @@
     while (!timedOut)
     {
       ReplicationMsg replMsg = null;
-      try
+      if (session != null)
       {
-        if (session != null)
-        {
-          replMsg = session.receive();
-        }
-        else if (broker != null)
-        {
-          replMsg = broker.receive();
-        }
+        replMsg = session.receive();
       }
-      catch (Exception ex)
+      else if (broker != null)
       {
-        ex.printStackTrace();
-        fail("Exception waiting for " + msgTypes2 + " message : "
-            + ex.getClass().getName() + " : " + ex.getMessage());
+        replMsg = broker.receive();
       }
 
       if (msgTypes2.contains(replMsg.getClass()))

--
Gitblit v1.10.0