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


Java XMLAssert.assertXMLEqual方法代码示例

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


在下文中一共展示了XMLAssert.assertXMLEqual方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testWriteSimple

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Test
public void testWriteSimple()
    throws Exception
{
    File defaultRepoDir = new File( "src/test/repositories/default-repository" );
    File expectedFile = new File( defaultRepoDir, "org/apache/maven/shared/maven-downloader/maven-metadata.xml" );
    String expectedContent = FileUtils.readFileToString( expectedFile, Charset.defaultCharset() );

    ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();

    metadata.setGroupId( "org.apache.maven.shared" );
    metadata.setArtifactId( "maven-downloader" );
    metadata.setVersion( "1.0" );
    metadata.setReleasedVersion( "1.1" );
    metadata.getAvailableVersions().add( "1.0" );
    metadata.getAvailableVersions().add( "1.1" );
    metadata.setLastUpdated( "20061212214311" );

    StringWriter actual = new StringWriter();
    RepositoryMetadataWriter.write( metadata, actual );

    XMLAssert.assertXMLEqual( "XML Contents", expectedContent, actual.toString() );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:24,代码来源:RepositoryMetadataWriterTest.java

示例2: testConfigCommandWithDefault

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Test (description = "Test with default mock configuration")
public void testConfigCommandWithDefault() throws Exception {
    LOGGER.info("About to send Config command (default), total routes: {}", getProducerTemplate().getCamelContext().getRoutes().size());
    ConfigurationManager configurationManager = MockRegistry.findConfigurationManager();
    Assert.assertNotNull(configurationManager);
    Exchange response = getProducerTemplate().request("jetty:http://localhost:" + getAvailablePort() + "/mock/cmd", exchange -> {
        exchange.getIn().setHeader(Exchange.HTTP_METHOD, ConfigurationManager.HTTP_GET);
        exchange.getIn().setHeader("config", "current");
    });
    String actualConfig = response.getOut().getBody(String.class);
    LOGGER.debug("Got actual: {}", actualConfig);
    Path pathToConfigFile = Paths.get(PathSupport.getPathToTestConfigForMockResources().toString(), "config-1-for-ConfigCommandTest.xml");
    Assert.assertTrue(Files.exists(pathToConfigFile));
    String expectedConfig = new String(Files.readAllBytes(pathToConfigFile));
    LOGGER.debug("Got expected: {}", expectedConfig);
    XMLAssert.assertXMLEqual(expectedConfig, actualConfig);
}
 
开发者ID:Technolords,项目名称:microservice-mock,代码行数:18,代码来源:ConfigCommandTest.java

示例3: testConformness

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Test
public void testConformness() throws Exception {
    XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance();
    StringWriter secStringWriter = new StringWriter();
    XMLStreamWriter secXmlStreamWriter = xmlOutputFactory.createXMLStreamWriter(secStringWriter);
    XMLSecurityEventWriter xmlSecurityEventWriter = new XMLSecurityEventWriter(secXmlStreamWriter);

    StringWriter stdStringWriter = new StringWriter();
    XMLEventWriter stdXmlEventWriter = xmlOutputFactory.createXMLEventWriter(stdStringWriter);

    XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
    XMLStreamReader xmlStreamReader =
        xmlInputFactory.createXMLStreamReader(this.getClass().getClassLoader().getResourceAsStream(
                "org/apache/xml/security/c14n/inExcl/plain-soap-1.1.xml"));

    while (xmlStreamReader.hasNext()) {
        XMLEvent xmlEvent = XMLSecEventFactory.allocate(xmlStreamReader, null);
        xmlSecurityEventWriter.add(xmlEvent);
        stdXmlEventWriter.add(xmlEvent);
        xmlStreamReader.next();
    }

    xmlSecurityEventWriter.close();
    stdXmlEventWriter.close();
    XMLAssert.assertXMLEqual(stdStringWriter.toString(), secStringWriter.toString());
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:27,代码来源:XMLSecurityEventWriterTest.java

示例4: testSetEndpoints

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的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: canConvertPropertiesToXmlFormat

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Test
public void canConvertPropertiesToXmlFormat() throws IOException, SAXException {
    StringWriter writer = new StringWriter();
    Properties log4jProperties = new Properties();
    log4jProperties.load(getClass().getClassLoader().getResourceAsStream("log4j.issue4.properties"));

    converter.toXml(log4jProperties, writer);

    String expected = readFromStream("log4j.issue4.expected.xml");
    String actual = writer.toString();

    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setControlEntityResolver(new Log4JEntityResolver());
    XMLUnit.setTestEntityResolver(new Log4JEntityResolver());

    Validator validator = new Validator(actual);
    validator.assertIsValid();

    XMLAssert.assertXMLEqual(expected, actual);
}
 
开发者ID:jroyals,项目名称:log4j-properties-converter,代码行数:21,代码来源:ConvertFromPropertiesToXmlTest.java

示例6: invokeRequestResponse

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Ignore // mime headers are not parsed into the SOAPMessage with CXF
@Test
public void invokeRequestResponse() throws Exception {
    String input = "<test:sayHello xmlns:test=\"urn:switchyard-component-soap:test-ws:1.0\">"
                 + "   <arg0>Magesh</arg0>"
                 + "</test:sayHello>";

    String output = "<test:sayHelloResponse xmlns:test=\"urn:switchyard-component-soap:test-ws:1.0\">"
                 + "   <return>Hello Magesh! The soapAction received is \"uri:something:that:needs#tobevalid\"</return>"
                 + "</test:sayHelloResponse>";


    Message responseMsg = _consumerService11.operation("sayHello").sendInOut(input);

    String response = toString(responseMsg.getContent(Node.class));
    XMLAssert.assertXMLEqual(output, response);
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:18,代码来源:SOAPGatewayTest.java

示例7: invokeRequestResponseSOAP12

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Ignore // mime headers are not parsed into the SOAPMessage with CXF
@Test
public void invokeRequestResponseSOAP12() throws Exception {
    String input = "<test:sayHello xmlns:test=\"urn:switchyard-component-soap:test-ws:1.0\">"
                 + "   <arg0>Magesh</arg0>"
                 + "</test:sayHello>";

    String output = "<test:sayHelloResponse xmlns:test=\"urn:switchyard-component-soap:test-ws:1.0\">"
                 + "   <return>Hello Magesh! The soapAction received is application/soap+xml; charset=utf-8; action=\"uri:soap12:that:needs#tobevalid\"</return>"
                 + "</test:sayHelloResponse>";


    Message responseMsg = _consumerService12.operation("sayHello").sendInOut(input);

    String response = toString(responseMsg.getContent(Node.class));
    XMLAssert.assertXMLEqual(output, response);
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:18,代码来源:SOAPGatewayTest.java

示例8: invokeRequestResponseFault

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Ignore
@Test
public void invokeRequestResponseFault() throws Exception {
    String input = "<test:sayHello xmlns:test=\"urn:switchyard-component-soap:test-ws:1.0\">"
                 + "   <arg0></arg0>"
                 + "</test:sayHello>";

    String output = "<SOAP-ENV:Fault xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                    + "   <faultcode>SOAP-ENV:Server.AppError</faultcode>"
                    + "   <faultstring>Invalid name</faultstring>"
                    + "   <detail>"
                    + "      <message>Looks like you did not specify a name!</message>"
                    + "      <errorcode>1000</errorcode>"
                    + "   </detail>"
                    + "</SOAP-ENV:Fault>";

    Message responseMsg = _consumerService11.operation("sayHello").sendInOut(input);
    String response = toString(responseMsg.getContent(Node.class));
    XMLAssert.assertXMLEqual(output, response);
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:21,代码来源:SOAPGatewayTest.java

示例9: testWriteUpdate

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Test
    public void testWriteUpdate() throws Exception {
        ModsDefinition mods = ModsUtils.unmarshal(PageMapperTest.class.getResource("page_mods.xml"), ModsDefinition.class);
        Page page = new Page();
        page.setNote("note updated");
        page.setIndex("2");
        page.setNumber("[2]");
        page.setType("TitlePage");
        page.setIdentifiers(Arrays.asList(
                new IdentifierItem(1, "uuid", "1 updated"),
                new IdentifierItem(0, "issn", "issn value updated"),
                new IdentifierItem("isbn", "isbn value inserted")));

        PageMapper instance = new PageMapper();
        ModsDefinition result = instance.map(mods, page);
        String resultXml = ModsUtils.toXml(result, true);
//        System.out.println(resultXml);

        ModsDefinition expectedMods = ModsUtils.unmarshal(PageMapperTest.class.getResource("page_mods_updated.xml"), ModsDefinition.class);
        String expectedXml = ModsUtils.toXml(expectedMods, true);
//        System.out.println(expectedXml);
        XMLAssert.assertXMLEqual(expectedXml, resultXml);
    }
 
开发者ID:proarc,项目名称:proarc,代码行数:24,代码来源:PageMapperTest.java

示例10: testTournamentNoUnassignedPlayers

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Test
public void testTournamentNoUnassignedPlayers() throws Exception
{
    TournamentPlayerListModel model = new TournamentPlayerListModel();
    model.setTournament(getTournamentVO("123456", "Test 1", parseDate("2011-11-25T08:42")));
    model.getCompetitors().add(getCompetitorVO("1234578", "Player 1", "playerid-1"));
    CompetitorVO competitorVO = getCompetitorVO("1234579", "Player 2", "playerid-2");
    competitorVO.setResult(new MoneyVO(Money.valueOf("-1", "USD")));
    competitorVO.setActive(false);
    model.getCompetitors().add(competitorVO);
    String content = RENDERER.render(model, RESOURCE_PREFIX + "tournament_player_add.xslt", getParameter());

    // Assert.assertEquals("players not listed correctly",getResource("tournament_no_unassigned.result.xml"),
    // content);
    XMLAssert.assertXMLEqual("players unassigned incorrectly",
                    wrapXMLRoot(getResource("tournament_no_unassigned.result.xml")), wrapXMLRoot(content));
}
 
开发者ID:Thomas-Bergmann,项目名称:Tournament,代码行数:18,代码来源:TournamentTemplateTest.java

示例11: verifyFilesOnEqual

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的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

示例12: verifyFileIsSimilarToFile

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Override
public void verifyFileIsSimilarToFile(String filePath, File lastDownloadedFile) throws IOException, SAXException, ParserConfigurationException {
    FileReader controlXML = new FileReader(getFileFromResourcesByFilePath(filePath));
    FileReader testXML = new FileReader(lastDownloadedFile);
    Diff diff = new Diff(controlXML, testXML);
    diff.overrideDifferenceListener(new IgnoreTextAndAttributeValuesDifferenceListener());
    XMLAssert.assertXMLEqual(diff, true);
}
 
开发者ID:tapack,项目名称:satisfy,代码行数:9,代码来源:XmlProvider.java

示例13: testBackupUsageScheduleSerialization

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Test
public void testBackupUsageScheduleSerialization() throws Exception {
    String xmlBackupUsageSchedule = xmlSerializer.serialize(backupUsageSchedule, false);
    Diff diff = new Diff(BACKUP_USAGE_SCHEDULE, xmlBackupUsageSchedule);
    diff.overrideElementQualifier(new ElementNameAndTextQualifier());
    XMLAssert.assertXMLEqual(diff, true);
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:8,代码来源:XMLSerializerTest.java

示例14: testSelectServerSerialization

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Test
public void testSelectServerSerialization() throws Exception {
    String xmlSelectServer = xmlSerializer.serialize(selectServer, false);
    Diff diff = new Diff(SELECT_SERVER, xmlSelectServer);
    diff.overrideElementQualifier(new ElementNameAndTextQualifier());
    XMLAssert.assertXMLEqual(diff, true);
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:8,代码来源:XMLSerializerTest.java

示例15: testServicePathsSerialization

import org.custommonkey.xmlunit.XMLAssert; //导入方法依赖的package包/类
@Test
public void testServicePathsSerialization() throws Exception {
    String xmlServicePaths = xmlSerializer.serialize(servicePaths, false);
    Diff diff = new Diff(PATHS_SERVICE, xmlServicePaths);
    diff.overrideElementQualifier(new ElementNameAndTextQualifier());
    XMLAssert.assertXMLEqual(diff, true);
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:8,代码来源:XMLSerializerTest.java


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