mirror of
https://github.com/apache/activemq.git
synced 2025-02-16 23:16:52 +00:00
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1457917 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7d90776846
commit
95f17c2040
@ -17,6 +17,7 @@
|
|||||||
package org.apache.activemq.store.kahadb;
|
package org.apache.activemq.store.kahadb;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@ -33,6 +34,7 @@ import org.apache.activemq.command.Message;
|
|||||||
import org.apache.activemq.command.MessageAck;
|
import org.apache.activemq.command.MessageAck;
|
||||||
import org.apache.activemq.command.ProducerInfo;
|
import org.apache.activemq.command.ProducerInfo;
|
||||||
import org.apache.activemq.command.SessionInfo;
|
import org.apache.activemq.command.SessionInfo;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,15 +43,33 @@ import org.apache.activemq.command.SessionInfo;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class KahaDBStoreRecoveryBrokerTest extends RecoveryBrokerTest {
|
public class KahaDBStoreRecoveryBrokerTest extends RecoveryBrokerTest {
|
||||||
|
public static final String KAHADB_DIR_BASE = "target/activemq-data/kahadb";
|
||||||
|
public static String kahaDbDirectoryName;
|
||||||
|
|
||||||
enum CorruptionType { None, FailToLoad, LoadInvalid, LoadCorrupt };
|
enum CorruptionType { None, FailToLoad, LoadInvalid, LoadCorrupt };
|
||||||
public CorruptionType failTest = CorruptionType.None;
|
public CorruptionType failTest = CorruptionType.None;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
kahaDbDirectoryName = KAHADB_DIR_BASE + "/" + System.currentTimeMillis();
|
||||||
|
super.setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void tearDown() throws Exception {
|
||||||
|
super.tearDown();
|
||||||
|
try {
|
||||||
|
File kahaDbDir = new File(kahaDbDirectoryName);
|
||||||
|
FileUtils.deleteDirectory(kahaDbDir);
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BrokerService createBroker() throws Exception {
|
protected BrokerService createBroker() throws Exception {
|
||||||
BrokerService broker = new BrokerService();
|
BrokerService broker = new BrokerService();
|
||||||
KahaDBStore kaha = new KahaDBStore();
|
KahaDBStore kaha = new KahaDBStore();
|
||||||
kaha.setDirectory(new File("target/activemq-data/kahadb"));
|
kaha.setDirectory(new File(kahaDbDirectoryName));
|
||||||
kaha.deleteAllMessages();
|
kaha.deleteAllMessages();
|
||||||
broker.setPersistenceAdapter(kaha);
|
broker.setPersistenceAdapter(kaha);
|
||||||
return broker;
|
return broker;
|
||||||
@ -60,7 +80,7 @@ public class KahaDBStoreRecoveryBrokerTest extends RecoveryBrokerTest {
|
|||||||
protected BrokerService createRestartedBroker() throws Exception {
|
protected BrokerService createRestartedBroker() throws Exception {
|
||||||
|
|
||||||
// corrupting index
|
// corrupting index
|
||||||
File index = new File("target/activemq-data/kahadb/db.data");
|
File index = new File(kahaDbDirectoryName + "/db.data");
|
||||||
RandomAccessFile raf = new RandomAccessFile(index, "rw");
|
RandomAccessFile raf = new RandomAccessFile(index, "rw");
|
||||||
switch (failTest) {
|
switch (failTest) {
|
||||||
case FailToLoad:
|
case FailToLoad:
|
||||||
@ -89,7 +109,7 @@ public class KahaDBStoreRecoveryBrokerTest extends RecoveryBrokerTest {
|
|||||||
KahaDBStore kaha = new KahaDBStore();
|
KahaDBStore kaha = new KahaDBStore();
|
||||||
// uncomment if you want to test archiving
|
// uncomment if you want to test archiving
|
||||||
//kaha.setArchiveCorruptedIndex(true);
|
//kaha.setArchiveCorruptedIndex(true);
|
||||||
kaha.setDirectory(new File("target/activemq-data/kahadb"));
|
kaha.setDirectory(new File(kahaDbDirectoryName));
|
||||||
broker.setPersistenceAdapter(kaha);
|
broker.setPersistenceAdapter(kaha);
|
||||||
return broker;
|
return broker;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user