Examples of BindingSet


Examples of org.openrdf.query.BindingSet

    try {
      assertNotNull(result);
      assertTrue(result.hasNext());

      while (result.hasNext()) {
        BindingSet solution = result.next();
        assertTrue(solution.hasBinding("name"));
        assertTrue(solution.hasBinding("mbox"));

        Value nameResult = solution.getValue("name");
        Value mboxResult = solution.getValue("mbox");

        assertEquals("unexpected value for name: " + nameResult, nameBob, nameResult);
        assertEquals("unexpected value for mbox: " + mboxResult, mboxBob, mboxResult);
      }
    }
View Full Code Here

Examples of org.openrdf.query.BindingSet

    try {
      assertNotNull(result);
      assertTrue(result.hasNext());

      while (result.hasNext()) {
        BindingSet solution = result.next();
        assertTrue(solution.hasBinding("name"));
        assertTrue(solution.hasBinding("mbox"));

        Value nameResult = solution.getValue("name");
        Value mboxResult = solution.getValue("mbox");

        assertEquals("unexpected value for name: " + nameResult, nameBob, nameResult);
        assertEquals("unexpected value for mbox: " + mboxResult, mboxBob, mboxResult);
      }
    }
View Full Code Here

Examples of org.openrdf.query.BindingSet

    try {
      assertNotNull(result);
      assertTrue(result.hasNext());

      while (result.hasNext()) {
        BindingSet solution = result.next();
        assertTrue(solution.hasBinding("person"));
        assertEquals(alexander, solution.getValue("person"));
      }
    }
    finally {
      result.close();
    }
View Full Code Here

Examples of org.openrdf.query.BindingSet

    Cursor<? extends BindingSet> iter;
    iter = con.evaluate(tupleQuery, EmptyBindingSet.getInstance(), false);

    try {
      BindingSet bindings = iter.next();
      assertEquals(subj, bindings.getValue("S"));
      assertEquals(pred, bindings.getValue("P"));
      assertEquals(obj, bindings.getValue("O"));
      assertNull(iter.next());
    }
    finally {
      iter.close();
    }
View Full Code Here

Examples of org.openrdf.query.BindingSet

    String qry = "PREFIX :<urn:test:> SELECT ?s ?v1 ?v2 WHERE " + optional;
    TupleQuery query = testCon.prepareTupleQuery(QueryLanguage.SPARQL, qry);
    TupleResult result = query.evaluate();
    Set<List<Value>> set = new HashSet<List<Value>>();
    while (result.hasNext()) {
      BindingSet bindings = result.next();
      set.add(Arrays.asList(bindings.getValue("v1"), bindings.getValue("v2")));
    }
    result.close();
    assertTrue(set.contains(Arrays.asList(v1, v2)));
    assertTrue(set.contains(Arrays.asList(v3, null)));
  }
View Full Code Here

Examples of org.openrdf.query.BindingSet

    Cursor<? extends BindingSet> iter;
    iter = con.evaluate(tupleQuery, EmptyBindingSet.getInstance(), false);

    con.begin();

    BindingSet bindings;
    while ((bindings = iter.next()) != null) {
      Value c = bindings.getValue("C");
      if (c instanceof Resource) {
        con.addStatement((Resource)c, RDF.TYPE, RDFS.CLASS);
      }
    }

    con.commit();

    // Simulate auto-commit

    assertEquals(3, countElements(con.getStatements(null, RDF.TYPE, RDFS.CLASS, false)));

    tupleQuery = QueryParserUtil.parseTupleQuery(QueryLanguage.SERQL, "SELECT P FROM {} P {}", null);
    iter = con.evaluate(tupleQuery, EmptyBindingSet.getInstance(), false);

    while ((bindings = iter.next()) != null) {
      Value p = bindings.getValue("P");
      if (p instanceof URI) {
        con.addStatement((URI)p, RDF.TYPE, RDF.PROPERTY);
      }
    }
View Full Code Here

Examples of org.openrdf.query.BindingSet

    String qry = "PREFIX :<urn:test:> SELECT ?p WHERE " + union;
    TupleQuery query = testCon.prepareTupleQuery(QueryLanguage.SPARQL, qry);
    TupleResult result = query.evaluate();
    List<Value> list = new ArrayList<Value>();
    while (result.hasNext()) {
      BindingSet bindings = result.next();
      list.add(bindings.getValue("p"));
    }
    result.close();
    assertTrue(list.contains(p1));
    assertTrue(list.contains(p2));
  }
View Full Code Here

Examples of org.openrdf.query.BindingSet

    BNode blankNode = null;

    TupleResult result = query.evaluate();
    while (result.hasNext()) {
      BindingSet set = result.next();
      blankNode = (BNode)set.getValue("s");
    }
    result.close();

    if (blankNode != null) {
      query = testCon.prepareTupleQuery(QueryLanguage.SPARQL, "select ?s where {?s ?p ?o}");
View Full Code Here

Examples of org.openrdf.query.BindingSet

  private int verifyQueryResult(Cursor<? extends BindingSet> resultIter, int expectedBindingCount)
    throws StoreException
  {
    int resultCount = 0;

    BindingSet resultBindings;
    while ((resultBindings = resultIter.next()) != null) {
      resultCount++;

      assertEquals("Wrong number of binding names for binding set", expectedBindingCount,
          resultBindings.getBindingNames().size());

      int bindingCount = 0;
      Iterator<Binding> bindingIter = resultBindings.iterator();
      while (bindingIter.hasNext()) {
        bindingIter.next();
        bindingCount++;
      }
View Full Code Here

Examples of org.openrdf.query.BindingSet

    TupleResult iter;
    iter = tupleQuery.evaluate();

    try {
      assertTrue(iter.hasNext());
      BindingSet bindings = iter.next();
      assertEquals(subj, bindings.getValue("S"));
      assertEquals(pred, bindings.getValue("P"));
      assertEquals(obj, bindings.getValue("O"));
      assertFalse(iter.hasNext());
    }
    finally {
      iter.close();
    }

    tupleQuery = testCon.prepareTupleQuery(QueryLanguage.SERQL, "SELECT S, P, O FROM {S} P {O} WHERE P = <"
        + pred.stringValue() + ">", null);
    tupleQuery.setBinding("S", subj);
    tupleQuery.setBinding("P", pred);
    tupleQuery.setBinding("O", obj);

    iter = tupleQuery.evaluate();

    try {
      assertTrue(iter.hasNext());
      BindingSet bindings = iter.next();
      assertEquals(subj, bindings.getValue("S"));
      assertEquals(pred, bindings.getValue("P"));
      assertEquals(obj, bindings.getValue("O"));
      assertFalse(iter.hasNext());
    }
    finally {
      iter.close();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.