use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseRecognizesBibtexKeyWithSpecialCharacters.
@Test
public void parseRecognizesBibtexKeyWithSpecialCharacters() throws IOException {
ParserResult result = parser.parse(new StringReader("@article{te_st:with-special(characters),author={Ed von Test}}"));
Collection<BibEntry> c = result.getDatabase().getEntries();
BibEntry e = c.iterator().next();
assertEquals("article", e.getType());
assertEquals(Optional.of("te_st:with-special(characters)"), e.getCiteKeyOptional());
assertEquals(2, e.getFieldNames().size());
assertEquals(Optional.of("Ed von Test"), e.getField("author"));
}
use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseSetsParsedSerialization.
@Test
public void parseSetsParsedSerialization() throws IOException {
String firstEntry = "@article{canh05," + " author = {Crowston, K. and Annabi, H.}," + OS.NEWLINE + " title = {Title A}}" + OS.NEWLINE;
String secondEntry = "@inProceedings{foo," + " author={Norton Bar}}";
ParserResult result = parser.parse(new StringReader(firstEntry + secondEntry));
for (BibEntry entry : result.getDatabase().getEntries()) {
if (entry.getCiteKeyOptional().get().equals("canh05")) {
assertEquals(firstEntry, entry.getParsedSerialization());
} else {
assertEquals(secondEntry, entry.getParsedSerialization());
}
}
}
use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseCommentWithoutBrackets.
@Test
public void parseCommentWithoutBrackets() throws IOException {
String commentText = "@Comment someComment";
ParserResult result = parser.parse(new StringReader(commentText));
assertEquals(commentText, result.getDatabase().getEpilog());
}
use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseRecognizesDateFieldWithConcatenation.
/**
* Test for SF Bug #48
*/
@Test
public void parseRecognizesDateFieldWithConcatenation() throws IOException {
ParserResult result = parser.parse(new StringReader("@article{test,date = {1-4~} # nov}"));
Collection<BibEntry> c = result.getDatabase().getEntries();
assertEquals(1, c.size());
BibEntry e = c.iterator().next();
assertEquals("article", e.getType());
assertEquals(Optional.of("test"), e.getCiteKeyOptional());
assertEquals(2, e.getFieldNames().size());
assertEquals(Optional.of("1-4~#nov#"), e.getField("date"));
}
use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseIgnoresAndWarnsAboutEntryWithUnmatchedOpenBracketInQuotationMarks.
@Test
public void parseIgnoresAndWarnsAboutEntryWithUnmatchedOpenBracketInQuotationMarks() throws IOException {
ParserResult result = parser.parse(new StringReader("@article{test,author=\"author {missing bracket\"}"));
assertTrue(result.hasWarnings());
Collection<BibEntry> c = result.getDatabase().getEntries();
assertEquals(0, c.size());
}
Aggregations