two consumers test for zero prefetch

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@744947 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2009-02-16 15:54:04 +00:00
parent 32d6841a13
commit b0eb9731c0
1 changed files with 19 additions and 0 deletions

View File

@ -136,6 +136,25 @@ public class ZeroPrefetchConsumerTest extends EmbeddedBrokerTestSupport {
answer = (TextMessage)consumer.receiveNoWait(); answer = (TextMessage)consumer.receiveNoWait();
assertNull("Should have not received a message!", answer); assertNull("Should have not received a message!", answer);
} }
public void testTwoConsumers() throws Exception {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(queue);
producer.send(session.createTextMessage("Msg1"));
producer.send(session.createTextMessage("Msg2"));
// now lets receive it
MessageConsumer consumer1 = session.createConsumer(queue);
MessageConsumer consumer2 = session.createConsumer(queue);
TextMessage answer = (TextMessage)consumer1.receiveNoWait();
assertEquals("Should have received a message!", answer.getText(), "Msg1");
answer = (TextMessage)consumer2.receiveNoWait();
assertEquals("Should have received a message!", answer.getText(), "Msg2");
answer = (TextMessage)consumer2.receiveNoWait();
assertNull("Should have not received a message!", answer);
}
protected void setUp() throws Exception { protected void setUp() throws Exception {
bindAddress = "tcp://localhost:61616"; bindAddress = "tcp://localhost:61616";