Пример #1
0
 @Test
 public void testAssemblerWorks() {
   Object result = AssemblerUtils.build("basic.ttl", SDBConnect.TYPE);
   assertNotNull("We have created an object", result);
   assertEquals("Made object superficially of right type", DatasetImpl.class, result.getClass());
   assertEquals(
       "Made object of right type",
       ReconnectingDatasetGraph.class,
       ((Dataset) result).asDatasetGraph().getClass());
 }
Пример #2
0
 @Test
 public void testQueryWorks() {
   ReconnectingDatasetGraph toQuery =
       (ReconnectingDatasetGraph)
           ((Dataset) AssemblerUtils.build("basic.ttl", SDBConnect.TYPE)).asDatasetGraph();
   toQuery.getDatasetGraph().getStore().getTableFormatter().format();
   Dataset ds = DatasetImpl.wrap(toQuery);
   // Dataset ds = new DatasetImpl(toQuery);
   QueryExecution qe = QueryExecutionFactory.create("ASK { ?s ?p ?o }", ds);
   assertTrue("Querying works", !qe.execAsk());
 }
Пример #3
0
  @Test
  public void testUpdateWorks() {
    ReconnectingDatasetGraph toQuery =
        (ReconnectingDatasetGraph)
            ((Dataset) AssemblerUtils.build("basic.ttl", SDBConnect.TYPE)).asDatasetGraph();
    toQuery.getDatasetGraph().getStore().getTableFormatter().format();
    UpdateRequest ur =
        UpdateFactory.create("insert data { <http://example.com/> <http://example.com/prop> 1 }");
    UpdateProcessor u = UpdateExecutionFactory.create(ur, toQuery);
    u.execute();

    assertTrue("Update works", !toQuery.getDatasetGraph().isEmpty());
  }
Пример #4
0
  @Test
  public void testFullQueryWorks() {
    ReconnectingDatasetGraph toQuery =
        (ReconnectingDatasetGraph)
            ((Dataset) AssemblerUtils.build("basic.ttl", SDBConnect.TYPE)).asDatasetGraph();
    toQuery.getDatasetGraph().getStore().getTableFormatter().format();
    Dataset ds = DatasetImpl.wrap(toQuery);
    // Dataset ds = new DatasetImpl(toQuery);
    QueryExecution qe = QueryExecutionFactory.create("SELECT * { ?s ?p ?o }", ds);
    ResultSet r = qe.execSelect();
    assertTrue("Querying works", !r.hasNext());
    qe.close();

    qe = QueryExecutionFactory.create("SELECT * { graph ?g { ?s ?p ?o } }", ds);
    r = qe.execSelect();
    assertTrue("Querying with named graphs works", !r.hasNext());
    qe.close();
  }
Пример #5
0
  @Test
  public void testUnionWorks() {
    Dataset ds = (Dataset) AssemblerUtils.build("union.ttl", SDBConnect.TYPE);
    ReconnectingDatasetGraph toQuery = (ReconnectingDatasetGraph) ds.asDatasetGraph();
    toQuery.getDatasetGraph().getStore().getTableFormatter().format();
    UpdateRequest ur =
        UpdateFactory.create(
            "insert data {"
                + "graph <http://example.com/a> { <http://example.com/1> <http://example.com/prop> 1 }"
                + "graph <http://example.com/b> { <http://example.com/2> <http://example.com/prop> 2 }"
                + "}");
    UpdateProcessor u = UpdateExecutionFactory.create(ur, toQuery);
    u.execute();

    QueryExecution qe = QueryExecutionFactory.create("SELECT * { ?s ?p ?o }", ds);
    ResultSetRewindable r = ResultSetFactory.makeRewindable(qe.execSelect());

    assertEquals("We have a union!", 2, r.size());
  }