From fc131ea0908b97218510836c06784accf07e40fc Mon Sep 17 00:00:00 2001 From: Bjørn Christian Seime Date: Tue, 7 Jan 2020 13:41:49 +0100 Subject: Remove use of common-lang in vespa-http-client --- .../yahoo/vespa/http/client/core/XmlFeedReaderTest.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'vespa-http-client/src') diff --git a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/XmlFeedReaderTest.java b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/XmlFeedReaderTest.java index 9abbf916cff..925f3105878 100644 --- a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/XmlFeedReaderTest.java +++ b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/XmlFeedReaderTest.java @@ -1,8 +1,9 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.http.client.core; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; import com.yahoo.vespa.http.client.FeedClient; -import org.apache.commons.lang3.StringEscapeUtils; import org.junit.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -17,7 +18,6 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.mockito.ArgumentMatchers.any; @@ -32,6 +32,8 @@ public class XmlFeedReaderTest { private final static String feedResource3 = "/xml-challenge2.xml"; private final static String feedResource4 = "/xml-challenge3.xml"; + private static final XmlMapper xmlMapper = new XmlMapper(); + private final String updateDocUpdate = "\n" + "\n" + @@ -232,13 +234,9 @@ public class XmlFeedReaderTest { InputStream inputStream2 = XmlFeedReaderTest.class.getResourceAsStream(filename); String rawXML = new java.util.Scanner(inputStream2, "UTF-8").useDelimiter("\\A").next(); - String rawDoc = rawXML.toString().split("")[0]; - assertThat(rawDoc.length() > 30, is(true)); - - String decodedRawXml = StringEscapeUtils.unescapeXml(rawDoc); - String decodedDoc = StringEscapeUtils.unescapeXml(document); - - assertThat(decodedDoc, containsString(decodedRawXml)); + JsonNode decodedDocument = xmlMapper.readTree(document); + JsonNode rawDocuments = xmlMapper.readTree(rawXML); + assertThat(decodedDocument, is(rawDocuments.get("document"))); } @Test public void testCData() throws Exception { -- cgit v1.2.3