User: user57  
  Date: 01/07/03 20:41:02

  Modified:    src/main/org/jboss/test/jmsra/test RaTest.java
  Log:
   o Make the destination flushing look less like the test header/ok footer.
   o Allow flush to handle messages that do not have the NR field.
   o Briefly documented what echo (ok most) of the tests are supposed to do.
  
  Revision  Changes    Path
  1.5       +26 -21    jbosstest/src/main/org/jboss/test/jmsra/test/RaTest.java
  
  Index: RaTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/jmsra/test/RaTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RaTest.java       2001/07/04 01:39:30     1.4
  +++ RaTest.java       2001/07/04 03:41:02     1.5
  @@ -26,6 +26,7 @@
   import javax.jms.Session;
   
   import junit.framework.TestCase;
  +import junit.framework.Assert;
   
   import org.jboss.test.jmsra.bean.*;
   
  @@ -36,7 +37,7 @@
    *
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Peter Antman</a>
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Jason Dillon</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public abstract class RaTest
       extends TestCase
  @@ -113,21 +114,15 @@
        * @param timeout   The time to wait for a message.
        *
        * @return  Publisher.JMS_MESSAGE_NR int property or -1 if no message
  -     *          was received (or it is invalid).
  +     *          was received.
        */
       protected int getJmsMessage(long timeout) throws Exception {
           Message msg = consumer.receive(timeout);
           if (msg != null) {
               System.out.println("Recived message: " + msg);
  -            try {
  -                int nr = msg.getIntProperty(Publisher.JMS_MESSAGE_NR);
  -                System.out.println("nr: " + nr);
  -                return nr;
  -            }
  -            catch (Exception e) {
  -                System.out.println("Invalid message, no NR");
  -                return -1;
  -            }
  +         int nr = msg.getIntProperty(Publisher.JMS_MESSAGE_NR);
  +         System.out.println("nr: " + nr);
  +         return nr;
           }
           else {
               System.out.println("NO message recived");
  @@ -135,13 +130,23 @@
           }
       }
       
  +    /**
  +     * Flush the destiniation so we know that it contains no
  +     * messages which might mess up the test.
  +     */
       protected void flush() throws Exception {
  -        System.out.println("---- Flushing Destination");
  -        int nr;
  -        while ((nr = getJmsMessage(FLUSH_TIMEOUT)) != -1) {
  -            System.out.println("ignoring message on queue with nr: " + nr);
  -        }
  -        System.out.println("---- Flushed");
  +        System.out.println(" > Flushing Destination");
  +
  +        int nr = 0;
  +     do {
  +         try {
  +             nr = getJmsMessage(FLUSH_TIMEOUT);
  +         }
  +         catch (Exception ignore) {}
  +     }
  +        while (nr != -1);
  +
  +        System.out.println(" > Flushed");
       }
       
       public void testSimple() throws Exception {
  @@ -149,7 +154,7 @@
           System.out.println("Verify simple send of message");
           publisher.simple(1);
   
  -        assert(1 == getJmsMessage());
  +     Assert.assertEquals(1, getJmsMessage());
           printOK();
       }
   
  @@ -158,7 +163,7 @@
           System.out.println("Verify simple failed transaction");
           publisher.simpleFail(2);
   
  -        assert(-1 == getJmsMessage());
  +        Assert.assertEquals(-1, getJmsMessage());
           printOK();
       }
   
  @@ -167,7 +172,7 @@
           System.out.println("Verify bean ok");
           publisher.beanOk(3);
   
  -        assert(3 == getJmsMessage());
  +        Assert.assertEquals(3, getJmsMessage());
           printOK();
       }
   
  @@ -180,7 +185,7 @@
           }
           catch (Exception ignore) {}
   
  -        assert(-1 == getJmsMessage());
  +        Assert.assertEquals(-1, getJmsMessage());
           printOK();
       }
   }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to