log.info("** leaving testMessageCountOverFullSize");
   public void testMessageCountOverFullSize() throws Exception   {      InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());      ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");      Connection conn = null;      int fullSize = 10;      int MESSAGE_COUNT = 100;      ServerManagement.deployQueue("QueueMessageCount2", fullSize, fullSize / 2, fullSize / 2 - 1);      ObjectName destObjectName =         new ObjectName("jboss.messaging.destination:service=Queue,name=QueueMessageCount2");      try      {         Queue queue = (Queue)ic.lookup("/queue/QueueMessageCount2");         conn = cf.createConnection();         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);         MessageProducer prod = session.createProducer(queue);         prod.setDeliveryMode(DeliveryMode.PERSISTENT);         // Send all messages to the queue and check messageCount after each send         for(int i = 0; i < MESSAGE_COUNT; i++)         {            TextMessage m = session.createTextMessage("message" + i);            prod.send(m);            int mc = ((Integer)ServerManagement.               getAttribute(destObjectName, "MessageCount")).intValue();            assertEquals(i + 1, mc);         }         // receive messages from queue one by one and check messageCount after each receive         MessageConsumer cons = session.createConsumer(queue);         conn.start();         int receivedCount = 0;         while((cons.receive(2000)) != null)         {            receivedCount++;            int mc = ((Integer)ServerManagement.               getAttribute(destObjectName, "MessageCount")).intValue();             if ((MESSAGE_COUNT - receivedCount)!=mc)             {                 retryForLogs(mc, receivedCount, MESSAGE_COUNT, destObjectName);             }            assertEquals(MESSAGE_COUNT - receivedCount, mc);         }         assertEquals(MESSAGE_COUNT, receivedCount);      }      finally      {         ServerManagement.undeployQueue("QueueMessageCount2");         if (conn != null)         {            conn.close();         }      }   }