fix unit tests

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1517076 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2013-08-23 22:18:16 +00:00
parent 174fe15b30
commit b3c132780b
5 changed files with 100 additions and 81 deletions

View File

@ -53,6 +53,7 @@ public class JmsCronSchedulerTest extends EmbeddedBrokerTestSupport {
final CountDownLatch latch = new CountDownLatch(COUNT);
consumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
latch.countDown();
count.incrementAndGet();
@ -118,7 +119,7 @@ public class JmsCronSchedulerTest extends EmbeddedBrokerTestSupport {
IOHelper.deleteChildren(schedulerDirectory);
}
BrokerService answer = new BrokerService();
answer.setPersistent(isPersistent());
answer.setPersistent(true);
answer.getManagementContext().setCreateConnector(false);
answer.setDeleteAllMessagesOnStartup(true);
answer.setDataDirectory("target");

View File

@ -21,6 +21,7 @@ import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.Message;
@ -51,6 +52,7 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
final CountDownLatch latch = new CountDownLatch(COUNT);
consumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
latch.countDown();
count.incrementAndGet();
@ -88,6 +90,7 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
final CountDownLatch latch = new CountDownLatch(COUNT);
consumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
latch.countDown();
}
@ -119,6 +122,7 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
final CountDownLatch latch = new CountDownLatch(COUNT);
consumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
try {
session.commit();
@ -158,6 +162,7 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
final CountDownLatch latch = new CountDownLatch(NUMBER);
consumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
latch.countDown();
count.incrementAndGet();
@ -242,6 +247,7 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
MessageConsumer consumer = sess.createConsumer(destination);
final CountDownLatch latch = new CountDownLatch(100);
consumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
latch.countDown();
}
@ -262,6 +268,7 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
// Make sure we sent all the messages we expected to send
Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return producer.getSentCount() == producer.getMessageCount();
}
@ -293,7 +300,7 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
IOHelper.deleteChildren(schedulerDirectory);
}
BrokerService answer = new BrokerService();
answer.setPersistent(isPersistent());
answer.setPersistent(true);
answer.setDeleteAllMessagesOnStartup(true);
answer.setDataDirectory("target");
answer.setSchedulerDirectoryFile(schedulerDirectory);

View File

@ -58,6 +58,7 @@ public class JobSchedulerManagementTest extends EmbeddedBrokerTestSupport {
final CountDownLatch latch = new CountDownLatch(COUNT);
consumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
latch.countDown();
}
@ -96,6 +97,7 @@ public class JobSchedulerManagementTest extends EmbeddedBrokerTestSupport {
final CountDownLatch latch = new CountDownLatch(COUNT);
consumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
latch.countDown();
}
@ -105,6 +107,7 @@ public class JobSchedulerManagementTest extends EmbeddedBrokerTestSupport {
MessageConsumer browser = session.createConsumer(browseDest);
final CountDownLatch browsedLatch = new CountDownLatch(COUNT);
browser.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
browsedLatch.countDown();
LOG.debug("Scheduled Message Browser got Message: " + message);
@ -158,6 +161,7 @@ public class JobSchedulerManagementTest extends EmbeddedBrokerTestSupport {
final CountDownLatch latch = new CountDownLatch(COUNT);
consumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
latch.countDown();
}
@ -167,6 +171,7 @@ public class JobSchedulerManagementTest extends EmbeddedBrokerTestSupport {
MessageConsumer browser = session.createConsumer(browseDest);
final CountDownLatch browsedLatch = new CountDownLatch(COUNT);
browser.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
browsedLatch.countDown();
LOG.debug("Scheduled Message Browser got Message: " + message);
@ -215,6 +220,7 @@ public class JobSchedulerManagementTest extends EmbeddedBrokerTestSupport {
final CountDownLatch latch = new CountDownLatch(COUNT + 2);
consumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
latch.countDown();
}
@ -224,6 +230,7 @@ public class JobSchedulerManagementTest extends EmbeddedBrokerTestSupport {
MessageConsumer browser = session.createConsumer(browseDest);
final CountDownLatch browsedLatch = new CountDownLatch(COUNT);
browser.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
browsedLatch.countDown();
LOG.debug("Scheduled Message Browser got Message: " + message);
@ -276,6 +283,7 @@ public class JobSchedulerManagementTest extends EmbeddedBrokerTestSupport {
final CountDownLatch latch = new CountDownLatch(COUNT);
consumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
latch.countDown();
}
@ -411,7 +419,7 @@ public class JobSchedulerManagementTest extends EmbeddedBrokerTestSupport {
IOHelper.deleteChildren(schedulerDirectory);
}
BrokerService answer = new BrokerService();
answer.setPersistent(isPersistent());
answer.setPersistent(true);
answer.setDeleteAllMessagesOnStartup(true);
answer.setDataDirectory("target");
answer.setSchedulerDirectoryFile(schedulerDirectory);

View File

@ -16,15 +16,16 @@
*/
package org.apache.activemq.broker.scheduler;
import junit.framework.TestCase;
import org.apache.activemq.store.kahadb.scheduler.JobSchedulerStoreImpl;
import org.apache.activemq.util.IOHelper;
import org.apache.activemq.util.ByteSequence;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import junit.framework.TestCase;
import org.apache.activemq.store.kahadb.scheduler.JobSchedulerStoreImpl;
import org.apache.activemq.util.ByteSequence;
import org.apache.activemq.util.IOHelper;
public class JobSchedulerStoreTest extends TestCase {
public void testRestart() throws Exception {
@ -41,6 +42,7 @@ public class JobSchedulerStoreTest extends TestCase {
list.add(buff);
}
JobScheduler js = store.getJobScheduler("test");
js.startDispatching();
int count = 0;
long startTime = 10 * 60 * 1000; long period = startTime;
for (ByteSequence job:list) {

View File

@ -247,6 +247,7 @@ public class JobSchedulerTest {
store.setDirectory(directory);
store.start();
scheduler = store.getJobScheduler("test");
scheduler.startDispatching();
}
@After