本文整理匯總了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) ;
}