本文整理汇总了Java中org.custommonkey.xmlunit.XMLUnit.buildTestDocument方法的典型用法代码示例。如果您正苦于以下问题:Java XMLUnit.buildTestDocument方法的具体用法?Java XMLUnit.buildTestDocument怎么用?Java XMLUnit.buildTestDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.custommonkey.xmlunit.XMLUnit
的用法示例。
在下文中一共展示了XMLUnit.buildTestDocument方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertXmlEqual
import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
/**
* 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.
* <p>Use of this method assumes the
* <a href="http://xmlunit.sourceforge.net/">XMLUnit<a/> library is available.
* @param expected the expected XML content
* @param actual the actual XML content
* @see org.springframework.test.web.servlet.result.MockMvcResultMatchers#xpath(String, Object...)
* @see org.springframework.test.web.servlet.result.MockMvcResultMatchers#xpath(String, Map, Object...)
*/
public void assertXmlEqual(String expected, String actual) throws Exception {
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreComments(true);
XMLUnit.setIgnoreAttributeOrder(true);
Document control = XMLUnit.buildControlDocument(expected);
Document test = XMLUnit.buildTestDocument(actual);
Diff diff = new Diff(control, test);
if (!diff.similar()) {
AssertionErrors.fail("Body content " + diff.toString());
}
}
示例2: transformerEncode
import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
private static ByteArrayOutputStream transformerEncode(final EXIFactory factory, final InputSource source)
throws Exception {
final SAXFactory exiFactory = new SAXFactory(factory);
final ByteArrayOutputStream os = new ByteArrayOutputStream();
final SAXEncoder encoder = exiFactory.createEXIWriter();
encoder.setOutputStream(os);
final Transformer transformer = TransformerFactory.newInstance().newTransformer();
final SAXResult outputTarget = new SAXResult(encoder);
final Document doc = XMLUnit.buildTestDocument(source);
transformer.transform(new DOMSource(doc), outputTarget);
return os;
}
示例3: test_Document2Document
import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Test
public void test_Document2Document() throws IOException, SAXException {
Document docIn = XMLUnit.buildTestDocument("<x><y/></x>");
DefaultMessage message = newMessage();
message.setContent(docIn);
Document docOut = message.getContent(Document.class);
Assert.assertTrue(docIn == docOut);
}
示例4: test_Document2Element
import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Test
public void test_Document2Element() throws IOException, SAXException {
Document docIn = XMLUnit.buildTestDocument("<x><y/></x>");
DefaultMessage message = newMessage();
message.setContent(docIn);
Element elementOut = message.getContent(Element.class);
Assert.assertTrue(docIn == elementOut.getParentNode());
}
示例5: test_Document2String
import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Test
public void test_Document2String() throws IOException, SAXException {
Document docIn = XMLUnit.buildTestDocument("<x><y/></x>");
DefaultMessage message = newMessage();
message.setContent(docIn);
String stringOut = message.getContent(String.class);
XMLAssert.assertXMLEqual("<x><y/></x>", stringOut);
}
示例6: test_Element2String
import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Test
public void test_Element2String() throws IOException, SAXException {
Document docIn = XMLUnit.buildTestDocument("<x><y/></x>");
DefaultMessage message = newMessage();
message.setContent(docIn);
char[] charsOut = message.getContent(char[].class);
XMLAssert.assertXMLEqual("<x><y/></x>", new String(charsOut));
}
示例7: test_DOMSource2String
import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Test
public void test_DOMSource2String() throws IOException, SAXException {
Document docIn = XMLUnit.buildTestDocument("<x><y/></x>");
DefaultMessage message = newMessage();
message.setContent(new DOMSource(docIn));
String stringOut = message.getContent(String.class);
XMLAssert.assertXMLEqual("<x><y/></x>", new String(stringOut));
}
示例8: test_DOMSourceToDocument
import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Test
public void test_DOMSourceToDocument() throws IOException, SAXException {
final Document docIn = XMLUnit.buildTestDocument("<x><y/></x>");
testFromDOM(new DOMSource(docIn), Document.class) ;
testFromDOM(new DOMSource(docIn.getDocumentElement()), Document.class) ;
}
示例9: test_DOMSourceToElement
import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Test
public void test_DOMSourceToElement() throws IOException, SAXException {
final Document docIn = XMLUnit.buildTestDocument("<x><y/></x>");
testFromDOM(new DOMSource(docIn), Element.class) ;
testFromDOM(new DOMSource(docIn.getDocumentElement()), Element.class) ;
}
示例10: test_DOMSourceToNode
import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Test
public void test_DOMSourceToNode() throws IOException, SAXException {
final Document docIn = XMLUnit.buildTestDocument("<x><y/></x>");
testFromDOM(new DOMSource(docIn), Node.class, Document.class) ;
testFromDOM(new DOMSource(docIn.getDocumentElement()), Node.class, Element.class) ;
}