Search in sources :

Example 1 with Builder

use of org.xmlunit.builder.Input.Builder in project jabref by JabRef.

the class BibTeXMLExporterTestFiles method testPerformExport.

@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.performExport(databaseContext, tempFile.getPath(), 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());
}
Also used : Path(java.nio.file.Path) BibEntry(org.jabref.model.entry.BibEntry) Builder(org.xmlunit.builder.Input.Builder) DefaultNodeMatcher(org.xmlunit.diff.DefaultNodeMatcher) Test(org.junit.Test)

Example 2 with Builder

use of org.xmlunit.builder.Input.Builder in project jabref by JabRef.

the class MSBibExportFormatTestFiles method testPerformExport.

@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();
    msBibExportFormat.performExport(databaseContext, tempFile.getPath(), charset, entries);
    Builder control = Input.from(Files.newInputStream(resourceDir.resolve(xmlFileName)));
    Builder test = Input.from(Files.newInputStream(Paths.get(tempFilename)));
    assertThat(test, CompareMatcher.isSimilarTo(control).withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)).throwComparisonFailure());
}
Also used : Path(java.nio.file.Path) BibEntry(org.jabref.model.entry.BibEntry) Builder(org.xmlunit.builder.Input.Builder) DefaultNodeMatcher(org.xmlunit.diff.DefaultNodeMatcher) Test(org.junit.Test)

Example 3 with Builder

use of org.xmlunit.builder.Input.Builder in project jabref by JabRef.

the class ModsExportFormatTestFiles method testImportAsModsAndExportAsMods.

@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.performExport(databaseContext, tempFile.getPath(), 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());
}
Also used : Path(java.nio.file.Path) BibEntry(org.jabref.model.entry.BibEntry) Builder(org.xmlunit.builder.Input.Builder) DefaultNodeMatcher(org.xmlunit.diff.DefaultNodeMatcher) Test(org.junit.Test)

Example 4 with Builder

use of org.xmlunit.builder.Input.Builder in project jabref by JabRef.

the class ModsExportFormatTestFiles method testPerformExport.

@Test
public final void testPerformExport() throws Exception {
    String xmlFileName = filename.replace(".bib", ".xml");
    String tempFilename = tempFile.getCanonicalPath();
    List<BibEntry> entries = bibtexImporter.importDatabase(importFile, charset).getDatabase().getEntries();
    Path xmlFile = Paths.get(ModsExportFormatTestFiles.class.getResource(xmlFileName).toURI());
    modsExportFormat.performExport(databaseContext, tempFile.getPath(), 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());
}
Also used : Path(java.nio.file.Path) BibEntry(org.jabref.model.entry.BibEntry) Builder(org.xmlunit.builder.Input.Builder) DefaultNodeMatcher(org.xmlunit.diff.DefaultNodeMatcher) Test(org.junit.Test)

Aggregations

Path (java.nio.file.Path)4 BibEntry (org.jabref.model.entry.BibEntry)4 Test (org.junit.Test)4 Builder (org.xmlunit.builder.Input.Builder)4 DefaultNodeMatcher (org.xmlunit.diff.DefaultNodeMatcher)4