use of org.jabref.model.database.BibDatabaseContext in project jabref by JabRef.
the class CsvExportFormatTest method setUp.
@Before
public void setUp() {
Map<String, ExportFormat> customFormats = new HashMap<>();
LayoutFormatterPreferences layoutPreferences = mock(LayoutFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS);
SavePreferences savePreferences = mock(SavePreferences.class);
ExportFormats.initAllExports(customFormats, layoutPreferences, savePreferences);
exportFormat = ExportFormats.getExportFormat("oocsv");
databaseContext = new BibDatabaseContext();
charset = Charsets.UTF_8;
}
use of org.jabref.model.database.BibDatabaseContext in project jabref by JabRef.
the class BibtexDatabaseWriterTest method roundtripWithUserComment.
@Test
public void roundtripWithUserComment() throws Exception {
Path testBibtexFile = Paths.get("src/test/resources/testbib/bibWithUserComments.bib");
Charset encoding = StandardCharsets.UTF_8;
ParserResult result = new BibtexParser(importFormatPreferences).parse(Importer.getReader(testBibtexFile, encoding));
SavePreferences preferences = new SavePreferences().withEncoding(encoding).withSaveInOriginalOrder(true);
BibDatabaseContext context = new BibDatabaseContext(result.getDatabase(), result.getMetaData(), new Defaults(BibDatabaseMode.BIBTEX));
StringSaveSession session = databaseWriter.savePartOfDatabase(context, result.getDatabase().getEntries(), preferences);
try (Scanner scanner = new Scanner(testBibtexFile, encoding.name())) {
assertEquals(scanner.useDelimiter("\\A").next(), session.getStringValue());
}
}
use of org.jabref.model.database.BibDatabaseContext in project jabref by JabRef.
the class BibtexDatabaseWriterTest method roundtrip.
@Test
public void roundtrip() throws Exception {
Path testBibtexFile = Paths.get("src/test/resources/testbib/complex.bib");
Charset encoding = StandardCharsets.UTF_8;
ParserResult result = new BibtexParser(importFormatPreferences).parse(Importer.getReader(testBibtexFile, encoding));
SavePreferences preferences = new SavePreferences().withEncoding(encoding).withSaveInOriginalOrder(true);
BibDatabaseContext context = new BibDatabaseContext(result.getDatabase(), result.getMetaData(), new Defaults(BibDatabaseMode.BIBTEX));
StringSaveSession session = databaseWriter.savePartOfDatabase(context, result.getDatabase().getEntries(), preferences);
try (Scanner scanner = new Scanner(testBibtexFile, encoding.name())) {
assertEquals(scanner.useDelimiter("\\A").next(), session.getStringValue());
}
}
use of org.jabref.model.database.BibDatabaseContext in project jabref by JabRef.
the class BibtexDatabaseWriterTest method roundtripWithUnknownMetaData.
@Test
public void roundtripWithUnknownMetaData() throws Exception {
Path testBibtexFile = Paths.get("src/test/resources/testbib/unknownMetaData.bib");
Charset encoding = StandardCharsets.UTF_8;
ParserResult result = new BibtexParser(importFormatPreferences).parse(Importer.getReader(testBibtexFile, encoding));
SavePreferences preferences = new SavePreferences().withEncoding(encoding).withSaveInOriginalOrder(true);
BibDatabaseContext context = new BibDatabaseContext(result.getDatabase(), result.getMetaData(), new Defaults(BibDatabaseMode.BIBTEX));
StringSaveSession session = databaseWriter.savePartOfDatabase(context, result.getDatabase().getEntries(), preferences);
try (Scanner scanner = new Scanner(testBibtexFile, encoding.name())) {
assertEquals(scanner.useDelimiter("\\A").next(), session.getStringValue());
}
}
use of org.jabref.model.database.BibDatabaseContext in project jabref by JabRef.
the class MSBibExportFormatTestFiles method setUp.
@Before
public void setUp() throws Exception {
resourceDir = Paths.get(MSBibExportFormatTestFiles.class.getResource("").toURI());
databaseContext = new BibDatabaseContext();
charset = StandardCharsets.UTF_8;
msBibExportFormat = new MSBibExportFormat();
tempFile = testFolder.newFile();
testImporter = new BibtexImporter(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS));
}
Aggregations