当前位置: 首页>>代码示例>>Java>>正文


Java XMLUnit.setIgnoreComments方法代码示例

本文整理汇总了Java中org.custommonkey.xmlunit.XMLUnit.setIgnoreComments方法的典型用法代码示例。如果您正苦于以下问题:Java XMLUnit.setIgnoreComments方法的具体用法?Java XMLUnit.setIgnoreComments怎么用?Java XMLUnit.setIgnoreComments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.custommonkey.xmlunit.XMLUnit的用法示例。


在下文中一共展示了XMLUnit.setIgnoreComments方法的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: 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

示例4: 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

示例5: 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

示例6: setUp

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
    // Arrange
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreAttributeOrder(true);
    XMLUnit.setIgnoreComments(true);
    fileReader = new FileReaderImpl();
    xacmlResult = "<xacmlResult><pdpDecision>Permit</pdpDecision><purposeOfUse>TREATMENT</purposeOfUse><messageId>4617a579-1881-4e40-9f98-f85bd81d6502</messageId><homeCommunityId>2.16.840.1.113883.3.467</homeCommunityId><pdpObligation>urn:oasis:names:tc:xspa:2.0:resource:org:us-privacy-law:42CFRPart2</pdpObligation><pdpObligation>urn:oasis:names:tc:xspa:2.0:resource:org:refrain-policy:NORDSLCD</pdpObligation><pdpObligation>urn:oasis:names:tc:xspa:2.0:resource:patient:redact:ETH</pdpObligation><pdpObligation>urn:oasis:names:tc:xspa:2.0:resource:patient:redact:PSY</pdpObligation><pdpObligation>urn:oasis:names:tc:xspa:2.0:resource:patient:mask:HIV</pdpObligation></xacmlResult>";
    xmlTransformer = new XmlTransformerImpl(new SimpleMarshallerImpl());
    documentFactModelExtractor = new DocumentFactModelExtractorImpl(
            xmlTransformer);
}
 
开发者ID:bhits,项目名称:dss-api,代码行数:13,代码来源:DocumentFactModelExtractorImplTest.java

示例7: initialise

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Before
public void initialise() {
	System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
			"org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
	System.setProperty("javax.xml.parsers.SAXParserFactory",
			"org.apache.xerces.jaxp.SAXParserFactoryImpl");
	System.setProperty("javax.xml.transform.TransformerFactory",
			"org.apache.xalan.processor.TransformerFactoryImpl");

	XMLUnit.setIgnoreComments(true);
	XMLUnit.setNormalizeWhitespace(true);
}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:13,代码来源:BasicTest.java

示例8: testResolveEmptyPom

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Test
public void testResolveEmptyPom()
    throws Exception
{
    Artifact artifact = new DefaultArtifact( "gid", "aid", "pom", "cla", "ver" );
    ArtifactMetadata md = new ArtifactMetadata();
    md.setExtension( "pom" );

    MetadataResult mockMdResult = EasyMock.createMock( MetadataResult.class );
    MetadataResolver mockMdResolver = EasyMock.createMock( MetadataResolver.class );
    ServiceLocator mockServiceLocator = EasyMock.createMock( ServiceLocator.class );
    EasyMock.expect( mockServiceLocator.getService( Configurator.class ) ).andReturn( getService( Configurator.class ) );
    EasyMock.expect( mockServiceLocator.getService( MetadataResolver.class ) ).andReturn( mockMdResolver );
    EasyMock.expect( mockMdResolver.resolveMetadata( EasyMock.anyObject( MetadataRequest.class ) ) ).andReturn( mockMdResult );
    EasyMock.expect( mockMdResult.getMetadataFor( artifact ) ).andReturn( md );
    EasyMock.replay( mockMdResult, mockMdResolver, mockServiceLocator );

    Resolver resolver = new DefaultResolver( mockServiceLocator );
    ResolutionRequest request = new ResolutionRequest( artifact );
    request.setPersistentFileNeeded( true );
    ResolutionResult result = resolver.resolve( request );
    assertNotNull( result );
    assertNotNull( result.getArtifactPath() );
    assertTrue( Files.isRegularFile( result.getArtifactPath() ) );

    EasyMock.verify( mockMdResult, mockMdResolver, mockServiceLocator );

    XMLUnit.setIgnoreWhitespace( true );
    XMLUnit.setIgnoreComments( true );
    XMLAssert.assertXMLEqual( new StringReader( "<project>\n" + //
        "  <modelVersion>4.0.0</modelVersion>\n" + //
        "  <groupId>gid</groupId>\n" + //
        "  <artifactId>aid</artifactId>\n" + //
        "  <version>ver</version>\n" + //
        "</project>" ), Files.newBufferedReader( result.getArtifactPath() ) );
}
 
开发者ID:fedora-java,项目名称:xmvn,代码行数:37,代码来源:BasicResolverTest.java

示例9: assertXMLIgnorePrefix

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
public static void assertXMLIgnorePrefix(String aMessage, Document aExpected, Document aActual) throws Exception {
    XMLUnit.setIgnoreComments(true);
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreAttributeOrder(true);

    Diff diff = new Diff(aExpected, aActual);
    diff.overrideDifferenceListener(new DifferenceListener() {

        public void skippedComparison(Node aArg0, Node aArg1) {
        }

        public int differenceFound(Difference aDifference) {
            if (aDifference.getId() == DifferenceConstants.NAMESPACE_PREFIX_ID) {
                return DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
            }
            return DifferenceListener.RETURN_ACCEPT_DIFFERENCE;
        }
    });
    try {
        XMLAssert.assertXMLEqual(diff, true);
    } catch (Throwable t) {
        dump(aActual);
        StringWriter sw = new StringWriter();
        t.printStackTrace(new PrintWriter(sw));
        fail(sw.toString());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:28,代码来源:XmlFixture.java

示例10: isXMLEqual

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
protected void isXMLEqual(Document control, Document test)
		throws SAXException, IOException {
	XMLUnit.setIgnoreWhitespace(true);
	XMLUnit.setIgnoreAttributeOrder(true);
	XMLUnit.setIgnoreComments(true);
	XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true);
	// XMLUnit.setNormalize(true);

	// Diff diff = compareXML (control, test);

	assertXMLEqual(control, test);
}
 
开发者ID:EXIficient,项目名称:exificient,代码行数:13,代码来源:DOMRoundtrip.java

示例11: beforeClass

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() {
	XMLUnit.setIgnoreAttributeOrder(true);
	XMLUnit.setIgnoreComments(true);
	XMLUnit.setIgnoreWhitespace(true);
	ourCtx = new FhirContext();
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:8,代码来源:XmlParserTest.java

示例12: initializeXMLUnit

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@BeforeClass (description = "Initialize XMLUnit")
public void initializeXMLUnit() {
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreAttributeOrder(true);
    XMLUnit.setIgnoreComments(true);
}
 
开发者ID:Technolords,项目名称:microservice-mock,代码行数:7,代码来源:ConfigCommandTest.java

示例13: setup

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Before
public void setup() {
    XMLUnit.setIgnoreComments(true);
    XMLUnit.setIgnoreWhitespace(true);
}
 
开发者ID:Accuity,项目名称:xml-document-merge,代码行数:6,代码来源:RuleProcessorTest.java

示例14: testResolvePomWithDep

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Test
public void testResolvePomWithDep()
    throws Exception
{
    Artifact artifact = new DefaultArtifact( "gid", "aid", "pom", "cla", "ver" );
    ArtifactMetadata md = new ArtifactMetadata();
    md.setExtension( "pom" );
    Dependency dep = new Dependency();
    dep.setGroupId( "dgid" );
    dep.setArtifactId( "daid" );
    dep.setRequestedVersion( "drqv" );
    dep.setResolvedVersion( "drsv" );
    DependencyExclusion excl = new DependencyExclusion();
    excl.setGroupId( "egid" );
    excl.setArtifactId( "eaid" );
    dep.addExclusion( excl );
    md.addDependency( dep );

    MetadataResult mockMdResult = EasyMock.createMock( MetadataResult.class );
    MetadataResolver mockMdResolver = EasyMock.createMock( MetadataResolver.class );
    ServiceLocator mockServiceLocator = EasyMock.createMock( ServiceLocator.class );
    EasyMock.expect( mockServiceLocator.getService( Configurator.class ) ).andReturn( getService( Configurator.class ) );
    EasyMock.expect( mockServiceLocator.getService( MetadataResolver.class ) ).andReturn( mockMdResolver );
    EasyMock.expect( mockMdResolver.resolveMetadata( EasyMock.anyObject( MetadataRequest.class ) ) ).andReturn( mockMdResult );
    EasyMock.expect( mockMdResult.getMetadataFor( artifact ) ).andReturn( md );
    EasyMock.replay( mockMdResult, mockMdResolver, mockServiceLocator );

    Resolver resolver = new DefaultResolver( mockServiceLocator );
    ResolutionRequest request = new ResolutionRequest( artifact );
    request.setPersistentFileNeeded( true );
    ResolutionResult result = resolver.resolve( request );
    assertNotNull( result );
    assertNotNull( result.getArtifactPath() );
    assertTrue( Files.isRegularFile( result.getArtifactPath() ) );

    EasyMock.verify( mockMdResult, mockMdResolver, mockServiceLocator );

    XMLUnit.setIgnoreWhitespace( true );
    XMLUnit.setIgnoreComments( true );
    XMLAssert.assertXMLEqual( new StringReader( "<project>\n" + //
        "  <modelVersion>4.0.0</modelVersion>\n" + //
        "  <groupId>gid</groupId>\n" + //
        "  <artifactId>aid</artifactId>\n" + //
        "  <version>ver</version>\n" + //
        "  <dependencies>\n" + //
        "    <dependency>\n" + //
        "      <groupId>dgid</groupId>\n" + //
        "      <artifactId>daid</artifactId>\n" + //
        "      <version>drqv</version>\n" + //
        "      <exclusions>\n" + //
        "        <exclusion>\n" + //
        "          <groupId>egid</groupId>\n" + //
        "          <artifactId>eaid</artifactId>\n" + //
        "        </exclusion>\n" + //
        "      </exclusions>\n" + //
        "    </dependency>\n" + //
        "  </dependencies>\n" + //
        "</project>" ), Files.newBufferedReader( result.getArtifactPath() ) );
}
 
开发者ID:fedora-java,项目名称:xmvn,代码行数:60,代码来源:BasicResolverTest.java

示例15: testDeployment

import org.custommonkey.xmlunit.XMLUnit; //导入方法依赖的package包/类
@Test
public void testDeployment()
    throws Exception
{
    Deployer deployer = getService( Deployer.class );
    Path plan = Files.createTempDirectory( "xmvn-test" ).resolve( "plan.xml" );
    DeploymentRequest req = new DeploymentRequest();
    req.setPlanPath( plan );
    req.setArtifact( new DefaultArtifact( "g:a:v" ).setPath( Paths.get( "src/test/resources/simple.xml" ) ) );
    req.addProperty( "foo", "bar" );
    req.addDependency( new DefaultArtifact( "g1:a1:e1:c1:v1" ) );
    req.addDependency( new DefaultArtifact( "g2:a2:e2:c2:v2" ), true,
                       Arrays.asList( new DefaultArtifact( "e:e:e:e:e" ),
                                      new DefaultArtifact( "eg2:ea2:ee2:ec2:ev2" ) ) );
    deployer.deploy( req );
    DeploymentRequest req2 = new DeploymentRequest();
    req2.setPlanPath( plan );
    req2.setArtifact( new DefaultArtifact( "foo:bar:pom:" ).setPath( Paths.get( "/dev/null" ) ) );
    deployer.deploy( req2 );

    XMLUnit.setIgnoreComments( true );
    XMLUnit.setIgnoreWhitespace( true );
    XMLAssert.assertXMLEqual( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + //
        "<metadata xmlns=\"http://fedorahosted.org/xmvn/METADATA/3.0.0\">\n" + //
        "  <artifacts>\n" + //
        "    <artifact>\n" + //
        "      <groupId>g</groupId>\n" + //
        "      <artifactId>a</artifactId>\n" + //
        "      <version>v</version>\n" + //
        "      <path>src/test/resources/simple.xml</path>\n" + //
        "      <properties>\n" + //
        "        <foo>bar</foo>\n" + //
        "      </properties>\n" + //
        "      <dependencies>\n" + //
        "        <dependency>\n" + //
        "          <groupId>g1</groupId>\n" + //
        "          <artifactId>a1</artifactId>\n" + //
        "          <extension>e1</extension>\n" + //
        "          <classifier>c1</classifier>\n" + //
        "          <requestedVersion>v1</requestedVersion>\n" + //
        "        </dependency>\n" + //
        "        <dependency>\n" + //
        "          <groupId>g2</groupId>\n" + //
        "          <artifactId>a2</artifactId>\n" + //
        "          <extension>e2</extension>\n" + //
        "          <classifier>c2</classifier>\n" + //
        "          <requestedVersion>v2</requestedVersion>\n" + //
        "          <optional>true</optional>\n" + //
        "          <exclusions>\n" + //
        "            <exclusion>\n" + //
        "              <groupId>e</groupId>\n" + //
        "              <artifactId>e</artifactId>\n" + //
        "            </exclusion>\n" + //
        "            <exclusion>\n" + //
        "              <groupId>eg2</groupId>\n" + //
        "              <artifactId>ea2</artifactId>\n" + //
        "            </exclusion>\n" + //
        "          </exclusions>\n" + //
        "        </dependency>\n" + //
        "      </dependencies>\n" + //
        "    </artifact>\n" + //
        "    <artifact>\n" + //
        "      <groupId>foo</groupId>\n" + //
        "      <artifactId>bar</artifactId>\n" + //
        "      <extension>pom</extension>\n" + //
        "      <version>SYSTEM</version>\n" + //
        "      <path>/dev/null</path>\n" + //
        "    </artifact>\n" + //
        "  </artifacts>\n" + //
        "</metadata>\n", new String( Files.readAllBytes( plan ) ) );
}
 
开发者ID:fedora-java,项目名称:xmvn,代码行数:72,代码来源:BasicDeployerTest.java


注:本文中的org.custommonkey.xmlunit.XMLUnit.setIgnoreComments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。