Package no.priv.garshol.duke.utils

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


      int offset = parseOffset(query);
      if (pagesize == 0)
        // this means paging has been turned off completely
        assertTrue("paging not truly disabled", limit == -1 && offset == -1);

      SparqlResult result = new SparqlResult();
      for (String var : vars)
        result.addVariable(var);

      int end;
      if (limit == -1)
        end = rows.length;
      else
        end = Math.min(offset + limit, rows.length);
      if (offset == -1)
        offset = 0; // we start at zero even so
      for (int ix = offset; ix < end; ix++)
        result.addRow(rows[ix]);

      pages++;
     
      return result;
    }
View Full Code Here


        thisquery += (" limit " + pagesize + " offset " + (pageno * pagesize));

      if (logger != null)
        logger.debug("SPARQL query: " + thisquery);

      SparqlResult result = runQuery(endpoint, thisquery);
      variables = result.getVariables();
      page = result.getRows();

      if (triple_mode && !page.isEmpty() && page.get(0).length != 3)
        throw new DukeConfigException("In triple mode SPARQL queries must " +
                                      "produce exactly three columns!");

View Full Code Here

public class SparqlClientTest {

  @Test
  public void testEmpty() throws IOException {
    SparqlResult result = load("sparql-empty.xml");
    assertEquals(0, result.getRows().size());
    assertEquals(0, result.getVariables().size());
  }
View Full Code Here

    assertEquals(0, result.getVariables().size());
  }

  @Test
  public void testOneRow() throws IOException {
    SparqlResult result = load("sparql-onerow.xml");

    assertEquals(1, result.getVariables().size());
    assertEquals("x", result.getVariables().get(0));
   
    assertEquals(1, result.getRows().size());
    String[] row = result.getRows().get(0);
    assertEquals(1, row.length);
    assertEquals("1", row[0]);
  }
View Full Code Here

    assertEquals("1", row[0]);
  }

  @Test
  public void testOneRow2Col() throws IOException {
    SparqlResult result = load("sparql-onerow2col.xml");

    assertEquals(2, result.getVariables().size());
    assertEquals("x", result.getVariables().get(0));
    assertEquals("y", result.getVariables().get(1));
   
    assertEquals(1, result.getRows().size());
    String[] row = result.getRows().get(0);
    assertEquals(2, row.length);
    assertEquals("1", row[0]);
    assertEquals("http://example.org", row[1]);
  }
View Full Code Here

    assertEquals("http://example.org", row[1]);
  }

  @Test
  public void testTwoRow2Col() throws IOException {
    SparqlResult result = load("sparql-tworow2col.xml");

    assertEquals(2, result.getVariables().size());
    assertEquals("x", result.getVariables().get(0));
    assertEquals("y", result.getVariables().get(1));

    List<String[]> results = result.getRows();
    assertEquals(2, results.size());
    String[] row = results.get(0);
    assertEquals(2, row.length);
    assertEquals("1", row[0]);
    assertEquals("http://example.org", row[1]);
View Full Code Here

    assertEquals("http://example.com", row[1]);   
  }

  @Test
  public void testTwoRow2ColInconsistent() throws IOException {
    SparqlResult result = load("sparql-tworow2col-inconsistent.xml");

    assertEquals(2, result.getVariables().size());
    assertEquals("x", result.getVariables().get(0));
    assertEquals("y", result.getVariables().get(1));

    List<String[]> results = result.getRows();
    assertEquals(2, results.size());
    String[] row = results.get(0);
    assertEquals(2, row.length);
    assertEquals("1", row[0]);
    assertEquals("http://example.org", row[1]);
View Full Code Here

    assertEquals("http://example.com", row[1]);   
  }

  @Test
  public void testBnode() throws IOException {
    SparqlResult result = load("sparql-bnode.xml");
    assertEquals(1, result.getVariables().size());
    assertEquals("x", result.getVariables().get(0));
   
    assertEquals(1, result.getRows().size());
    String[] row = result.getRows().get(0);
    assertEquals(1, row.length);
    assertEquals("r2", row[0]);
}
View Full Code Here

TOP

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

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.