Aklakan commented on code in PR #2925: URL: https://github.com/apache/jena/pull/2925#discussion_r1915207573
########## jena-arq/src/test/java/org/apache/jena/sparql/graph/GraphsTests.java: ########## @@ -106,56 +110,80 @@ protected void fillDataset(Dataset dataset) { m.isIsomorphicWith(calcUnion) ; } - @Test public void graph5() + @Test public void graph5() { Dataset ds = getDataset() ; int x = query(queryString, ds.getNamedModel(Quad.defaultGraphIRI.getURI())) ; assertEquals(1,x) ; } - @Test public void graph6() + @Test public void graph6() { Dataset ds = getDataset() ; int x = query(queryString, ds.getNamedModel(Quad.defaultGraphNodeGenerated.getURI())) ; assertEquals(1,x) ; } - @Test public void graph_count1() + /** Test that checks that {@link QueryExecBuilder#table()} correctly detaches the bindings such that they remain + * valid even after the query execution and the data set have been closed. */ + @Test public void table1() + { + // Use a transaction if the reference data set is in one. + Dataset ref = getDataset() ; + + Table expected = SSE.parseTable("(table (row (?s <x>) (?p <p>) (?o \"Default graph\") ) )") ; + Table actual ; + Dataset ds = createDataset() ; + try { + if (ref.isInTransaction()) { + Txn.executeWrite(ds, () -> fillDataset(ds)) ; + actual = Txn.calculateRead(ds, () -> QueryExec.dataset(ds.asDatasetGraph()).query(queryString).table()) ; + } else { + fillDataset(ds) ; + actual = QueryExec.dataset(ds.asDatasetGraph()).query(queryString).table() ; + } + } finally { + ds.close() ; + } + assertEquals(expected, actual) ; Review Comment: As mentioned, I view Table as a Collection and RowSet as an Iterator. If I am not mistaken, then table's `equals()` method naturally and succinctly performs an exact comparison (using term equality). For working with iterators (RowSet/ResultSet) one should of course use ResultSetCompare / RowSetOps methods. In this case, one could also write a bit more verbose: `assertTrue(ResultSetCompare.exactEquals(expected.toRowSet(), actual.toRowSet());` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: pr-unsubscr...@jena.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@jena.apache.org For additional commands, e-mail: pr-h...@jena.apache.org