Package org.springframework.test.util
Class XmlExpectationsHelper
- java.lang.Object
- org.springframework.test.util.XmlExpectationsHelper
public class XmlExpectationsHelper extends Object
A helper class for assertions on XML content.- Since:
- 3.2
- Author:
- Rossen Stoyanchev
Constructor Summary
Constructors Constructor Description XmlExpectationsHelper()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assertNode(String content, Matcher<? super Node> matcher)
void
assertSource(String content, Matcher<? super Source> matcher)
void
assertXmlEqual(String expected, String actual)
Parse the expected and actual content strings as XML and assert that the two are "similar" -- i.e.
Constructor Detail
XmlExpectationsHelper
public XmlExpectationsHelper()
Method Detail
assertNode
public void assertNode(String content, Matcher<? super Node> matcher) throws Exception
- Throws:
Exception
assertSource
public void assertSource(String content, Matcher<? super Source> matcher) throws Exception
- Throws:
Exception
- See Also:
- xml-matchers
assertXmlEqual
public void assertXmlEqual(String expected, String actual) throws Exception
Parse the expected and actual content strings as XML and assert that the two are "similar" -- i.e. they contain the same elements and attributes regardless of order.Use of this method assumes the XMLUnit library is available.
- Parameters:
expected
- the expected XML contentactual
- the actual XML content- Throws:
Exception
- See Also:
MockMvcResultMatchers.xpath(String, Object...)
,MockMvcResultMatchers.xpath(String, Map, Object...)