From 0579a9546a69cbb4c0831abf744fa9c084ab3050 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Thu, 3 Feb 2022 13:27:06 +0100 Subject: changed link to new forum location --- .../yacy/document/parser/GenericXMLParserTest.java | 108 ++++++++++----------- .../document/parser/html/ContentScraperTest.java | 48 ++++----- .../net/yacy/document/parser/ooxmlParserTest.java | 10 +- 3 files changed, 83 insertions(+), 83 deletions(-) (limited to 'test') diff --git a/test/java/net/yacy/document/parser/GenericXMLParserTest.java b/test/java/net/yacy/document/parser/GenericXMLParserTest.java index 3d2ae67a3..41115b304 100644 --- a/test/java/net/yacy/document/parser/GenericXMLParserTest.java +++ b/test/java/net/yacy/document/parser/GenericXMLParserTest.java @@ -58,7 +58,7 @@ public class GenericXMLParserTest { @Before public void setUp() { - parser = new GenericXMLParser(); + this.parser = new GenericXMLParser(); } /** @@ -73,11 +73,11 @@ public class GenericXMLParserTest { final String[] fileNames = { "umlaute_dc_xml_iso.xml", "umlaute_dc_xml_utf8.xml" }; final File folder = new File("test" + File.separator + "parsertest" + File.separator); - for (String fileName : fileNames) { - FileInputStream inStream = new FileInputStream(new File(folder, fileName)); - DigestURL location = new DigestURL("http://localhost/" + fileName); + for (final String fileName : fileNames) { + final FileInputStream inStream = new FileInputStream(new File(folder, fileName)); + final DigestURL location = new DigestURL("http://localhost/" + fileName); try { - Document[] documents = parser.parse(location, "text/xml", null, new VocabularyScraper(), 0, + final Document[] documents = this.parser.parse(location, "text/xml", null, new VocabularyScraper(), 0, inStream); assertNotNull("Parser result must not be null for file " + fileName, documents); assertNotNull("Parsed text must not be empty for file " + fileName, documents[0].getTextString()); @@ -107,11 +107,11 @@ public class GenericXMLParserTest { private void testCharsetDetection(final GenericXMLParser parser, final byte[] encodedXML, final String contentTypeHeader, final String expectedCharset, final String expectedConntainedText) throws Exception { - InputStream inStream = new ByteArrayInputStream(encodedXML); - String charsetFromHttpHeader = HeaderFramework.getCharacterEncoding(contentTypeHeader); - DigestURL location = new DigestURL("http://localhost/testfile.xml"); + final InputStream inStream = new ByteArrayInputStream(encodedXML); + final String charsetFromHttpHeader = HeaderFramework.getCharacterEncoding(contentTypeHeader); + final DigestURL location = new DigestURL("http://localhost/testfile.xml"); try { - Document[] documents = parser.parse(location, contentTypeHeader, charsetFromHttpHeader, + final Document[] documents = parser.parse(location, contentTypeHeader, charsetFromHttpHeader, new VocabularyScraper(), 0, inStream); assertEquals(expectedCharset, documents[0].getCharset()); assertNotNull(documents[0].getTextString()); @@ -138,7 +138,7 @@ public class GenericXMLParserTest { */ byte[] encodedXML = ("" + UMLAUT_TEXT_TAG) .getBytes(StandardCharsets.UTF_8); - testCharsetDetection(parser, encodedXML, "application/xml; charset=utf-8", StandardCharsets.UTF_8.name(), + testCharsetDetection(this.parser, encodedXML, "application/xml; charset=utf-8", StandardCharsets.UTF_8.name(), "Maßkrügen"); /* @@ -146,7 +146,7 @@ public class GenericXMLParserTest { * declaration */ encodedXML = ("" + UMLAUT_TEXT_TAG).getBytes(StandardCharsets.UTF_8); - testCharsetDetection(parser, encodedXML, "application/xml; charset=utf-8", StandardCharsets.UTF_8.name(), + testCharsetDetection(this.parser, encodedXML, "application/xml; charset=utf-8", StandardCharsets.UTF_8.name(), "Maßkrügen"); } @@ -169,7 +169,7 @@ public class GenericXMLParserTest { */ byte[] encodedXML = ("" + UMLAUT_TEXT_TAG) .getBytes(StandardCharsets.UTF_16); - testCharsetDetection(parser, encodedXML, "application/xml; charset=utf-16", StandardCharsets.UTF_16.name(), + testCharsetDetection(this.parser, encodedXML, "application/xml; charset=utf-16", StandardCharsets.UTF_16.name(), "Maßkrügen"); /* @@ -177,7 +177,7 @@ public class GenericXMLParserTest { * XML declaration having only BOM (Byte Order Mark) */ encodedXML = ("" + UMLAUT_TEXT_TAG).getBytes(StandardCharsets.UTF_16); - testCharsetDetection(parser, encodedXML, "application/xml; charset=utf-16", + testCharsetDetection(this.parser, encodedXML, "application/xml; charset=utf-16", StandardCharsets.UTF_16BE.name(), "Maßkrügen"); /* @@ -186,14 +186,14 @@ public class GenericXMLParserTest { */ encodedXML = ("" + UMLAUT_TEXT_TAG) .getBytes(StandardCharsets.UTF_16); - testCharsetDetection(parser, encodedXML, "application/xml", StandardCharsets.UTF_16.name(), "Maßkrügen"); + testCharsetDetection(this.parser, encodedXML, "application/xml", StandardCharsets.UTF_16.name(), "Maßkrügen"); /* * Charset is omitted in both Content-Type HTTP header and XML * declaration with BOM (Byte Order Mark) */ encodedXML = ("" + UMLAUT_TEXT_TAG).getBytes(StandardCharsets.UTF_16); - testCharsetDetection(parser, encodedXML, "application/xml", StandardCharsets.UTF_16BE.name(), "Maßkrügen"); + testCharsetDetection(this.parser, encodedXML, "application/xml", StandardCharsets.UTF_16BE.name(), "Maßkrügen"); } /** @@ -211,9 +211,9 @@ public class GenericXMLParserTest { * ISO-8859-1 charset provided only in XML declaration without BOM (Byte * Order Mark) */ - byte[] encodedXML = ("" + UMLAUT_TEXT_TAG) + final byte[] encodedXML = ("" + UMLAUT_TEXT_TAG) .getBytes(StandardCharsets.ISO_8859_1); - testCharsetDetection(parser, encodedXML, "application/xml", StandardCharsets.ISO_8859_1.name(), + testCharsetDetection(this.parser, encodedXML, "application/xml", StandardCharsets.ISO_8859_1.name(), "Maßkrügen"); } @@ -234,7 +234,7 @@ public class GenericXMLParserTest { * XML encoded as UTF-8 without BOM (Byte Order Mark) */ byte[] encodedXML = ("" + UMLAUT_TEXT_TAG).getBytes(StandardCharsets.UTF_8); - testCharsetDetection(parser, encodedXML, "application/xml", StandardCharsets.UTF_8.name(), "Maßkrügen"); + testCharsetDetection(this.parser, encodedXML, "application/xml", StandardCharsets.UTF_8.name(), "Maßkrügen"); /* * XML encoded as ASCII, with non ascii chars encoded as entities @@ -242,7 +242,7 @@ public class GenericXMLParserTest { encodedXML = ("" + "In München steht ein Hofbräuhaus, dort gibt es Bier in Maßkrügen") .getBytes(StandardCharsets.US_ASCII); - testCharsetDetection(parser, encodedXML, "application/xml", StandardCharsets.UTF_8.name(), "Maßkrügen"); + testCharsetDetection(this.parser, encodedXML, "application/xml", StandardCharsets.UTF_8.name(), "Maßkrügen"); } /** @@ -260,9 +260,9 @@ public class GenericXMLParserTest { * UTF-16BE charset provided both in Content-Type HTTP header and in XML * declaration, without BOM (Byte Order Mark) */ - byte[] encodedXML = ("" + UMLAUT_TEXT_TAG) + final byte[] encodedXML = ("" + UMLAUT_TEXT_TAG) .getBytes(StandardCharsets.UTF_16BE); - testCharsetDetection(parser, encodedXML, "application/xml; charset=utf-16be", + testCharsetDetection(this.parser, encodedXML, "application/xml; charset=utf-16be", StandardCharsets.UTF_16BE.name(), "Maßkrügen"); } @@ -279,24 +279,24 @@ public class GenericXMLParserTest { + "" + "" + "" + "XHTML attributes URLs test" + "" + "" - + "Here are YaCyhome page and International Forum." + + "Here are YaCyhome page and International Forum." + "And this is a relative link to a sub document." + "" + ""; - InputStream inStream = new ByteArrayInputStream(xhtml.getBytes(StandardCharsets.UTF_8.name())); + final InputStream inStream = new ByteArrayInputStream(xhtml.getBytes(StandardCharsets.UTF_8.name())); final String contentTypeHeader = "text/xhtml"; - String charsetFromHttpHeader = HeaderFramework.getCharacterEncoding(contentTypeHeader); - DigestURL location = new DigestURL("http://localhost/testfile.xml"); + final String charsetFromHttpHeader = HeaderFramework.getCharacterEncoding(contentTypeHeader); + final DigestURL location = new DigestURL("http://localhost/testfile.xml"); try { - Document[] documents = parser.parse(location, contentTypeHeader, charsetFromHttpHeader, + final Document[] documents = this.parser.parse(location, contentTypeHeader, charsetFromHttpHeader, new VocabularyScraper(), 0, inStream); assertEquals(1, documents.length); - Collection detectedAnchors = documents[0].getAnchors(); + final Collection detectedAnchors = documents[0].getAnchors(); assertNotNull(detectedAnchors); assertEquals(3, detectedAnchors.size()); assertTrue(detectedAnchors.contains(new AnchorURL("http://www.w3.org/1999/xhtml"))); assertTrue(detectedAnchors.contains(new AnchorURL("http://yacy.net"))); - assertTrue(detectedAnchors.contains(new AnchorURL("https://searchlab.eu"))); + assertTrue(detectedAnchors.contains(new AnchorURL("https://community.searchlab.eu"))); } finally { inStream.close(); } @@ -316,23 +316,23 @@ public class GenericXMLParserTest { + "" + "XHTML content URLs test" + "" + "" + "Here are some YaCy links:" + "
" + "
Home page
" + "
http://yacy.net
" + "
International Forum
" - + "
https://searchlab.eu
" + "
" + + "
https://community.searchlab.eu
" + "" + "And this is a mention to a relative link : /document.html " + "" + ""; - InputStream inStream = new ByteArrayInputStream(xhtml.getBytes(StandardCharsets.UTF_8.name())); + final InputStream inStream = new ByteArrayInputStream(xhtml.getBytes(StandardCharsets.UTF_8.name())); final String contentTypeHeader = "text/xhtml"; - String charsetFromHttpHeader = HeaderFramework.getCharacterEncoding(contentTypeHeader); - DigestURL location = new DigestURL("http://localhost/testfile.xml"); + final String charsetFromHttpHeader = HeaderFramework.getCharacterEncoding(contentTypeHeader); + final DigestURL location = new DigestURL("http://localhost/testfile.xml"); try { - Document[] documents = parser.parse(location, contentTypeHeader, charsetFromHttpHeader, + final Document[] documents = this.parser.parse(location, contentTypeHeader, charsetFromHttpHeader, new VocabularyScraper(), 0, inStream); assertEquals(1, documents.length); - Collection detectedAnchors = documents[0].getAnchors(); + final Collection detectedAnchors = documents[0].getAnchors(); assertNotNull(detectedAnchors); assertEquals(3, detectedAnchors.size()); assertTrue(detectedAnchors.contains(new AnchorURL("http://www.w3.org/1999/xhtml"))); assertTrue(detectedAnchors.contains(new AnchorURL("http://yacy.net"))); - assertTrue(detectedAnchors.contains(new AnchorURL("https://searchlab.eu"))); + assertTrue(detectedAnchors.contains(new AnchorURL("https://community.searchlab.eu"))); } finally { inStream.close(); } @@ -346,12 +346,12 @@ public class GenericXMLParserTest { public void testParseXMLFragment() throws Exception { final String xhtml = "Node content1Node content2"; - InputStream inStream = new ByteArrayInputStream(xhtml.getBytes(StandardCharsets.UTF_8.name())); + final InputStream inStream = new ByteArrayInputStream(xhtml.getBytes(StandardCharsets.UTF_8.name())); final String contentTypeHeader = "text/xml"; - String charsetFromHttpHeader = HeaderFramework.getCharacterEncoding(contentTypeHeader); - DigestURL location = new DigestURL("http://localhost/testfile.xml"); + final String charsetFromHttpHeader = HeaderFramework.getCharacterEncoding(contentTypeHeader); + final DigestURL location = new DigestURL("http://localhost/testfile.xml"); try { - Document[] documents = parser.parse(location, contentTypeHeader, charsetFromHttpHeader, + final Document[] documents = this.parser.parse(location, contentTypeHeader, charsetFromHttpHeader, new VocabularyScraper(), 0, inStream); assertEquals(1, documents.length); assertEquals("Node content1 Node content2", documents[0].getTextString()); @@ -368,13 +368,13 @@ public class GenericXMLParserTest { */ @Test public void testParseWithLimits() throws Exception { - String xhtml = "" + final String xhtml = "" + "" + "" + "" + "" + "XHTML content URLs test" + "" + "" + "

Here are some YaCy URLs: " + "Home page : http://yacy.net - International Forum : " - + "https://searchlab.eu " + + "https://community.searchlab.eu " + "and this is a mention to a relative URL : /document.html

" + "

Here are YaCybug tracker and Wiki." + "And this is a relative link to another sub document

" @@ -383,21 +383,21 @@ public class GenericXMLParserTest { /* Content within limits */ InputStream inStream = new ByteArrayInputStream(xhtml.getBytes(StandardCharsets.UTF_8.name())); final String contentTypeHeader = "text/xhtml"; - String charsetFromHttpHeader = HeaderFramework.getCharacterEncoding(contentTypeHeader); - DigestURL location = new DigestURL("http://localhost/testfile.xml"); + final String charsetFromHttpHeader = HeaderFramework.getCharacterEncoding(contentTypeHeader); + final DigestURL location = new DigestURL("http://localhost/testfile.xml"); try { - Document[] documents = parser.parseWithLimits(location, contentTypeHeader, charsetFromHttpHeader, new VocabularyScraper(), 0, inStream, Integer.MAX_VALUE, Long.MAX_VALUE); + final Document[] documents = this.parser.parseWithLimits(location, contentTypeHeader, charsetFromHttpHeader, new VocabularyScraper(), 0, inStream, Integer.MAX_VALUE, Long.MAX_VALUE); assertEquals(1, documents.length); assertFalse(documents[0].isPartiallyParsed()); assertTrue(documents[0].getTextString().contains("And this is a relative link")); - Collection detectedAnchors = documents[0].getAnchors(); + final Collection detectedAnchors = documents[0].getAnchors(); assertNotNull(detectedAnchors); assertEquals(5, detectedAnchors.size()); assertTrue(detectedAnchors.contains(new AnchorURL("http://www.w3.org/1999/xhtml"))); assertTrue(detectedAnchors.contains(new AnchorURL("http://yacy.net"))); - assertTrue(detectedAnchors.contains(new AnchorURL("https://searchlab.eu"))); + assertTrue(detectedAnchors.contains(new AnchorURL("https://community.searchlab.eu"))); assertTrue(detectedAnchors.contains(new AnchorURL("http://mantis.tokeek.de"))); assertTrue(detectedAnchors.contains(new AnchorURL("https://wiki.yacy.net/index.php/"))); } finally { @@ -407,7 +407,7 @@ public class GenericXMLParserTest { /* Links limit exceeded */ inStream = new ByteArrayInputStream(xhtml.getBytes(StandardCharsets.UTF_8.name())); try { - Document[] documents = parser.parseWithLimits(location, contentTypeHeader, charsetFromHttpHeader, + final Document[] documents = this.parser.parseWithLimits(location, contentTypeHeader, charsetFromHttpHeader, new VocabularyScraper(), 0, inStream, 2, Long.MAX_VALUE); assertEquals(1, documents.length); assertTrue(documents[0].isPartiallyParsed()); @@ -415,7 +415,7 @@ public class GenericXMLParserTest { assertTrue(documents[0].getTextString().contains("Home page")); assertFalse(documents[0].getTextString().contains("And this is a relative link")); - Collection detectedAnchors = documents[0].getAnchors(); + final Collection detectedAnchors = documents[0].getAnchors(); assertNotNull(detectedAnchors); assertEquals(2, detectedAnchors.size()); assertTrue(detectedAnchors.contains(new AnchorURL("http://www.w3.org/1999/xhtml"))); @@ -425,7 +425,7 @@ public class GenericXMLParserTest { } /* Bytes limit exceeded */ - StringBuilder xhtmlBuilder = new StringBuilder("") + final StringBuilder xhtmlBuilder = new StringBuilder("") .append("") .append("") .append("") @@ -434,7 +434,7 @@ public class GenericXMLParserTest { .append("") .append("

Here are some YaCy URLs: ") .append("Home page : http://yacy.net - International Forum : ") - .append("https://searchlab.eu ") + .append("https://community.searchlab.eu ") .append("and this is a mention to a relative URL : /document.html

"); /* Add some filler text to reach a total size beyond SAX parser internal input stream buffers */ @@ -442,25 +442,25 @@ public class GenericXMLParserTest { xhtmlBuilder.append("

Some text to parse

"); } - int firstBytes = xhtmlBuilder.toString().getBytes(StandardCharsets.UTF_8.name()).length; + final int firstBytes = xhtmlBuilder.toString().getBytes(StandardCharsets.UTF_8.name()).length; xhtmlBuilder.append("

Here are YaCybug tracker and Wiki.") .append("And this is a relative link to another sub document

") .append(""); inStream = new ByteArrayInputStream(xhtmlBuilder.toString().getBytes(StandardCharsets.UTF_8.name())); try { - Document[] documents = parser.parseWithLimits(location, contentTypeHeader, charsetFromHttpHeader, new VocabularyScraper(), 0, inStream, Integer.MAX_VALUE, firstBytes); + final Document[] documents = this.parser.parseWithLimits(location, contentTypeHeader, charsetFromHttpHeader, new VocabularyScraper(), 0, inStream, Integer.MAX_VALUE, firstBytes); assertEquals(1, documents.length); assertTrue(documents[0].isPartiallyParsed()); assertTrue(documents[0].getTextString().contains("and this is a mention to a relative URL")); assertFalse(documents[0].getTextString().contains("And this is a relative link to another")); - Collection detectedAnchors = documents[0].getAnchors(); + final Collection detectedAnchors = documents[0].getAnchors(); assertNotNull(detectedAnchors); assertEquals(3, detectedAnchors.size()); assertTrue(detectedAnchors.contains(new AnchorURL("http://www.w3.org/1999/xhtml"))); assertTrue(detectedAnchors.contains(new AnchorURL("http://yacy.net"))); - assertTrue(detectedAnchors.contains(new AnchorURL("https://searchlab.eu"))); + assertTrue(detectedAnchors.contains(new AnchorURL("https://community.searchlab.eu"))); } finally { inStream.close(); } diff --git a/test/java/net/yacy/document/parser/html/ContentScraperTest.java b/test/java/net/yacy/document/parser/html/ContentScraperTest.java index 105303166..cdb4f3951 100644 --- a/test/java/net/yacy/document/parser/html/ContentScraperTest.java +++ b/test/java/net/yacy/document/parser/html/ContentScraperTest.java @@ -143,13 +143,13 @@ public class ContentScraperTest { @Test public void testGetStartDates() throws MalformedURLException, IOException { List dateResultList; - DigestURL root = new DigestURL("http://test.org/test.html"); + final DigestURL root = new DigestURL("http://test.org/test.html"); - String page = "" + final String page = "" + "" // html5 time tag + ""; - ContentScraper scraper = new ContentScraper(root, 10, new HashSet(), new VocabularyScraper(), 0); + final ContentScraper scraper = new ContentScraper(root, 10, new HashSet(), new VocabularyScraper(), 0); final Writer writer = new TransformerWriter(null, null, scraper, false); FileUtils.copy(new StringReader(page), writer); @@ -157,11 +157,11 @@ public class ContentScraperTest { dateResultList = scraper.getStartDates(); - Calendar cal = Calendar.getInstance(); + final Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(0); // to zero hours cal.set(2016, Calendar.DECEMBER, 23); - for (Date d : dateResultList) { + for (final Date d : dateResultList) { Assert.assertEquals(cal.getTime(), d); } scraper.close(); @@ -173,35 +173,35 @@ public class ContentScraperTest { */ @Test public void testFindAbsoluteURLs() throws MalformedURLException { - final String[] urlStrings = { "http://yacy.net", "https://searchlab.eu", "https://en.wikipedia.org" }; + final String[] urlStrings = { "http://yacy.net", "https://community.searchlab.eu", "https://en.wikipedia.org" }; final List urls = new ArrayList<>(); - for (String urlString : urlStrings) { + for (final String urlString : urlStrings) { urls.add(new AnchorURL(urlString)); } /* Test with various white space separators */ - String[] separators = { " ", "\n", "\t", "\r" }; - for (String separator : separators) { - StringBuilder text = new StringBuilder(); - for (String urlString : urlStrings) { + final String[] separators = { " ", "\n", "\t", "\r" }; + for (final String separator : separators) { + final StringBuilder text = new StringBuilder(); + for (final String urlString : urlStrings) { if (text.length() > 0) { text.append(separator); } text.append(urlString); } - Collection detectedURLs = new ArrayList<>(); + final Collection detectedURLs = new ArrayList<>(); ContentScraper.findAbsoluteURLs(text.toString(), detectedURLs, null); Assert.assertEquals(urls.size(), detectedURLs.size()); Assert.assertTrue(urls.containsAll(detectedURLs)); } /* URLs surrounded with parenthesis */ - String[] texts = { "(http://yacy.net)", "YaCy home page (http://yacy.net)", + final String[] texts = { "(http://yacy.net)", "YaCy home page (http://yacy.net)", "Nested parentheses (YaCy home page (http://yacy.net))", "Text in parenthesis (example : http://yacy.net)", "A markdown link [YaCy home page](http://yacy.net)", "A markdown [example](http://yacy.net \"YaCy home page\") inline link" }; - for (String text : texts) { - Collection detectedURLs = new ArrayList<>(); + for (final String text : texts) { + final Collection detectedURLs = new ArrayList<>(); ContentScraper.findAbsoluteURLs(text, detectedURLs, null); Assert.assertEquals(1, detectedURLs.size()); Assert.assertEquals(new AnchorURL("http://yacy.net"), detectedURLs.iterator().next()); @@ -209,11 +209,11 @@ public class ContentScraperTest { /* URLs surrounded with square brackets */ //http://[abcd:ef01:2345:6789:abcd:ef01:2345:6789]/ - String[] squareBracketsTexts = { "[http://yacy.net]", "YaCy home page [http://yacy.net]", + final String[] squareBracketsTexts = { "[http://yacy.net]", "YaCy home page [http://yacy.net]", "Nested brackets [YaCy home page [http://yacy.net]]", "A mediawiki external link with different label [http://yacy.net YaCy home page]" }; - for(String text : squareBracketsTexts) { - Collection detectedURLs = new ArrayList<>(); + for(final String text : squareBracketsTexts) { + final Collection detectedURLs = new ArrayList<>(); ContentScraper.findAbsoluteURLs(text, detectedURLs, null); Assert.assertEquals(1, detectedURLs.size()); Assert.assertEquals(new AnchorURL("http://yacy.net"), detectedURLs.iterator().next()); @@ -221,11 +221,11 @@ public class ContentScraperTest { /* URLs surrounded with curly brackets */ //http://[abcd:ef01:2345:6789:abcd:ef01:2345:6789]/ - String[] curlyBracketsTexts = { "{http://yacy.net}", "YaCy home page {http://yacy.net}", + final String[] curlyBracketsTexts = { "{http://yacy.net}", "YaCy home page {http://yacy.net}", "Nested brackets {YaCy home page {http://yacy.net}}", "Text in brackets {example : http://yacy.net}" }; - for(String text : curlyBracketsTexts) { - Collection detectedURLs = new ArrayList<>(); + for(final String text : curlyBracketsTexts) { + final Collection detectedURLs = new ArrayList<>(); ContentScraper.findAbsoluteURLs(text, detectedURLs, null); Assert.assertEquals(1, detectedURLs.size()); Assert.assertEquals(new AnchorURL("http://yacy.net"), detectedURLs.iterator().next()); @@ -277,7 +277,7 @@ public class ContentScraperTest { */ @Test public void testFindAbsoluteURLsMaxURLs() throws MalformedURLException { - final String text = "Some test URLS : http://yacy.net - https://searchlab.eu - https://en.wikipedia.org"; + final String text = "Some test URLS : http://yacy.net - https://community.searchlab.eu - https://en.wikipedia.org"; /* No limit */ ArrayList detectedURLs = new ArrayList<>(); @@ -425,7 +425,7 @@ public class ContentScraperTest { html2Results.put(html, expectedUrls); for (final Entry html2Result : html2Results.entrySet()) { - ContentScraper scraper = new ContentScraper(docUrl, 10, new HashSet(), new VocabularyScraper(), 0); + final ContentScraper scraper = new ContentScraper(docUrl, 10, new HashSet(), new VocabularyScraper(), 0); try (final Writer writer = new TransformerWriter(null, null, scraper, false)) { FileUtils.copy(new StringReader(html2Result.getKey()), writer); @@ -500,7 +500,7 @@ public class ContentScraperTest { for (final Entry html2Result : html2Results.entrySet()) { - ContentScraper scraper = new ContentScraper(docUrl, 10, new HashSet(), new VocabularyScraper(), 0); + final ContentScraper scraper = new ContentScraper(docUrl, 10, new HashSet(), new VocabularyScraper(), 0); try (final Writer writer = new TransformerWriter(null, null, scraper, false)) { FileUtils.copy(new StringReader(html2Result.getKey()), writer); diff --git a/test/java/net/yacy/document/parser/ooxmlParserTest.java b/test/java/net/yacy/document/parser/ooxmlParserTest.java index f5cf79e47..12d30dee2 100644 --- a/test/java/net/yacy/document/parser/ooxmlParserTest.java +++ b/test/java/net/yacy/document/parser/ooxmlParserTest.java @@ -93,7 +93,7 @@ public class ooxmlParserTest { final String mimetype = testFile[1]; final AnchorURL url = new AnchorURL("http://localhost/" + filename); - AbstractParser p = new ooxmlParser(); + final AbstractParser p = new ooxmlParser(); inStream = new FileInputStream(file); final Document[] docs = p.parse(url, mimetype, null, new VocabularyScraper(), 0, inStream); for (final Document doc : docs) { @@ -116,7 +116,7 @@ public class ooxmlParserTest { if (content != null) { try { content.close(); - } catch (IOException ioe) { + } catch (final IOException ioe) { System.out.println("Could not close text input stream"); } } @@ -126,7 +126,7 @@ public class ooxmlParserTest { if (inStream != null) { try { inStream.close(); - } catch (IOException ioe) { + } catch (final IOException ioe) { System.out.println("Could not close input stream on file " + filename); } } @@ -145,7 +145,7 @@ public class ooxmlParserTest { final String mimetype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; final AnchorURL url = new AnchorURL("http://localhost/" + fileName); - AbstractParser p = new ooxmlParser(); + final AbstractParser p = new ooxmlParser(); try(InputStream inStream = new FileInputStream(file);) { final Document[] docs = p.parse(url, mimetype, null, new VocabularyScraper(), 0, inStream); assertNotNull("Documents result must not be null", docs); @@ -153,7 +153,7 @@ public class ooxmlParserTest { assertNotNull("Detected URLs must not be null", anchors); assertEquals("2 URLs should be detected", 2, anchors.size()); assertTrue("YaCy home page URL should have been parsed: " + anchors.toString(), anchors.contains(new AnchorURL("http://yacy.net/"))); - assertTrue("YaCy forum URL should have been parsed: " + anchors.toString(), anchors.contains(new AnchorURL("https://searchlab.eu/"))); + assertTrue("YaCy forum URL should have been parsed: " + anchors.toString(), anchors.contains(new AnchorURL("https://community.searchlab.eu/"))); } } -- cgit v1.2.3