mirror of https://github.com/apache/activemq.git
test showing npe remove issue in kahadb index
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@983644 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7629eafd0a
commit
530ab0420b
|
@ -21,6 +21,7 @@ import java.text.NumberFormat;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.kahadb.index.BTreeIndex;
|
||||
import org.apache.kahadb.index.Index;
|
||||
|
@ -173,6 +174,44 @@ public class BTreeIndexTest extends IndexTestSupport {
|
|||
this.index.unload(tx);
|
||||
tx.commit();
|
||||
}
|
||||
|
||||
|
||||
public void testRandomRemove() throws Exception {
|
||||
|
||||
createPageFileAndIndex(100);
|
||||
BTreeIndex<String,Long> index = ((BTreeIndex<String,Long>)this.index);
|
||||
this.index.load(tx);
|
||||
tx.commit();
|
||||
|
||||
final int count = 4000;
|
||||
doInsert(count);
|
||||
|
||||
Random rand = new Random(System.currentTimeMillis());
|
||||
int i = 0, prev = 0;
|
||||
while (!index.isEmpty(tx)) {
|
||||
prev = i;
|
||||
i = rand.nextInt(count);
|
||||
try {
|
||||
index.remove(tx, key(i));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail("unexpected exception on " + i + ", prev: " + prev + ", ex: " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testRemovePattern() throws Exception {
|
||||
createPageFileAndIndex(100);
|
||||
BTreeIndex<String,Long> index = ((BTreeIndex<String,Long>)this.index);
|
||||
this.index.load(tx);
|
||||
tx.commit();
|
||||
|
||||
final int count = 4000;
|
||||
doInsert(count);
|
||||
|
||||
index.remove(tx, key(3697));
|
||||
index.remove(tx, key(1566));
|
||||
}
|
||||
|
||||
void doInsertReverse(int count) throws Exception {
|
||||
for (int i = count-1; i >= 0; i--) {
|
||||
|
|
Loading…
Reference in New Issue