Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

add test case for Records (used in HostBalancer) - simulating seek error (http://mantis.tokeek.de/view.php?id=411)

reger1f2eba977ddb
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();
+ }
+}