activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5578 - remove timing deps from the test
Date Fri, 20 Feb 2015 12:02:16 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 023b2ac04 -> 2949e8dbf


https://issues.apache.org/jira/browse/AMQ-5578 - remove timing deps from the test


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/2949e8db
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/2949e8db
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/2949e8db

Branch: refs/heads/master
Commit: 2949e8dbf73b316b1c2f3794eef59cfb29d2183d
Parents: 023b2ac
Author: gtully <gary.tully@gmail.com>
Authored: Fri Feb 20 12:03:12 2015 +0000
Committer: gtully <gary.tully@gmail.com>
Committed: Fri Feb 20 12:03:12 2015 +0000

----------------------------------------------------------------------
 .../disk/journal/PreallocationJournalTest.java  | 22 +++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/2949e8db/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/journal/PreallocationJournalTest.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/journal/PreallocationJournalTest.java
b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/journal/PreallocationJournalTest.java
index bf5b65b..9c21a56 100644
--- a/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/journal/PreallocationJournalTest.java
+++ b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/journal/PreallocationJournalTest.java
@@ -17,6 +17,7 @@
 package org.apache.activemq.store.kahadb.disk.journal;
 
 import org.apache.activemq.store.kahadb.KahaDBStore;
+import org.apache.activemq.util.Wait;
 import org.junit.Test;
 
 import java.io.File;
@@ -61,16 +62,23 @@ public class PreallocationJournalTest  {
         store.setPreallocationStrategy(preallocationStrategy);
         store.start();
 
-        // time for files to get there.. i know this is a brittle test! need to find
-        // a better way (callbacks?) to notify when the journal is completely up
-        TimeUnit.MILLISECONDS.sleep(500);
-        File journalLog = new File(dataDirectory, "db-1.log");
-        assertTrue(journalLog.exists());
+        final File journalLog = new File(dataDirectory, "db-1.log");
+        assertTrue("file exists", Wait.waitFor(new Wait.Condition() {
+            @Override
+            public boolean isSatisified() throws Exception {
+                return journalLog.exists();
+            }
+        }));
 
 
         FileInputStream is = new FileInputStream(journalLog);
-        FileChannel channel = is.getChannel();
-        assertEquals(Journal.DEFAULT_MAX_FILE_LENGTH, channel.size());
+        final FileChannel channel = is.getChannel();
+        assertTrue("file size as expected", Wait.waitFor(new Wait.Condition() {
+            @Override
+            public boolean isSatisified() throws Exception {
+                return Journal.DEFAULT_MAX_FILE_LENGTH == channel.size();
+            }
+        }));
 
         channel.position(1 * 1024 * 1024 + 1);
         ByteBuffer buff = ByteBuffer.allocate(1);


Mime
View raw message