@@ -47,7 +47,7 @@ private static String getTextFileContent(String path)
4747 }
4848
4949 private void testArchive (TestArchive archive )
50- throws IOException {
50+ throws IOException , EntryNotFoundException {
5151 // test the zim file main page title
5252 TestEntry mainPage = archive .getMainEntry ();
5353 assertTrue (mainPage .isRedirect ());
@@ -158,20 +158,24 @@ private void testArchive(TestArchive archive)
158158 // Test invalid path
159159 try {
160160 archive .getEntryByTitle ("Wrong title" );
161- } catch (Exception e ) {
161+ } catch (EntryNotFoundException e ) {
162162 assertEquals ("Cannot find entry" , e .getMessage ());
163+ } catch (Exception e ) {
164+ fail ("ERROR: Must be a EntryNotFoundException." );
163165 }
164166
165167 try {
166168 archive .getEntryByPath ("wrong_path.html" );
167- } catch (Exception e ) {
169+ } catch (EntryNotFoundException e ) {
168170 assertEquals ("Cannot find entry" , e .getMessage ());
171+ } catch (Exception e ) {
172+ fail ("ERROR: Must be a EntryNotFoundException." );
169173 }
170174 }
171175
172176 @ Test
173177 public void testArchiveDirect ()
174- throws JNIKiwixException , IOException , ZimFileFormatException {
178+ throws JNIKiwixException , IOException , ZimFileFormatException , EntryNotFoundException {
175179 TestArchive archive = new TestArchive ("small.zim" );
176180 testArchive (archive );
177181 assertTrue (archive .check ());
@@ -200,12 +204,14 @@ public void testNotValid() {
200204 fail ("ERROR: Archive created with invalid Zim file!" );
201205 } catch (ZimFileFormatException e ) {
202206 assertEquals ("Invalid magic number" , e .getMessage ());
207+ } catch (Exception e ) {
208+ fail ("ERROR: Must be a ZimFileFormatException." );
203209 }
204210 }
205211
206212 @ Test
207213 public void testArchiveByFd ()
208- throws JNIKiwixException , IOException , ZimFileFormatException {
214+ throws JNIKiwixException , IOException , ZimFileFormatException , EntryNotFoundException {
209215 FileInputStream fis = new FileInputStream ("small.zim" );
210216 TestArchive archive = new TestArchive (fis .getFD ());
211217 testArchive (archive );
@@ -216,7 +222,7 @@ public void testArchiveByFd()
216222
217223 @ Test
218224 public void testArchiveWithAnEmbeddedArchive ()
219- throws JNIKiwixException , IOException , ZimFileFormatException {
225+ throws JNIKiwixException , IOException , ZimFileFormatException , EntryNotFoundException {
220226 File plainArchive = new File ("small.zim" );
221227 FileInputStream fis = new FileInputStream ("small.zim.embedded" );
222228 TestArchive archive = new TestArchive (fis .getFD (), 8 , plainArchive .length ());
0 commit comments