From 1f2eba977ddbc41bdd2d2434e8a61badd9c110a6 Mon Sep 17 00:00:00 2001 From: reger Date: Sun, 6 Jul 2014 20:41:26 +0200 Subject: [PATCH] add test case for Records (used in HostBalancer) - simulating seek error (http://mantis.tokeek.de/view.php?id=411) --- test/net/yacy/kelondro/io/RecordsTest.java | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 test/net/yacy/kelondro/io/RecordsTest.java diff --git a/test/net/yacy/kelondro/io/RecordsTest.java b/test/net/yacy/kelondro/io/RecordsTest.java new file mode 100644 index 000000000..6b49e5a47 --- /dev/null +++ b/test/net/yacy/kelondro/io/RecordsTest.java @@ -0,0 +1,52 @@ + +package net.yacy.kelondro.io; + +import java.io.File; +import net.yacy.cora.document.encoding.ASCII; +import static org.junit.Assert.assertEquals; +import org.junit.Test; + + +public class RecordsTest { + + final String tesDir = "test/DATA/INDEX/QUEUE"; + + /** + * Test of cleanLast method, of class Records. + */ + @Test + public void testCleanLast_byteArr_int() throws Exception { + + File tablefile = new File(tesDir, "test.stack"); + + byte[] b = ASCII.getBytes("testDataString"); + Records rec = new Records(tablefile, b.length); + + rec.add(b, 0); // add some data + + for (int i = 0; i < 5; i++) { // multiple cleanlast + rec.cleanLast(b, 0); + } + assertEquals(0,rec.size()); + rec.close(); + } + + /** + * Test of cleanLast method, of class Records. + */ + @Test + public void testCleanLast() throws Exception { + + File tablefile = new File (tesDir,"test.stack"); + + byte[] b = ASCII.getBytes("testdata"); + Records rec = new Records(tablefile, b.length); + + rec.add(b, 0); // add data + for (int i = 0; i < 5; i++) { // multiple cleanLast + rec.cleanLast(); + } + assertEquals(0,rec.size()); + rec.close(); + } +}