Package no.priv.garshol.duke

Examples of no.priv.garshol.duke.RecordIterator


    Column c = new Column("F2", null, null, new LowerCaseNormalizeCleaner());
    c.setSplitOn(";");
    source.addColumn(c);
    source.addColumn(new Column("F3", null, null, null));

    RecordIterator it = read("F1,F2,F3\na, b ; d ; e ,c");

    Record r = it.next();
    assertEquals("a", r.getValue("F1"));
    assertEquals("c", r.getValue("F3"));

    Collection<String> values = r.getValues("F2");
    assertEquals(3, values.size());
View Full Code Here


  public void testNoValueForEmpty() throws IOException {
    source.addColumn(new Column("F1", null, null, null));
    source.addColumn(new Column("F2", null, null, null));
    source.addColumn(new Column("F3", null, null, null));

    RecordIterator it = read("F1,F2,F3\na,b,");

    Record r = it.next();
    assertEquals("a", r.getValue("F1"));
    assertEquals("b", r.getValue("F2"));
    assertEquals(r.getValue("F3"), null);
  }
View Full Code Here

    Column c = new Column("F2", null, null, null);
    c.setSplitOn(";");
    source.addColumn(c);
    source.addColumn(new Column("F3", null, null, null));

    RecordIterator it = read("F1,F2,F3\na,b;;e,c");

    Record r = it.next();
    assertEquals("a", r.getValue("F1"));
    assertEquals("c", r.getValue("F3"));

    Collection<String> values = r.getValues("F2");
    assertEquals(2, values.size());
View Full Code Here

  public void testSeparator() throws IOException {
    source.addColumn(new Column("F1", null, null, null));
    source.addColumn(new Column("F2", null, null, null));
    source.addColumn(new Column("F3", null, null, null));

    RecordIterator it = read("F1;F2;F3\na;b;c", ';');

    Record r = it.next();
    assertEquals("a", r.getValue("F1"));
    assertEquals("b", r.getValue("F2"));
    assertEquals("c", r.getValue("F3"));
  }
View Full Code Here

    source.addColumn(new Column("F1", null, null, null));
    source.addColumn(new Column("F2", null, null, null));
    source.addColumn(new Column("F3", null, null, null));

    try {
      RecordIterator it = read("", ';');
      fail("accepted file with no header");
    } catch (DukeException e) {
      // as wanted
    }
  }
View Full Code Here

    source.addColumn(new Column("F3", null, null, null));
  }

  @Test
  public void testEmpty() throws IOException {
    RecordIterator it = source.getRecordsFromString("");
    assertTrue(!it.hasNext());
  }
View Full Code Here

    assertEquals("c", r.getValue("F3"));
  }
 
  @Test
  public void multipleRecords() {
    RecordIterator it = source.getRecordsFromString("{\"F1\":\"a\",\"F2\" : \"b\", \"F3\" : \"c\"}{\"F1\":\"a2\",\"F2\" : \"b2\", \"F3\" : \"c2\"}");
    Record r1 = it.next();
    assertEquals("a", r1.getValue("F1"));
    assertEquals("b", r1.getValue("F2"));
    assertEquals("c", r1.getValue("F3"));
    Record r2 =  it.next();
    assertEquals("a2", r2.getValue("F1"));
    assertEquals("b2", r2.getValue("F2"));
    assertEquals("c2", r2.getValue("F3"));
  }
View Full Code Here

    source.setQuery("select * from testdata order by id");
  }

  @Test
  public void testEmpty() {
    RecordIterator it = source.getRecords();
    assertTrue(!it.hasNext());   
  }
View Full Code Here

    perform("insert into testdata values (1, 'foo')");

    source.addColumn(new Column("ID", null, null, null));
    source.addColumn(new Column("NAME", null, null, null));
       
    RecordIterator it = source.getRecords();
    assertTrue(it.hasNext());

    Record r = it.next();
    assertEquals("1", r.getValue("ID"));
    assertEquals("foo", r.getValue("NAME"));

    assertFalse(it.hasNext());
  }
View Full Code Here

  public void testOneRowSkipColumn() {
    perform("insert into testdata values (1, 'foo')");

    source.addColumn(new Column("ID", null, null, null));
       
    RecordIterator it = source.getRecords();
    assertTrue(it.hasNext());

    Record r = it.next();
    assertEquals("1", r.getValue("ID"));
    assertEquals(null, r.getValue("NAME"));

    assertFalse(it.hasNext());
  }
View Full Code Here

TOP

Related Classes of no.priv.garshol.duke.RecordIterator

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.