LimitedSizeNativeStoreConnection extends NativeStoreConnection { public void setMaxCollectionsSize(int maxCollectionsSize) { this.maxCollectionsSize = maxCollectionsSize; } protected  LimitedSizeNativeStoreConnection(NativeStore nativeStore); int getMaxCollectionsSize(); void setMaxCollectionsSize(int maxCollectionsSize);  }
@Test public void testLimit() throws Exception { ((LimitedSizeNativeStoreConnection) ((SailRepositoryConnection) testCon).getSailConnection()) .setMaxCollectionsSize(2); testCon.begin(); ValueFactory vf = testCon.getValueFactory(); IRI context1 = vf.createIRI("http: IRI predicate = vf.createIRI("http: IRI object = vf.createIRI("http: for (int j = 0; j < 100; j++) { testCon.add(vf.createIRI("http: } testCon.commit(); String queryString = "SELECT DISTINCT ?s WHERE {?s ?p ?o}"; TupleQuery q = testCon.prepareTupleQuery(QueryLanguage.SPARQL, queryString); QueryEvaluationException shouldThrow = runQuery(q); assertNotNull(shouldThrow); queryString = "SELECT DISTINCT ?o WHERE {?s ?p ?o}"; q = testCon.prepareTupleQuery(QueryLanguage.SPARQL, queryString); shouldThrow = runQuery(q); assertNull(shouldThrow); }
@Test public void testOrderAndLimit() throws Exception { ((LimitedSizeNativeStoreConnection) ((SailRepositoryConnection) testCon).getSailConnection()) .setMaxCollectionsSize(2); testCon.begin(); ValueFactory vf = testCon.getValueFactory(); IRI context1 = vf.createIRI("http: IRI predicate = vf.createIRI("http: IRI object = vf.createIRI("http: for (int j = 0; j < 100; j++) { testCon.add(vf.createIRI("http: } testCon.commit(); String queryString = "SELECT DISTINCT ?s WHERE {?s ?p ?o} ORDER BY ?s"; TupleQuery q = testCon.prepareTupleQuery(QueryLanguage.SPARQL, queryString); QueryEvaluationException shouldThrow = runQuery(q); assertNotNull(shouldThrow); queryString = "SELECT DISTINCT ?s WHERE {?s ?p ?o} ORDER BY ?s LIMIT 2"; q = testCon.prepareTupleQuery(QueryLanguage.SPARQL, queryString); shouldThrow = runQuery(q); assertNull(shouldThrow); }