diff options
| author | reger <reger18@arcor.de> | 2014-07-06 00:38:16 +0200 |
|---|---|---|
| committer | reger <reger18@arcor.de> | 2014-07-06 00:38:16 +0200 |
| commit | 3b77e41f1aa48b166bdef27de32b740c700dd54e (patch) | |
| tree | 618123e8897d546cd8ef4060f2fd13efe20ded26 | |
| parent | ba5a59a28ddcf23f9ea882b05d7d5341fd02f24f (diff) | |
adding test for HostQueue crawl stack
- simulating problem with zero length stack file (but not fixing it)
- adding test data clean to maven pom
| -rw-r--r-- | pom.xml | 12 | ||||
| -rw-r--r-- | test/net/yacy/crawler/HostQueueTest.java | 62 |
2 files changed, 74 insertions, 0 deletions
@@ -100,6 +100,18 @@ </plugin> <plugin> + <artifactId>maven-clean-plugin</artifactId> + <version>2.5</version> + <configuration> + <filesets> + <fileset> + <directory>test/DATA</directory> + </fileset> + </filesets> + </configuration> + </plugin> + + <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.4</version> <configuration> diff --git a/test/net/yacy/crawler/HostQueueTest.java b/test/net/yacy/crawler/HostQueueTest.java new file mode 100644 index 000000000..6f819b453 --- /dev/null +++ b/test/net/yacy/crawler/HostQueueTest.java @@ -0,0 +1,62 @@ +
+package net.yacy.crawler;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import net.yacy.cora.document.id.DigestURL;
+import net.yacy.cora.util.SpaceExceededException;
+import net.yacy.crawler.retrieval.Request;
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+/**
+* test HostQueue
+* directorylayout is
+*
+* stackDir (dir)
+* +-- hostDir (dir)
+* +-- crawldepth.stack (file)
+*/
+public class HostQueueTest {
+ final String stackDir = "test/DATA/INDEX/QUEUE/CrawlerCoreStacks";
+
+ /**
+ * Test of clear method, of class HostQueue.
+ */
+ @Test
+ public void testClear() throws MalformedURLException, IOException, SpaceExceededException {
+ File stackDirFile = new File(stackDir);
+ String hostDir = "a.com";
+ int hostPort = 80;
+
+ // open queue
+ HostQueue testhq = new HostQueue(stackDirFile, hostDir, hostPort, true, true);
+
+ // add a url
+ String urlstr = "http://" + hostDir + "/test.html";
+ DigestURL url = new DigestURL(urlstr);
+ Request req = new Request(url, null);
+ testhq.push(req, null, null);
+
+ int sizeA = testhq.size();
+ assertTrue (sizeA > 0);
+
+ testhq.clear(); // clear the complete host queue (should delete all files in stackDir)
+
+ int sizeB = testhq.size();
+ assertEquals (0,sizeB);
+
+ // verify stackDir empty (double check)
+ String[] filelist = stackDirFile.list();
+ assertEquals ("host files in queue dir",0,filelist.length);
+
+ testhq.close();
+
+ // verify stackDir empty
+ filelist = stackDirFile.list();
+ assertEquals ("host files in queue dir",0,filelist.length);
+
+ }
+
+}
|
