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


Java Input类代码示例

本文整理汇总了Java中org.xmlunit.builder.Input的典型用法代码示例。如果您正苦于以下问题:Java Input类的具体用法?Java Input怎么用?Java Input使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: similarVectors

import org.xmlunit.builder.Input; //导入依赖的package包/类
@Test
public void similarVectors() throws Exception {
    String actual;

    try {
        MPD mpd = PARSER.parse(Files.newInputStream(path));
        actual = PARSER.writeAsString(mpd);
    } catch (Exception e) {
        return;
    }

    Assert.assertThat(path + " is similar", actual,
            CompareMatcher.isSimilarTo(Input.fromFile(path.toFile()))
                    .withDifferenceEvaluator(DIFFERENCE_EVALUATOR)
                    .ignoreComments()
                    .ignoreWhitespace());
}
 
开发者ID:carlanton,项目名称:mpd-tools,代码行数:18,代码来源:MPDParserTest.java

示例2: doesNotDeleteRelationWhenSubjectNull

import org.xmlunit.builder.Input; //导入依赖的package包/类
@Test
public void doesNotDeleteRelationWhenSubjectNull() throws Exception {
  testRdfDescriptionSaver.addRelation(BASE_URI,
    "http://purl.org/dc/terms/rightsHolder", "http://example.com/rightsHolder", BASE_URI);
  testRdfDescriptionSaver.delRelation(null,
    "http://purl.org/dc/terms/title", "http://purl.org/dc/terms/rightsHolder", BASE_URI);
  testRdfDescriptionSaver.commit();

  Source expected = Input.fromByteArray(
    (
      "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n" +
        "  <rdf:Description rdf:about=\"http://example.org/datasets/DUMMY/clusius2\">\n" +
        "    <rightsHolder xmlns=\"http://purl.org/dc/terms/\" " +
        "       rdf:resource=\"http://example.com/rightsHolder\" /> \n" +
        "  </rdf:Description>\n" +
        "</rdf:RDF>\n"
    ).getBytes(StandardCharsets.UTF_8)
  ).build();

  Source actual = Input.fromFile(descriptionFile).build();
  assertThat(actual,
    isSimilarTo(expected).ignoreWhitespace().withComparisonFormatter(new DefaultComparisonFormatter())
  );

}
 
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:26,代码来源:RdfDescriptionSaverTest.java

示例3: xmlContent

import org.xmlunit.builder.Input; //导入依赖的package包/类
private Condition<File> xmlContent(URL expected) {
	return new Condition<File>("XML Content") {

		@Override
		public boolean matches(File actual) {
			Diff diff = DiffBuilder.compare(Input.from(expected))
					.withTest(Input.from(actual)).checkForSimilar().ignoreWhitespace()
					.build();
			if (diff.hasDifferences()) {
				try {
					String content = new String(
							FileCopyUtils.copyToByteArray(actual));
					throw new AssertionError(diff.toString() + "\n" + content);
				}
				catch (IOException ex) {
					throw new IllegalStateException(ex);
				}
			}
			return true;
		}

	};
}
 
开发者ID:spring-io,项目名称:artifactory-resource,代码行数:24,代码来源:MavenMetadataGeneratorTests.java

示例4: proceed

import org.xmlunit.builder.Input; //导入依赖的package包/类
@Override
public void proceed() {
	File recordFolder = new File(recordPath+ File.separator + step);
	File replayFolder = new File(replayPath+ File.separator + step);

	for (File recordFile : Files.fileTreeTraverser().preOrderTraversal(recordFolder)) {
		String relativePath = recordFolder.toURI().relativize(recordFile.toURI()).getPath();
		File replayFile = new File(replayFolder + File.separator + relativePath);

		if (recordFile.isFile() && replayFile.isFile()) {
			LOGGER.debug("xmlasserting " + recordFile.getPath()  + " with "+ replayFile.getPath() );

			
			try { 
			    compare(Input.fromFile(recordFile), Input.fromFile(replayFile)).build();
			} catch (AssertionError e) {
				throw new AssertionException(XMLFileAssertion.class.getSimpleName() + ":" +  relativePath , e);
			}
			
			
		}
	}
}
 
开发者ID:rockitconsulting,项目名称:test.rockitizer,代码行数:24,代码来源:XMLFileAssertion.java

示例5: assertPreservationInformationIdenticalTo

import org.xmlunit.builder.Input; //导入依赖的package包/类
public SipFileValidator assertPreservationInformationIdenticalTo(String resource) throws IOException {
  ZipEntry entry = zipFile.getEntry("eas_pdi.xml");
  Assert.assertNotNull("Missing Preservation Information", entry);

  try (InputStream expectedIn = owner.getClass()
    .getResourceAsStream(resource); InputStream actualIn = zipFile.getInputStream(entry)) {

    Diff myDiff = DiffBuilder.compare(Input.fromStream(expectedIn))
      .withTest(Input.fromStream(actualIn))
      .checkForSimilar()
      .ignoreWhitespace()
      .ignoreComments()
      .build();
    Assert.assertFalse("XML similar " + myDiff.toString(), myDiff.hasDifferences());

  }
  return this;

}
 
开发者ID:Enterprise-Content-Management,项目名称:infoarchive-sip-sdk,代码行数:20,代码来源:SipFileValidator.java

示例6: executeOnReceive

import org.xmlunit.builder.Input; //导入依赖的package包/类
@Override
public void executeOnReceive(MediatorHTTPRequest request) {
    assertEquals(testConfig.getDynamicConfig().get("upstream-scheme"), request.getScheme());
    assertEquals(testConfig.getDynamicConfig().get("upstream-host"), request.getHost());
    assertEquals(testConfig.getDynamicConfig().get("upstream-port"), new Double(request.getPort()));
    assertEquals(Constants.FHIR_MIME_XML, request.getHeaders().get("Content-Type"));

    if (request.getParams()!=null) {
        for (Pair<String, String> param : request.getParams()) {
            if (param.getKey().equals("_format")) {
                fail("Mediator should not forward _format param");
            }
        }
    }

    Diff diff = DiffBuilder
            .compare(Input.fromString(patientXML))
            .withTest(Input.fromString(request.getBody()))
            .ignoreComments()
            .ignoreWhitespace()
            .build();
    assertFalse(diff.hasDifferences());
}
 
开发者ID:jembi,项目名称:openhim-mediator-fhir-proxy,代码行数:24,代码来源:FhirProxyHandlerTest.java

示例7: compareTmx

import org.xmlunit.builder.Input; //导入依赖的package包/类
protected void compareTmx(File orig, File created, int count) throws Exception {
  Set<String> tmxOrig = readTmxSegments(orig);
  Set<String> tmxCreated = readTmxSegments(created);
  assertEquals(count, tmxCreated.size());
  assertEquals(tmxOrig.size(), tmxCreated.size());

  List<String> listOrig = new ArrayList<>(tmxOrig);
  List<String> listCreated = new ArrayList<>(tmxCreated);
  for (int i = 0; i < listOrig.size(); i++) {
    Diff myDiff = DiffBuilder.compare(Input.fromString(listOrig.get(i)))
        .withTest(Input.fromString(listCreated.get(i)))
        .checkForSimilar()
        .ignoreWhitespace()
        .build();
    assertFalse(myDiff.hasDifferences());
  }
}
 
开发者ID:miurahr,项目名称:tmpotter,代码行数:18,代码来源:TmxTestBase.java

示例8: testPerformExport

import org.xmlunit.builder.Input; //导入依赖的package包/类
@Test
public final void testPerformExport() throws IOException, SaveException {
    String xmlFileName = filename.replace(".bib", ".xml");
    Path importFile = resourceDir.resolve(filename);

    List<BibEntry> entries = testImporter.importDatabase(importFile, StandardCharsets.UTF_8).getDatabase()
            .getEntries();

    msBibExportFormat.export(databaseContext, tempFile, charset, entries);

    Builder control = Input.from(Files.newInputStream(resourceDir.resolve(xmlFileName)));
    Builder test = Input.from(Files.newInputStream(tempFile));

    assertThat(test, CompareMatcher.isSimilarTo(control)
            .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)).throwComparisonFailure());
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:17,代码来源:MSBibExportFormatTestFiles.java

示例9: testPerformExport

import org.xmlunit.builder.Input; //导入依赖的package包/类
@Test
public final void testPerformExport() throws IOException, SaveException {
    String xmlFileName = filename.replace(".bib", ".xml");
    Path importFile = resourceDir.resolve(filename);
    String tempFilename = tempFile.getCanonicalPath();

    List<BibEntry> entries = testImporter.importDatabase(importFile, StandardCharsets.UTF_8).getDatabase()
            .getEntries();

    bibtexmlExportFormat.export(databaseContext, tempFile.toPath(), charset, entries);

    Builder control = Input.from(Files.newInputStream(resourceDir.resolve(xmlFileName)));
    Builder test = Input.from(Files.newInputStream(Paths.get(tempFilename)));

    Assert.assertThat(test, CompareMatcher.isSimilarTo(control)
            .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)).throwComparisonFailure());
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:18,代码来源:BibTeXMLExporterTestFiles.java

示例10: testImportAsModsAndExportAsMods

import org.xmlunit.builder.Input; //导入依赖的package包/类
@Test
public final void testImportAsModsAndExportAsMods() throws Exception {
    String xmlFileName = filename.replace(".bib", ".xml");
    String tempFilename = tempFile.getCanonicalPath();
    Path xmlFile = Paths.get(ModsExportFormatTestFiles.class.getResource(xmlFileName).toURI());

    List<BibEntry> entries = modsImporter.importDatabase(xmlFile, charset).getDatabase().getEntries();

    modsExportFormat.export(databaseContext, tempFile.toPath(), charset, entries);

    Builder control = Input.from(Files.newInputStream(xmlFile));
    Builder test = Input.from(Files.newInputStream(Paths.get(tempFilename)));

    Assert.assertThat(test, CompareMatcher.isSimilarTo(control)
            .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)).throwComparisonFailure());
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:17,代码来源:ModsExportFormatTestFiles.java

示例11: testComparisonType_HAS_DOCTYPE_DECLARATION

import org.xmlunit.builder.Input; //导入依赖的package包/类
@Test
public void testComparisonType_HAS_DOCTYPE_DECLARATION() throws Exception {
    // prepare data
    DocumentBuilderFactory dbf = getDocumentBuilderFactoryWithoutValidation();
    Document controlDoc = Convert.toDocument(Input.fromString("<!DOCTYPE Book><a/>").build(), dbf);

    Diff diff = DiffBuilder.compare(controlDoc).withTest("<a/>").build();
    assertPreRequirements(diff, ComparisonType.HAS_DOCTYPE_DECLARATION);
    Comparison firstDiff = diff.getDifferences().iterator().next().getComparison();

    // run test
    String description = compFormatter.getDescription(firstDiff);
    String controlDetails =  getDetails(firstDiff.getControlDetails(), firstDiff.getType());
    String testDetails =  getDetails(firstDiff.getTestDetails(), firstDiff.getType());

    // validate result
    Assert.assertEquals("Expected has doctype declaration 'true' but was 'false' - "
            + "comparing <!DOCTYPE Book><a...> at / to <a...> at /", description);

    assertEquals("<!DOCTYPE Book>\n<a/>", controlDetails);
    assertEquals("<a/>", testDetails);
}
 
开发者ID:xmlunit,项目名称:xmlunit,代码行数:23,代码来源:DefaultComparisonFormatterTest.java

示例12: testComparisonType_DOCTYPE_NAME

import org.xmlunit.builder.Input; //导入依赖的package包/类
@Test
public void testComparisonType_DOCTYPE_NAME() throws Exception {
    // prepare data
    DocumentBuilderFactory dbf = getDocumentBuilderFactoryWithoutValidation();
    Document controlDoc = Convert.toDocument(Input.fromString("<!DOCTYPE Book ><a/>").build(), dbf);
    Document testDoc = Convert.toDocument(Input.fromString("<!DOCTYPE XY ><a/>").build(), dbf);

    Diff diff = DiffBuilder.compare(controlDoc).withTest(testDoc).build();
    assertPreRequirements(diff, ComparisonType.DOCTYPE_NAME);
    Comparison firstDiff = diff.getDifferences().iterator().next().getComparison();

    // run test
    String description = compFormatter.getDescription(firstDiff);
    String controlDetails =  getDetails(firstDiff.getControlDetails(), firstDiff.getType());
    String testDetails =  getDetails(firstDiff.getTestDetails(), firstDiff.getType());

    // validate result
    Assert.assertEquals("Expected doctype name 'Book' but was 'XY' - "
            + "comparing <!DOCTYPE Book><a...> at / to <!DOCTYPE XY><a...> at /", description);

    assertEquals("<!DOCTYPE Book>\n<a/>", controlDetails);
    assertEquals("<!DOCTYPE XY>\n<a/>", testDetails);
}
 
开发者ID:xmlunit,项目名称:xmlunit,代码行数:24,代码来源:DefaultComparisonFormatterTest.java

示例13: testComparisonType_DOCTYPE_PUBLIC_ID

import org.xmlunit.builder.Input; //导入依赖的package包/类
@Test
public void testComparisonType_DOCTYPE_PUBLIC_ID() throws Exception {
    // prepare data
    DocumentBuilderFactory dbf = getDocumentBuilderFactoryWithoutValidation();
    Document controlDoc = Convert.toDocument(Input.fromString(
            "<!DOCTYPE Book PUBLIC \"XMLUNIT/TEST/PUB\" \"http://example.org/nonsense\"><a/>").build(), dbf);
    Document testDoc = Convert.toDocument(Input.fromString(
            "<!DOCTYPE Book SYSTEM \"http://example.org/nonsense\"><a/>").build(), dbf);

    Diff diff = DiffBuilder.compare(controlDoc).withTest(testDoc).build();
    assertPreRequirements(diff, ComparisonType.DOCTYPE_PUBLIC_ID);
    Comparison firstDiff = diff.getDifferences().iterator().next().getComparison();

    // run test
    String description = compFormatter.getDescription(firstDiff);
    String controlDetails =  getDetails(firstDiff.getControlDetails(), firstDiff.getType());
    String testDetails =  getDetails(firstDiff.getTestDetails(), firstDiff.getType());

    // validate result
    Assert.assertEquals("Expected doctype public id 'XMLUNIT/TEST/PUB' but was 'null' - "
            + "comparing <!DOCTYPE Book PUBLIC \"XMLUNIT/TEST/PUB\" \"http://example.org/nonsense\"><a...> at / "
            + "to <!DOCTYPE Book SYSTEM \"http://example.org/nonsense\"><a...> at /", description);

    assertEquals("<!DOCTYPE Book PUBLIC \"XMLUNIT/TEST/PUB\" \"http://example.org/nonsense\">\n<a/>", controlDetails);
    assertEquals("<!DOCTYPE Book SYSTEM \"http://example.org/nonsense\">\n<a/>", testDetails);
}
 
开发者ID:xmlunit,项目名称:xmlunit,代码行数:27,代码来源:DefaultComparisonFormatterTest.java

示例14: shouldDetectCommentInPrelude

import org.xmlunit.builder.Input; //导入依赖的package包/类
@Test
public void shouldDetectCommentInPrelude() {
    DOMDifferenceEngine d = new DOMDifferenceEngine();
    Document d1 = Convert.toDocument(Input.fromFile(TestResources.TEST_RESOURCE_DIR
                                                    + "BookXsdGenerated.xml")
                                     .build());
    Document d2 = Convert.toDocument(Input.fromFile(TestResources.TEST_RESOURCE_DIR
                                                    + "BookXsdGeneratedWithComment.xml")
                                     .build());
    DiffExpecter ex = new DiffExpecter(ComparisonType.CHILD_NODELIST_LENGTH,
                                       "/", "/");
    d.addDifferenceListener(ex);
    d.setComparisonController(ComparisonControllers.StopWhenDifferent);
    assertEquals(wrapAndStop(ComparisonResult.DIFFERENT),
                 d.compareNodes(d1, new XPathContext(),
                                d2, new XPathContext()));
}
 
开发者ID:xmlunit,项目名称:xmlunit,代码行数:18,代码来源:DOMDifferenceEngineTest.java

示例15: shouldDetectMissingXsiType

import org.xmlunit.builder.Input; //导入依赖的package包/类
@Test
public void shouldDetectMissingXsiType() {
    DOMDifferenceEngine d = new DOMDifferenceEngine();
    Document d1 = Convert.toDocument(Input.fromString("<doc xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
                                                      + "<effectiveTime xsi:type=\"IVL_TS\"></effectiveTime></doc>")
                                     .build());
    Document d2 = Convert.toDocument(Input.fromString("<doc xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
                                                      + "<effectiveTime></effectiveTime></doc>")
                                     .build());

    DiffExpecter ex = new DiffExpecter(ComparisonType.ATTR_NAME_LOOKUP,
                                       "/doc[1]/effectiveTime[1]/@type",
                                       "/doc[1]/effectiveTime[1]");
    d.addDifferenceListener(ex);
    d.setComparisonController(ComparisonControllers.StopWhenDifferent);
    assertEquals(wrapAndStop(ComparisonResult.DIFFERENT),
                 d.compareNodes(d1, new XPathContext(),
                                d2, new XPathContext()));
}
 
开发者ID:xmlunit,项目名称:xmlunit,代码行数:20,代码来源:DOMDifferenceEngineTest.java


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