示例#1
0
 /**
  * Waits for listen_thread to set run to true. Use this when running Server.startThread and you
  * want to ensure the ListenThread is ready to accept connections before continuing.
  *
  * @param server The Server to check the listen_thread on.
  */
 private void waitListenThreadStart(Server server) {
   boolean loop = true;
   Timing new_timer = new Timing();
   while (loop) {
     if (server.getListenThread().getRun() || new_timer.getTime() > timeout) {
       loop = false;
     }
   }
   Assert.assertTrue(server.getListenThread().getRun(), "ListenThread did not start in time");
 }
示例#2
0
 /**
  * Checks the state of the specified Server. Use this when waiting for a Server to finish closing.
  *
  * @param server The Server to check the state of.
  * @param state The state expected on the Server.
  */
 private void waitServerState(Server server, int state) {
   boolean loop = true;
   Timing new_timer = new Timing();
   while (loop) {
     if (server.getState() == state || new_timer.getTime() > timeout) {
       loop = false;
     }
   }
   Assert.assertEquals(server.getState(), state, "Server state was not set in time");
 }
示例#3
0
 /**
  * Ensures the queue_list attribute of Server is not empty.
  *
  * @param server The Server to check queue_list on.
  */
 private void waitMessageQueueAddNotEmpty(Server server) {
   boolean loop = true;
   Timing new_timer = new Timing();
   while (loop) {
     if (!server.getQueueList().isEmpty() || new_timer.getTime() > timeout) {
       loop = false;
     }
   }
   Assert.assertFalse(server.getQueueList().isEmpty(), "MessageQueue was not constructed");
 }
示例#4
0
 /**
  * Checks the state of a MessageQueue on a Server. Use this when waiting for a new MessageQueue to
  * start before continuing, or waiting for a MessageQueue to register that it should be
  * disconnected.
  *
  * @param server The Server containing the MessageQueue.
  * @param hash the hash of the MessageQueue.
  * @param state the state expected on the MessageQueue.
  */
 private void waitMessageQueueState(Server server, String hash, int state) {
   boolean loop = true;
   Timing new_timer = new Timing();
   while (loop) {
     if (server.getQueueList().get(hash).getRun() == state || new_timer.getTime() > timeout) {
       loop = false;
     }
   }
   Assert.assertEquals(
       server.getQueueList().get(hash).getRun(),
       state,
       "MessageQueue state was not set correctly");
 }