Skip to content

Commit 8627773

Browse files
WAT extractor: add attributes of the <html> element as metadata
- make tests run also on JDK 8
1 parent 581b43a commit 8627773

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/test/java/org/archive/resource/html/ExtractingParseObserverTest.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,17 @@ private void checkLinks(Resource resource, String[][] expectedLinks) {
241241
}
242242
}
243243

244-
private void checkExtractHtmlLangAttribute(Resource resource, Map<String, String> langAttributes)
244+
private void checkExtractHtmlLangAttribute(Resource resource, String... langAttributes)
245245
throws JSONException {
246246
assertNotNull(resource);
247247
assertTrue("Wrong instance type of Resource: " + resource.getClass(), resource instanceof HTMLResource);
248248
JSONArray metas = resource.getMetaData().getJSONObject("Head").getJSONArray("Metas");
249249
assertNotNull(metas);
250250
JSONObject meta = metas.getJSONObject(0);
251-
for (String key : langAttributes.keySet()) {
251+
for (int i = 0; i < langAttributes.length; i += 2) {
252+
String key = langAttributes[i];
252253
assertNotNull(meta.get(key));
253-
assertEquals(meta.get(key), langAttributes.get(key));
254+
assertEquals(meta.get(key), langAttributes[i+1]);
254255
}
255256
}
256257

@@ -433,11 +434,11 @@ public void testHtmlLanguageAttributeExtraction() throws ResourceParseException,
433434
ResourceProducer producer = ProducerUtils.getProducer(getClass().getResource(testFileName).getPath());
434435
ResourceFactoryMapper mapper = new ExtractingResourceFactoryMapper();
435436
ExtractingResourceProducer extractor = new ExtractingResourceProducer(producer, mapper);
436-
checkExtractHtmlLangAttribute(extractor.getNext(), Map.of("name", "HTML@/lang", "content", "en"));
437-
checkExtractHtmlLangAttribute(extractor.getNext(), Map.of("name", "HTML@/lang", "content", "zh-CN"));
438-
checkExtractHtmlLangAttribute(extractor.getNext(), Map.of("name", "HTML@/lang", "content", "cs-cz"));
439-
checkExtractHtmlLangAttribute(extractor.getNext(), Map.of("name", "HTML@/lang", "content", "en"));
440-
checkExtractHtmlLangAttribute(extractor.getNext(), Map.of("name", "HTML@/xml:lang", "content", "es-MX"));
437+
checkExtractHtmlLangAttribute(extractor.getNext(), "name", "HTML@/lang", "content", "en");
438+
checkExtractHtmlLangAttribute(extractor.getNext(), "name", "HTML@/lang", "content", "zh-CN");
439+
checkExtractHtmlLangAttribute(extractor.getNext(), "name", "HTML@/lang", "content", "cs-cz");
440+
checkExtractHtmlLangAttribute(extractor.getNext(), "name", "HTML@/lang", "content", "en");
441+
checkExtractHtmlLangAttribute(extractor.getNext(), "name", "HTML@/xml:lang", "content", "es-MX");
441442
}
442443

443444
public void testHtmlParserEntityDecoding() {

0 commit comments

Comments
 (0)