/** * Parse with expectation of failure. * * @param query * The query or update request. */ private void negativeTest(final String query) { try { parseOperation(query); fail("Negative test - should fail"); } catch (MalformedQueryException ex) { // Ignore expected exception. } }
/** * Use of an ungrouped variable in a project expression, where the variable * appears in a GROUP BY expression */ public void test_agg12() throws MalformedQueryException { final String query = "PREFIX : <http://www.example.org/>\n"+ "SELECT ?O1 (COUNT(?O2) AS ?C)\n"+ "WHERE { ?S :p ?O1; :q ?O2 } GROUP BY (?O1 + ?O2)"; negativeTest(query); }
/** PREFIX but otherwise empty UPDATE. */ public void test_syntax_update_30() throws MalformedQueryException { final String query = "PREFIX : <http://example/>\n# Otherwise empty\n"; parseOperation(query); }
/** BASE but otherwise empty UPDATE. */ public void test_syntax_update_39() throws MalformedQueryException { final String query = "BASE <http://example/>\n# Otherwise empty\n"; parseOperation(query); } /** PREFIX but otherwise empty UPDATE. */
/** Too many separators (in UPDATE request) */ public void test_syntax_update_bad_08() throws MalformedQueryException { final String query = "CREATE GRAPH <:g> ;; LOAD <:remote> into GRAPH <:g>"; negativeTest(query); }
/** * PrefixName with hex-encoded colon. */ public void test_qname_escape_02() throws MalformedQueryException { final String query = "PREFIX og: <http://ogp.me/ns#>\n" + "SELECT * WHERE { ?page og:audio%3Atitle ?title }"; parseOperation(query); }
/** * Parse with expectation of failure. * * @param query * The query or update request. */ private void negativeTest(final String query) { try { parseOperation(query); fail("Negative test - should fail"); } catch (MalformedQueryException ex) { // Ignore expected exception. } }
/** grouping by expression, done wrong */ public void test_agg08() throws MalformedQueryException { final String query = "PREFIX : <http://www.example.org/>\n" + "SELECT ((?O1 + ?O2) AS ?O12) (COUNT(?O1) AS ?C)\n" + "WHERE { ?S :p ?O1; :q ?O2 } GROUP BY (?O1 + ?O2)\n" + "ORDER BY ?O12"; negativeTest(query); }
/** * Positive test (originally failed because it was being passed to * parseQuery() rather than parseUpdate()). */ public void test_syntax_update_01() throws MalformedQueryException { final String query="BASE <http://example/base#>\n"+ "PREFIX : <http://example/>\n"+ "LOAD <http://example.org/faraway>"; parseOperation(query); }
/** * Use of an ungrouped variable in a project expression */ public void test_agg11() throws MalformedQueryException { final String query = "PREFIX : <http://www.example.org/>\n" + "SELECT ((?O1 + ?O2) AS ?O12) (COUNT(?O1) AS ?C)\n" + "WHERE { ?S :p ?O1; :q ?O2 } GROUP BY (?S)"; negativeTest(query); }
/** Empty UPDATE. */ public void test_syntax_update_38() throws MalformedQueryException { final String query = "# Empty\n"; parseOperation(query); }
/** BNode in DELETE WHERE */ public void test_syntax_update_bad_10() throws MalformedQueryException { final String query = "DELETE WHERE { _:a <:p> <:o> }"; negativeTest(query); }
/** * PrefixName with backslash-escaped colon (qname in select). */ public void test_qname_escape_01b() throws MalformedQueryException { if (!BigdataStatics.runKnownBadTests) { // FIXME See #1076 Negative parser tests return; } final String query = "PREFIX og: <http://ogp.me/ns#>\n" + "SELECT ( og:audio\\:title as ?x )" + "WHERE {?page og:foo ?title}"; parseOperation(query); }
/** * Projection of an ungrouped variable (not appearing in the GROUP BY * expression) */ public void test_agg09() throws MalformedQueryException { final String query = "PREFIX : <http://www.example.org/>\n" + "SELECT ?P (COUNT(?O) AS ?C)\n" + "WHERE { ?S ?P ?O } GROUP BY ?S"; negativeTest(query); }
/** * PrefixName with backslash-escaped colons. * <pre> * SELECT * WHERE { * ?page og:audio\:title ?title * } * </pre> * @throws MalformedQueryException * @see syntax-query/qname-escape-01.rq */ public void test_qname_escape_01() throws MalformedQueryException { if (!BigdataStatics.runKnownBadTests) { // FIXME See #1076 Negative parser tests return; } final String query = "PREFIX og: <http://ogp.me/ns#>\n" + " SELECT * WHERE {\n" + " ?page og:audio\\:title ?title\n" + "}"; parseOperation(query); }
/** * Same variable can not be projected more than once. */ public void test_syn_bad_03() throws MalformedQueryException { final String query = "SELECT (1 AS ?X) (1 AS ?X) {}"; negativeTest(query); }
/** BASE but otherwise empty UPDATE. */ public void test_syntax_update_39() throws MalformedQueryException { final String query = "BASE <http://example/>\n# Otherwise empty\n"; parseOperation(query); } /** PREFIX but otherwise empty UPDATE. */
/** * Variable in DELETE DATA's data. */ public void test_syntax_update_bad_03() throws MalformedQueryException { final String query = "DELETE DATA { ?s <:p> <:o> }"; negativeTest(query); }
/** * PrefixName with hex-encoded colon. */ public void test_qname_escape_02() throws MalformedQueryException { final String query = "PREFIX og: <http://ogp.me/ns#>\n" + "SELECT * WHERE { ?page og:audio%3Atitle ?title }"; parseOperation(query); }
/** Variable in INSERT DATA's data. */ public void test_syntax_update_bad_04() throws MalformedQueryException { final String query = "INSERT DATA { GRAPH ?g {<:s> <:p> <:o> } }"; negativeTest(query); }