/** * Get everything matching an access path description. */ public void test_GET_accessPath_delete_all() throws Exception { doInsertbyURL("POST", packagePath + "test_delete_by_access_path.ttl"); final long result = countResults(doGetWithAccessPath(// // requestPath,// null,// s null,// p null )); assertEquals(7, result); }
/** * Delete everything matching an access path description. */ public void test_DELETE_accessPath_delete_all() throws Exception { doInsertbyURL("POST", packagePath + "test_delete_by_access_path.ttl"); final long mutationResult = doDeleteWithAccessPath(// // requestPath,// null,// s null,// p null ); assertEquals(7, mutationResult); }
public void test_INSERT_triples_with_BODY_and_defaultContext() throws Exception { if(TestMode.quads != getTestMode()) return; final String resource = packagePath + "insert_triples_with_defaultContext.ttl"; final Graph g = loadGraphFromResource(resource); // Load the resource into the KB. doInsertByBody("POST", RDFFormat.TURTLE, g, new URIImpl( "http://example.org")); // Verify that the data were inserted into the appropriate context. { final String queryStr = "select * { GRAPH <http://example.org> {?s ?p ?p} }"; final TupleQuery query = cxn.prepareTupleQuery(QueryLanguage.SPARQL, queryStr); assertEquals(7, countResults(query.evaluate())); } }
/** * Delete using an access path with the context position bound. */ public void test_DELETE_accessPath_delete_c_nothingMatched() throws Exception { if(TestMode.quads != getTestMode()) return; doInsertbyURL("POST", packagePath + "test_delete_by_access_path.trig"); final long mutationResult = doDeleteWithAccessPath(// // requestPath,// null,// s null,// p null,// o new URIImpl("http://xmlns.com/foaf/0.1/XXX") // c ); assertEquals(0, mutationResult); }
public void test_INSERT_triples_with_URI_and_defaultContext() throws Exception { if(TestMode.quads != getTestMode()) return; // Load the resource into the KB. { final File file = new File(packagePath + "insert_triples_with_defaultContext.ttl"); cxn.add(file, "", RDFFormat.TURTLE, new URIImpl("http://example.org")); assertEquals(7, getExactSize()); } // Verify that the data were inserted into the appropriate context. { final String queryStr = "select * { GRAPH <http://example.org> {?s ?p ?p} }"; final TupleQuery query = cxn.prepareTupleQuery(QueryLanguage.SPARQL, queryStr); assertEquals(7, countResults(query.evaluate())); } }
final Literal o = getVeryLargeLiteral(); final Statement stmt = new StatementImpl(s, p, o); g.add(stmt); assertEquals( 1L, doInsertByBody("POST", RDFFormat.RDFXML, g, null/* defaultContext */)); g2 = asGraph(query.evaluate()); assertEquals(1, g2.size()); assertTrue(g2.match(s, p, o).hasNext());
@Override protected void doInsertWithBodyTest(final String method, final int ntriples, /*final String servlet,*/ final RDFFormat format) throws Exception { final Graph g = genNTRIPLES2(ntriples); cxn.add(g); assertEquals(ntriples, getExactSize()); // Verify the expected #of statements in the store. { final String queryStr = "select * where {?s ?p ?o}"; final TupleQuery query = cxn.prepareTupleQuery(QueryLanguage.SPARQL, queryStr); assertEquals(ntriples, countResults(query.evaluate())); } }
/** * A GET query which should result in an error (the query is not well * formed). */ public void test_GET_SELECT_ERROR() throws Exception { final String queryStr = "select * where {?s ?p ?o} X {}"; final TupleQuery query = cxn.prepareTupleQuery(QueryLanguage.SPARQL, queryStr); try { assertEquals(0, countResults(query.evaluate())); fail("should be an error"); } catch (QueryEvaluationException ex) { // perfect } }
/** * Test the CONTEXTS method. */ public void test_CONTEXTS() throws Exception { if (getTestMode() != TestMode.quads) return; doInsertbyURL("POST", packagePath + "test_estcard.trig"); final RepositoryResult<Resource> contexts = cxn.getContextIDs(); int size = 0; while (contexts.hasNext()) { contexts.next(); size++; } assertEquals(3, size); }
/** * Test ability to load data from a URI. */ public void test_INSERT_LOAD_FROM_URI() throws Exception { // Verify nothing in the KB. { final String queryStr = "ASK where {?s ?p ?o}"; final BooleanQuery query = cxn.prepareBooleanQuery(QueryLanguage.SPARQL, queryStr); assertEquals(false, query.evaluate()); } // #of statements in that RDF file. final long expectedStatementCount = 4; // Load the resource into the KB. { cxn.add( this.getClass().getClassLoader().getResource("com/bigdata/rdf/rio/small.rdf"), "", RDFFormat.RDFXML); //cxn.add(new URL("file:bigdata-rdf/src/test/com/bigdata/rdf/rio/small.rdf"), "", RDFFormat.RDFXML); assertEquals(expectedStatementCount, getExactSize()); } /* * Verify KB has the loaded data. */ { final String queryStr = "SELECT * where {?s ?p ?o}"; final TupleQuery query = cxn.prepareTupleQuery(QueryLanguage.SPARQL, queryStr); assertEquals(expectedStatementCount, countResults(query.evaluate())); } }
/** * Basic test creates a read/write connection, issues begin(), and then * issues rollback() on the connection. */ public void test_tx_begin_rollback() throws RepositoryException { assertFalse(cxn.isActive()); cxn.begin(); assertTrue(cxn.isActive()); cxn.rollback(); assertFalse(cxn.isActive()); }
public void test_INSERT_withBody_TURTLE() throws Exception { doInsertWithBodyTest("POST", 23, RDFFormat.TURTLE); }
/** * Select everything in the kb using a GET. There will be no solutions * (assuming that we are using a told triple kb or quads kb w/o axioms). */ public void test_SELECT_ALL() throws Exception { final String queryStr = "select * where {?s ?p ?o}"; final TupleQuery query = cxn.prepareTupleQuery(QueryLanguage.SPARQL, queryStr); assertEquals(0, countResults(query.evaluate())); }
/** * "ASK" query with an empty KB. */ public void test_ASK() throws Exception { final String queryStr = "ASK where {?s ?p ?o}"; final BooleanQuery query = cxn.prepareBooleanQuery(QueryLanguage.SPARQL, queryStr); assertEquals(false, query.evaluate()); }
/** * Delete everything in a different named graph (context). */ public void test_DELETE_accessPath_delete_c1() throws Exception { if(TestMode.quads != getTestMode()) return; doInsertbyURL("POST", packagePath + "test_delete_by_access_path.trig"); final long mutationResult = doDeleteWithAccessPath(// // requestPath,// null,// s null,// p null,// o new URIImpl("http://www.bigdata.com/c1") // c ); assertEquals(2, mutationResult); }
throws Exception { if(TestMode.quads != getTestMode()) return; assertEquals(false, query.evaluate()); assertEquals(7, getExactSize()); assertEquals(expectedStatementCount, countResults(query.evaluate()));
final Literal o = getVeryLargeLiteral(); final Statement stmt = new StatementImpl(s, p, o); g.add(stmt); assertEquals( 1L, doInsertByBody("POST", RDFFormat.RDFXML, g, null/* defaultContext */)); g2 = asGraph(query.evaluate()); assertEquals(1, g2.size()); assertTrue(g2.match(s, p, o).hasNext());
@Override protected void doInsertWithBodyTest(final String method, final int ntriples, /*final String servlet,*/ final RDFFormat format) throws Exception { final Graph g = genNTRIPLES2(ntriples); cxn.add(g); assertEquals(ntriples, getExactSize()); // Verify the expected #of statements in the store. { final String queryStr = "select * where {?s ?p ?o}"; final TupleQuery query = cxn.prepareTupleQuery(QueryLanguage.SPARQL, queryStr); assertEquals(ntriples, countResults(query.evaluate())); } }
/** * A GET query which should result in an error (the query is not well * formed). */ public void test_GET_SELECT_ERROR() throws Exception { final String queryStr = "select * where {?s ?p ?o} X {}"; final TupleQuery query = cxn.prepareTupleQuery(QueryLanguage.SPARQL, queryStr); try { assertEquals(0, countResults(query.evaluate())); fail("should be an error"); } catch (QueryEvaluationException ex) { // perfect } }
/** * Test the CONTEXTS method. */ public void test_CONTEXTS() throws Exception { if (getTestMode() != TestMode.quads) return; doInsertbyURL("POST", packagePath + "test_estcard.trig"); final RepositoryResult<Resource> contexts = cxn.getContextIDs(); int size = 0; while (contexts.hasNext()) { contexts.next(); size++; } assertEquals(3, size); }