NO-JIRA: Trivial test fixes
This commit is contained in:
parent
2968e0a7da
commit
303d97c76d
|
@ -29,6 +29,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
|||
import org.apache.activemq.artemis.core.server.Queue;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.artemis.tests.util.Wait;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -506,7 +507,7 @@ public class LVQTest extends ActiveMQTestBase {
|
|||
|
||||
@Test
|
||||
public void testScheduledMessages() throws Exception {
|
||||
final long DELAY_TIME = 5000;
|
||||
final long DELAY_TIME = 10;
|
||||
final int MESSAGE_COUNT = 5;
|
||||
Queue queue = server.locateQueue(qName1);
|
||||
ClientProducer producer = clientSession.createProducer(address);
|
||||
|
@ -518,25 +519,16 @@ public class LVQTest extends ActiveMQTestBase {
|
|||
m.setDurable(true);
|
||||
m.putStringProperty(Message.HDR_LAST_VALUE_NAME, rh);
|
||||
timeSent = System.currentTimeMillis();
|
||||
m.putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, timeSent + DELAY_TIME);
|
||||
m.putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, timeSent + (i * DELAY_TIME));
|
||||
producer.send(m);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
|
||||
// allow schedules to elapse so the messages will be delivered to the queue
|
||||
long start = System.currentTimeMillis();
|
||||
while (queue.getScheduledCount() > 0 && System.currentTimeMillis() - start <= DELAY_TIME) {
|
||||
Thread.sleep(50);
|
||||
}
|
||||
|
||||
assertTrue(queue.getScheduledCount() == 0);
|
||||
Wait.waitFor(() -> queue.getScheduledCount() == 0);
|
||||
|
||||
clientSession.start();
|
||||
ClientMessage m = consumer.receive(DELAY_TIME);
|
||||
ClientMessage m = consumer.receive(5000);
|
||||
assertNotNull(m);
|
||||
long actualDelay = System.currentTimeMillis() - timeSent + 50;
|
||||
assertTrue(actualDelay >= DELAY_TIME);
|
||||
m.acknowledge();
|
||||
assertEquals(m.getBodyBuffer().readString(), "m" + (MESSAGE_COUNT - 1));
|
||||
assertEquals(0, queue.getScheduledCount());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue