@@ -834,25 +834,33 @@ void queryWithMaxWarningCount(ArangoDatabase db) {
834
834
@ ParameterizedTest (name = "{index}" )
835
835
@ MethodSource ("dbs" )
836
836
void queryCursor (ArangoDatabase db ) {
837
- final int numbDocs = 10 ;
838
- for (int i = 0 ; i < numbDocs ; i ++) {
839
- db .collection (CNAME1 ).insertDocument (new BaseDocument (), null );
840
- }
841
-
842
- final int batchSize = 5 ;
843
- final ArangoCursor <String > cursor = db .query ("for i in " + CNAME1 + " return i._id" , String .class ,
844
- new AqlQueryOptions ().batchSize (batchSize ).count (true ));
845
- assertThat ((Object ) cursor ).isNotNull ();
846
- assertThat (cursor .getCount ()).isGreaterThanOrEqualTo (numbDocs );
847
-
848
- final ArangoCursor <String > cursor2 = db .cursor (cursor .getId (), String .class );
849
- assertThat ((Object ) cursor2 ).isNotNull ();
850
- assertThat (cursor2 .getCount ()).isGreaterThanOrEqualTo (numbDocs );
851
- assertThat ((Iterator <?>) cursor2 ).hasNext ();
837
+ ArangoCursor <Integer > cursor = db .query ("for i in 1..4 return i" , Integer .class ,
838
+ new AqlQueryOptions ().batchSize (1 ));
839
+ List <Integer > result = new ArrayList <>();
840
+ result .add (cursor .next ());
841
+ result .add (cursor .next ());
842
+ ArangoCursor <Integer > cursor2 = db .cursor (cursor .getId (), Integer .class );
843
+ result .add (cursor2 .next ());
844
+ result .add (cursor2 .next ());
845
+ assertThat (cursor2 .hasNext ()).isFalse ();
846
+ assertThat (result ).containsExactly (1 , 2 , 3 , 4 );
847
+ }
852
848
853
- for (int i = 0 ; i < batchSize ; i ++, cursor .next ()) {
854
- assertThat ((Iterator <?>) cursor ).hasNext ();
855
- }
849
+ @ ParameterizedTest (name = "{index}" )
850
+ @ MethodSource ("dbs" )
851
+ void queryCursorRetry (ArangoDatabase db ) throws IOException {
852
+ assumeTrue (isAtLeastVersion (3 , 11 ));
853
+ ArangoCursor <Integer > cursor = db .query ("for i in 1..4 return i" , Integer .class ,
854
+ new AqlQueryOptions ().batchSize (1 ).allowRetry (true ));
855
+ List <Integer > result = new ArrayList <>();
856
+ result .add (cursor .next ());
857
+ result .add (cursor .next ());
858
+ ArangoCursor <Integer > cursor2 = db .cursor (cursor .getId (), Integer .class , cursor .getNextBatchId ());
859
+ result .add (cursor2 .next ());
860
+ result .add (cursor2 .next ());
861
+ cursor2 .close ();
862
+ assertThat (cursor2 .hasNext ()).isFalse ();
863
+ assertThat (result ).containsExactly (1 , 2 , 3 , 4 );
856
864
}
857
865
858
866
@ ParameterizedTest (name = "{index}" )
0 commit comments