Beispiel #1
0
  private Dataset setUpDataset(Query query, TestItem testItem) {
    try {
      // testItem.requiresTextIndex()

      if (doesQueryHaveDataset(query) && doesTestItemHaveDataset(testItem)) {
        // Only warn if there are results to test
        // Syntax tests may have FROM etc and a manifest data file.
        if (testItem.getResultFile() != null)
          Log.warn(this, testItem.getName() + " : query data source and also in test file");
      }

      // In test file?
      if (doesTestItemHaveDataset(testItem))
        // Not specified in the query - get from test item and load
        return createDataset(testItem.getDefaultGraphURIs(), testItem.getNamedGraphURIs());

      // Check 3 - were there any at all?

      if (!doesQueryHaveDataset(query)) fail("No dataset");

      // Left to query
      return null;

    } catch (JenaException jEx) {
      fail("JenaException creating data source: " + jEx.getMessage());
      return null;
    }
  }
  // All throwable handling.
  private static void perform(Query query, String string, Action action) {
    Reader in = new StringReader(string);
    ARQParser parser = new ARQParser(in);

    try {
      query.setStrict(true);
      parser.setQuery(query);
      action.exec(parser);
    } catch (com.hp.hpl.jena.sparql.lang.arq.ParseException ex) {
      throw new QueryParseException(
          ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginColumn);
    } catch (com.hp.hpl.jena.sparql.lang.arq.TokenMgrError tErr) {
      // Last valid token : not the same as token error message - but this should not happen
      int col = parser.token.endColumn;
      int line = parser.token.endLine;
      throw new QueryParseException(tErr.getMessage(), line, col);
    } catch (QueryException ex) {
      throw ex;
    } catch (JenaException ex) {
      throw new QueryException(ex.getMessage(), ex);
    } catch (Error err) {
      // The token stream can throw errors.
      throw new QueryParseException(err.getMessage(), err, -1, -1);
    } catch (Throwable th) {
      Log.warn(ParserSPARQL11.class, "Unexpected throwable: ", th);
      throw new QueryException(th.getMessage(), th);
    }
  }
 public void testConnectionDescriptionFailsOnMissingType() {
   ConnectionDescription c = new ConnectionDescription("eh:/subject", "URL", null, null, null);
   try {
     c.getConnection();
     fail("should trap null type");
   } catch (JenaException e) {
     assertTrue(
         e.getMessage().endsWith("cannot be opened because no dbURL or dbType was specified"));
   }
 }