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


Java XMLUnit.setIgnoreWhitespace方法代碼示例

本文整理匯總了Java中org.custommonkey.xmlunit.XMLUnit.setIgnoreWhitespace方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLUnit.setIgnoreWhitespace方法的具體用法?Java XMLUnit.setIgnoreWhitespace怎麽用?Java XMLUnit.setIgnoreWhitespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.custommonkey.xmlunit.XMLUnit的用法示例。


在下文中一共展示了XMLUnit.setIgnoreWhitespace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: compare

import org.custommonkey.xmlunit.XMLUnit; //導入方法依賴的package包/類
@Override
protected boolean compare(File baselineFile, File comparisonFile) {
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

        factory.setNamespaceAware(true);
        factory.setCoalescing(true);
        factory.setIgnoringElementContentWhitespace(true);
        factory.setIgnoringComments(true);

        DocumentBuilder builder = factory.newDocumentBuilder();
        Document baselineXml = builder.parse(baselineFile);
        Document comparisonXml = builder.parse(comparisonFile);

        baselineXml.normalizeDocument();
        comparisonXml.normalizeDocument();

        XMLUnit.setIgnoreAttributeOrder(true);
        XMLUnit.setIgnoreComments(true);
        XMLUnit.setIgnoreWhitespace(true);

        return XMLUnit.compareXML(baselineXml, comparisonXml).similar();
    } catch (SAXException | IOException | ParserConfigurationException e) {
        throw new TransformationUtilityException("An exception happened when comparing the two XML files", e);
    }
}
 
開發者ID:paypal,項目名稱:butterfly,代碼行數:27,代碼來源:CompareXMLFiles.java

示例2: assertEqualsXml

import org.custommonkey.xmlunit.XMLUnit; //導入方法依賴的package包/類
/**
 * Assert that the specified XML file has not semantically changed,
 * although it might be identical to the original one due to format
 * changes, comments not being present, etc
 *
 * @param relativeFilePath relative path to file to be evaluated
 * @throws ParserConfigurationException
 * @throws IOException
 * @throws SAXException
 */
protected void assertEqualsXml(String relativeFilePath) throws ParserConfigurationException, IOException, SAXException {
    File originalFile = new File(appFolder, relativeFilePath);
    File transformedFile = new File(transformedAppFolder, relativeFilePath);

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

    factory.setNamespaceAware(true);
    factory.setCoalescing(true);
    factory.setIgnoringElementContentWhitespace(true);
    factory.setIgnoringComments(true);

    DocumentBuilder builder = factory.newDocumentBuilder();
    Document originalXml = builder.parse(originalFile);
    Document transformedXml = builder.parse(transformedFile);

    originalXml.normalizeDocument();
    transformedXml.normalizeDocument();

    XMLUnit.setIgnoreAttributeOrder(true);
    XMLUnit.setIgnoreComments(true);
    XMLUnit.setIgnoreWhitespace(true);

    Assert.assertTrue(XMLUnit.compareXML(originalXml, transformedXml).similar());
}
 
開發者ID:paypal,項目名稱:butterfly,代碼行數:35,代碼來源:TransformationUtilityTestHelper.java

示例3: testCreateElement

import org.custommonkey.xmlunit.XMLUnit; //導入方法依賴的package包/類
@Test
public void testCreateElement() throws Exception {
    final Document document = XmlUtil.newDocument();
    final Element top = XmlUtil.createElement(document, "top", Optional.of("namespace"));

    top.appendChild(XmlUtil.createTextElement(document, "innerText", "value", Optional.of("namespace")));
    top.appendChild(XmlUtil.createTextElementWithNamespacedContent(document, "innerPrefixedText", "pref", "prefixNamespace", "value", Optional.of("namespace")));
    top.appendChild(XmlUtil.createTextElementWithNamespacedContent(document, "innerPrefixedText", "pref", "prefixNamespace", "value", Optional.of("randomNamespace")));

    document.appendChild(top);
    assertEquals("top", XmlUtil.createDocumentCopy(document).getDocumentElement().getTagName());

    XMLUnit.setIgnoreAttributeOrder(true);
    XMLUnit.setIgnoreWhitespace(true);

    final Diff diff = XMLUnit.compareXML(XMLUnit.buildControlDocument(xml), document);
    assertTrue(diff.toString(), diff.similar());
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:19,代碼來源:XmlUtilTest.java

示例4: testSetEndpoints

import org.custommonkey.xmlunit.XMLUnit; //導入方法依賴的package包/類
public void testSetEndpoints() throws Exception {
    // Create a new Camel context and add an endpoint
    CamelContextFactoryBean camelContext = new CamelContextFactoryBean();
    List<CamelEndpointFactoryBean> endpoints = new LinkedList<CamelEndpointFactoryBean>();
    CamelEndpointFactoryBean endpoint = new CamelEndpointFactoryBean();
    endpoint.setId("endpoint1");
    endpoint.setUri("mock:end");
    endpoints.add(endpoint);
    camelContext.setEndpoints(endpoints);

    // Compare the new context with our reference context
    Reader expectedContext = null;
    try {
        expectedContext = new InputStreamReader(getClass().getResourceAsStream("/org/apache/camel/spring/context-with-endpoint.xml"));
        String createdContext = contextAsString(camelContext);
        XMLUnit.setIgnoreWhitespace(true);
        XMLAssert.assertXMLEqual(expectedContext, new StringReader(createdContext));
    } finally {
        IOHelper.close(expectedContext);
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:22,代碼來源:CamelContextFactoryBeanTest.java

示例5: writeDeliveryReportResponse

import org.custommonkey.xmlunit.XMLUnit; //導入方法依賴的package包/類
@Test
public void writeDeliveryReportResponse() throws Exception {
    DeliveryReportResponse deliveryResponse = new DeliveryReportResponse();
    deliveryResponse.setErrorCode(5);
    deliveryResponse.setErrorMessage("Success");

    StringWriter sw = new StringWriter();
    SxmpWriter.write(sw, deliveryResponse);

    logger.debug(sw.toString());

    StringBuilder expectedXML = new StringBuilder(200)
        .append("<?xml version=\"1.0\"?>\n")
        .append("<operation type=\"deliveryReport\">\n")
        .append(" <deliveryReportResponse>\n")
        .append("   <error code=\"5\" message=\"Success\"/>\n")
        .append(" </deliveryReportResponse>\n")
        .append("</operation>\n")
        .append("");

    // compare to actual correct submit response
    XMLUnit.setIgnoreWhitespace(true);
    Diff myDiff = new Diff(expectedXML.toString(), sw.toString());
    DetailedDiff myDetailedDiff = new DetailedDiff(myDiff);
    Assert.assertTrue("XML are similar " + myDetailedDiff, myDetailedDiff.similar());
}
 
開發者ID:nkasvosve,項目名稱:beyondj,代碼行數:27,代碼來源:SxmpWriterTest.java

示例6: testMarshalAsByteArrayOutputStream

import org.custommonkey.xmlunit.XMLUnit; //導入方法依賴的package包/類
@Test
public void testMarshalAsByteArrayOutputStream()
        throws SimpleMarshallerException, SAXException, IOException {
    // Arrange
    XMLUnit.setIgnoreAttributeOrder(true);
    XMLUnit.setIgnoreComments(true);
    XMLUnit.setIgnoreWhitespace(true);
    final String expectedOutput = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ruleExecutionContainer><executionResponseList/></ruleExecutionContainer>";
    final RuleExecutionContainer r = createRuleExecutionContainer();

    // Act
    final ByteArrayOutputStream output = marshaller
            .marshalAsByteArrayOutputStream(r);

    assertNotNull(output);
    assertXMLEqual(expectedOutput, output.toString());
}
 
開發者ID:bhits,項目名稱:common-libraries,代碼行數:18,代碼來源:SimpleMarshallerImplTest.java

示例7: testCreate

import org.custommonkey.xmlunit.XMLUnit; //導入方法依賴的package包/類
@Test
public void testCreate() throws Exception {
    SwitchYardModel switchyard = new V1SwitchYardModel(SwitchYardNamespace.V_1_0.uri());
    TransformsModel transforms = new V1TransformsModel(SwitchYardNamespace.V_1_0.uri());
    JavaTransformModel javaTransform = new V1JavaTransformModel(TransformNamespace.V_1_0.uri());
    javaTransform.setFrom(new QName("msgA"));
    javaTransform.setTo(new QName("msgB"));
    javaTransform.setClazz("org.examples.transform.AtoBTransform");
    transforms.addTransform(javaTransform);
    SmooksTransformModel smooksTransform = new V1SmooksTransformModel(TransformNamespace.V_1_0.uri());
    smooksTransform.setFrom(new QName("msgC"));
    smooksTransform.setTo(new QName("msgD"));
    smooksTransform.setTransformType("XML2JAVA");
    smooksTransform.setConfig("/trasnforms/xxx.xml");
    smooksTransform.setReportPath("/tmp/smooksreport.html");
    transforms.addTransform(smooksTransform);
    switchyard.setTransforms(transforms);
    String new_xml = switchyard.toString();
    String old_xml = new ModelPuller<SwitchYardModel>().pull(XML, getClass()).toString();
    XMLUnit.setIgnoreWhitespace(true);
    Diff diff = XMLUnit.compareXML(old_xml, new_xml);
    Assert.assertTrue(diff.toString(), diff.identical());
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:24,代碼來源:TransformModelTests.java

示例8: testOrders

import org.custommonkey.xmlunit.XMLUnit; //導入方法依賴的package包/類
@Test
public void testOrders() throws Exception {
    HTTPMixIn httpMixIn = new HTTPMixIn();

    httpMixIn.initialize();
    try {
        XMLUnit.setIgnoreWhitespace(true);
        String port = getSoapClientPort();
        String wsdl = httpMixIn.sendString("http://localhost:" + port + "/quickstart-bean/OrderService?wsdl", "", HTTPMixIn.HTTP_GET);
        XMLAssert.assertXMLEqual(new InputStreamReader(Classes.getResourceAsStream("quickstarts/bean-service/OrderService.wsdl")), new StringReader(wsdl));
        String response = httpMixIn.postString("http://localhost:" + port + "/quickstart-bean/OrderService", SOAP_REQUEST);
        XMLAssert.assertXpathEvaluatesTo("PO-19838-XYZ", "//orderAck/orderId", response);
        XMLAssert.assertXpathEvaluatesTo("true", "//orderAck/accepted", response);
        XMLAssert.assertXpathEvaluatesTo("Order Accepted [intercepted]", "//orderAck/status", response);
    } finally {
        httpMixIn.uninitialize();
    }
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:19,代碼來源:BeanServiceQuickstartTest.java

示例9: setUp

import org.custommonkey.xmlunit.XMLUnit; //導入方法依賴的package包/類
@Before
public void setUp() {
    XMLUnit.setIgnoreWhitespace(true);

    when(viewProvider.get()).thenReturn(view);
    when(childViewProvider.get()).thenReturn(childView);
    when(parserFactory.create()).thenReturn(new LabellingInteractionBeanMockParser(CHILDREN_FULL));
    testObj = new LabellingBuilder(parserFactory, new LabellingViewBuilder(viewProvider, childViewProvider));

    stub(view.getContainer()).toReturn(mock(ForIsWidget.class));
}
 
開發者ID:YoungDigitalPlanet,項目名稱:empiria.player,代碼行數:12,代碼來源:LabellingBuilderTest.java

示例10: setUp

import org.custommonkey.xmlunit.XMLUnit; //導入方法依賴的package包/類
@Override
public void setUp() throws Exception {
  // Initialise the GATE library and creole register
  Gate.init();

  XMLUnit.setIgnoreComments(true);
  XMLUnit.setIgnoreWhitespace(true);
  XMLUnit.setIgnoreAttributeOrder(true);
}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:10,代碼來源:TestCreoleAnnotationHandler.java

示例11: verifyThatResponseIsEqualToFile

import org.custommonkey.xmlunit.XMLUnit; //導入方法依賴的package包/類
@Then("verify that response is equal to file '$filePath'")
public void verifyThatResponseIsEqualToFile(String filePath) throws SOAPException, IOException, SAXException {
    FileReader expectedResponseXML = new FileReader(getFileFromResourcesByFilePath(filePath));
    SOAPMessage rawSoapResponse = (SOAPMessage) Thucydides.getCurrentSession().get(RESPONSE);
    String cleanResponse = getXmlPayload(rawSoapResponse);
    StringReader actualResponseXML = new StringReader(cleanResponse);
    XMLUnit.setIgnoreWhitespace(true);
    Diff diff = new Diff(expectedResponseXML, actualResponseXML);
    StringBuffer stringBuffer = diff.appendMessage(new StringBuffer());
    assertTrue(stringBuffer.toString(), diff.similar());
}
 
開發者ID:tapack,項目名稱:satisfy,代碼行數:12,代碼來源:WebserviceSteps.java

示例12: verifyFilesOnEqual

import org.custommonkey.xmlunit.XMLUnit; //導入方法依賴的package包/類
@Override
public void verifyFilesOnEqual(String filePath, File lastDownloadedFile) throws IOException, SAXException, ParserConfigurationException {
    FileReader controlXML = new FileReader(getFileFromResourcesByFilePath(filePath));
    FileReader testXML = new FileReader(lastDownloadedFile);
    XMLUnit.setIgnoreWhitespace(true);
    XMLAssert.assertXMLEqual("THE FILE '" + lastDownloadedFile.getName() + "' DOESN'T CONTAIN EXPECTED VALUE", controlXML, testXML);
}
 
開發者ID:tapack,項目名稱:satisfy,代碼行數:8,代碼來源:XmlProvider.java

示例13: thenXMLResponseEqualToFile

import org.custommonkey.xmlunit.XMLUnit; //導入方法依賴的package包/類
@Then("verify REST-XML response is equal to '$file'")
public void thenXMLResponseEqualToFile(String file) throws IOException, SAXException {
    File fileFromResources = getFileFromResourcesByFilePath(file);
    List<String> expected = Files.readLines(fileFromResources, Charset.defaultCharset());
    String expectedXml = expected.stream()
            .map(StringUtils::chomp)
            .map(StringUtils::strip)
            .collect(Collectors.joining());
    Response response = getVariableValue(KEY);
    String actualXml = response.getBody().asString();
    XMLUnit.setIgnoreWhitespace(true);
    DetailedDiff myDiff = new DetailedDiff(new Diff(expectedXml, actualXml));
    assertThat(myDiff.toString(), actualXml, is(expectedXml));
}
 
開發者ID:tapack,項目名稱:satisfy,代碼行數:15,代碼來源:RestXMLOnlySteps.java

示例14: assertXMLEquals

import org.custommonkey.xmlunit.XMLUnit; //導入方法依賴的package包/類
public static void assertXMLEquals(String expectedXML, String actualXML) throws Exception {
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true);
    XMLUnit.setIgnoreAttributeOrder(true);

    DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(expectedXML, actualXML));

    List<?> allDifferences = diff.getAllDifferences();
    Assert.assertEquals("Differences found: "+ diff.toString(), 0, allDifferences.size());
}
 
開發者ID:hashmapinc,項目名稱:WitsmlObjectsLibrary,代碼行數:11,代碼來源:TestUtilities.java

示例15: writeSubmitRequestWithNationalAndApplication

import org.custommonkey.xmlunit.XMLUnit; //導入方法依賴的package包/類
@Test
public void writeSubmitRequestWithNationalAndApplication() throws Exception {
    SubmitRequest request = new SubmitRequest();
    request.setAccount(new Account("customer1", "test1"));
    request.setApplication(new Application("TestApp"));
    request.setOperatorId(20);
    request.setSourceAddress(new MobileAddress(MobileAddress.Type.NATIONAL, "0123456789"));
    request.setDestinationAddress(new MobileAddress(MobileAddress.Type.INTERNATIONAL, "+13135551212"));
    request.setText("Hello World");

    StringWriter sw = new StringWriter();
    SxmpWriter.write(sw, request);

    logger.debug(sw.toString());

    StringBuilder expectedXML = new StringBuilder(200)
        .append("<?xml version=\"1.0\"?>\n")
        .append("<operation type=\"submit\">\n")
        .append(" <account username=\"customer1\" password=\"test1\"/>\n")
        .append(" <application>TestApp</application>\n")
        .append(" <submitRequest>\n")
        .append("  <operatorId>20</operatorId>\n")
        .append("  <priority>0</priority>\n")
        .append("  <deliveryReport>false</deliveryReport>\n")
        .append("  <sourceAddress type=\"national\">0123456789</sourceAddress>\n")
        .append("  <destinationAddress type=\"international\">+13135551212</destinationAddress>\n")
        .append("  <text encoding=\"UTF-8\">48656C6C6F20576F726C64</text>\n")
        .append(" </submitRequest>\n")
        .append("</operation>\n")
        .append("");

    // compare to actual correct submit response
    XMLUnit.setIgnoreWhitespace(true);
    Diff myDiff = new Diff(expectedXML.toString(), sw.toString());
    DetailedDiff myDetailedDiff = new DetailedDiff(myDiff);
    Assert.assertTrue("XML are similar " + myDetailedDiff, myDetailedDiff.similar());
}
 
開發者ID:nkasvosve,項目名稱:beyondj,代碼行數:38,代碼來源:SxmpWriterTest.java


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