mirror of https://github.com/apache/activemq.git
Fix all failing tests.
This commit is contained in:
parent
4273b1301d
commit
cce75e0926
|
@ -19,6 +19,8 @@ package org.apache.activemq.broker.policy;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.jms.ConnectionFactory;
|
import javax.jms.ConnectionFactory;
|
||||||
import javax.jms.Message;
|
import javax.jms.Message;
|
||||||
import javax.jms.MessageConsumer;
|
import javax.jms.MessageConsumer;
|
||||||
|
@ -30,7 +32,6 @@ import org.apache.activemq.broker.BrokerService;
|
||||||
import org.apache.activemq.broker.region.policy.AbortSlowAckConsumerStrategy;
|
import org.apache.activemq.broker.region.policy.AbortSlowAckConsumerStrategy;
|
||||||
import org.apache.activemq.broker.region.policy.PolicyEntry;
|
import org.apache.activemq.broker.region.policy.PolicyEntry;
|
||||||
import org.apache.activemq.broker.region.policy.PolicyMap;
|
import org.apache.activemq.broker.region.policy.PolicyMap;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.BlockJUnit4ClassRunner;
|
import org.junit.runners.BlockJUnit4ClassRunner;
|
||||||
|
@ -86,9 +87,10 @@ public class AbortSlowAckConsumer0Test extends AbortSlowConsumer0Test {
|
||||||
super.testSlowConsumerIsAbortedViaJmx();
|
super.testSlowConsumerIsAbortedViaJmx();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("AMQ-5001")
|
|
||||||
@Test
|
@Test
|
||||||
public void testZeroPrefetchConsumerIsAborted() throws Exception {
|
public void testZeroPrefetchConsumerIsAborted() throws Exception {
|
||||||
|
strategy.setMaxTimeSinceLastAck(2000); // Make it shorter
|
||||||
|
|
||||||
ActiveMQConnection conn = (ActiveMQConnection) createConnectionFactory().createConnection();
|
ActiveMQConnection conn = (ActiveMQConnection) createConnectionFactory().createConnection();
|
||||||
conn.setExceptionListener(this);
|
conn.setExceptionListener(this);
|
||||||
connections.add(conn);
|
connections.add(conn);
|
||||||
|
@ -102,17 +104,19 @@ public class AbortSlowAckConsumer0Test extends AbortSlowConsumer0Test {
|
||||||
Message message = consumer.receive(5000);
|
Message message = consumer.receive(5000);
|
||||||
assertNotNull(message);
|
assertNotNull(message);
|
||||||
|
|
||||||
|
TimeUnit.SECONDS.sleep(15);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
consumer.receive(20000);
|
consumer.receive(5000);
|
||||||
fail("Slow consumer not aborted.");
|
fail("Slow consumer not aborted.");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("AMQ-5001")
|
|
||||||
@Test
|
@Test
|
||||||
public void testIdleConsumerCanBeAbortedNoMessages() throws Exception {
|
public void testIdleConsumerCanBeAbortedNoMessages() throws Exception {
|
||||||
strategy.setIgnoreIdleConsumers(false);
|
strategy.setIgnoreIdleConsumers(false);
|
||||||
|
strategy.setMaxTimeSinceLastAck(2000); // Make it shorter
|
||||||
|
|
||||||
ActiveMQConnection conn = (ActiveMQConnection) createConnectionFactory().createConnection();
|
ActiveMQConnection conn = (ActiveMQConnection) createConnectionFactory().createConnection();
|
||||||
conn.setExceptionListener(this);
|
conn.setExceptionListener(this);
|
||||||
|
@ -123,18 +127,26 @@ public class AbortSlowAckConsumer0Test extends AbortSlowConsumer0Test {
|
||||||
assertNotNull(consumer);
|
assertNotNull(consumer);
|
||||||
conn.start();
|
conn.start();
|
||||||
|
|
||||||
|
startProducers(destination, 1);
|
||||||
|
|
||||||
|
Message message = consumer.receive(5000);
|
||||||
|
assertNotNull(message);
|
||||||
|
|
||||||
|
// Consumer needs to be closed before the reeive call.
|
||||||
|
TimeUnit.SECONDS.sleep(15);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
consumer.receive(20000);
|
consumer.receive(5000);
|
||||||
fail("Idle consumer not aborted.");
|
fail("Idle consumer not aborted.");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("AMQ-5001")
|
|
||||||
@Test
|
@Test
|
||||||
public void testIdleConsumerCanBeAborted() throws Exception {
|
public void testIdleConsumerCanBeAborted() throws Exception {
|
||||||
AbortSlowAckConsumerStrategy strategy = createSlowConsumerStrategy();
|
AbortSlowAckConsumerStrategy strategy = createSlowConsumerStrategy();
|
||||||
strategy.setIgnoreIdleConsumers(false);
|
strategy.setIgnoreIdleConsumers(false);
|
||||||
|
strategy.setMaxTimeSinceLastAck(2000); // Make it shorter
|
||||||
|
|
||||||
ActiveMQConnection conn = (ActiveMQConnection) createConnectionFactory().createConnection();
|
ActiveMQConnection conn = (ActiveMQConnection) createConnectionFactory().createConnection();
|
||||||
conn.setExceptionListener(this);
|
conn.setExceptionListener(this);
|
||||||
|
@ -144,15 +156,18 @@ public class AbortSlowAckConsumer0Test extends AbortSlowConsumer0Test {
|
||||||
final MessageConsumer consumer = sess.createConsumer(destination);
|
final MessageConsumer consumer = sess.createConsumer(destination);
|
||||||
assertNotNull(consumer);
|
assertNotNull(consumer);
|
||||||
conn.start();
|
conn.start();
|
||||||
startProducers(destination, 20);
|
startProducers(destination, 1);
|
||||||
|
|
||||||
Message message = consumer.receive(5000);
|
Message message = consumer.receive(5000);
|
||||||
assertNotNull(message);
|
assertNotNull(message);
|
||||||
message.acknowledge();
|
message.acknowledge();
|
||||||
|
|
||||||
|
// Consumer needs to be closed before the reeive call.
|
||||||
|
TimeUnit.SECONDS.sleep(15);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
consumer.receive(20000);
|
consumer.receive(5000);
|
||||||
fail("Slow consumer not aborted.");
|
fail("Idle consumer not aborted.");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue