Package no.priv.garshol.duke.utils

Examples of no.priv.garshol.duke.utils.CSVReader


  }

  @Test
  public void testTwoRowsRN() throws IOException {
    String data = "a,b,c\r\nd,e,f";
    CSVReader reader = new CSVReader(new StringReader(data));

    String[] row = reader.next();
    compareRows("first row read incorrectly", new String[]{"a", "b", "c"},
                row);
    row = reader.next();
    compareRows("second row read incorrectly", new String[]{"d", "e", "f"},
                row);
    compareRows("reading not terminated correctly", null, reader.next());
  }
View Full Code Here


  }

  @Test
  public void testTwoRowsR() throws IOException {
    String data = "a,b,c\rd,e,f";
    CSVReader reader = new CSVReader(new StringReader(data));

    String[] row = reader.next();
    compareRows("first row read incorrectly", new String[]{"a", "b", "c"},
                row);
    row = reader.next();
    compareRows("second row read incorrectly", new String[]{"d", "e", "f"},
                row);
    compareRows("reading not terminated correctly", null, reader.next());
  }
View Full Code Here

  }

  @Test
  public void testTwoRowsBuffering() throws IOException {
    String data = "aaa,bbb,ccc\nddd,eee,fff";
    CSVReader reader = new CSVReader(new StringReader(data), 15);

    String[] row = reader.next();
    compareRows("first row read incorrectly", new String[]{"aaa", "bbb", "ccc"},
                row);
    row = reader.next();
    compareRows("second row read incorrectly", new String[]{"ddd", "eee", "fff"},
                row);
    compareRows("reading not terminated correctly", null, reader.next());
  }
View Full Code Here

  }

  @Test
  public void testOneRowQuotesAndComma() throws IOException {
    String data = "aaa,\"b,b\",ccc";
    CSVReader reader = new CSVReader(new StringReader(data));

    String[] row = reader.next();
    compareRows("first row read incorrectly", new String[]{"aaa", "b,b", "ccc"},
                row);
    compareRows("reading not terminated correctly", null, reader.next());
  }
View Full Code Here

  }

  @Test
  public void testOneRowEmptyQuoted() throws IOException {
    String data = "aaa,\"\",ccc";
    CSVReader reader = new CSVReader(new StringReader(data));

    String[] row = reader.next();
    compareRows("first row read incorrectly", new String[]{"aaa", "", "ccc"},
                row);
    compareRows("reading not terminated correctly", null, reader.next());
  }
View Full Code Here

  }

  @Test
  public void testOneRowWithQuoteCharacters() throws IOException {
    String data = "TRMMMXN128F42936A5,\"Symphony No. 1 G minor \"\"Sinfonie Serieuse\"\"/Allegro con energia\",SOZVAPQ12A8C13B63C,\"Berwald: Symphonies Nos. 1/2/3/4\",AR2NS5Y1187FB5879D";
    CSVReader reader = new CSVReader(new StringReader(data));

    String[] row = reader.next();
    compareRows("first row read incorrectly",
                new String[]{"TRMMMXN128F42936A5",
                             "Symphony No. 1 G minor \"Sinfonie Serieuse\"/Allegro con energia",
                             "SOZVAPQ12A8C13B63C",
                             "Berwald: Symphonies Nos. 1/2/3/4",
                             "AR2NS5Y1187FB5879D"},
                row);
    compareRows("reading not terminated correctly", null, reader.next());
  }
View Full Code Here

  }

  @Test
  public void testOneRowWithQuoteCharacters2() throws IOException {
    String data = "\"\"\"quoted\"\"\"";
    CSVReader reader = new CSVReader(new StringReader(data));

    String[] row = reader.next();
    compareRows("first row read incorrectly",
                new String[]{"\"quoted\""},
                row);
    compareRows("reading not terminated correctly", null, reader.next());
  }
View Full Code Here

  }

  @Test
  public void testSeparator() throws IOException {
    String data = "a;b;c\nd;e;f";
    CSVReader reader = new CSVReader(new StringReader(data));
    reader.setSeparator(';');

    String[] row = reader.next();
    compareRows("first row read incorrectly", new String[]{"a", "b", "c"},
                row);
    row = reader.next();
    compareRows("second row read incorrectly", new String[]{"d", "e", "f"},
                row);
    compareRows("reading not terminated correctly", null, reader.next());
  }
View Full Code Here

TOP

Related Classes of no.priv.garshol.duke.utils.CSVReader

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.