Package org.openrdf.result

Examples of org.openrdf.result.TupleResult


  }

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

    try {
      if (result.hasNext()) {
        fail("Query result should be empty");
      }
    }
    finally {
      result.close();
    }
  }
View Full Code Here


  public void testValueExceptionLessThan()
    throws Exception
  {
    TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryStr1);
    TupleResult evaluate = query.evaluate();
    try {
      assertFalse(evaluate.hasNext());
    }
    finally {
      evaluate.close();
    }
  }
View Full Code Here

  public void testValueExceptionEqual()
    throws Exception
  {
    TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryStr2);
    TupleResult evaluate = query.evaluate();
    try {
      assertFalse(evaluate.hasNext());
    }
    finally {
      evaluate.close();
    }
  }
View Full Code Here

  private void assertResult(String queryStr, List<String> names)
    throws StoreException, MalformedQueryException, EvaluationException
  {
    TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryStr);
    TupleResult result = query.evaluate();
    for (String name : names) {
      Value value = result.next().getValue("name");
      assertEquals(name, ((Literal)value).getLabel());
    }
    assertFalse(result.hasNext());
    result.close();
  }
View Full Code Here

  private boolean evaluateSparql(String qry)
    throws StoreException, MalformedQueryException, EvaluationException
  {
    TupleQuery query = con.prepareTupleQuery(QueryLanguage.SPARQL, qry);
    TupleResult evaluate = query.evaluate();
    try {
      return evaluate.hasNext();
    }
    finally {
      evaluate.close();
    }
  }
View Full Code Here

        + "        mf:action {query}; " + "        mf:result {result} " + "USING NAMESPACE "
        + "  mf = <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#>, "
        + "  mfx = <http://www.openrdf.org/test-manifest-extensions#>, "
        + "  qt = <http://www.w3.org/2001/sw/DataAccess/tests/test-query#>";

    TupleResult tests = con.prepareTupleQuery(QueryLanguage.SERQL, query).evaluate();
    while (tests.hasNext()) {
      BindingSet testBindings = tests.next();
      String testName = testBindings.getValue("testName").toString();
      String queryFile = testBindings.getValue("query").toString();
      Value result = testBindings.getValue("result");
      if (MFX_CORRECT.equals(result)) {
        positiveTests.addTest(factory.createTest(testName, queryFile, result));
      }
      else if (MFX_PARSE_ERROR.equals(result)) {
        negativeTests.addTest(factory.createTest(testName, queryFile, result));
      }
      else {
        logger.warn("Unexpected result value for test \"" + testName + "\": " + result);
      }
    }

    tests.close();
    con.close();
    manifestRep.shutDown();

    suite.addTest(positiveTests);
    suite.addTest(negativeTests);
View Full Code Here

    queryBuilder.append(" SELECT name, mbox");
    queryBuilder.append(" FROM {} foaf:name {name};");
    queryBuilder.append("         foaf:mbox {mbox}");
    queryBuilder.append(" USING NAMESPACE foaf = <" + FOAF_NS + ">");

    TupleResult result = testCon.prepareTupleQuery(QueryLanguage.SERQL, queryBuilder.toString()).evaluate();

    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");

        assertTrue((nameAlice.equals(nameResult) || nameBob.equals(nameResult)));
        assertTrue((mboxAlice.equals(mboxResult) || mboxBob.equals(mboxResult)));
      }
    }
    finally {
      result.close();
    }
  }
View Full Code Here

    StringBuilder queryBuilder = new StringBuilder();
    queryBuilder.append(" SELECT person");
    queryBuilder.append(" FROM {person} foaf:name {").append(Александър.getLabel()).append("}");
    queryBuilder.append(" USING NAMESPACE foaf = <" + FOAF_NS + ">");

    TupleResult result = testCon.prepareTupleQuery(QueryLanguage.SERQL, queryBuilder.toString()).evaluate();

    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

    queryBuilder.append(" USING NAMESPACE foaf = <" + FOAF_NS + ">");

    TupleQuery query = testCon.prepareTupleQuery(QueryLanguage.SERQL, queryBuilder.toString());
    query.setBinding("name", nameBob);

    TupleResult result = query.evaluate();

    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);
      }
    }
    finally {
      result.close();
    }
  }
View Full Code Here

    Query query = testCon.prepareQuery(QueryLanguage.SERQL, queryBuilder.toString());
    assertTrue(query instanceof TupleQuery);
    query.setBinding("name", nameBob);

    TupleResult result = ((TupleQuery)query).evaluate();

    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);
      }
    }
    finally {
      result.close();
    }
  }
View Full Code Here

TOP

Related Classes of org.openrdf.result.TupleResult

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.