Package net.sf.jabref.export.layout

Examples of net.sf.jabref.export.layout.LayoutFormatter


  public void tearDown() {
    super.tearDown();
  }

  public void testFormat() throws URISyntaxException {
    LayoutFormatter pdf = new ResolvePDF();

    assertEquals("", pdf.format(""));
   
    /*
     * Check one that will be found
     */
    String result = pdf.format("Organization Science\\HipKro03 - Hello.pdf");
    assertTrue(result.startsWith("file:/"));
   
    assertTrue(result.endsWith("/Organization%20Science/HipKro03%20-%20Hello.pdf"));
   
    // Should not contain a backslash:
    assertEquals(-1, result.indexOf('\\'));
   
    assertTrue(new File(new URI(result)).exists());
   
    /*
     * And one that is not to be found
     */
    result = pdf.format("Organization Science/Does not exist.pdf");
    assertEquals("Organization Science/Does not exist.pdf", result);
  }
View Full Code Here


  /**
   * Test method for {@link net.sf.jabref.export.layout.format.AuthorLastFirstAbbrCommas#format(java.lang.String)}.
   */
  public void testFormat() {
      LayoutFormatter a = new AuthorLastFirstAbbrCommas();

      // Empty case
      assertEquals("", a.format(""));

      // Single Names
      assertEquals("Someone, V. S.", a.format("Van Something Someone"));

      // Two names
      assertEquals("von Neumann, J. and Black Brown, P.", a
        .format("John von Neumann and Black Brown, Peter"));

      // Three names
      assertEquals("von Neumann, J., Smith, J. and Black Brown, P.", a
        .format("von Neumann, John and Smith, John and Black Brown, Peter"));

      assertEquals("von Neumann, J., Smith, J. and Black Brown, P.", a
        .format("John von Neumann and John Smith and Black Brown, Peter"));
   
  }
View Full Code Here

  /**
   * Test method for {@link net.sf.jabref.export.layout.format.AuthorLastFirstOxfordCommas#format(java.lang.String)}.
   */
  public void testFormat() {
    LayoutFormatter a = new AuthorLastFirstOxfordCommas();

    // Empty case
    assertEquals("", a.format(""));

    // Single Names
    assertEquals("Someone, Van Something", a.format("Van Something Someone"));

    // Two names
    assertEquals("von Neumann, John and Black Brown, Peter", a
      .format("John von Neumann and Black Brown, Peter"));

    // Three names
    assertEquals("von Neumann, John, Smith, John, and Black Brown, Peter", a
      .format("von Neumann, John and Smith, John and Black Brown, Peter"));

    assertEquals("von Neumann, John, Smith, John, and Black Brown, Peter", a
      .format("John von Neumann and John Smith and Black Brown, Peter"));
  }
View Full Code Here

    assertEquals("Other, A. N.", abbreviate(name));
  }

  public void testFormat() {

    LayoutFormatter a = new AuthorLastFirstAbbreviator();
   
    assertEquals("", a.format(""));
    assertEquals("Someone, V. S.", a.format("Someone, Van Something"));
    assertEquals("Smith, J.", a.format("Smith, John"));
    assertEquals("von Neumann, J. and Smith, J. and Black Brown, P.",
        a.format("von Neumann, John and Smith, John and Black Brown, Peter"));
   
  }
View Full Code Here

*
*/
public class AuthorFirstAbbrLastCommasTest extends TestCase {

  public void testFormat() {
    LayoutFormatter a = new AuthorFirstAbbrLastCommas();

    // Empty case
    assertEquals("", a.format(""));

    // Single Names
    assertEquals("V. S. Someone", a.format("Someone, Van Something"));

    // Two names
    assertEquals("J. von Neumann and P. Black Brown", a
      .format("John von Neumann and Black Brown, Peter"));

    // Three names
    assertEquals("J. von Neumann, J. Smith and P. Black Brown", a
      .format("von Neumann, John and Smith, John and Black Brown, Peter"));

    assertEquals("J. von Neumann, J. Smith and P. Black Brown", a
      .format("John von Neumann and John Smith and Black Brown, Peter"));
  }
View Full Code Here

*/
public class AuthorAbbreviatorTest extends TestCase {

  public void testFormat() {

    LayoutFormatter a = new AuthorLastFirstAbbreviator();
    LayoutFormatter b = new AuthorAbbreviator();

    assertEquals(b.format(""), a.format(""));
    assertEquals(b.format("Someone, Van Something"), a.format("Someone, Van Something"));
    assertEquals(b.format("Smith, John"), a.format("Smith, John"));
    assertEquals(b.format("von Neumann, John and Smith, John and Black Brown, Peter"), a
      .format("von Neumann, John and Smith, John and Black Brown, Peter"));

  }
View Full Code Here

  /**
   * Test method for
   * {@link net.sf.jabref.export.layout.format.AuthorAndsReplacer#format(java.lang.String)}.
   */
  public void testFormat() {
    LayoutFormatter a = new AuthorAndsReplacer();

    // Empty case
    assertEquals("", a.format(""));

    // Single Names don't change
    assertEquals("Someone, Van Something", a.format("Someone, Van Something"));

    // Two names just an &
    assertEquals("John Smith & Black Brown, Peter", a
      .format("John Smith and Black Brown, Peter"));

    // Three names put a comma:
    assertEquals("von Neumann, John; Smith, John & Black Brown, Peter", a
      .format("von Neumann, John and Smith, John and Black Brown, Peter"));

    assertEquals("John von Neumann; John Smith & Peter Black Brown", a
      .format("John von Neumann and John Smith and Peter Black Brown"));
  }
View Full Code Here

  }

  public void testComposite() {

    {
      LayoutFormatter f = new CompositeFormat();
      assertEquals("No Change", f.format("No Change"));
    }
    {
      LayoutFormatter f = new CompositeFormat(new LayoutFormatter[]{new LayoutFormatter(){

        public String format(String fieldText) {
          return fieldText + fieldText;
        }
       
      }, new LayoutFormatter(){

        public String format(String fieldText) {
          return "A" + fieldText;
        }
       
      }, new LayoutFormatter(){

        public String format(String fieldText) {
          return "B" + fieldText;
        }
       
      }});
     
      assertEquals("BAff", f.format("f"));
    }
   
    {
      LayoutFormatter f = new CompositeFormat(new AuthorOrgSci(),
        new NoSpaceBetweenAbbreviations());
      LayoutFormatter first = new AuthorOrgSci();
      LayoutFormatter second = new NoSpaceBetweenAbbreviations();
     
      assertEquals(second.format(first.format("John Flynn and Sabine Gartska")), f.format("John Flynn and Sabine Gartska"));
      assertEquals(second.format(first.format("Sa Makridakis and Sa Ca Wheelwright and Va Ea McGee")), f.format("Sa Makridakis and Sa Ca Wheelwright and Va Ea McGee"));
    }
  }
View Full Code Here

  /**
   * Test method for {@link net.sf.jabref.export.layout.format.AuthorFirstAbbrLastOxfordCommas#format(java.lang.String)}.
   */
  public void testFormat() {
    LayoutFormatter a = new AuthorFirstAbbrLastOxfordCommas();

    // Empty case
    assertEquals("", a.format(""));

    // Single Names
    assertEquals("V. S. Someone", a.format("Someone, Van Something"));

    // Two names
    assertEquals("J. von Neumann and P. Black Brown", a
      .format("John von Neumann and Black Brown, Peter"));

    // Three names
    assertEquals("J. von Neumann, J. Smith, and P. Black Brown", a
      .format("von Neumann, John and Smith, John and Black Brown, Peter"));

    assertEquals("J. von Neumann, J. Smith, and P. Black Brown", a
      .format("John von Neumann and John Smith and Black Brown, Peter"));
  }
View Full Code Here

public class RemoveTildeTest extends TestCase {

  public void testFormatString() {

    LayoutFormatter l = new RemoveTilde();

    assertEquals("", l.format(""));
   
    assertEquals("simple", l.format("simple"));
   
    assertEquals(" ", l.format("~"));
   
    assertEquals("   ", l.format("~~~"));
   
    assertEquals(" \\~ ", l.format("~\\~~"));
   
    assertEquals("\\\\ ", l.format("\\\\~"));
   
    assertEquals("Doe Joe and Jane, M. and Kamp, J. A.", l
        .format("Doe Joe and Jane, M. and Kamp, J.~A."));
   
    assertEquals("T\\~olkien, J. R. R.", l
        .format("T\\~olkien, J.~R.~R."));
  }
View Full Code Here

TOP

Related Classes of net.sf.jabref.export.layout.LayoutFormatter

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.