Exemplo n.º 1
0
  @Test
  public void testSparql() {

    String queryStr = "select distinct ?Concept where {[] a ?Concept} LIMIT 10";
    Query query = QueryFactory.create(queryStr);

    // Remote execution.
    try (QueryExecution qexec =
        QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query)) {
      // Set the DBpedia specific timeout.
      ((QueryEngineHTTP) qexec).addParam("timeout", "10000");

      // Execute.
      ResultSet rs = qexec.execSelect();
      ResultSetFormatter.out(System.out, rs, query);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 2
0
 /** Run a single test of any sort, performing any appropriate logging and error reporting. */
 public void runTest(Resource test) {
   System.out.println("Running " + test);
   boolean success = false;
   boolean fail = false;
   try {
     success = doRunTest(test);
   } catch (Exception e) {
     fail = true;
     System.out.print("\nException: " + e);
     e.printStackTrace();
   }
   testCount++;
   if (success) {
     System.out.print((testCount % 40 == 0) ? ".\n" : ".");
     System.out.flush();
     passCount++;
   } else {
     System.out.println("\nFAIL: " + test);
   }
   Resource resultType = null;
   if (fail) {
     resultType = OWLResults.FailingRun;
   } else {
     if (test.hasProperty(RDF.type, OWLTest.NegativeEntailmentTest)
         || test.hasProperty(RDF.type, OWLTest.ConsistencyTest)) {
       resultType = success ? OWLResults.PassingRun : OWLResults.FailingRun;
     } else {
       resultType = success ? OWLResults.PassingRun : OWLResults.IncompleteRun;
     }
   }
   // log to the rdf result format
   Resource result =
       testResults
           .createResource()
           .addProperty(RDF.type, OWLResults.TestRun)
           .addProperty(RDF.type, resultType)
           .addProperty(OWLResults.test, test)
           .addProperty(OWLResults.system, jena2);
 }