Package no.priv.garshol.duke

Examples of no.priv.garshol.duke.RecordIterator


public class InMemoryDataSourceTest {

  @Test
  public void testEmpty() {
    InMemoryDataSource src = new InMemoryDataSource();
    RecordIterator it = src.getRecords();
    assertFalse("empty data source contains records",
                it.hasNext());
  }
View Full Code Here


    records.add(TestUtils.makeRecord("ID", "1"));
    records.add(TestUtils.makeRecord("ID", "2"));
    records.add(TestUtils.makeRecord("ID", "3"));
   
    InMemoryDataSource src = new InMemoryDataSource(records);
    RecordIterator it = src.getRecords();

    assertTrue("record missing", it.hasNext());
    assertEquals("wrong record", it.next().getValue("ID"), "1");
    assertTrue("record missing", it.hasNext());
    assertEquals("wrong record", it.next().getValue("ID"), "2");
    assertTrue("record missing", it.hasNext());
    assertEquals("wrong record", it.next().getValue("ID"), "3");

    assertFalse("too many records",
                it.hasNext());
  }
View Full Code Here

 
  @Test
  public void testEmpty() {
    source.setVariables(new String[] {});
    source.setRows(new String[][] {});
    RecordIterator it = source.getRecords();
    assertFalse("empty data source contains records",
                it.hasNext());
    assertEquals("wrong number of pages", 1, source.getPages());
  }
View Full Code Here

  public void testTripleModeNoUri() {
    setupTripleConfig1("?url"); // NOTE: url, not uri
    source.setRows(new String[][] {{"http://a/1", "http://a/name", "1"}});
   
    try {
      RecordIterator it = source.getRecords();
      it.next();
      fail("No config exception, despite missing '?uri' column");
    } catch (DukeConfigException e) {
    }
  }
View Full Code Here

    source.setVariables(new String[] {"S", "P", "O", "C"});
    source.setRows(new String[][] {
        {"http://a/1", "http://a/name", "1", "blubb"}});

    try {
      RecordIterator it = source.getRecords();
      it.next();
      fail("Didn't catch four result columns in triple mode");
    } catch (DukeConfigException e) {
    }
  }
View Full Code Here

  @Test
  public void testSingleTriple() {
    setupTripleConfig1("?uri");
    source.setRows(new String[][] {{"http://a/1", "http://a/name", "1"}});
   
    RecordIterator it = source.getRecords();
    assertTrue("data source contains no records", it.hasNext());

    Record r = it.next();
    assertEquals("wrong ID", "http://a/1", r.getValue("ID"));
    assertEquals("wrong NAME", "1", r.getValue("NAME"));
    assertEquals("wrong AGE", null, r.getValue("AGE"));

    assertFalse("data source contains more than one record", it.hasNext());
    assertEquals("wrong number of pages", 2, source.getPages());
  }
View Full Code Here

    setupTripleConfig1("?uri");
    source.setRows(new String[][] {
        {"http://a/1", "http://a/name", "1"},
        {"http://a/1", "http://a/age", "32"}});
   
    RecordIterator it = source.getRecords();
    assertTrue("data source contains no records", it.hasNext());

    Record r = it.next();
    assertEquals("wrong ID", "http://a/1", r.getValue("ID"));
    assertEquals("wrong NAME", "1", r.getValue("NAME"));
    assertEquals("wrong AGE", "32", r.getValue("AGE"));

    assertFalse("data source contains more than one record", it.hasNext());
    assertEquals("wrong number of pages", 2, source.getPages());
  }
View Full Code Here

        {"http://a/1", "http://a/name", "1"},
        {"http://a/1", "http://a/age", "32"},
        {"http://a/2", "http://a/name", "2"},
        {"http://a/2", "http://a/age", "23"}});
   
    RecordIterator it = source.getRecords();
    assertTrue("data source contains no records", it.hasNext());

    Record r = it.next();
    assertEquals("wrong ID", "http://a/1", r.getValue("ID"));
    assertEquals("wrong NAME", "1", r.getValue("NAME"));
    assertEquals("wrong AGE", "32", r.getValue("AGE"));

    assertTrue("data source contains only one record", it.hasNext());

    r = it.next();
    assertEquals("wrong ID", "http://a/2", r.getValue("ID"));
    assertEquals("wrong NAME", "2", r.getValue("NAME"));
    assertEquals("wrong AGE", "23", r.getValue("AGE"));   
   
    assertFalse("data source contains more than two records", it.hasNext());
    assertEquals("wrong number of pages", 2, source.getPages());
  }
View Full Code Here

        {"http://a/1", "http://a/name", "one"},
        {"http://a/1", "http://a/age", "32"},
        {"http://a/2", "http://a/name", "2"},
        {"http://a/2", "http://a/age", "23"}});
   
    RecordIterator it = source.getRecords();
    assertTrue("data source contains no records", it.hasNext());

    Record r = it.next();
    assertEquals("wrong ID", "http://a/1", r.getValue("ID"));   
    assertEquals("wrong AGE", "32", r.getValue("AGE"));

    Collection<String> values = r.getValues("NAME");
    assertEquals("wrong number of NAMEs", 2, values.size());
    assertTrue("NAMEs doesn't contain '1'", values.contains("1"));
    assertTrue("NAMEs doesn't contain 'one'", values.contains("one"));

    assertTrue("data source contains only one record", it.hasNext());

    r = it.next();
    assertEquals("wrong ID", "http://a/2", r.getValue("ID"));
    assertEquals("wrong NAME", "2", r.getValue("NAME"));
    assertEquals("wrong AGE", "23", r.getValue("AGE"));   
   
    assertFalse("data source contains more than two records", it.hasNext());
    assertEquals("wrong number of pages", 2, source.getPages());
  }
View Full Code Here

        {"http://a/1", "http://a/name", "1"},
        {"http://a/1", "http://a/age", "32"},
        // next column is not configured. Duke should accept it even so
        {"http://a/1", "http://a/wtf", "whee"}});
   
    RecordIterator it = source.getRecords();
    assertTrue("data source contains no records", it.hasNext());

    Record r = it.next();
    assertEquals("wrong ID", "http://a/1", r.getValue("ID"));
    assertEquals("wrong NAME", "1", r.getValue("NAME"));
    assertEquals("wrong AGE", "32", r.getValue("AGE"));

    assertFalse("data source contains more than one record", it.hasNext());
    assertEquals("wrong number of pages", 2, source.getPages());
  }
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.