summaryrefslogtreecommitdiff
path: root/test/net
diff options
context:
space:
mode:
authorluc <luc@debianluc>2016-01-19 08:06:49 +0100
committerluc <luc@debianluc>2016-01-19 08:06:49 +0100
commitef83e34b8a62e678bb3d102cb0a23dd9d979d85e (patch)
treef06db2959508b72a1498e9b70c3faae2a90b0104 /test/net
parent231be83eb65e7289ad56a3544fc9029dda656009 (diff)
parent6c25710a34b4417d6bf3db2589709ead39557a6d (diff)
Merge branch 'master' of https://github.com/yacy/yacy_search_server
Diffstat (limited to 'test/net')
-rw-r--r--test/net/yacy/cora/document/id/DigestURLTest.java33
-rw-r--r--test/net/yacy/cora/document/id/MultiProtocolURLTest.java241
-rw-r--r--test/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnectorTest.java175
-rw-r--r--test/net/yacy/cora/protocol/HeaderFrameworkTest.java22
-rw-r--r--test/net/yacy/cora/protocol/ResponseHeaderTest.java135
-rw-r--r--test/net/yacy/cora/util/NumberToolsTest.java27
-rw-r--r--test/net/yacy/crawler/HostQueueTest.java62
-rw-r--r--test/net/yacy/data/wiki/WikiCodeTest.java35
-rw-r--r--test/net/yacy/document/ParserTest.java194
-rw-r--r--test/net/yacy/document/WordTokenizerTest.java33
-rw-r--r--test/net/yacy/document/parser/htmlParserTest.java144
-rw-r--r--test/net/yacy/document/parser/images/genericImageParserTest.java39
-rw-r--r--test/net/yacy/document/parser/images/metadataImageParserTest.java40
-rw-r--r--test/net/yacy/document/parser/pdfParserTest.java47
-rw-r--r--test/net/yacy/kelondro/io/RecordsTest.java52
-rw-r--r--test/net/yacy/kelondro/util/MemoryControlTest.java43
-rw-r--r--test/net/yacy/peers/operation/yacyVersionTest.java37
-rw-r--r--test/net/yacy/search/query/QueryGoalTest.java38
-rw-r--r--test/net/yacy/search/snippet/TextSnippetTest.java168
19 files changed, 0 insertions, 1565 deletions
diff --git a/test/net/yacy/cora/document/id/DigestURLTest.java b/test/net/yacy/cora/document/id/DigestURLTest.java
deleted file mode 100644
index 587a4ee27..000000000
--- a/test/net/yacy/cora/document/id/DigestURLTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package net.yacy.cora.document.id;
-
-import java.net.MalformedURLException;
-import junit.framework.TestCase;
-import org.junit.Test;
-
-public class DigestURLTest extends TestCase {
-
- @Test
- public void testIdentPort() throws MalformedURLException {
- String[][] testStrings = new String[][]{
- new String[]{"http://www.yacy.net:", "http://www.yacy.net/"},
- new String[]{"http://www.yacy.net:80", "http://www.yacy.net/"},
- new String[]{"http://www.yacy.net:/", "http://www.yacy.net/"},
- new String[]{"http://www.yacy.net: /", "http://www.yacy.net/"}
- };
-
- for (int i = 0; i < testStrings.length; i++) {
- // desired conversion result
- System.out.print("testIdentPort: " + testStrings[i][0]);
- String shouldBe = testStrings[i][1];
-
- // conversion result
- String resolvedURL = (new DigestURL(testStrings[i][0])).toNormalform(false);
-
- // test if equal
- assertEquals(shouldBe, resolvedURL);
- System.out.println(" -> " + resolvedURL);
-
- }
- }
-
-}
diff --git a/test/net/yacy/cora/document/id/MultiProtocolURLTest.java b/test/net/yacy/cora/document/id/MultiProtocolURLTest.java
deleted file mode 100644
index b3c3abf14..000000000
--- a/test/net/yacy/cora/document/id/MultiProtocolURLTest.java
+++ /dev/null
@@ -1,241 +0,0 @@
-package net.yacy.cora.document.id;
-
-import static org.junit.Assert.*;
-
-import java.net.MalformedURLException;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.TreeSet;
-
-import org.junit.Test;
-//import junit.framework.TestCase;
-
-public class MultiProtocolURLTest {
-
- @Test
- public void testSessionIdRemoval() throws MalformedURLException {
- String[][] testURIs = new String[][]{
- // meaning: original uri, stripped version
- new String[]{"http://test.de/bla.php?phpsessionid=asdf", "http://test.de/bla.php"},
- new String[]{"http://test.de/bla?phpsessionid=asdf&fdsa=asdf", "http://test.de/bla?fdsa=asdf"},
- new String[]{"http://test.de/bla?asdf=fdsa&phpsessionid=asdf", "http://test.de/bla?asdf=fdsa"},
- new String[]{"http://test.de/bla?asdf=fdsa&phpsessionid=asdf&fdsa=asdf", "http://test.de/bla?asdf=fdsa&fdsa=asdf"},};
- TreeSet<String> idNames = new TreeSet<String>();
- idNames.add("phpsessionid");
-
- MultiProtocolURL.initSessionIDNames(idNames);
-
- for (int i = 0; i < testURIs.length; i++) {
- MultiProtocolURL uri = new MultiProtocolURL(testURIs[i][0]);
-
- assertEquals(uri.toNormalform(true, true), testURIs[i][1]);
- }
- }
-
- @Test
- public void testResolveBackpath() {
- String[][] testStrings = new String[][]{
- new String[]{"/..home", "/..home"},
- new String[]{"/test/..home/test.html", "/test/..home/test.html"},
- new String[]{"/../", "/../"},
- new String[]{"/..", "/.."},
- new String[]{"/test/..", "/"},
- new String[]{"/test/../", "/"},
- new String[]{"/test/test2/..", "/test"},
- new String[]{"/test/test2/../", "/test/"},
- new String[]{"/test/test2/../hallo", "/test/hallo"},
- new String[]{"/test/test2/../hallo/", "/test/hallo/"},
- new String[]{"/home/..test/../hallo/../", "/home/"}
- };
- String testhost = "http://localhost";
- for (int i = 0; i < testStrings.length; i++) {
- // desired conversion result
- System.out.print("testResolveBackpath: " + testStrings[i][0]);
- String shouldBe = testhost + testStrings[i][1];
-
- // conversion result
- String resolvedURL = "";
- try {
- resolvedURL = (new MultiProtocolURL(testhost + testStrings[i][0])).toNormalform(false);
- } catch (final MalformedURLException ex) {
- fail("malformed URL");
- }
- // test if equal
- assertEquals(shouldBe, resolvedURL);
- System.out.println(" -> " + resolvedURL);
-
- }
- }
-
- /**
- * Test of isLocal method, of class MultiProtocolURL. including IPv6 url
- * data
- *
- * @throws java.net.MalformedURLException
- */
- @Test
- public void testIsLocal() throws MalformedURLException {
- LinkedHashMap<String,Boolean> testurls = new LinkedHashMap<String,Boolean>(); // <url,expected_result>
-
- // valid IPv6 local loopback addresses
- testurls.put("http://[0:0:0:0:0:0:0:1]/index.html", Boolean.TRUE);
- testurls.put("http://[::1]/index.html", Boolean.TRUE);
- testurls.put("http://[::1]:8090/index.html", Boolean.TRUE);
- testurls.put("http://[0::1]/index.html", Boolean.TRUE);
- testurls.put("http://[::0:1]:80/index.html", Boolean.TRUE);
-
- testurls.put("http://[fc00:0:0:0:0:0:0:1]/index.html", Boolean.TRUE);
- testurls.put("http://[fc00::fa01:ff]/index.html", Boolean.TRUE);
- testurls.put("http://[fD00:0:0:0:0:0:0:1]/index.html", Boolean.TRUE);
- testurls.put("http://[fe80:0:0:0:0:0:0:1]/index.html", Boolean.TRUE);
- testurls.put("http://[fe80::1]/index.html", Boolean.TRUE);
-
- // test urls for possible issue with IPv6 misinterpretation
- testurls.put("http://fcedit.com", Boolean.FALSE);
- testurls.put("http://fdedit.com", Boolean.FALSE);
- testurls.put("http://fe8edit.com", Boolean.FALSE);
-
- // valid IPv6 examples taken from http://www.ietf.org/rfc/rfc2732.txt cap 2.
- testurls.put("http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html", Boolean.TRUE); // ip is link-local (fe80/10)
- testurls.put("http://[1080:0:0:0:8:800:200C:417A]/index.html", Boolean.FALSE);
- testurls.put("http://[3ffe:2a00:100:7031::1]", Boolean.FALSE);
- testurls.put("http://[1080::8:800:200C:417A]/foo", Boolean.FALSE);
- testurls.put("http://[::192.9.5.5]/ipng", Boolean.FALSE);
- testurls.put("http://[::FFFF:129.144.52.38]:80/index.html", Boolean.FALSE);
- testurls.put("http://[2010:836B:4179::836B:4179]", Boolean.FALSE);
-
- for (String u : testurls.keySet()) {
-
- MultiProtocolURL uri = new MultiProtocolURL(u);
- boolean result = uri.isLocal();
-
- System.out.println ("testIsLocal: " + u + " -> " + result);
- assertEquals(u, testurls.get(u), result);
-
- }
- }
-
- @Test
- public void testGetHost() throws MalformedURLException {
- String[][] testStrings = new String[][]{
- // teststring , expectedresult
- new String[]{"http://www.yacy.net", "www.yacy.net"},
- new String[]{"http://www.yacy.net:8090", "www.yacy.net"},
- new String[]{"http://www.yacy.net/test?query=test", "www.yacy.net"},
- new String[]{"http://www.yacy.net/?query=test", "www.yacy.net"},
- new String[]{"http://www.yacy.net?query=test", "www.yacy.net"},
- new String[]{"http://www.yacy.net:?query=test", "www.yacy.net"},
- new String[]{"//www.yacy.net:?query=test", "www.yacy.net"},
- };
-
- for (int i = 0; i < testStrings.length; i++) {
- // desired conversion result
- System.out.print("testGetHost: " + testStrings[i][0]);
- String shouldBe = testStrings[i][1];
-
- // conversion result
- String resolvedHost = new MultiProtocolURL(testStrings[i][0]).getHost();
-
- // test if equal
- assertEquals(shouldBe, resolvedHost);
- System.out.println(" -> " + resolvedHost);
-
- }
- }
-
- /**
- * Test getProtocol()
- */
- @Test
- public void testGetProtocol() throws MalformedURLException {
- Map<String, String> testurls = new HashMap<String, String>();
- // ( 1. parameter = urlstring to test, 2. parameter = expected protocol)
- testurls.put("http://host.com", "http");
- testurls.put("HTTPS://host.com", "https");
- testurls.put("Ftp://host.com", "ftp");
- testurls.put("SMB://host.com", "smb");
- testurls.put("/file.com", "file");
- testurls.put("file://host.com/file.com", "file");
- testurls.put("MailTo:Abc@host.com", "mailto");
-
- for (String txt : testurls.keySet()) {
- MultiProtocolURL url = new MultiProtocolURL(txt);
- assertEquals("test " + txt, url.getProtocol(), testurls.get(txt));
-
- }
- }
-
- /**
- * Test of toNormalform method, of class MultiProtocolURL.
- */
- @Test
- public void testToNormalform() throws Exception {
- // some test url/uri with problems in the past
- String[][] testStrings = new String[][]{
- // teststring , expectedresult
- new String[]{"http://www.heise.de/newsticker/thema/%23saukontrovers", "http://www.heise.de/newsticker/thema/%23saukontrovers"}, // http://mantis.tokeek.de/view.php?id=519
- new String[]{"http://www.heise.de/newsticker/thema/#saukontrovers", "http://www.heise.de/newsticker/thema/"}, // anchor fragment
- new String[]{"http://www.liferay.com/community/wiki/-/wiki/Main/Wiki+Portlet", "http://www.liferay.com/community/wiki/-/wiki/Main/Wiki+Portlet"}, // http://mantis.tokeek.de/view.php?id=559
- new String[]{"http://de.wikipedia.org/wiki/Philippe_Ariès", "http://de.wikipedia.org/wiki/Philippe_Ari%C3%A8s"} // UTF-8 2 byte char
- };
-
- for (String[] testString : testStrings) {
- // desired conversion result
- System.out.print("toNormalform orig uri: " + testString[0]);
- String shouldBe = testString[1];
- // conversion result
- String resultUrl = new MultiProtocolURL(testString[0]).toNormalform(true);
- // test if equal
- assertEquals(shouldBe, resultUrl);
- System.out.println(" -> " + resultUrl);
- }
- }
-
- /**
- * Test of getAttribute method, of class MultiProtocolURL.
- */
- @Test
- public void testGetAttribute() throws Exception {
- // some test url/uri with problems in the past
- String[][] testStrings = new String[][]{
- // teststring , expectedresult
- new String[]{"http://yacy.net?&test", "test"}
- };
-
- for (String[] testString : testStrings) {
- // desired conversion result
- System.out.print("test getAttribute: " + testString[0]);
- String shouldBe = testString[1];
-
- MultiProtocolURL resultUrl = new MultiProtocolURL(testString[0]);
- Map<String, String> attr = resultUrl.getAttributes();
-
- assertEquals("", attr.get(shouldBe));
- System.out.println(" -> " + resultUrl.toNormalform(false));
- }
- }
-
- /**
- * Test of getFileExtension method, of class MultiProtocolURL.
- */
- @Test
- public void testGetFileExtension() throws MalformedURLException {
- Map<String, String> testurls = new HashMap<String, String>();
- // key=testurl, value=result
- testurls.put("path/file.xml","xml"); // easiest
- testurls.put("path/file?h.pdf",""); // file w/o extension
- testurls.put("file.html?param=h.pdf","html"); // dot in query part
- testurls.put("url?param=h.pdf",""); // dot in query part
- testurls.put("file.html?param", "html");
- testurls.put("/path/","");
- for (String s : testurls.keySet()) {
- System.out.println("test getFileExtension: " + s + " -> " + testurls.get(s));
- String result = MultiProtocolURL.getFileExtension(s);
- assertEquals(testurls.get(s),result);
- }
- }
-}
-
-
-
diff --git a/test/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnectorTest.java b/test/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnectorTest.java
deleted file mode 100644
index ff4411622..000000000
--- a/test/net/yacy/cora/federate/solr/connector/EmbeddedSolrConnectorTest.java
+++ /dev/null
@@ -1,175 +0,0 @@
-package net.yacy.cora.federate.solr.connector;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Date;
-import java.util.HashSet;
-import net.yacy.cora.federate.solr.instance.EmbeddedInstance;
-import net.yacy.search.schema.CollectionSchema;
-import net.yacy.search.schema.WebgraphSchema;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrInputDocument;
-import org.junit.AfterClass;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import org.junit.BeforeClass;
-
-
-public class EmbeddedSolrConnectorTest {
-
- static EmbeddedSolrConnector solr;
-
- public EmbeddedSolrConnectorTest() {
- }
-
- /**
- * init for all test cases (via BeforeClass annotation),
- * for the expensive creating or loading of index
- */
- @BeforeClass
- public static void initTesting() {
- File solr_config = new File("defaults/solr");
- File storage = new File("test/DATA/INDEX/webportal/SEGMENTS/text/solr/");
- storage.mkdirs();
- System.out.println("setup EmeddedSolrConnector using config dir: " + solr_config.getAbsolutePath());
- try {
- EmbeddedInstance localCollectionInstance = new EmbeddedInstance(solr_config, storage, CollectionSchema.CORE_NAME, new String[]{CollectionSchema.CORE_NAME, WebgraphSchema.CORE_NAME});
- solr = new EmbeddedSolrConnector(localCollectionInstance);
- solr.clear(); // delete all documents in index (for clean testing)
- } catch (final IOException ex) {
- fail("IOException starting Jetty");
- }
- }
-
- @AfterClass
- public static void finalizeTesting() {
- solr.close();
- }
-
- /**
- * Test of query solr via jetty
- */
- @Test
- public void testQuery() throws IOException {
- System.out.println("adding test document to solr");
- SolrInputDocument doc = new SolrInputDocument();
- String id = Long.toString(System.currentTimeMillis());
- doc.addField(CollectionSchema.id.name(), id);
- doc.addField(CollectionSchema.title.name(), "Lorem ipsum");
- doc.addField(CollectionSchema.host_s.name(), "yacy.net");
- // mixing in the id as unique word
- doc.addField(CollectionSchema.text_t.name(), "Lorem ipsum dolor sit amet, consectetur adipisicing elit, x"+id+ " sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
-
- solr.add(doc);
- solr.commit(true);
-
- System.out.println("query solr");
- long expResult = 1;
- long result = solr.getCountByQuery(CollectionSchema.text_t.name() + ":x" + id);
- System.out.println("found = " + result + " (expected = 1 )");
- assertEquals(expResult, result);
- }
-
- /**
- * Test of update (partial update)
- */
- @Test
- public void testUdate() throws IOException {
- SolrInputDocument doc = new SolrInputDocument();
- String id = Long.toString(System.currentTimeMillis());
- System.out.println("testUpdate: adding test document to solr ID=" + id);
- doc.addField(CollectionSchema.id.name(), id);
- doc.addField(CollectionSchema.title.name(), "Lorem ipsum");
- doc.addField(CollectionSchema.host_s.name(), "yacy.net");
- doc.addField(CollectionSchema.text_t.name(), "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
-
- solr.add(doc);
- solr.commit(true);
-
- System.out.println("testUpdate: update one document ID=" + id);
-
- HashSet<String> fieldnames = new HashSet<String>();
- fieldnames.addAll(doc.getFieldNames());
-
- SolrInputDocument sid = new SolrInputDocument();
- sid.addField(CollectionSchema.id.name(), doc.getFieldValue(CollectionSchema.id.name()));
- sid.addField(CollectionSchema.host_s.name(), "yacy.yacyh");
- solr.update(sid);
- solr.commit(true);
-
- long expResult = 1;
- SolrDocumentList sl = solr.getDocumentListByQuery(CollectionSchema.host_s.name()+":yacy.yacyh",null,0,10);
- assertTrue(sl.size() >= expResult);
-
- System.out.println("testUpdate: verify update of document ID=" + id);
- String foundid = null;
- for (SolrDocument rdoc : sl) {
- foundid = (String) rdoc.getFieldValue("id");
- if (id.equals(foundid)) {
- HashSet<String> newfieldnames = new HashSet<String>();
- newfieldnames.addAll(rdoc.getFieldNames());
- assertTrue(newfieldnames.containsAll(fieldnames));
- break;
- }
- }
- assertEquals(id, foundid);
- }
-
- /**
- * Test for partial update for document containing a multivalued date field
- * this is a Solr issue (2015-09-12)
- * the test case is just to demonstrate the effect on YaCy (currently catching the solr exception and reinserting a document with fields missing)
- *
- * Solr 5.4.0 bugfix @see http://issues.apache.org/jira/browse/SOLR-8050 Partial update on document with multivalued date field fails
- */
- @Test
- public void testUdate_withMultivaluedDateField() throws SolrException, IOException {
- SolrInputDocument doc = new SolrInputDocument();
- String id = Long.toString(System.currentTimeMillis());
- System.out.println("testUpdate: adding test document to solr ID=" + id);
- doc.addField(CollectionSchema.id.name(), id);
- doc.addField(CollectionSchema.title.name(), "Lorem ipsum");
- doc.addField(CollectionSchema.host_s.name(), "yacy.net");
- doc.addField(CollectionSchema.text_t.name(), "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
- doc.addField(CollectionSchema.dates_in_content_dts.name(), new Date());
-
- solr.add(doc);
- solr.commit(true);
-
- System.out.println("testUpdate: update one document ID=" + id);
-
- HashSet<String> fieldnames = new HashSet<String>();
- fieldnames.addAll(doc.getFieldNames());
-
- SolrInputDocument sid = new SolrInputDocument();
- sid.addField(CollectionSchema.id.name(), id);
- sid.addField(CollectionSchema.host_s.name(), "yacy.yacy");
- solr.update(sid);
- solr.commit(true);
-
- long expResult = 1;
- SolrDocumentList sl = solr.getDocumentListByQuery(CollectionSchema.host_s.name()+":yacy.yacy",null,0,10);
- assertTrue(sl.size() >= expResult);
-
- System.out.println("testUpdate: verify update of document ID=" + id);
- String foundid = null;
- for (SolrDocument rdoc : sl) {
- foundid = (String) rdoc.getFieldValue("id");
- if (id.equals(foundid)) {
- HashSet<String> newfieldnames = new HashSet<String>();
- newfieldnames.addAll(rdoc.getFieldNames());
- if (!newfieldnames.containsAll(fieldnames)) {
- System.err.println("!!!++++++++++++++++++++++++++++++++++++!!!");
- System.err.println("fields in original document: "+fieldnames.toString());
- System.err.println("fields after partial update: "+newfieldnames.toString());
- System.err.println("!!!++++++++++++++++++++++++++++++++++++!!!");
- }
- assertTrue (newfieldnames.containsAll(fieldnames));
- break;
- }
- }
- assertEquals(id, foundid);
- }
-}
diff --git a/test/net/yacy/cora/protocol/HeaderFrameworkTest.java b/test/net/yacy/cora/protocol/HeaderFrameworkTest.java
deleted file mode 100644
index 792e67be8..000000000
--- a/test/net/yacy/cora/protocol/HeaderFrameworkTest.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package net.yacy.cora.protocol;
-
-import java.util.Date;
-import junit.framework.TestCase;
-import org.junit.Test;
-
-public class HeaderFrameworkTest extends TestCase {
-
- /**
- * Test of httpHeader date parsing routine
- */
- @Test
- public void testParseHTTPDate() {
- Date parsedDate = HeaderFramework.parseHTTPDate("Tue, 08 Jul 2003 21:22:46 GMT");
-
- // returned date must not be null
- assertNotNull(parsedDate);
-
- // Print Result
- System.out.println("testParseHTTPDate: " + parsedDate.toString());
- }
-}
diff --git a/test/net/yacy/cora/protocol/ResponseHeaderTest.java b/test/net/yacy/cora/protocol/ResponseHeaderTest.java
deleted file mode 100644
index 4d16f381d..000000000
--- a/test/net/yacy/cora/protocol/ResponseHeaderTest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package net.yacy.cora.protocol;
-
-import java.util.Date;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class ResponseHeaderTest {
-
- /**
- * Test of age method, of class ResponseHeader.
- * testing many combination of header.date and header.last_modified
- * test goal: age is suppose to always >= 0
- */
- @Test
- public void testAge() {
- // because ResponseHeader caches date values internally on 1st access,
- // we need to create a new instance for every testcase
-
- ResponseHeader testhdr1 = new ResponseHeader(200);
- ResponseHeader testhdr2 = new ResponseHeader(200);
- ResponseHeader testhdr3 = new ResponseHeader(200);
-
- // access-sequence 1 = age() without accessing any date before
- // access-sequence 2 = access date() then age()
- // access-sequence 3 = access lastModified() then age()
-
- // test case with sorce: date=null lastmodified=null
- long age1 = testhdr1.age();
-
- testhdr2.date();
- testhdr3.lastModified();
-
- assertEquals("access-sequence 1 date=null lastmod=null AGE="+age1, 0, age1);
-
- testhdr2.lastModified();
-
- long age2 = testhdr2.age();
- assertEquals("access-sequence 2 date=null lastmod=null AGE="+age2, 0, age2);
-
- testhdr3.date();
-
- long age3 = testhdr3.age();
- assertEquals("access-sequence 3 date=null lastmod=null AGE="+age3, 0, age3);
-
- Date past = new Date(System.currentTimeMillis() / 2);
- Date future = new Date(System.currentTimeMillis() * 2);
-
- Date[] testdate = new Date[3];
- testdate[0] = past;
- testdate[1] = new Date();
- testdate[2] = future;
- String[] testdatename = new String[] {"past","now","future"}; // date names just for output
-
- for (int id = 0; id < testdate.length; id++) {
-
- // test case with sorce: date=testdate(x) lastmodified=null
- testhdr1 = new ResponseHeader(200);
- testhdr1.put(HeaderFramework.DATE, HeaderFramework.formatRFC1123(testdate[id]));
- testhdr2 = new ResponseHeader(200);
- testhdr2.put(HeaderFramework.DATE, HeaderFramework.formatRFC1123(testdate[id]));
- testhdr3 = new ResponseHeader(200);
- testhdr3.put(HeaderFramework.DATE, HeaderFramework.formatRFC1123(testdate[id]));
-
- age1 = testhdr1.age();
- testhdr2.date();
- testhdr3.lastModified();
-
- assertTrue("access-sequence 1."+id+" date=" + testdatename[id] + " lastmod=null AGE= " + age1, age1 >= 0);
-
- age2 = testhdr2.age();
- assertTrue("access-sequence 2."+id+" date=" + testdatename[id] + " lastmod=null AGE= " + age2, age2 >= 0);
-
- age3 = testhdr3.age();
- assertTrue("access-sequence 3."+id+" date=" + testdatename[id] + " lastmod=null AGE= " + age3, age3 >= 0);
-
- // test case with sorce: date=null lastmodified=testdat(x)
- testhdr1 = new ResponseHeader(200);
- testhdr1.put(HeaderFramework.LAST_MODIFIED, HeaderFramework.formatRFC1123(testdate[id]));
- testhdr2 = new ResponseHeader(200);
- testhdr2.put(HeaderFramework.LAST_MODIFIED, HeaderFramework.formatRFC1123(testdate[id]));
- testhdr3 = new ResponseHeader(200);
- testhdr3.put(HeaderFramework.LAST_MODIFIED, HeaderFramework.formatRFC1123(testdate[id]));
-
- age1 = testhdr1.age();
- testhdr2.date();
- testhdr3.lastModified();
-
- assertTrue("access-sequence 1."+id+" date=null lastmod=" + testdatename[id] + " AGE= " + age1, age1 >= 0);
-
- age2 = testhdr2.age();
- assertTrue("access-sequence 2."+id+" date=null lastmod=" + testdatename[id] + " AGE= " + age2, age2 >= 0);
-
- age3 = testhdr3.age();
- assertTrue("access-sequence 3."+id+" date=null lastmod=" + testdatename[id] + " AGE= " + age3, age3 >= 0);
-
- for (int imd = 0; imd < testdate.length; imd++) {
- // test case with sorce: date=testdate(x) lastmodified=testdate(y)
- testhdr1 = new ResponseHeader(200);
- testhdr1.put(HeaderFramework.DATE, HeaderFramework.formatRFC1123(testdate[id]));
- testhdr1.put(HeaderFramework.LAST_MODIFIED, HeaderFramework.formatRFC1123(testdate[imd]));
-
- testhdr2 = new ResponseHeader(200);
- testhdr2.put(HeaderFramework.DATE, HeaderFramework.formatRFC1123(testdate[id]));
- testhdr2.put(HeaderFramework.LAST_MODIFIED, HeaderFramework.formatRFC1123(testdate[imd]));
-
- testhdr3 = new ResponseHeader(200);
- testhdr3.put(HeaderFramework.DATE, HeaderFramework.formatRFC1123(testdate[id]));
- testhdr3.put(HeaderFramework.LAST_MODIFIED, HeaderFramework.formatRFC1123(testdate[imd]));
-
- age1 = testhdr1.age();
-
- testhdr2.date();
- testhdr3.lastModified();
-
- assertTrue("case 1."+id+"."+imd+" date=" + testdatename[id] + " lastmod=" + testdatename[imd] + " AGE= " + age1, age1 >= 0);
-
- // hint to mismatch of date
- Date d1 = testhdr1.date();
- Date m1 = testhdr1.lastModified();
- if (d1.before(m1)) {
- System.err.println("this faulty combination with lastmod after date (date="+testdatename[id]+" lastmod="+testdatename[imd]+") is accepted without correction");
- }
-
- age2 = testhdr2.age();
- assertTrue("case 2."+id+"."+imd+" date=" + testdatename[id] + " lastmod=" + testdatename[imd] + " AGE= " + age2, age2 >= 0);
-
- age3 = testhdr3.age();
- assertTrue("case 3."+id+"."+imd+" date=" + testdatename[id] + " lastmod=" + testdatename[imd] + " AGE= " + age3, age3 >= 0);
- }
-
- }
-
- }
-
-}
diff --git a/test/net/yacy/cora/util/NumberToolsTest.java b/test/net/yacy/cora/util/NumberToolsTest.java
deleted file mode 100644
index d714b9248..000000000
--- a/test/net/yacy/cora/util/NumberToolsTest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package net.yacy.cora.util;
-
-import static net.yacy.cora.util.NumberTools.parseIntDecSubstring;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class NumberToolsTest {
-
- /**
- * Test of parseLongDecSubstring method, of class NumberTools.
- */
- @Test
- public void testParseIntDecSubstring() {
- String[] TestNumbers = new String[]{
- "101", " 102", " 103", " 104 ",
- "+105", " -106", " +107 ", " -108 ",
- "109px", " 110px"};
-
- int i=101;
- for (String s : TestNumbers) {
- int result = parseIntDecSubstring(s);
- assertEquals (s + " = " + Integer.toString(i),i,Math.abs(result));
- i++;
- }
-
- }
-}
diff --git a/test/net/yacy/crawler/HostQueueTest.java b/test/net/yacy/crawler/HostQueueTest.java
deleted file mode 100644
index 6f819b453..000000000
--- a/test/net/yacy/crawler/HostQueueTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-
-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);
-
- }
-
-}
diff --git a/test/net/yacy/data/wiki/WikiCodeTest.java b/test/net/yacy/data/wiki/WikiCodeTest.java
deleted file mode 100644
index c4b75a511..000000000
--- a/test/net/yacy/data/wiki/WikiCodeTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package net.yacy.data.wiki;
-
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-
-public class WikiCodeTest {
-
- /**
- * test geo location metadata convert
- */
- @Test
- public void testProcessMetadata() {
- String[] testmeta = new String[]{
- "{{coordinate|NS=52.205944|EW=0.117593|region=GB-CAM|type=landmark}}", // decimal N-E location
- "{{coordinate|NS=43/50/29/N|EW=73/23/17/W|type=landmark|region=US-NY}}", // N-W location
-
- "{{Coordinate |text=DMS |NS=50/7/49/N |EW=6/8/09/E |type=landmark |region=BE-WLG |name=Monument des trois Frontières}}",
- "{{Coordinate |text=DMS |NS= 49.047169|EW=7.899148|region=DE-RP |type=landmark |name=Europadenkmal (Rheinland-Pfalz)}}",
-
- "{{coordinate|NS=0.00000|EW=0.117593}}", // testing equator coord
- "{{coordinate|NS=-10.00000|EW=-10.10000}}" // testing S-E location
-
- };
- WikiCode wc = new WikiCode();
- for (int i = 0; i < testmeta.length; i++) {
- String result = wc.transform("http://wiki:8080",testmeta[i]);
- System.out.println(testmeta[i] + " --> " + result);
- // simply check if replacement took place, if no coordinate recognized original string is just html encoded
- assertFalse(result.contains("#124;")); // simple check - result not containing char code for "{",
- assertFalse(result.contains("#125;")); // simple check - result not containing char code for "}"
- }
- }
-
-} \ No newline at end of file
diff --git a/test/net/yacy/document/ParserTest.java b/test/net/yacy/document/ParserTest.java
deleted file mode 100644
index 9d00c9b07..000000000
--- a/test/net/yacy/document/ParserTest.java
+++ /dev/null
@@ -1,194 +0,0 @@
-package net.yacy.document;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import net.yacy.cora.document.id.AnchorURL;
-import net.yacy.document.parser.docParser;
-import net.yacy.document.parser.odtParser;
-import net.yacy.document.parser.ooxmlParser;
-import net.yacy.document.parser.pdfParser;
-import net.yacy.document.parser.pptParser;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertThat;
-import org.junit.Test;
-
-
-public class ParserTest {
-
- @Test public void testooxmlParsers() throws FileNotFoundException, Parser.Failure, MalformedURLException, UnsupportedEncodingException, IOException {
- final String[][] testFiles = new String[][] {
- // meaning: filename in test/parsertest, mimetype, title, creator, description,
- new String[]{"umlaute_windows.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "In München steht ein Hofbräuhaus, dort gibt es Bier in Maßkrügen", "", ""},
- new String[]{"umlaute_windows.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "Folie 1", "", ""},
- };
-
- for (final String[] testFile : testFiles) {
- try {
- final String filename = "test/parsertest/" + testFile[0];
- final File file = new File(filename);
- final String mimetype = testFile[1];
- final AnchorURL url = new AnchorURL("http://localhost/"+filename);
-
- AbstractParser p = new ooxmlParser();
- final Document[] docs = p.parse(url, mimetype, null, new VocabularyScraper(), 0, new FileInputStream(file));
- for (final Document doc: docs) {
- final Reader content = new InputStreamReader(doc.getTextStream(), doc.getCharset());
- final StringBuilder str = new StringBuilder();
- int c;
- while( (c = content.read()) != -1 )
- str.append((char)c);
-
- System.out.println("Parsed " + filename + ": " + str);
- assertThat(str.toString(), containsString("In München steht ein Hofbräuhaus, dort gibt es Bier in Maßkrügen"));
- assertThat(doc.dc_title(), containsString(testFile[2]));
- assertThat(doc.dc_creator(), containsString(testFile[3]));
- if (testFile[4].length() > 0) assertThat(doc.dc_description()[0], containsString(testFile[4]));
- }
- } catch (final InterruptedException ex) {}
- }
- }
-
- @Test public void testodtParsers() throws FileNotFoundException, Parser.Failure, MalformedURLException, UnsupportedEncodingException, IOException {
- final String[][] testFiles = new String[][] {
- // meaning: filename in test/parsertest, mimetype, title, creator, description,
- new String[]{"umlaute_linux.odt", "application/vnd.oasis.opendocument.text", "Münchner Hofbräuhaus", "", "Kommentar zum Hofbräuhaus"},
- new String[]{"umlaute_linux.ods", "application/vnd.oasis.opendocument.spreadsheat", "", "", ""},
- new String[]{"umlaute_linux.odp", "application/vnd.oasis.opendocument.presentation", "", "", ""},
- };
-
- for (final String[] testFile : testFiles) {
- try {
- final String filename = "test/parsertest/" + testFile[0];
- final File file = new File(filename);
- final String mimetype = testFile[1];
- final AnchorURL url = new AnchorURL("http://localhost/"+filename);
-
- AbstractParser p = new odtParser();
- final Document[] docs = p.parse(url, mimetype, null, new VocabularyScraper(), 0, new FileInputStream(file));
- for (final Document doc: docs) {
- final Reader content = new InputStreamReader(doc.getTextStream(), doc.getCharset());
- final StringBuilder str = new StringBuilder();
- int c;
- while( (c = content.read()) != -1 )
- str.append((char)c);
-
- System.out.println("Parsed " + filename + ": " + str);
- assertThat(str.toString(), containsString("In München steht ein Hofbräuhaus, dort gibt es Bier in Maßkrügen"));
- assertThat(doc.dc_title(), containsString(testFile[2]));
- assertThat(doc.dc_creator(), containsString(testFile[3]));
- if (testFile[4].length() > 0) assertThat(doc.dc_description()[0], containsString(testFile[4]));
- }
- } catch (final InterruptedException ex) {}
- }
- }
-
- @Test public void testpdfParsers() throws FileNotFoundException, Parser.Failure, MalformedURLException, UnsupportedEncodingException, IOException {
- final String[][] testFiles = new String[][] {
- // meaning: filename in test/parsertest, mimetype, title, creator, description,
- new String[]{"umlaute_linux.pdf", "application/pdf", "", "", ""},
- };
-
- for (final String[] testFile : testFiles) {
- try {
- final String filename = "test/parsertest/" + testFile[0];
- final File file = new File(filename);
- final String mimetype = testFile[1];
- final AnchorURL url = new AnchorURL("http://localhost/"+filename);
-
- AbstractParser p = new pdfParser();
- final Document[] docs = p.parse(url, mimetype, null, new VocabularyScraper(), 0, new FileInputStream(file));
- for (final Document doc: docs) {
- final Reader content = new InputStreamReader(doc.getTextStream(), doc.getCharset());
- final StringBuilder str = new StringBuilder();
- int c;
- while( (c = content.read()) != -1 )
- str.append((char)c);
-
- System.out.println("Parsed " + filename + ": " + str);
- assertThat(str.toString(), containsString("In München steht ein Hofbräuhaus, dort gibt es Bier in Maßkrügen"));
- assertThat(doc.dc_title(), containsString(testFile[2]));
- assertThat(doc.dc_creator(), containsString(testFile[3]));
- if (testFile[4].length() > 0) assertThat(doc.dc_description()[0], containsString(testFile[4]));
- }
- } catch (final InterruptedException ex) {}
- }
- }
-
- @Test public void testdocParsers() throws FileNotFoundException, Parser.Failure, MalformedURLException, UnsupportedEncodingException, IOException {
- final String[][] testFiles = new String[][] {
- // meaning: filename in test/parsertest, mimetype, title, creator, description,
- new String[]{"umlaute_windows.doc", "application/msword", "", "", ""},
- };
-
- for (final String[] testFile : testFiles) {
- try {
- final String filename = "test/parsertest/" + testFile[0];
- final File file = new File(filename);
- final String mimetype = testFile[1];
- final AnchorURL url = new AnchorURL("http://localhost/"+filename);
-
- AbstractParser p = new docParser();
- final Document[] docs = p.parse(url, mimetype, null, new VocabularyScraper(), 0, new FileInputStream(file));
- for (final Document doc: docs) {
- final Reader content = new InputStreamReader(doc.getTextStream(), doc.getCharset());
- final StringBuilder str = new StringBuilder();
- int c;
- while( (c = content.read()) != -1 )
- str.append((char)c);
-
- System.out.println("Parsed " + filename + ": " + str);
- assertThat(str.toString(), containsString("In München steht ein Hofbräuhaus, dort gibt es Bier in Maßkrügen"));
- assertThat(doc.dc_title(), containsString(testFile[2]));
- assertThat(doc.dc_creator(), containsString(testFile[3]));
- if (testFile[4].length() > 0) assertThat(doc.dc_description()[0], containsString(testFile[4]));
- }
- } catch (final InterruptedException ex) {}
- }
- }
-
- /**
- * Powerpoint parser test *
- */
- @Test
- public void testpptParsers() throws FileNotFoundException, Parser.Failure, MalformedURLException, UnsupportedEncodingException, IOException, InterruptedException {
- final String[][] testFiles = new String[][]{
- // meaning: filename in test/parsertest, mimetype, title, creator, description,
- new String[]{"umlaute_linux.ppt", "application/powerpoint", "In München steht ein Hofbräuhaus, dort gibt es Bier in Maßkrügen", "", ""},
- new String[]{"umlaute_windows.ppt", "application/powerpoint", "In München steht ein Hofbräuhaus, dort gibt es Bier in Maßkrügen", "afieg", ""},
- new String[]{"umlaute_mac.ppt", "application/powerpoint", "In München steht ein Hofbräuhaus, dort gibt es Bier in Maßkrügen", "Bob", ""}
- };
-
- for (final String[] testFile : testFiles) {
-
- final String filename = "test/parsertest/" + testFile[0];
- final File file = new File(filename);
- final String mimetype = testFile[1];
- final AnchorURL url = new AnchorURL("http://localhost/" + filename);
-
- AbstractParser p = new pptParser();
- final Document[] docs = p.parse(url, mimetype, null, new VocabularyScraper(), 0, new FileInputStream(file));
- for (final Document doc : docs) {
- final Reader content = new InputStreamReader(doc.getTextStream(), doc.getCharset());
- final StringBuilder str = new StringBuilder();
- int c;
- while ((c = content.read()) != -1) {
- str.append((char) c);
- }
-
- System.out.println("Parsed " + filename + ": " + str);
- assertThat(str.toString(), containsString("In München steht ein Hofbräuhaus, dort gibt es Bier in Maßkrügen"));
- assertThat(doc.dc_title(), containsString(testFile[2]));
- assertThat(doc.dc_creator(), containsString(testFile[3]));
- if (testFile[4].length() > 0) {
- assertThat(doc.dc_description()[0], containsString(testFile[4]));
- }
- }
- }
- }
- }
diff --git a/test/net/yacy/document/WordTokenizerTest.java b/test/net/yacy/document/WordTokenizerTest.java
deleted file mode 100644
index c32e71ead..000000000
--- a/test/net/yacy/document/WordTokenizerTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package net.yacy.document;
-
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class WordTokenizerTest {
-
- /**
- * Test of nextElement method, of class WordTokenizer.
- */
- @Test
- public void testNextElement() {
- // test sentences containing 10x the word "word"
- String[] testTxtArr = new String[]{
- " word word..... (word) [word] . 'word word' \"word word\" word ? word! ",
- "word-word word . word.word@word.word ....word... word,word "
- };
-
- for (String testTxt : testTxtArr) {
- SentenceReader sr = new SentenceReader(testTxt);
- WordTokenizer wt = new WordTokenizer(sr, null);
- int cnt = 0;
- while (wt.hasMoreElements()) {
- StringBuilder sb = wt.nextElement();
- assertEquals("word", sb.toString());
- cnt++;
- }
- wt.close();
- assertEquals(10, cnt);
- }
- }
-
-}
diff --git a/test/net/yacy/document/parser/htmlParserTest.java b/test/net/yacy/document/parser/htmlParserTest.java
deleted file mode 100644
index 97ce36717..000000000
--- a/test/net/yacy/document/parser/htmlParserTest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package net.yacy.document.parser;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.net.MalformedURLException;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import junit.framework.TestCase;
-import net.yacy.cora.document.id.AnchorURL;
-import net.yacy.document.Document;
-import net.yacy.document.Parser;
-import net.yacy.document.VocabularyScraper;
-import net.yacy.document.parser.html.ContentScraper;
-import net.yacy.document.parser.html.ImageEntry;
-import static net.yacy.document.parser.htmlParser.parseToScraper;
-import org.junit.Test;
-
-public class htmlParserTest extends TestCase {
-
- @Test
- public void testGetRealCharsetEncoding() {
- String[][] testStrings = new String[][] {
- new String[]{null,null},
- new String[]{"windows1250","windows-1250"},
- new String[]{"windows_1250","windows-1250"},
- new String[]{"ISO-8859-1", StandardCharsets.ISO_8859_1.name()},
- new String[]{"ISO8859-1", StandardCharsets.ISO_8859_1.name()},
- new String[]{"ISO-88591", StandardCharsets.ISO_8859_1.name()},
- new String[]{"ISO88591", StandardCharsets.ISO_8859_1.name()},
- new String[]{"iso_8859_1", StandardCharsets.ISO_8859_1.name()},
- new String[]{"cp-1252","windows-1252"},
- new String[]{"gb_2312","gb2312"}, // was: x-EUC-CN
- new String[]{"gb_2312-80","gb2312"}, // was: x-EUC-CN
- new String[]{"UTF-8;", StandardCharsets.UTF_8.name()}
- };
-
- for (int i=0; i < testStrings.length; i++) {
- // desired conversion result
- String shouldBe = testStrings[i][1];
- shouldBe = shouldBe!=null ? shouldBe.toLowerCase() : null;
-
- // conversion result
- String charset = htmlParser.patchCharsetEncoding(testStrings[i][0]);
-
- // test if equal
- assertEquals(shouldBe, charset!=null ? charset.toLowerCase() : null);
- System.out.println("testGetRealCharsetEncoding: " + (testStrings[i][0]!=null?testStrings[i][0]:"null") + " -> " + (charset!=null?charset:"null") + " | Supported: " + (charset!=null?Charset.isSupported(charset):false));
-
- }
-
- }
-
- /**
- * Test of parse method, of class htmlParser.
- * - test getCharset
- */
- @Test
- public void testParse() throws MalformedURLException, Parser.Failure, InterruptedException, FileNotFoundException {
- System.out.println("htmlParser.parse");
-
- String[] testFiles = {
- "umlaute_html_iso.html",
- "umlaute_html_utf8.html",
- "umlaute_html_namedentities.html"};
-
- final String mimetype = "text/html";
- //final String resulttxt = "In München steht ein Hofbräuhaus. Dort gibt es Bier aus Maßkrügen.";
-
- for (String testfile : testFiles) {
- final String filename = "test/parsertest/" + testfile;
- final File file = new File(filename);
-
- final AnchorURL url = new AnchorURL("http://localhost/" + filename);
- System.out.println("parse file: " + filename);
-
- htmlParser p = new htmlParser();
- final Document[] docs = p.parse(url, mimetype, null, new VocabularyScraper(), 0, new FileInputStream(file));
-
- Document doc = docs[0];
- String txt = doc.getCharset();
- assertTrue("get Charset", txt != null);
- System.out.println("detected charset = " + txt);
-
- }
- }
-
- /**
- * Test of parseToScraper method, of class htmlParser.
- */
- @Test
- public void testParseToScraper_4args() throws Exception {
- // test link with inline html in text
- // expectation to deliver pure text as it is possibly indexed in outboundlinks_anchortext_txt/inboundlinks_anchortext_txt
- final AnchorURL url = new AnchorURL("http://localhost/");
- final String charset = StandardCharsets.UTF_8.name();
- final String testhtml = "<html><body>"
- + "<a href='x1.html'><span>testtext</span></a>" // "testtext"
- + "<a href=\"http://localhost/x2.html\"> <i id=\"home-icon\" class=\"img-sprite\"></i>Start</a>" // "Start"
- + "<a href='x1.html'><span class='button'><img src='pic.gif'/></span></a>" // "" + image
- + "<figure><img width=\"550px\" title=\"image as exemple\" alt=\"image as exemple\" src=\"./img/my_image.png\"></figrue>" // + img width 550 (+html5 figure)
- + "</body></html>";
-
- ContentScraper scraper = parseToScraper(url, charset, new VocabularyScraper(), 0, testhtml, 10);
- List<AnchorURL> anchorlist = scraper.getAnchors();
-
- String linktxt = anchorlist.get(0).getTextProperty();
- assertEquals("testtext", linktxt);
-
- linktxt = anchorlist.get(1).getTextProperty();
- assertEquals("Start", linktxt);
-
- linktxt = anchorlist.get(2).getTextProperty();
- assertEquals("", linktxt);
-
- int cnt = scraper.getImages().size();
- assertEquals(2,cnt);
- ImageEntry img = scraper.getImages().get(1);
- assertEquals(550,img.width());
- }
-
- /**
- * Test of parseToScraper method, of class htmlParser
- * for scraping tag content from text (special test to verify <style> not counted as text
- */
- @Test
- public void testParseToScraper_TagTest() throws Exception {
- final AnchorURL url = new AnchorURL("http://localhost/");
- final String charset = StandardCharsets.UTF_8.name();
- final String textSource = "test text";
- final String testhtml = "<html>"
- + "<head><style type=\"text/css\"> h1 { color: #ffffff; }</style></head>"
- + "<body>"
- + "<p>" + textSource + "</p>"
- + "</body></html>";
-
- ContentScraper scraper = parseToScraper(url, charset, new VocabularyScraper(), 0, testhtml, 10);
-
- String txt = scraper.getText();
- System.out.println("ScraperTagTest: [" + textSource + "] = [" + txt + "]");
- assertEquals(txt, textSource);
- }
-}
diff --git a/test/net/yacy/document/parser/images/genericImageParserTest.java b/test/net/yacy/document/parser/images/genericImageParserTest.java
deleted file mode 100644
index f2da567be..000000000
--- a/test/net/yacy/document/parser/images/genericImageParserTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-
-package net.yacy.document.parser.images;
-
-import java.io.File;
-import java.io.FileInputStream;
-import net.yacy.cora.document.id.AnchorURL;
-import net.yacy.document.Document;
-import net.yacy.document.VocabularyScraper;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class genericImageParserTest {
-
- /**
- * Test of parse method, of class genericImageParser.
- */
- @Test
- public void testParse() throws Exception {
- System.out.println("genericImageParser.parse Jpeg");
-
- final String testFiles = "YaCyLogo_120ppi.jpg";
- final String mimetype = "image/jpeg";
- final String charset = null;
-
- final String filename = "test/parsertest/" + testFiles;
- final File file = new File(filename);
-
- final AnchorURL url = new AnchorURL("http://localhost/" + filename);
- System.out.println("parse file: " + filename);
-
- genericImageParser p = new genericImageParser();
- final Document[] docs = p.parse(url, mimetype, charset, new VocabularyScraper(), 0, new FileInputStream(file));
-
- Document doc = docs[0];
- assertEquals("YaCy Logo",doc.dc_title());
- System.out.println(doc.toString());
- }
-
-}
diff --git a/test/net/yacy/document/parser/images/metadataImageParserTest.java b/test/net/yacy/document/parser/images/metadataImageParserTest.java
deleted file mode 100644
index 4c0939319..000000000
--- a/test/net/yacy/document/parser/images/metadataImageParserTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-
-package net.yacy.document.parser.images;
-
-import java.io.File;
-import java.io.FileInputStream;
-import net.yacy.cora.document.id.AnchorURL;
-import net.yacy.document.Document;
-import net.yacy.document.VocabularyScraper;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class metadataImageParserTest {
-
-
- /**
- * Test of parse method, of class metadataImageParser.
- */
- @Test
- public void testParse() throws Exception {
- System.out.println("metadataImageParser.parse TIF");
-
- final String testFiles = "YaCyLogo_120ppi.tif";
- final String mimetype = "image/tiff";
- final String charset = null;
-
- final String filename = "test/parsertest/" + testFiles;
- final File file = new File(filename);
-
- final AnchorURL url = new AnchorURL("http://localhost/" + filename);
- System.out.println("parse file: " + filename);
-
- metadataImageParser p = new metadataImageParser();
- final Document[] docs = p.parse(url, mimetype, charset, new VocabularyScraper(), 0, new FileInputStream(file));
-
- Document doc = docs[0];
- assertEquals("YaCy Logo",doc.dc_title());
- System.out.println(doc.toString());
- }
-
-}
diff --git a/test/net/yacy/document/parser/pdfParserTest.java b/test/net/yacy/document/parser/pdfParserTest.java
deleted file mode 100644
index 56cc2d842..000000000
--- a/test/net/yacy/document/parser/pdfParserTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package net.yacy.document.parser;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.Collection;
-import static junit.framework.TestCase.assertEquals;
-import net.yacy.cora.document.id.AnchorURL;
-import net.yacy.document.Document;
-import net.yacy.document.VocabularyScraper;
-import org.junit.Test;
-
-public class pdfParserTest {
-
- /**
- * Test extraction of links in parse method, of class pdfParser.
- */
- @Test
- public void testParse() throws Exception {
- System.out.println("pdfParser.parse");
-
- final String testFiles = "umlaute_linux.pdf";
- final String mimetype = "application/pdf";
- final String charset = null;
-
- //final String resulttxt = "In München steht ein Hofbräuhaus. Dort gibt es Bier aus Maßkrügen.";
- final String filename = "test/parsertest/" + testFiles;
- final File file = new File(filename);
-
- final AnchorURL url = new AnchorURL("http://localhost/" + filename);
- System.out.println("parse file: " + filename);
-
- pdfParser p = new pdfParser();
- final Document[] docs = p.parse(url, mimetype, charset, new VocabularyScraper(), 0, new FileInputStream(file));
-
- Document doc = docs[0];
- int ilinks = doc.getAnchors().size();
- assertEquals("number of links in pdf", 1, ilinks);
-
- Collection<AnchorURL> links = doc.getAnchors();
- System.out.println("number of links detected = " + ilinks);
- for (AnchorURL aurl : links) {
- System.out.println(" found: " + aurl.toString());
- }
-
- }
-
-}
diff --git a/test/net/yacy/kelondro/io/RecordsTest.java b/test/net/yacy/kelondro/io/RecordsTest.java
deleted file mode 100644
index 6b49e5a47..000000000
--- a/test/net/yacy/kelondro/io/RecordsTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-
-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();
- }
-}
diff --git a/test/net/yacy/kelondro/util/MemoryControlTest.java b/test/net/yacy/kelondro/util/MemoryControlTest.java
deleted file mode 100644
index 5c8666436..000000000
--- a/test/net/yacy/kelondro/util/MemoryControlTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-
-package net.yacy.kelondro.util;
-
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-
-
-public class MemoryControlTest {
-
- final int onemb = 1024 * 1024;
-
- /**
- * Test of request method, of class MemoryControl.
- */
- @Test
- public void testRequest_StandardStrategy() {
- MemoryControl.setStandardStrategy(true);
- MemoryControl.setProperMbyte(24);
-
- int memblock = onemb * 13; // memsize to allocate
-
- int iterations = (int) MemoryControl.available() / memblock;
- int arraysize = (int) MemoryControl.maxMemory() / memblock + 10;
-
- byte[][] x = new byte[arraysize][];
-
- int i = 0;
-
- while (i < arraysize && MemoryControl.request(memblock, false)) {
- x[i] = new byte[memblock];
- // for realistic test produce some memory avail to GC
- if (MemoryControl.request(memblock, false)) {
- x[i] = new byte[memblock];
- }
-
- i++;
- }
- System.out.println("allocated " + i + " * " + memblock/onemb + " MB = " + i*memblock/onemb + " MB");
-
- assertTrue(i >= iterations);
- }
-
-}
diff --git a/test/net/yacy/peers/operation/yacyVersionTest.java b/test/net/yacy/peers/operation/yacyVersionTest.java
deleted file mode 100644
index 8de1dfe11..000000000
--- a/test/net/yacy/peers/operation/yacyVersionTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package net.yacy.peers.operation;
-
-import junit.framework.TestCase;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class yacyVersionTest extends TestCase {
-
- /**
- * Test method for 'yacy.combinedVersionString2PrettyString(String)'
- * @author Bost
- */
- @Test
- public void testCombinedVersionString2PrettyString() {
- Assert.assertArrayEquals(new String[]{"dev","0000"}, yacyVersion.combined2prettyVersion("")); // not a number
- Assert.assertArrayEquals(new String[]{"dev","0000"}, yacyVersion.combined2prettyVersion(" ")); // not a number
- Assert.assertArrayEquals(new String[]{"dev","02417"}, yacyVersion.combined2prettyVersion("0.10002417"));
- Assert.assertArrayEquals(new String[]{"dev","0244"}, yacyVersion.combined2prettyVersion("0.1000244"));
- Assert.assertArrayEquals(new String[]{"dev","02417"}, yacyVersion.combined2prettyVersion("0.10002417"));
- Assert.assertArrayEquals(new String[]{"dev","0000"}, yacyVersion.combined2prettyVersion("0.100024400")); // input is too long
- Assert.assertArrayEquals(new String[]{"dev","0244"}, yacyVersion.combined2prettyVersion("0.1090244"));
- Assert.assertArrayEquals(new String[]{"0.110","0244"}, yacyVersion.combined2prettyVersion("0.1100244"));
- Assert.assertArrayEquals(new String[]{"0.111","0244"}, yacyVersion.combined2prettyVersion("0.1110244"));
- Assert.assertArrayEquals(new String[]{"dev","0000"}, yacyVersion.combined2prettyVersion("0.0")); // input is valid - no warning generated
- Assert.assertArrayEquals(new String[]{"dev","0000"}, yacyVersion.combined2prettyVersion(" 0.11102440")); // spaces are not allowed
- Assert.assertArrayEquals(new String[]{"0.111","0000"}, yacyVersion.combined2prettyVersion("0.111")); // was (input is too short)
- Assert.assertArrayEquals(new String[]{"dev","0000"}, yacyVersion.combined2prettyVersion("0.1112440\t\n")); // \t and \n are not allowed
- Assert.assertArrayEquals(new String[]{"dev","0000"}, yacyVersion.combined2prettyVersion("124353432xxxx4546399999")); // not a number + too long
- Assert.assertArrayEquals(new String[]{"dev","0000"}, yacyVersion.combined2prettyVersion("123456789x")); // not a number
- Assert.assertArrayEquals(new String[]{"dev","0000"}, yacyVersion.combined2prettyVersion("9999999999")); // missing decimal point
- Assert.assertArrayEquals(new String[]{"999.999","9990"}, yacyVersion.combined2prettyVersion("999.999999")); // was (floating point part must have 3 and SVN-Version 4 digits)
- Assert.assertArrayEquals(new String[]{"0.999","99999"}, yacyVersion.combined2prettyVersion("0.99999999"));
- Assert.assertArrayEquals(new String[]{"99999.004","56789"}, yacyVersion.combined2prettyVersion("99999.00456789"));
- Assert.assertArrayEquals(new String[]{"dev","0000"}, yacyVersion.combined2prettyVersion("99999.003456789")); // input is too long
- }
-
-}
diff --git a/test/net/yacy/search/query/QueryGoalTest.java b/test/net/yacy/search/query/QueryGoalTest.java
deleted file mode 100644
index 74387082c..000000000
--- a/test/net/yacy/search/query/QueryGoalTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package net.yacy.search.query;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
-public class QueryGoalTest {
-
- /**
- * Test of getIncludeString method, of class QueryGoal.
- */
- @Test
- public void testGetIncludeString() {
- HashMap<String, String[]> testdata = new HashMap<String, String[]>();
- // Prameter: (Query, [result_term1, result_term2 ..])
- testdata.put("O'Reily's book", new String[]{"o'reily's", "book"});
- testdata.put("\"O'Reily's book\"", new String[]{"o'reily's book"}); // quoted term
- testdata.put("\"O'Reily's\" +book", new String[]{"o'reily's", "book"}); // +word
- testdata.put("Umphrey's + McGee", new String[]{"umphrey's", "mcgee"});
- testdata.put("'The Book' library", new String[]{"the book","library"}); //single quoted term
-
- for (String testquery : testdata.keySet()) {
- QueryGoal qg = new QueryGoal(testquery); // get test query
- String[] singlestr = testdata.get(testquery); // get result strings
-
- Iterator<String> it = qg.getIncludeStrings();
- int i = 0;
- while (it.hasNext()) {
- String s = it.next();
- System.out.println(singlestr[i] + " = " + s);
- assertEquals(s, singlestr[i]);
- i++;
- }
- }
- }
-
-}
diff --git a/test/net/yacy/search/snippet/TextSnippetTest.java b/test/net/yacy/search/snippet/TextSnippetTest.java
deleted file mode 100644
index 5e703d3f8..000000000
--- a/test/net/yacy/search/snippet/TextSnippetTest.java
+++ /dev/null
@@ -1,168 +0,0 @@
-
-package net.yacy.search.snippet;
-
-import java.net.MalformedURLException;
-import net.yacy.cora.document.encoding.ASCII;
-import net.yacy.cora.document.id.DigestURL;
-import net.yacy.cora.federate.yacy.CacheStrategy;
-import net.yacy.cora.storage.HandleSet;
-import net.yacy.cora.util.CommonPattern;
-import net.yacy.kelondro.data.meta.URIMetadataNode;
-import net.yacy.search.query.QueryGoal;
-import net.yacy.search.schema.CollectionSchema;
-import org.apache.solr.common.SolrDocument;
-import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.Test;
-
-
-public class TextSnippetTest {
-
- // declare some required parameter
- final CacheStrategy cacheStrategy = CacheStrategy.CACHEONLY;
- final boolean pre = true;
- final int snippetMaxLength = 220;
- final boolean reindexing = false;
-
- SolrDocument doc;
-
- public TextSnippetTest() {
- }
-
- @Before
- public void setUp() throws Exception {
-
- // prepare a empty test document
- doc = new SolrDocument();
- DigestURL url = new DigestURL("http://localhost/page.html");
- doc.addField(CollectionSchema.id.name(), ASCII.String(url.hash()));
- doc.addField(CollectionSchema.sku.name(), url.toNormalform(false));
- // for testcases add other fields
- // fields involved in snippet extraction:
- // url, title, keywords, author, text_t
- }
-
- @Test
- public void testTextSnippet() throws MalformedURLException {
-
- URIMetadataNode testpage = new URIMetadataNode(doc);
- testpage.addField(CollectionSchema.title.name(), "New test case");
- testpage.addField(CollectionSchema.keywords.name(), "junit");
- testpage.addField(CollectionSchema.author.name(), "test author");
- testpage.addField(CollectionSchema.text_t.name(), "A new testcase has been introduced. "
- + "It includes a few test lines and one line that should match.");
-
- String querywords = "testcase line";
- QueryGoal qg = new QueryGoal(querywords);
- HandleSet queryhashes = qg.getIncludeHashes();
-
- TextSnippet ts = new TextSnippet(
- null,
- testpage,
- queryhashes,
- cacheStrategy,
- pre,
- snippetMaxLength,
- reindexing
- );
- String rstr = ts.getError();
- assertEquals("testTextSnippet Error Code: ", "", rstr);
-
- String[] wordlist = CommonPattern.SPACE.split(querywords);
- rstr = ts.toString();
- System.out.println("testTextSnippet: query=" + querywords);
- System.out.println("testTextSnippet: snippet=" + rstr);
- // check words included in snippet
- for (String word : wordlist) {
- assertTrue("testTextSnippet word included " + word, rstr.contains(word));
- }
-
- }
-
- /**
- * Test of getLineMarked method, of class TextSnippet.
- */
- @Test
- public void testGetLineMarked() throws MalformedURLException {
- URIMetadataNode testpage = new URIMetadataNode(doc);
- testpage.addField(CollectionSchema.title.name(), "New test case");
- testpage.addField(CollectionSchema.keywords.name(), "junit");
- testpage.addField(CollectionSchema.author.name(), "test author");
- testpage.addField(CollectionSchema.text_t.name(),
- "A new testcase has been introduced. "
- + "It includes a few test lines and one line that should match.");
-
- String querywords = "testcase line";
- QueryGoal qg = new QueryGoal(querywords);
- HandleSet queryhashes = qg.getIncludeHashes();
-
- TextSnippet ts = new TextSnippet(
- null,
- testpage,
- queryhashes,
- cacheStrategy,
- pre,
- snippetMaxLength,
- reindexing
- );
-
- String rstr = ts.getError();
- assertEquals("testGetLineMarked Error Code: ", "", rstr);
-
- // check words marked in snippet
- rstr = ts.getLineMarked(qg);
- System.out.println("testGetLineMarked: query=" + querywords);
- System.out.println("testGetLineMarked: snippet=" + rstr);
- String[] wordlist = CommonPattern.SPACE.split(querywords);
- for (String wordstr : wordlist) {
- assertTrue("testGetLineMarked marked word " + wordstr, rstr.contains("<b>" + wordstr + "</b>"));
- }
- }
-
- /**
- * Test of descriptionline method, of class TextSnippet.
- * checking poper encoding of remaining html in raw snippet line.
- */
- @Test
- public void testDescriptionline() throws MalformedURLException {
- String rawtestline = "Über großer test case </span> <pre> <hr><hr /></pre>"; // test line with html, risk of snippet format issue
-
- DigestURL url = new DigestURL("http://localhost/page.html");
- QueryGoal qg = new QueryGoal("test");
-
- // test with raw line (no marking added by YaCy)
- TextSnippet ts = new TextSnippet(
- url.hash(),
- rawtestline,
- true, // isMarked,
- TextSnippet.ResultClass.SOURCE_METADATA, "");
-
- String sniptxt = ts.descriptionline(qg); // snippet text for display
- System.out.println("testDescriptionline: snippet=" + sniptxt);
- assertFalse ("HTML code not allowed in snippet text",sniptxt.contains("<pre>")); // display text not to include unwanted html
-
- // test with marking of query word
- ts = new TextSnippet(
- url.hash(),
- rawtestline,
- false, // isMarked,
- TextSnippet.ResultClass.SOURCE_METADATA, "");
-
- sniptxt = ts.descriptionline(qg);
- System.out.println("testDescriptionline: snippet=" + sniptxt);
- assertFalse ("HTML code not allowed in snippet text",sniptxt.contains("<pre>")); // display text not to include unwanted html
- assertTrue ("Query word not marked", sniptxt.contains("<b>test</b>")); // query word to be marked
-
- // test text with some numbers (english/german format)
- rawtestline = "Test Version 1.83 calculates pi to 3,14 always";
- ts = new TextSnippet(
- url.hash(),
- rawtestline,
- false, // isMarked,
- TextSnippet.ResultClass.SOURCE_METADATA, "");
- sniptxt = ts.descriptionline(qg);
- System.out.println("testDescriptionline: (with numbers) snippet="+sniptxt);
- assertTrue ("number (.) broken up",sniptxt.contains("1.83"));
- assertTrue ("number (,) broken up",sniptxt.contains("3,14"));
- }
-}