當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLUnit.buildTestDocument方法代碼示例

本文整理匯總了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());
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:24,代碼來源:XmlExpectationsHelper.java

示例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;
}
 
開發者ID:EXIficient,項目名稱:exificient,代碼行數:13,代碼來源:TransformerEncodeTest.java

示例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);
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:11,代碼來源:BasicDOMTransformerTest.java

示例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());
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:11,代碼來源:BasicDOMTransformerTest.java

示例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);
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:11,代碼來源:BasicDOMTransformerTest.java

示例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));
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:11,代碼來源:BasicDOMTransformerTest.java

示例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));
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:11,代碼來源:BasicDOMTransformerTest.java

示例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) ;
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:7,代碼來源:BasicDOMTransformerTest.java

示例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) ;
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:7,代碼來源:BasicDOMTransformerTest.java

示例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) ;
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:7,代碼來源:BasicDOMTransformerTest.java


注:本文中的org.custommonkey.xmlunit.XMLUnit.buildTestDocument方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。