Package no.priv.garshol.duke.datasources

Examples of no.priv.garshol.duke.datasources.Column


    assertEquals("c", r.getValue("F3"));
  }

  @Test
  public void testSingleRecordWithoutHeader() throws IOException {
    source.addColumn(new Column("1", "F1", null, null));
    source.addColumn(new Column("2", "F2", null, null));
    source.addColumn(new Column("3", "F3", null, null));
    source.setHeaderLine(false);

    RecordIterator it = read("a,b,c");

    Record r = it.next();
View Full Code Here


    assertEquals("c", r.getValue("F3"));
  }

  @Test
  public void testSingleRecordWithoutHeaderExtraColumn() throws IOException {
    source.addColumn(new Column("1", "F1", null, null));
    source.addColumn(new Column("2", "F2", null, null));
    source.addColumn(new Column("3", "F3", null, null));
    source.setHeaderLine(false);

    RecordIterator it = read("a,b,c,d");

    Record r = it.next();
View Full Code Here

    assertEquals("c", r.getValue("F3"));
  }

  @Test
  public void testSingleRecordWithoutHeaderSkipColumn() throws IOException {
    source.addColumn(new Column("1", "F1", null, null));
    source.addColumn(new Column("3", "F3", null, null));
    source.setHeaderLine(false);

    RecordIterator it = read("a,b,c");

    Record r = it.next();
View Full Code Here

    assertEquals("c", r.getValue("F3"));
  }

  @Test
  public void testColumnNotInHeader() 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));
    source.addColumn(new Column("F4", null, null, null));

    try {
      RecordIterator it = read("F1,F2,F3\na,b,c");
      Record r = it.next();
      fail("Didn't catch missing column F4");
View Full Code Here

    }
  }

  @Test
  public void testHeaderNotInConfig() 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));
    source.addColumn(new Column("F4", null, null, null));

    try {
      RecordIterator it = read("F5,F2,F3\na,b,c");
      Record r = it.next();
      fail("Didn't catch unknown column F5");
View Full Code Here

    }
  }

  @Test
  public void testSplitting() throws IOException {
    source.addColumn(new Column("F1", null, null, null));
    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;d;e,c");

    Record r = it.next();
    assertEquals("a", r.getValue("F1"));
View Full Code Here

    assertTrue(values.contains("e"));
  }

  @Test
  public void testSplittingCleaning() throws IOException {
    source.addColumn(new Column("F1", null, null, null));
    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"));
View Full Code Here

    assertTrue(values.contains("e"));
  }

  @Test
  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"));
View Full Code Here

    assertEquals(r.getValue("F3"), null);
  }

  @Test
  public void testNoValueForEmptySplit() throws IOException {
    source.addColumn(new Column("F1", null, null, null));
    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"));
View Full Code Here

    assertTrue(values.contains("e"));
  }

  @Test
  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"));
View Full Code Here

TOP

Related Classes of no.priv.garshol.duke.datasources.Column

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.