Package org.jboss.test.messaging.core

Examples of org.jboss.test.messaging.core.SimpleReceiver


         assertTrue(delivery.isDone());
      }

      assertEqualSets(refs, queue.browse());

      SimpleReceiver receiver = new SimpleReceiver("ACKING", SimpleReceiver.ACKING);
      queue.add(receiver);
      queue.deliver();
      assertEquals(10, receiver.getMessages().size());
      for(int i = 0; i < NUMBER_OF_MESSAGES; i++)
      {
         assertEquals(i, ((Message)receiver.getMessages().get(i)).getMessageID());        
      }
      receiver.clear();

      queue.deliver();
      assertEquals(0, receiver.getMessages().size());
   }
View Full Code Here


         // we test only non-recoverable channels now
         return;
      }

      // add an ACKING receiver to the channel
      SimpleReceiver r = new SimpleReceiver("AckingReceiver", SimpleReceiver.ACKING);
      assertTrue(queue.add(r));

      MessageReference ref = createReference(0, false, "payload");
      SimpleDeliveryObserver observer = new SimpleDeliveryObserver();

      // non-transacted send, non-reliable message, one message
      Delivery delivery = queue.handle(observer, ref, null);

      assertTrue(delivery.isDone());
      assertTrue(queue.browse().isEmpty());

      List received = r.getMessages();
      assertEquals(1, received.size());
      Message sm = (Message)received.iterator().next();
      assertFalse(sm.isReliable());
      assertEquals(0, sm.getMessageID());
   }
View Full Code Here

         // we test only non-recoverable channels now
         return;
      }

      // add an ACKING receiver to the channel
      SimpleReceiver r = new SimpleReceiver("AckingReceiver", SimpleReceiver.ACKING);
      assertTrue(queue.add(r));

      SimpleDeliveryObserver observer = new SimpleDeliveryObserver();

      MessageReference[] refs = new MessageReference[NUMBER_OF_MESSAGES];
      for(int i = 0; i < NUMBER_OF_MESSAGES; i++)
      {
         refs[i] = createReference(i, false, "payload" + i);

         // non-transacted send, non-reliable message, multiple messages
         Delivery delivery = queue.handle(observer, refs[i], null);

         assertTrue(delivery.isDone());
      }

      assertTrue(queue.browse().isEmpty());

      List received = r.getMessages();
      assertEqualSets(refs, received);
   }
View Full Code Here

         // we test channels that don't accept reliable messages
         return;
      }

      // add an ACKING receiver to the channel
      SimpleReceiver r = new SimpleReceiver("AckingReceiver", SimpleReceiver.ACKING);
      assertTrue(queue.add(r));

      MessageReference ref = createReference(0, true, "payload");
      SimpleDeliveryObserver observer = new SimpleDeliveryObserver();

      // non-transacted send, reliable message, one message
      Delivery delivery = queue.handle(observer, ref, null);

      assertNull(delivery);

      assertTrue(queue.browse().isEmpty());
      assertTrue(r.getMessages().isEmpty());
   }
View Full Code Here

         // we test channels that accept reliable messages
         return;
      }

      // add an ACKING receiver to the channel
      SimpleReceiver r = new SimpleReceiver("AckingReceiver", SimpleReceiver.ACKING);
      assertTrue(queue.add(r));

      MessageReference ref = createReference(0, true, "payload");
      SimpleDeliveryObserver observer = new SimpleDeliveryObserver();

      // non-transacted send, reliable message, one message
      Delivery delivery = queue.handle(observer, ref, null);

      assertTrue(delivery.isDone());

      assertTrue(queue.browse().isEmpty());

      List received = r.getMessages();
      assertEquals(1, received.size());
      Message sm = (Message)received.iterator().next();
      assertTrue(sm.isReliable());
      assertEquals(0, sm.getMessageID());
   }
View Full Code Here

         // we test channels that don't accept reliable messages
         return;
      }

      // add an ACKING receiver to the channel
      SimpleReceiver r = new SimpleReceiver("AckingReceiver", SimpleReceiver.ACKING);
      assertTrue(queue.add(r));

      SimpleDeliveryObserver observer = new SimpleDeliveryObserver();

      MessageReference[] refs = new MessageReference[NUMBER_OF_MESSAGES];
      for(int i = 0; i < NUMBER_OF_MESSAGES; i++)
      {
         refs[i] = createReference(i, true, "payload" + i);

         // non-transacted send, reliable message, multiple messages
         Delivery delivery = queue.handle(observer, refs[i], null);

         assertNull(delivery);
      }

      assertTrue(queue.browse().isEmpty());
      assertTrue(r.getMessages().isEmpty());
   }
View Full Code Here

         // we test channels that accept reliable messages
         return;
      }

      // add an ACKING receiver to the channel
      SimpleReceiver r = new SimpleReceiver("AckingReceiver", SimpleReceiver.ACKING);
      assertTrue(queue.add(r));

      SimpleDeliveryObserver observer = new SimpleDeliveryObserver();

      MessageReference[] refs = new MessageReference[NUMBER_OF_MESSAGES];
      for(int i = 0; i < NUMBER_OF_MESSAGES; i++)
      {
         refs[i] = createReference(i, true, "payload" + i);

         // non-transacted send, reliable message, multiple messages
         Delivery delivery = queue.handle(observer, refs[i], null);

         assertTrue(delivery.isDone());
      }

      assertTrue(queue.browse().isEmpty());
      assertEqualSets(refs, r.getMessages());
   }
View Full Code Here

         // we test only non-recoverable channels now
         return;
      }

      // add an ACKING receiver to the channel
      SimpleReceiver r = new SimpleReceiver("AckingReceiver", SimpleReceiver.ACKING);
      assertTrue(queue.add(r));

      MessageReference ref = createReference(0, false, "payload");
      SimpleDeliveryObserver observer = new SimpleDeliveryObserver();

      Transaction tx = tr.createTransaction();

      // transacted send, non-reliable message, one message
      // for a transactional send, handle() return value is unspecified
      queue.handle(observer, ref, tx);

      // no messages in the channel
      assertEquals(0, queue.browse().size());

      // no message at the receiver
      assertTrue(r.getMessages().isEmpty());

      tx.commit();

      assertTrue(queue.browse().isEmpty());

      List received = r.getMessages();
      assertEquals(1, received.size());
      Message sm = (Message)received.iterator().next();
      assertFalse(sm.isReliable());
      assertEquals(0, sm.getMessageID());
   }
View Full Code Here

         // we test only non-recoverable channels now
         return;
      }

      // add an ACKING receiver to the channel
      SimpleReceiver r = new SimpleReceiver("AckingReceiver", SimpleReceiver.ACKING);
      assertTrue(queue.add(r));

      SimpleDeliveryObserver observer = new SimpleDeliveryObserver();

      Transaction tx = tr.createTransaction();

      MessageReference[] refs = new MessageReference[NUMBER_OF_MESSAGES];
      for(int i = 0; i < NUMBER_OF_MESSAGES; i++)
      {
         refs[i] = createReference(i, false, "payload" + i);

         // transacted send, non-reliable message, multiple messages
         // for a transactional send, handle() return value is unspecified
         queue.handle(observer, refs[i], tx);
      }

      // no messages in the channel
      assertEquals(0, queue.browse().size());

      // no message at the receiver
      assertTrue(r.getMessages().isEmpty());

      tx.commit();

      assertTrue(queue.browse().isEmpty());
      assertEqualSets(refs, r.getMessages());
   }
View Full Code Here

         // we test channels that don't accept reliable messages
         return;
      }

      // add an ACKING receiver to the channel
      SimpleReceiver r = new SimpleReceiver("AckingReceiver", SimpleReceiver.ACKING);
      assertTrue(queue.add(r));


      MessageReference ref = createReference(0, true, "payload");
      SimpleDeliveryObserver observer = new SimpleDeliveryObserver();

      Transaction tx = tr.createTransaction();

      // transacted send, reliable message, one message
      // for a transactional send, handle() return value is unspecified
      queue.handle(observer, ref, tx);

      // no messages in the channel yet
      assertEquals(0, queue.browse().size());

      // no message at the receiver
      assertTrue(r.getMessages().isEmpty());

      try
      {
         tx.commit();
         fail("this should throw exception");
      }
      catch(Exception e)
      {
         // OK
      }

      // no messages in the channel
      assertEquals(0, queue.browse().size());

      // no message at the receiver
      assertTrue(r.getMessages().isEmpty());
   }
View Full Code Here

TOP

Related Classes of org.jboss.test.messaging.core.SimpleReceiver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.