mirror of
https://github.com/kiwix/java-libkiwix.git
synced 2025-08-04 11:36:11 -04:00
Better testing of errors.
This commit is contained in:
parent
40dd4ea853
commit
827ab31c38
@ -116,6 +116,7 @@ public class test {
|
||||
|
||||
assertFalse(archive.getRandomEntry().getTitle().isEmpty());
|
||||
|
||||
// Test different iterators
|
||||
{
|
||||
TestEntryIterator iter = archive.iterByPath();
|
||||
assertTrue(iter.hasNext());
|
||||
@ -153,7 +154,20 @@ public class test {
|
||||
assertEquals("main.html", iter.next().getPath());
|
||||
assertFalse(iter.hasNext());
|
||||
}
|
||||
}
|
||||
|
||||
// Test invalid path
|
||||
try {
|
||||
archive.getEntryByTitle("Wrong title");
|
||||
} catch(Exception e) {
|
||||
assertEquals("Cannot find entry", e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
archive.getEntryByPath("wrong_path.html");
|
||||
} catch(Exception e) {
|
||||
assertEquals("Cannot find entry", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArchiveDirect()
|
||||
@ -163,9 +177,12 @@ public class test {
|
||||
assertTrue(archive.check());
|
||||
assertEquals("small.zim", archive.getFilename());
|
||||
archive.dispose();
|
||||
}
|
||||
|
||||
// test reader with invalid zim file
|
||||
String zimFile = "test.zim";
|
||||
@Test
|
||||
public void testNonExistant() {
|
||||
// test reader with non existant zim file
|
||||
String zimFile = "non_existant.zim";
|
||||
try {
|
||||
TestArchive archive1 = new TestArchive(zimFile);
|
||||
fail("ERROR: Archive created with invalid Zim file!");
|
||||
@ -174,6 +191,18 @@ public class test {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotValid() {
|
||||
// test reader with non existant zim file
|
||||
String zimFile = "test.java";
|
||||
try {
|
||||
TestArchive archive1 = new TestArchive(zimFile);
|
||||
fail("ERROR: Archive created with invalid Zim file!");
|
||||
} catch (ZimFileFormatException e) {
|
||||
assertEquals("Invalid magic number", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArchiveByFd()
|
||||
throws JNIKiwixException, IOException, ZimFileFormatException {
|
||||
|
Loading…
x
Reference in New Issue
Block a user