當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。