Search in sources :

Example 91 with ParserResult

use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.

the class BibtexParserTest method parseRecognizesPreambleInParenthesis.

@Test
public void parseRecognizesPreambleInParenthesis() throws IOException {
    ParserResult result = parser.parse(new StringReader("@preamble(some text and \\latex)"));
    assertEquals(Optional.of("some text and \\latex"), result.getDatabase().getPreamble());
}
Also used : ParserResult(org.jabref.logic.importer.ParserResult) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 92 with ParserResult

use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.

the class BibtexParserTest method parseIgnoresAndWarnsAboutEntryWithFieldsThatAreNotSeperatedByComma.

@Test
public void parseIgnoresAndWarnsAboutEntryWithFieldsThatAreNotSeperatedByComma() throws IOException {
    ParserResult result = parser.parse(new StringReader("@article{test,author={Ed von Test} year=2005}"));
    assertTrue(result.hasWarnings());
    Collection<BibEntry> c = result.getDatabase().getEntries();
    assertEquals(0, c.size());
}
Also used : ParserResult(org.jabref.logic.importer.ParserResult) BibEntry(org.jabref.model.entry.BibEntry) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 93 with ParserResult

use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.

the class BibtexParserTest method parseRecognizesUppercaseFields.

@Test
public void parseRecognizesUppercaseFields() throws IOException {
    ParserResult result = parser.parse(new StringReader("@article{test,AUTHOR={Ed von Test}}"));
    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("Ed von Test"), e.getField("author"));
}
Also used : ParserResult(org.jabref.logic.importer.ParserResult) BibEntry(org.jabref.model.entry.BibEntry) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 94 with ParserResult

use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.

the class MrDLibImporterTest method testImportDatabaseMin.

@Test
public void testImportDatabaseMin() throws IOException {
    ParserResult parserResult = importer.importDatabase(inputMin);
    List<BibEntry> resultList = parserResult.getDatabase().getEntries();
    assertSame(0, resultList.size());
}
Also used : ParserResult(org.jabref.logic.importer.ParserResult) BibEntry(org.jabref.model.entry.BibEntry) Test(org.junit.Test)

Example 95 with ParserResult

use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.

the class BibtexParserTest method parseRecognizesPreambleWithConcatenation.

@Test
public void parseRecognizesPreambleWithConcatenation() throws IOException {
    ParserResult result = parser.parse(new StringReader("@preamble{\"some text\" # \"and \\latex\"}"));
    assertEquals(Optional.of("\"some text\" # \"and \\latex\""), result.getDatabase().getPreamble());
}
Also used : ParserResult(org.jabref.logic.importer.ParserResult) StringReader(java.io.StringReader) Test(org.junit.Test)

Aggregations

ParserResult (org.jabref.logic.importer.ParserResult)196 Test (org.junit.Test)145 BibEntry (org.jabref.model.entry.BibEntry)131 StringReader (java.io.StringReader)130 BibtexParser (org.jabref.logic.importer.fileformat.BibtexParser)38 BibtexString (org.jabref.model.entry.BibtexString)30 ArrayList (java.util.ArrayList)23 BibDatabase (org.jabref.model.database.BibDatabase)20 Path (java.nio.file.Path)14 IOException (java.io.IOException)12 StringWriter (java.io.StringWriter)12 File (java.io.File)10 InputStreamReader (java.io.InputStreamReader)10 HashMap (java.util.HashMap)10 BibDatabaseContext (org.jabref.model.database.BibDatabaseContext)9 InputStream (java.io.InputStream)8 Defaults (org.jabref.model.Defaults)8 Charset (java.nio.charset.Charset)6 Scanner (java.util.Scanner)5 BufferedReader (java.io.BufferedReader)4