@@ -123,6 +123,14 @@ private void testArchive(TestArchive archive)
123123 assertEquals ("favicon.png" , iter .next ().getPath ());
124124 assertEquals ("main.html" , iter .next ().getPath ());
125125 assertFalse (iter .hasNext ());
126+ try {
127+ iter .next ();
128+ fail ("ERROR: next() should raise a NoSuchElementException." );
129+ } catch (NoSuchElementException e ) {
130+ // We are good
131+ } catch (Exception e ) {
132+ fail ("ERROR: Must be a NoSuchElementException." );
133+ }
126134 }
127135
128136 {
@@ -131,6 +139,14 @@ private void testArchive(TestArchive archive)
131139 assertEquals ("main.html" , iter .next ().getPath ());
132140 // No favicon, because favicon is not a main article (no title)
133141 assertFalse (iter .hasNext ());
142+ try {
143+ iter .next ();
144+ fail ("ERROR: next() should raise a NoSuchElementException." );
145+ } catch (NoSuchElementException e ) {
146+ // We are good
147+ } catch (Exception e ) {
148+ fail ("ERROR: Must be a NoSuchElementException." );
149+ }
134150 }
135151
136152 {
@@ -139,20 +155,44 @@ private void testArchive(TestArchive archive)
139155 assertEquals ("main.html" , iter .next ().getPath ());
140156 assertEquals ("favicon.png" , iter .next ().getPath ());
141157 assertFalse (iter .hasNext ());
158+ try {
159+ iter .next ();
160+ fail ("ERROR: next() should raise a NoSuchElementException." );
161+ } catch (NoSuchElementException e ) {
162+ // We are good
163+ } catch (Exception e ) {
164+ fail ("ERROR: Must be a NoSuchElementException." );
165+ }
142166 }
143167
144168 {
145169 TestEntryIterator iter = archive .findByPath ("ma" );
146170 assertTrue (iter .hasNext ());
147171 assertEquals ("main.html" , iter .next ().getPath ());
148172 assertFalse (iter .hasNext ());
173+ try {
174+ iter .next ();
175+ fail ("ERROR: next() should raise a NoSuchElementException." );
176+ } catch (NoSuchElementException e ) {
177+ // We are good
178+ } catch (Exception e ) {
179+ fail ("ERROR: Must be a NoSuchElementException." );
180+ }
149181 }
150182
151183 {
152184 TestEntryIterator iter = archive .findByTitle ("Test" );
153185 assertTrue (iter .hasNext ());
154186 assertEquals ("main.html" , iter .next ().getPath ());
155187 assertFalse (iter .hasNext ());
188+ try {
189+ iter .next ();
190+ fail ("ERROR: next() should raise a NoSuchElementException." );
191+ } catch (NoSuchElementException e ) {
192+ // We are good
193+ } catch (Exception e ) {
194+ fail ("ERROR: Must be a NoSuchElementException." );
195+ }
156196 }
157197
158198 // Test invalid path
@@ -210,7 +250,7 @@ public void testNotValid() {
210250 } catch (ZimFileFormatException e ) {
211251 assertEquals ("Invalid magic number" , e .getMessage ());
212252 } catch (Exception e ) {
213- fail ("ERROR: Must be a ZimFileFormatException." );
253+ fail ("ERROR: Must be a ZimFileFormatException." );
214254 }
215255 }
216256
@@ -459,6 +499,14 @@ public void testSearcher() throws Exception, ZimFileFormatException, JNIKiwixExc
459499 assertTrue (results .hasNext ());
460500 TestSuggestionItem suggestionItem = results .next ();
461501 assertFalse (results .hasNext ());
502+ try {
503+ results .next ();
504+ fail ("ERROR: next() should raise a NoSuchElementException." );
505+ } catch (NoSuchElementException e ) {
506+ // We are good
507+ } catch (Exception e ) {
508+ fail ("ERROR: Must be a NoSuchElementException." );
509+ }
462510 assertEquals ("Test ZIM file" , suggestionItem .getTitle ());
463511 assertEquals ("main.html" , suggestionItem .getPath ());
464512 assertTrue (suggestionItem .hasSnippet ());
0 commit comments