git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1441085 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2013-01-31 17:44:04 +00:00
parent b8bbca6773
commit f88b21613b
1 changed files with 106 additions and 103 deletions

View File

@ -33,6 +33,7 @@ public class OptimizedAckTest extends TestSupport {
private static final Logger LOG = LoggerFactory.getLogger(OptimizedAckTest.class);
private ActiveMQConnection connection;
@Override
protected void setUp() throws Exception {
super.setUp();
connection = (ActiveMQConnection) createConnection();
@ -43,6 +44,7 @@ public class OptimizedAckTest extends TestSupport {
connection.setPrefetchPolicy(prefetchPolicy);
}
@Override
protected void tearDown() throws Exception {
connection.close();
super.tearDown();
@ -68,13 +70,14 @@ public class OptimizedAckTest extends TestSupport {
}
}));
for (int i=0; i<10; i++) {
for (int i = 0; i < 10; i++) {
javax.jms.Message msg = consumer.receive(4000);
long inFlightCount = regionBroker.getDestinationStatistics().getInflight().getCount();
assertNotNull(msg);
if (i<7) {
assertEquals("all prefetch is still in flight", 10, regionBroker.getDestinationStatistics().getInflight().getCount());
if (i < 7) {
assertEquals("all prefetch is still in flight", 10, inFlightCount);
} else {
assertTrue("most are acked but 3 remain", Wait.waitFor(new Wait.Condition(){
assertTrue("most are acked but 3 remain", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
LOG.info("inflight count: " + regionBroker.getDestinationStatistics().getInflight().getCount());
@ -105,15 +108,15 @@ public class OptimizedAckTest extends TestSupport {
}
}));
for (int i=0; i<10; i++) {
for (int i = 0; i < 10; i++) {
Thread.sleep(400);
javax.jms.Message msg = consumer.receive(4000);
long inFlightCount = regionBroker.getDestinationStatistics().getInflight().getCount();
assertNotNull(msg);
if (i<7) {
if (i < 7) {
assertEquals("all prefetch is still in flight: " + i, 10, inFlightCount);
} else {
assertTrue("most are acked but 3 remain", Wait.waitFor(new Wait.Condition(){
assertTrue("most are acked but 3 remain", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 3 == regionBroker.getDestinationStatistics().getInflight().getCount();
@ -144,14 +147,14 @@ public class OptimizedAckTest extends TestSupport {
}
}));
for (int i=0; i<10; i++) {
for (int i = 0; i < 10; i++) {
javax.jms.Message msg = consumer.receive(4000);
long inFlightCount = regionBroker.getDestinationStatistics().getInflight().getCount();
assertNotNull(msg);
if (i<7) {
if (i < 7) {
assertEquals("all prefetch is still in flight", 10, inFlightCount);
} else {
assertTrue("most are acked but 3 remain", Wait.waitFor(new Wait.Condition(){
assertTrue("most are acked but 3 remain", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
LOG.info("inflight count: " + regionBroker.getDestinationStatistics().getInflight().getCount());
@ -161,7 +164,7 @@ public class OptimizedAckTest extends TestSupport {
}
}
assertTrue("After delay the scheduled ack should ack all inflight.", Wait.waitFor(new Wait.Condition(){
assertTrue("After delay the scheduled ack should ack all inflight.", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
LOG.info("inflight count: " + regionBroker.getDestinationStatistics().getInflight().getCount());