private void ensureEquivalent(Message m1, Message m2) throws JMSException
public static void ensureEquivalent(Message m1, Message m2) throws JMSException
   private void ensureEquivalent(Message m1, Message m2) throws JMSException   {      assertTrue(m1 != m2);      assertEquals(m1.getJMSMessageID(), m2.getJMSMessageID());      assertEquals(m1.getJMSTimestamp(), m2.getJMSTimestamp());      byte[] corrIDBytes = null;      String corrIDString = null;      try      {         corrIDBytes = m1.getJMSCorrelationIDAsBytes();      }      catch(JMSException e)      {         // correlation ID specified as String         corrIDString = m1.getJMSCorrelationID();      }      if (corrIDBytes != null)      {         assertTrue(Arrays.equals(corrIDBytes, m2.getJMSCorrelationIDAsBytes()));      }      else if (corrIDString != null)      {         assertEquals(corrIDString, m2.getJMSCorrelationID());      }      else      {         // no correlation id         try         {            byte[] corrID2 = m2.getJMSCorrelationIDAsBytes();            assertNull(corrID2);         }         catch(JMSException e)         {            // correlatin ID specified as String            String corrID2 = m2.getJMSCorrelationID();            assertNull(corrID2);         }      }      assertEquals(m1.getJMSReplyTo(), m2.getJMSReplyTo());      assertEquals(m1.getJMSDestination(), m2.getJMSDestination());      assertEquals(m1.getJMSDeliveryMode(), m2.getJMSDeliveryMode());      assertEquals(m1.getJMSRedelivered(), m2.getJMSRedelivered());      assertEquals(m1.getJMSType(), m2.getJMSType());      assertEquals(m1.getJMSExpiration(), m2.getJMSExpiration());      assertEquals(m1.getJMSPriority(), m2.getJMSPriority());      int m1PropertyCount = 0, m2PropertyCount = 0;      for(Enumeration p = m1.getPropertyNames(); p.hasMoreElements(); m1PropertyCount++)      {         p.nextElement();      }      for(Enumeration p = m2.getPropertyNames(); p.hasMoreElements(); m2PropertyCount++)      {         p.nextElement();      }      assertEquals(m1PropertyCount, m2PropertyCount);      for(Enumeration props = m1.getPropertyNames(); props.hasMoreElements(); )      {         boolean found = false;         String name = (String)props.nextElement();         boolean booleanProperty = false;         try         {            booleanProperty = m1.getBooleanProperty(name);            found = true;         }         catch(JMSException e)         {            // not a boolean         }         if (found)         {            assertEquals(booleanProperty, m2.getBooleanProperty(name));            continue;         }         byte byteProperty = 0;         try         {            byteProperty = m1.getByteProperty(name);            found = true;         }         catch(JMSException e)         {            // not a byte         }         if (found)         {            assertEquals(byteProperty, m2.getByteProperty(name));            continue;         }         short shortProperty = 0;         try         {            shortProperty = m1.getShortProperty(name);            found = true;         }         catch(JMSException e)         {            // not a short         }         if (found)         {            assertEquals(shortProperty, m2.getShortProperty(name));            continue;         }         int intProperty = 0;         try         {            intProperty = m1.getIntProperty(name);            found = true;         }         catch(JMSException e)         {            // not a int         }         if (found)         {            assertEquals(intProperty, m2.getIntProperty(name));            continue;         }         long longProperty = 0;         try         {            longProperty = m1.getLongProperty(name);            found = true;         }         catch(JMSException e)         {            // not a long         }         if (found)         {            assertEquals(longProperty, m2.getLongProperty(name));            continue;         }         float floatProperty = 0;         try         {            floatProperty = m1.getFloatProperty(name);            found = true;         }         catch(JMSException e)         {            // not a float         }         if (found)         {            assertTrue(floatProperty == m2.getFloatProperty(name));            continue;         }         double doubleProperty = 0;         try         {            doubleProperty = m1.getDoubleProperty(name);            found = true;         }         catch(JMSException e)         {            // not a double         }         if (found)         {            assertTrue(doubleProperty == m2.getDoubleProperty(name));            continue;         }         String stringProperty = null;         try         {            stringProperty = m1.getStringProperty(name);            found = true;         }         catch(JMSException e)         {            // not a String         }         if (found)         {            assertEquals(stringProperty, m2.getStringProperty(name));            continue;         }         fail("Cannot identify property " + name);      }   }