Removed timing dependent asserts in test that could cause intermittent failures.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@652368 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hadrian Zbarcea 2008-04-30 12:31:46 +00:00
parent a61e5bce17
commit 101a3e453a
2 changed files with 9 additions and 12 deletions

View File

@ -161,10 +161,8 @@ class DataFileAppender {
WriteCommand write = new WriteCommand(location, data, sync); WriteCommand write = new WriteCommand(location, data, sync);
// Locate datafile and enqueue into the executor in sychronized block so // Locate datafile and enqueue into the executor in sychronized block so
// that // that writes get equeued onto the executor in order that they were assigned
// writes get equeued onto the executor in order that they were assigned // by the data manager (which is basically just appending)
// by
// the data manager (which is basically just appending)
synchronized (this) { synchronized (this) {
// Find the position where this item will land at. // Find the position where this item will land at.
@ -197,10 +195,8 @@ class DataFileAppender {
WriteCommand write = new WriteCommand(location, data, onComplete); WriteCommand write = new WriteCommand(location, data, onComplete);
// Locate datafile and enqueue into the executor in sychronized block so // Locate datafile and enqueue into the executor in sychronized block so
// that // that writes get equeued onto the executor in order that they were assigned
// writes get equeued onto the executor in order that they were assigned // by the data manager (which is basically just appending)
// by
// the data manager (which is basically just appending)
synchronized (this) { synchronized (this) {
// Find the position where this item will land at. // Find the position where this item will land at.

View File

@ -66,7 +66,8 @@ public class DataFileAppenderTest extends TestCase {
for (int i=0; i<iterations; i++) { for (int i=0; i<iterations; i++) {
dataManager.write(data, false); dataManager.write(data, false);
} }
assertTrue("writes are queued up", dataManager.getInflightWrites().size() >= iterations); // at this point most probably dataManager.getInflightWrites().size() >= 0
// as the Thread created in DataFileAppender.enqueue() may not have caught up.
Thread.sleep(1000); Thread.sleep(1000);
assertTrue("queued data is written", dataManager.getInflightWrites().isEmpty()); assertTrue("queued data is written", dataManager.getInflightWrites().isEmpty());
} }
@ -76,15 +77,15 @@ public class DataFileAppenderTest extends TestCase {
final int iterations = 10; final int iterations = 10;
final CountDownLatch latch = new CountDownLatch(iterations); final CountDownLatch latch = new CountDownLatch(iterations);
ByteSequence data = new ByteSequence("DATA".getBytes()); ByteSequence data = new ByteSequence("DATA".getBytes());
for (int i=0; i<iterations; i++) { for (int i=0; i < iterations; i++) {
dataManager.write(data, new Runnable() { dataManager.write(data, new Runnable() {
public void run() { public void run() {
latch.countDown(); latch.countDown();
} }
}); });
} }
assertTrue("writes are queued up", dataManager.getInflightWrites().size() >= iterations); // at this point most probably dataManager.getInflightWrites().size() >= 0
assertEquals("none written", iterations, latch.getCount()); // as the Thread created in DataFileAppender.enqueue() may not have caught up.
Thread.sleep(1000); Thread.sleep(1000);
assertTrue("queued data is written", dataManager.getInflightWrites().isEmpty()); assertTrue("queued data is written", dataManager.getInflightWrites().isEmpty());
assertEquals("none written", 0, latch.getCount()); assertEquals("none written", 0, latch.getCount());