Package net.sf.jabref.imports

Examples of net.sf.jabref.imports.ParserResult


  public BibtexEntry t1BibtexEntry() throws IOException {
    return bibtexString2BibtexEntry(t1BibtexString());
  }

  public static BibtexEntry bibtexString2BibtexEntry(String s) throws IOException {
    ParserResult result = BibtexParser.parse(new StringReader(s));
    Collection<BibtexEntry> c = result.getDatabase().getEntries();
    assertEquals(1, c.size());
    return c.iterator().next();
  }
View Full Code Here


*/
public class BibtexParserTest extends TestCase {

  public void testParseReader() throws IOException {

    ParserResult result = BibtexParser.parse(new StringReader(
      "@article{test,author={Ed von Test}}"));

    Collection<BibtexEntry> c = result.getDatabase().getEntries();
    assertEquals(1, c.size());

    BibtexEntry e = c.iterator().next();
    assertEquals("test", e.getCiteKey());
    assertEquals(2, e.getAllFields().size());
View Full Code Here

  public void testParse() throws IOException {

    // Test Standard parsing
    BibtexParser parser = new BibtexParser(new StringReader(
      "@article{test,author={Ed von Test}}"));
    ParserResult result = parser.parse();

    Collection<BibtexEntry> c = result.getDatabase().getEntries();
    assertEquals(1, c.size());

    BibtexEntry e = c.iterator().next();
    assertEquals("test", e.getCiteKey());
    assertEquals(2, e.getAllFields().size());
View Full Code Here

  public void testParse2() throws IOException {

    BibtexParser parser = new BibtexParser(new StringReader(
      "@article{test,author={Ed von Test}}"));
    ParserResult result = parser.parse();

    BibtexEntry e = new BibtexEntry("", BibtexEntryType.ARTICLE);
    e.setField("author", "Ed von Test");
    e.setField("bibtexkey", "test");

    Collection<BibtexEntry> c = result.getDatabase().getEntries();
    assertEquals(1, c.size());

    BibtexEntry e2 = c.iterator().next();

    assertNotSame(e.getId(), e2.getId());
View Full Code Here

   *
   * @throws IOException
   */
  public void testBigNumbers() throws IOException {

    ParserResult result = BibtexParser.parse(new StringReader("@article{canh05,"
      + "isbn = 1234567890123456789,\n" + "isbn2 = {1234567890123456789},\n"
      + "small = 1234,\n" + "}"));

    Collection<BibtexEntry> c = result.getDatabase().getEntries();
    BibtexEntry e = c.iterator().next();

    assertEquals("1234567890123456789", e.getField("isbn"));
    assertEquals("1234567890123456789", e.getField("isbn2"));
    assertEquals("1234", e.getField("small"));
View Full Code Here

    assertEquals("1234", e.getField("small"));
  }

  public void testBigNumbers2() throws IOException {

    ParserResult result = BibtexParser.parse(new StringReader(""
      + "@string{bourdieu = {Bourdieu, Pierre}}"
      + "@book{bourdieu-2002-questions-sociologie, " + "  Address = {Paris},"
      + "  Author = bourdieu," + "  Isbn = 2707318256," + "  Publisher = {Minuit},"
      + "  Title = {Questions de sociologie}," + "  Year = 2002" + "}"));

    Collection<BibtexEntry> c = result.getDatabase().getEntries();
    assertEquals(1, c.size());

    BibtexEntry e = c.iterator().next();

    assertEquals("bourdieu-2002-questions-sociologie", e.getCiteKey());
View Full Code Here

  }

  private BibtexDatabase getDatabse() {
    Globals.prefs = JabRefPreferences.getInstance();
    File fileToLoad = new File(PATH_TO_TEST_BIBTEX);
    ParserResult pr = JabRef.openBibFile(fileToLoad.getPath(), true);
    BibtexDatabase filledDatabase = pr.getDatabase();
    return filledDatabase;
  }
View Full Code Here

    }
  }

  public static BibtexEntry bibtexString2BibtexEntry(String s)
      throws IOException {
    ParserResult result = BibtexParser.parse(new StringReader(s));
    Collection<BibtexEntry> c = result.getDatabase().getEntries();
    assertEquals(1, c.size());
    return c.iterator().next();
  }
View Full Code Here

   * Test that readXMP and writeXMP work together.
   *
   * @throws Exception
   */
  public void testReadWriteXMP() throws Exception {
    ParserResult result = BibtexParser
        .parse(new StringReader(
            "@article{canh05,"
                + "  author = {Crowston, K. and Annabi, H. and Howison, J. and Masango, C.},"
                + "\n"
                + "  title = {Effective work practices for floss development: A model and propositions},"
                + "\n"
                + "  booktitle = {Hawaii International Conference On System Sciences (HICSS)},"
                + "\n"
                + "  year = {2005},"
                + "\n"
                + "  owner = {oezbek},"
                + "\n"
                + "  timestamp = {2006.05.29},"
                + "\n"
                + "  url = {http://james.howison.name/publications.html}"
                + "\n" + "}"));

    Collection<BibtexEntry> c = result.getDatabase().getEntries();
    assertEquals(1, c.size());

    BibtexEntry e = c.iterator().next();

    XMPUtil.writeXMP(pdfFile, e, null);
View Full Code Here

   *
   * @throws Exception
   *
   */
  public void testXMLEscape() throws Exception {
    ParserResult result = BibtexParser
        .parse(new StringReader(
            "@article{canh05,"
                + "  author = {Crowston, K. and Annabi, H. and Howison, J. and Masango, C.},"
                + "\n"
                + "  title = {</bibtex:title> \" bla \" '' '' && &  for floss development: A model and propositions},"
                + "\n"
                + "  booktitle = {<randomXML>},"
                + "\n"
                + "  year = {2005},"
                + "\n"
                + "  owner = {oezbek},"
                + "\n"
                + "  timestamp = {2006.05.29},"
                + "\n"
                + "  url = {http://james.howison.name/publications.html}"
                + "\n" + "}"));

    Collection<BibtexEntry> c = result.getDatabase().getEntries();
    assertEquals(1, c.size());

    BibtexEntry e = c.iterator().next();

    XMPUtil.writeXMP(pdfFile, e, null);
View Full Code Here

TOP

Related Classes of net.sf.jabref.imports.ParserResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.