You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2015/02/23 23:18:19 UTC
activemq git commit: Clean up the test,
use more sensible waits and don't create JMX connectors since not
needed, reduces runtime by one third.
Repository: activemq
Updated Branches:
refs/heads/master 85b9c81a3 -> 05b401993
Clean up the test, use more sensible waits and don't create JMX
connectors since not needed, reduces runtime by one third.
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/05b40199
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/05b40199
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/05b40199
Branch: refs/heads/master
Commit: 05b401993b215c55e277776f2e3143ec5758bfc6
Parents: 85b9c81
Author: Timothy Bish <ta...@gmail.com>
Authored: Mon Feb 23 17:17:58 2015 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Mon Feb 23 17:18:12 2015 -0500
----------------------------------------------------------------------
.../org/apache/activemq/JMSConsumerTest.java | 38 ++++++++------------
.../org/apache/activemq/JmsTestSupport.java | 6 +++-
2 files changed, 20 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/05b40199/activemq-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java
index c793dc8..4f02d47 100755
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java
@@ -47,8 +47,6 @@ import org.slf4j.LoggerFactory;
/**
* Test cases used to test the JMS message consumer.
- *
- *
*/
public class JMSConsumerTest extends JmsTestSupport {
@@ -110,16 +108,15 @@ public class JMSConsumerTest extends JmsTestSupport {
// Send a message, but should not get delivered.
sendMessages(session, destination, 1);
- assertFalse(done2.await(1, TimeUnit.SECONDS));
+ assertFalse(done2.await(500, TimeUnit.MILLISECONDS));
assertEquals(1, counter.get());
// Start the consumer, and the message should now get delivered.
consumer.start();
- assertTrue(done2.await(1, TimeUnit.SECONDS));
+ assertTrue(done2.await(500, TimeUnit.MILLISECONDS));
assertEquals(2, counter.get());
}
-
public void testMessageListenerWithConsumerCanBeStoppedConcurently() throws Exception {
final AtomicInteger counter = new AtomicInteger(0);
@@ -132,7 +129,6 @@ public class JMSConsumerTest extends JmsTestSupport {
// preload the queue
sendMessages(session, destination, 2000);
-
final ActiveMQMessageConsumer consumer = (ActiveMQMessageConsumer)session.createConsumer(destination);
final Map<Thread, Throwable> exceptions =
@@ -183,12 +179,14 @@ public class JMSConsumerTest extends JmsTestSupport {
});
assertTrue(closeDone.await(20, TimeUnit.SECONDS));
+
// await possible exceptions
- Thread.sleep(1000);
+ executor.shutdown();
+ executor.awaitTermination(1, TimeUnit.SECONDS);
+
assertTrue("no exceptions: " + exceptions, exceptions.isEmpty());
}
-
public void initCombosForTestMutiReceiveWithPrefetch1() {
addCombinationValues("deliveryMode", new Object[] {Integer.valueOf(DeliveryMode.NON_PERSISTENT), Integer.valueOf(DeliveryMode.PERSISTENT)});
addCombinationValues("ackMode", new Object[] {Integer.valueOf(Session.AUTO_ACKNOWLEDGE), Integer.valueOf(Session.DUPS_OK_ACKNOWLEDGE),
@@ -661,7 +659,6 @@ public class JMSConsumerTest extends JmsTestSupport {
}
message.acknowledge();
assertNull(consumer.receiveNoWait());
-
}
public void initCombosForTestPrefetch1MessageNotDispatched() {
@@ -704,7 +701,6 @@ public class JMSConsumerTest extends JmsTestSupport {
session2.commit();
assertNull(consumer.receiveNoWait());
-
}
public void initCombosForTestDontStart() {
@@ -771,7 +767,6 @@ public class JMSConsumerTest extends JmsTestSupport {
assertNull(consumer.receiveNoWait());
}
-
public void testDupsOkConsumer() throws Exception {
// Receive a message with the JMS API
@@ -788,13 +783,13 @@ public class JMSConsumerTest extends JmsTestSupport {
Message m = consumer.receive(1000);
assertNotNull(m);
}
- assertNull(consumer.receive(1000));
+ assertNull(consumer.receive(500));
// Close out the consumer.. no other messages should be left on the queue.
consumer.close();
consumer = session.createConsumer(destination);
- assertNull(consumer.receive(1000));
+ assertNull(consumer.receive(500));
}
public void testRedispatchOfUncommittedTx() throws Exception {
@@ -831,7 +826,6 @@ public class JMSConsumerTest extends JmsTestSupport {
redispatchSession.close();
}
-
public void testRedispatchOfRolledbackTx() throws Exception {
connection.start();
@@ -865,10 +859,9 @@ public class JMSConsumerTest extends JmsTestSupport {
redispatchSession.close();
}
-
public void initCombosForTestAckOfExpired() {
addCombinationValues("destinationType",
- new Object[] {Byte.valueOf(ActiveMQDestination.QUEUE_TYPE), Byte.valueOf(ActiveMQDestination.TOPIC_TYPE)});
+ new Object[] {Byte.valueOf(ActiveMQDestination.QUEUE_TYPE), Byte.valueOf(ActiveMQDestination.TOPIC_TYPE)});
}
public void testAckOfExpired() throws Exception {
@@ -886,7 +879,7 @@ public class JMSConsumerTest extends JmsTestSupport {
Session sendSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = sendSession.createProducer(destination);
- producer.setTimeToLive(1000);
+ producer.setTimeToLive(500);
final int count = 4;
for (int i = 0; i < count; i++) {
TextMessage message = sendSession.createTextMessage("" + i);
@@ -894,7 +887,7 @@ public class JMSConsumerTest extends JmsTestSupport {
}
// let first bunch in queue expire
- Thread.sleep(2000);
+ Thread.sleep(1000);
producer.setTimeToLive(0);
for (int i = 0; i < count; i++) {
@@ -904,7 +897,7 @@ public class JMSConsumerTest extends JmsTestSupport {
ActiveMQMessageConsumer amqConsumer = (ActiveMQMessageConsumer) consumer;
- for(int i=0; i<count; i++) {
+ for (int i=0; i<count; i++) {
TextMessage msg = (TextMessage) amqConsumer.receive();
assertNotNull(msg);
assertTrue("message has \"no expiry\" text: " + msg.getText(), msg.getText().contains("no expiry"));
@@ -924,14 +917,13 @@ public class JMSConsumerTest extends JmsTestSupport {
protected DestinationViewMBean createView(ActiveMQDestination destination) throws Exception {
- String domain = "org.apache.activemq";
- ObjectName name;
+ String domain = "org.apache.activemq";
+ ObjectName name;
if (destination.isQueue()) {
name = new ObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=test");
} else {
name = new ObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Topic,destinationName=test");
}
- return (DestinationViewMBean)broker.getManagementContext().newProxyInstance(name, DestinationViewMBean.class, true);
+ return (DestinationViewMBean) broker.getManagementContext().newProxyInstance(name, DestinationViewMBean.class, true);
}
-
}
http://git-wip-us.apache.org/repos/asf/activemq/blob/05b40199/activemq-unit-tests/src/test/java/org/apache/activemq/JmsTestSupport.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/JmsTestSupport.java b/activemq-unit-tests/src/test/java/org/apache/activemq/JmsTestSupport.java
index 5531410..b1a2ca0 100755
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/JmsTestSupport.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/JmsTestSupport.java
@@ -111,9 +111,12 @@ public class JmsTestSupport extends CombinationTestSupport {
}
protected BrokerService createBroker() throws Exception {
- return BrokerFactory.createBroker(new URI("broker://()/localhost?persistent=false"));
+ BrokerService service = BrokerFactory.createBroker(new URI("broker://()/localhost?persistent=false"));
+ service.getManagementContext().setCreateConnector(false);;
+ return service;
}
+ @Override
protected void setUp() throws Exception {
super.setUp();
@@ -129,6 +132,7 @@ public class JmsTestSupport extends CombinationTestSupport {
connections.add(connection);
}
+ @Override
protected void tearDown() throws Exception {
for (Iterator<Connection> iter = connections.iterator(); iter.hasNext();) {
Connection conn = iter.next();