Update xmlunit library to version 2.1.0
xmlunit 2.1.0 is the latest release for xmlunit. Most of the xmlunit functionality used within spring-framework was done through the xmlunit 1.x helper class `org.custommonkey.xmlunit.XMLAssert`. As of xmlunit 2.0.0 most of the XML comparison methods are done through hamcrest matchers exposed by the xmlunit-matchers library. In some cases during the migration, the matchers had to be customized with custom `NodeMatcher` or `DifferenceEvaluator` instances in order to keep the assertions correct (they were performed with xmlunit 1.x previously). Issue: SPR-14043
This commit is contained in:
committed by
Brian Clozel
parent
9fb8a2eb2e
commit
3635c9dbfe
@@ -16,26 +16,25 @@
|
||||
|
||||
package org.springframework.web.servlet.view.feed;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.rometools.rome.feed.atom.Content;
|
||||
import com.rometools.rome.feed.atom.Entry;
|
||||
import com.rometools.rome.feed.atom.Feed;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.mock.web.test.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.test.MockHttpServletResponse;
|
||||
import org.xmlunit.matchers.CompareMatcher;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.*;
|
||||
import static org.custommonkey.xmlunit.XMLUnit.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
@@ -47,7 +46,6 @@ public class AtomFeedViewTests {
|
||||
@Before
|
||||
public void createView() throws Exception {
|
||||
view = new MyAtomFeedView();
|
||||
setIgnoreWhitespace(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -64,9 +62,13 @@ public class AtomFeedViewTests {
|
||||
String expected = "<feed xmlns=\"http://www.w3.org/2005/Atom\">" + "<title>Test Feed</title>" +
|
||||
"<entry><title>2</title><summary>This is entry 2</summary></entry>" +
|
||||
"<entry><title>1</title><summary>This is entry 1</summary></entry>" + "</feed>";
|
||||
assertXMLEqual(expected, response.getContentAsString());
|
||||
assertThat(response.getContentAsString(), isSimilarTo(expected));
|
||||
}
|
||||
|
||||
private static CompareMatcher isSimilarTo(final String content) {
|
||||
return CompareMatcher.isSimilarTo(content)
|
||||
.ignoreWhitespace();
|
||||
}
|
||||
|
||||
private static class MyAtomFeedView extends AbstractAtomFeedView {
|
||||
|
||||
|
||||
@@ -16,25 +16,25 @@
|
||||
|
||||
package org.springframework.web.servlet.view.feed;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.rometools.rome.feed.rss.Channel;
|
||||
import com.rometools.rome.feed.rss.Description;
|
||||
import com.rometools.rome.feed.rss.Item;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.mock.web.test.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.test.MockHttpServletResponse;
|
||||
import org.xmlunit.matchers.CompareMatcher;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.*;
|
||||
import static org.custommonkey.xmlunit.XMLUnit.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.xmlunit.matchers.CompareMatcher.isSimilarTo;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
@@ -46,7 +46,6 @@ public class RssFeedViewTests {
|
||||
@Before
|
||||
public void createView() throws Exception {
|
||||
view = new MyRssFeedView();
|
||||
setIgnoreWhitespace(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -64,7 +63,7 @@ public class RssFeedViewTests {
|
||||
"<channel><title>Test Feed</title><link>http://example.com</link><description>Test feed description</description>" +
|
||||
"<item><title>2</title><description>This is entry 2</description></item>" +
|
||||
"<item><title>1</title><description>This is entry 1</description></item>" + "</channel></rss>";
|
||||
assertXMLEqual(expected, response.getContentAsString());
|
||||
assertThat(response.getContentAsString(), isSimilarTo(expected).ignoreWhitespace());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user