@@ -69,28 +69,39 @@ public void givenExtractedThrownLimitErrorWhenFeedFreshDataThenReturnTokenStarti
69
69
public void givenExtractInvokedWithDifferentFramingAfterBufferFullErrorTWhenFeedFreshDataThenReturnTokenStartingFromEndOfOffendingToken () {
70
70
sut .extract ("aaaa" );
71
71
72
+ // it goes to 11 on a sizeLimit of 10, but doesn't trigger the exception till the next separator is reached
73
+ sut .extract ("aaaaaaa" ).forEach (s -> {});
74
+
75
+ Iterable <String > tokenIterable = sut .extract ("aa\n bbbb\n ccc" );
72
76
Exception thrownException = assertThrows (IllegalStateException .class , () -> {
73
- sut .extract ("aaaaaaa" ).forEach (s -> {});
77
+ // now when querying and the next delimiter is present, the error is raised
78
+ tokenIterable .forEach (s -> {});
74
79
});
75
80
assertThat (thrownException .getMessage (), containsString ("input buffer full" ));
76
81
77
- List <String > tokens = toList (sut .extract ("aa\n bbbb\n ccc" ));
82
+ // the iteration on token can proceed
83
+ List <String > tokens = toList (tokenIterable );
78
84
assertEquals (List .of ("bbbb" ), tokens );
79
85
}
80
86
81
87
@ Test
82
88
public void giveMultipleSegmentsThatGeneratesMultipleBufferFullErrorsThenIsAbleToRecoverTokenization () {
83
89
sut .extract ("aaaa" );
84
90
91
+ // it goes to 11 on a sizeLimit of 10, but doesn't trigger the exception till the next separator is reached
92
+ sut .extract ("aaaaaaa" ).forEach (s -> {});
93
+
94
+ Iterable <String > tokenIterable = sut .extract ("aa\n bbbbbbbbbbb\n cc" );
95
+
85
96
//first buffer full on 13 "a" letters
86
97
Exception thrownException = assertThrows (IllegalStateException .class , () -> {
87
- sut . extract ( "aaaaaaa" ) .forEach (s -> {});
98
+ tokenIterable .forEach (s -> {});
88
99
});
89
100
assertThat (thrownException .getMessage (), containsString ("input buffer full" ));
90
101
91
102
// second buffer full on 11 "b" letters
92
103
Exception secondThrownException = assertThrows (IllegalStateException .class , () -> {
93
- sut . extract ( "aa \n bbbbbbbbbbb \n cc" );
104
+ tokenIterable . forEach ( s -> {} );
94
105
});
95
106
assertThat (secondThrownException .getMessage (), containsString ("input buffer full" ));
96
107
0 commit comments