当前位置: 首页>>代码示例>>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;未经允许,请勿转载。