Simplify Database methods, move logic to DatabaseComponent.

This commit is contained in:
akwizgran
2011-10-19 15:54:56 +01:00
parent f18ddfe55f
commit 93cd31fa2d
9 changed files with 256 additions and 175 deletions

View File

@@ -719,7 +719,7 @@ public class H2DatabaseTest extends TestCase {
@Test
public void testRetransmission() throws Exception {
BatchId[] ids = new BatchId[Database.RETRANSMIT_THRESHOLD + 5];
BatchId[] ids = new BatchId[DatabaseConstants.RETRANSMIT_THRESHOLD + 5];
for(int i = 0; i < ids.length; i++) {
ids[i] = new BatchId(TestUtils.getRandomId());
}
@@ -740,7 +740,7 @@ public class H2DatabaseTest extends TestCase {
// The contact acks the batches in reverse order. The first
// RETRANSMIT_THRESHOLD - 1 acks should not trigger any retransmissions
for(int i = 0; i < Database.RETRANSMIT_THRESHOLD - 1; i++) {
for(int i = 0; i < DatabaseConstants.RETRANSMIT_THRESHOLD - 1; i++) {
db.removeAckedBatch(txn, contactId, ids[ids.length - i - 1]);
Collection<BatchId> lost = db.getLostBatches(txn, contactId);
assertEquals(Collections.emptyList(), lost);
@@ -748,7 +748,7 @@ public class H2DatabaseTest extends TestCase {
// The next ack should trigger the retransmission of the remaining
// five outstanding batches
int index = ids.length - Database.RETRANSMIT_THRESHOLD;
int index = ids.length - DatabaseConstants.RETRANSMIT_THRESHOLD;
db.removeAckedBatch(txn, contactId, ids[index]);
Collection<BatchId> lost = db.getLostBatches(txn, contactId);
for(int i = 0; i < index; i++) {
@@ -761,7 +761,7 @@ public class H2DatabaseTest extends TestCase {
@Test
public void testNoRetransmission() throws Exception {
BatchId[] ids = new BatchId[Database.RETRANSMIT_THRESHOLD * 2];
BatchId[] ids = new BatchId[DatabaseConstants.RETRANSMIT_THRESHOLD * 2];
for(int i = 0; i < ids.length; i++) {
ids[i] = new BatchId(TestUtils.getRandomId());
}