You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2009/09/24 15:49:08 UTC
svn commit: r818485 - in /activemq/branches/activemq-5.3: ./
activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBTest.java
Author: chirino
Date: Thu Sep 24 13:49:08 2009
New Revision: 818485
URL: http://svn.apache.org/viewvc?rev=818485&view=rev
Log:
Merging http://svn.apache.org/viewvc?view=rev&revision=818484
Modified:
activemq/branches/activemq-5.3/ (props changed)
activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBTest.java
Propchange: activemq/branches/activemq-5.3/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep 24 13:49:08 2009
@@ -1 +1 @@
-/activemq/trunk:816278-816279,816298,818138,818140-818147,818155,818160-818176,818209,818211,818224-818262,818480
+/activemq/trunk:816278-816279,816298,818138,818140-818147,818155,818160-818176,818209,818211,818224-818262,818480,818484
Modified: activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBTest.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBTest.java?rev=818485&r1=818484&r2=818485&view=diff
==============================================================================
--- activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBTest.java (original)
+++ activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/store/kahadb/KahaDBTest.java Thu Sep 24 13:49:08 2009
@@ -24,6 +24,8 @@
import javax.jms.*;
import java.io.File;
import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.io.FileNotFoundException;
/**
* @author chirino
@@ -68,7 +70,7 @@
broker = createBroker(kaha);
fail("expected IOException");
} catch (IOException e) {
- assertTrue( e.getMessage().startsWith("Detected missing journal files") );
+ assertTrue( e.getMessage().startsWith("Detected missing/corrupt journal files") );
}
}
@@ -99,6 +101,75 @@
broker.stop();
}
+
+ public void testCheckCorruptionNotIgnored() throws Exception {
+ KahaDBStore kaha = createStore(true);
+ assertFalse(kaha.isChecksumJournalFiles());
+ assertFalse(kaha.isCheckForCorruptJournalFiles());
+
+ kaha.setJournalMaxFileLength(1024*100);
+ kaha.setChecksumJournalFiles(true);
+ BrokerService broker = createBroker(kaha);
+ sendMessages(1000);
+ broker.stop();
+
+ // Modify/Corrupt some journal files..
+ assertExistsAndCorrupt(new File(kaha.getDirectory(), "db-4.log"));
+ assertExistsAndCorrupt(new File(kaha.getDirectory(), "db-8.log"));
+
+ kaha = createStore(false);
+ kaha.setJournalMaxFileLength(1024*100);
+ kaha.setChecksumJournalFiles(true);
+ kaha.setCheckForCorruptJournalFiles(true);
+ assertFalse(kaha.isIgnoreMissingJournalfiles());
+ try {
+ broker = createBroker(kaha);
+ fail("expected IOException");
+ } catch (IOException e) {
+ assertTrue( e.getMessage().startsWith("Detected missing/corrupt journal files") );
+ }
+
+ }
+
+ private void assertExistsAndCorrupt(File file) throws IOException {
+ assertTrue(file.exists());
+ RandomAccessFile f = new RandomAccessFile(file, "rw");
+ try {
+ f.seek(1024*5+134);
+ f.write("... corruption string ...".getBytes());
+ } finally {
+ f.close();
+ }
+ }
+
+
+ public void testCheckCorruptionIgnored() throws Exception {
+ KahaDBStore kaha = createStore(true);
+ kaha.setJournalMaxFileLength(1024*100);
+ kaha.setChecksumJournalFiles(true);
+ BrokerService broker = createBroker(kaha);
+ sendMessages(1000);
+ broker.stop();
+
+ // Delete some journal files..
+ assertExistsAndCorrupt(new File(kaha.getDirectory(), "db-4.log"));
+ assertExistsAndCorrupt(new File(kaha.getDirectory(), "db-8.log"));
+
+ kaha = createStore(false);
+ kaha.setIgnoreMissingJournalfiles(true);
+ kaha.setJournalMaxFileLength(1024*100);
+ kaha.setChecksumJournalFiles(true);
+ kaha.setCheckForCorruptJournalFiles(true);
+ broker = createBroker(kaha);
+
+ // We know we won't get all the messages but we should get most of them.
+ int count = receiveMessages();
+ assertTrue("Expected to received a min # of messages.. Got: "+count, count > 990 );
+ assertTrue( count < 1000 );
+
+ broker.stop();
+ }
+
private void assertExistsAndDelete(File file) {
assertTrue(file.exists());
file.delete();