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());
|
assertFalse(archive.getRandomEntry().getTitle().isEmpty());
|
||||||
|
|
||||||
|
// Test different iterators
|
||||||
{
|
{
|
||||||
TestEntryIterator iter = archive.iterByPath();
|
TestEntryIterator iter = archive.iterByPath();
|
||||||
assertTrue(iter.hasNext());
|
assertTrue(iter.hasNext());
|
||||||
@ -153,6 +154,19 @@ public class test {
|
|||||||
assertEquals("main.html", iter.next().getPath());
|
assertEquals("main.html", iter.next().getPath());
|
||||||
assertFalse(iter.hasNext());
|
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
|
@Test
|
||||||
@ -163,9 +177,12 @@ public class test {
|
|||||||
assertTrue(archive.check());
|
assertTrue(archive.check());
|
||||||
assertEquals("small.zim", archive.getFilename());
|
assertEquals("small.zim", archive.getFilename());
|
||||||
archive.dispose();
|
archive.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
// test reader with invalid zim file
|
@Test
|
||||||
String zimFile = "test.zim";
|
public void testNonExistant() {
|
||||||
|
// test reader with non existant zim file
|
||||||
|
String zimFile = "non_existant.zim";
|
||||||
try {
|
try {
|
||||||
TestArchive archive1 = new TestArchive(zimFile);
|
TestArchive archive1 = new TestArchive(zimFile);
|
||||||
fail("ERROR: Archive created with invalid Zim file!");
|
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
|
@Test
|
||||||
public void testArchiveByFd()
|
public void testArchiveByFd()
|
||||||
throws JNIKiwixException, IOException, ZimFileFormatException {
|
throws JNIKiwixException, IOException, ZimFileFormatException {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user