Examples of TupleResult


Examples of org.openrdf.result.TupleResult

  {
    String queryString = readQueryString();
    Query query = prepareQuery(queryString);

    if (query instanceof TupleQuery) {
      TupleResult queryResult = ((TupleQuery)query).evaluate();

      TupleResult expectedResult = readExpectedTupleQueryResult();
      compareTupleQueryResults(queryResult, expectedResult);

      // Graph queryGraph = RepositoryUtil.asGraph(queryResult);
      // Graph expectedGraph = readExpectedTupleQueryResult();
      // compareGraphs(queryGraph, expectedGraph);
View Full Code Here

Examples of org.openrdf.result.TupleResult

    query.append(" FROM {testURI} mf:resultCardinality {mf:LaxCardinality}");
    query.append(" USING NAMESPACE mf = <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>");
    TupleQuery laxCardinalityQuery = con.prepareTupleQuery(QueryLanguage.SERQL, query.toString());

    logger.debug("evaluating query..");
    TupleResult testCases = testCaseQuery.evaluate();
    while (testCases.hasNext()) {
      BindingSet bindingSet = testCases.next();

      URI testURI = (URI)bindingSet.getValue("testURI");
      String testName = bindingSet.getValue("testName").toString();
      String resultFile = bindingSet.getValue("resultFile").toString();
      String queryFile = bindingSet.getValue("queryFile").toString();
      URI defaultGraphURI = (URI)bindingSet.getValue("defaultGraph");
      Value action = bindingSet.getValue("action");

      logger.debug("found test case : {}", testName);

      // Query named graphs
      namedGraphsQuery.setBinding("action", action);
      TupleResult namedGraphs = namedGraphsQuery.evaluate();

      DatasetImpl dataset = null;

      if (defaultGraphURI != null || namedGraphs.hasNext()) {
        dataset = new DatasetImpl();

        if (defaultGraphURI != null) {
          dataset.addDefaultGraph(defaultGraphURI);
        }

        while (namedGraphs.hasNext()) {
          BindingSet graphBindings = namedGraphs.next();
          URI namedGraphURI = (URI)graphBindings.getValue("graph");
          dataset.addNamedGraph(namedGraphURI);
        }
      }

      // Check for lax-cardinality conditions
      boolean laxCardinality = false;
      laxCardinalityQuery.setBinding("testURI", testURI);
      TupleResult laxCardinalityResult = laxCardinalityQuery.evaluate();
      try {
        laxCardinality = laxCardinalityResult.hasNext();
      }
      finally {
        laxCardinalityResult.close();
      }

      SPARQLQueryTest test = factory.createSPARQLQueryTest(testURI.toString(), testName, queryFile,
          resultFile, dataset, laxCardinality);
      if (test != null) {
View Full Code Here

Examples of org.openrdf.result.TupleResult

  {
    // Try to extract suite name from manifest file
    TupleQuery manifestNameQuery = con.prepareTupleQuery(QueryLanguage.SERQL,
        "SELECT ManifestName FROM {ManifestURL} rdfs:label {ManifestName}");
    manifestNameQuery.setBinding("ManifestURL", con.getValueFactory().createURI(manifestFileURL));
    TupleResult manifestNames = manifestNameQuery.evaluate();
    try {
      if (manifestNames.hasNext()) {
        return manifestNames.next().getValue("ManifestName").stringValue();
      }
    }
    finally {
      manifestNames.close();
    }

    // Derive name from manifest URL
    int lastSlashIdx = manifestFileURL.lastIndexOf('/');
    int secLastSlashIdx = manifestFileURL.lastIndexOf('/', lastSlashIdx - 1);
View Full Code Here

Examples of org.openrdf.result.TupleResult

  public void testInline()
    throws Exception
  {
    TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryInline);
    TupleResult result = query.evaluate();
    assertEquals(hunt, result.next().getValue("name"));
    assertFalse(result.hasNext());
    result.close();
  }
View Full Code Here

Examples of org.openrdf.result.TupleResult

  public void testBinding()
    throws Exception
  {
    TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryBinding);
    query.setBinding("pattern", vf.createLiteral("@work.example"));
    TupleResult result = query.evaluate();
    assertEquals(hunt, result.next().getValue("name"));
    assertFalse(result.hasNext());
    result.close();
  }
View Full Code Here

Examples of org.openrdf.result.TupleResult

        + "        mf:action {} qt:query {query}; " + "                     qt:data {input} "
        + "USING NAMESPACE " + "  mf = <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>, "
        + "  qt = <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>, "
        + "  tck = <urn:openrdf.org:sesame:tests#> ";

    TupleResult tests = con.prepareTupleQuery(QueryLanguage.SERQL, query).evaluate();
    while (tests.hasNext()) {
      BindingSet testBindings = tests.next();
      String testName = ((Literal)testBindings.getValue("testName")).getLabel();
      String inputFile = testBindings.getValue("input").toString();
      String queryFile = testBindings.getValue("query").toString();
      String resultFile = testBindings.getValue("result").toString();
      String entailment = ((Literal)testBindings.getValue("entailment")).getLabel();

      query = "SELECT graph " + "FROM {} mf:name {testName}; "
          + "        mf:action {} qt:graphData {graph} " + "WHERE testName = \""
          + SeRQLUtil.encodeString(testName) + "\" " + "USING NAMESPACE"
          + "  mf = <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>,"
          + "  qt = <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>";

      List<String> graphNames = new ArrayList<String>();

      TupleResult graphs = con.prepareTupleQuery(QueryLanguage.SERQL, query).evaluate();
      while (graphs.hasNext()) {
        BindingSet graphBindings = graphs.next();
        graphNames.add(graphBindings.getValue("graph").toString());
      }
      graphs.close();

      if (testName.startsWith("test-029:")) {
        logger.error("test-029 SKIPPED in {}", SeRQLQueryTestCase.class.getName());
        continue;
      }
View Full Code Here

Examples of org.openrdf.result.TupleResult

    throws Exception
  {
    TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryBindingFlags);
    query.setBinding("pattern", vf.createLiteral("@Work.example"));
    query.setBinding("flags", vf.createLiteral("i"));
    TupleResult result = query.evaluate();
    assertEquals(hunt, result.next().getValue("name"));
    assertFalse(result.hasNext());
    result.close();
  }
View Full Code Here

Examples of org.openrdf.result.TupleResult

    URI flags = vf.createURI("http://example.org/ns#", "flags");
    BNode bnode = vf.createBNode();
    conn.add(bnode, pattern, vf.createLiteral("@Work.example"));
    conn.add(bnode, flags, vf.createLiteral("i"));
    TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryExpr);
    TupleResult result = query.evaluate();
    assertEquals(hunt, result.next().getValue("name"));
    assertFalse(result.hasNext());
    result.close();
  }
View Full Code Here

Examples of org.openrdf.result.TupleResult

  }

  public void testGetBindingNames()
    throws Exception
  {
    TupleResult result = con.prepareTupleQuery(QueryLanguage.SERQL, multipleResultQuery).evaluate();
    try {
      List<String> headers = result.getBindingNames();

      if (!headers.get(0).equals("P")) {
        fail("first header element should be 'P' but is '" + headers.get(0) + "'");
      }
      if (!headers.get(1).equals("D")) {
        fail("second header element should be 'D' but is '" + headers.get(1) + "'");
      }
    }
    finally {
      result.close();
    }
  }
View Full Code Here

Examples of org.openrdf.result.TupleResult

  */

  public void testIterator()
    throws Exception
  {
    TupleResult result = con.prepareTupleQuery(QueryLanguage.SERQL, multipleResultQuery).evaluate();

    try {
      int count = 0;
      while (result.hasNext()) {
        result.next();
        count++;
      }

      if (count <= 1) {
        fail("query should have multiple results.");
      }
    }
    finally {
      result.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.