Skip to content

Commit 73039e4

Browse files
committed
Add a lot of test on libkiwix.
1 parent 09c0e01 commit 73039e4

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

lib/src/test/catalog.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
<author>
1313
<name>Kiwix</name>
1414
</author>
15+
<publisher>
16+
<name>Publisher</name>
17+
</publisher>
18+
<category>Super category</category>
1519
<link rel="http://opds-spec.org/acquisition/open-access" type="application/x-zim" href="http://localhost/small.zim" length="78982" />
1620
<link rel="http://opds-spec.org/image/thumbnail" type="image/png" href="/meta?name=favicon&amp;content=small" />
1721
</entry>

lib/src/test/test.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,36 @@ public void testLibrary()
209209
String[] bookIds = lib.getBooksIds();
210210
assertEquals(bookIds.length, 1);
211211
lib.filter(new Filter().local(true));
212+
assertTrue(Arrays.equals(lib.getBooksPublishers(), new String[]{"Publisher"}));
213+
assertTrue(Arrays.equals(lib.getBooksCreators(), new String[]{"Kiwix"}));
214+
assertTrue(Arrays.equals(lib.getBooksCategories(), new String[]{"Super category"}));
215+
assertTrue(Arrays.equals(lib.getBooksLanguages(), new String[]{"en"}));
216+
217+
218+
// getArchiveById needs books with valid path. Which is not possible by definition if library is initialized by opds stream.
219+
//assertEquals("86c91e51-55bf-8882-464e-072aca37a3e8", lib.getArchiveById("86c91e51-55bf-8882-464e-072aca37a3e8").getUuid());
212220

213221
TestBook book = lib.getBookById(bookIds[0]);
214222
assertEquals(book.getTitle(), "Test ZIM file");
215223
assertEquals(book.getTags(), "unit;test");
216224
assertEquals(book.getIllustration(48).width(), 48);
217225
assertEquals(book.getIllustration(48).url(), "http://localhost/meta?name=favicon&content=small");
218226
assertEquals(book.getUrl(), "http://localhost/small.zim");
227+
assertEquals(book.getPath(), "");
228+
assertEquals(book.getHumanReadableIdFromPath(), "");
229+
assertFalse(book.isPathValid());
230+
assertEquals(book.getDescription(), "This is a ZIM file used in libzim unit-tests");
231+
assertEquals(book.getCreator(), "Kiwix");
232+
assertEquals(book.getPublisher(), "Publisher");
233+
assertEquals(book.getFlavour(), "");
234+
assertEquals(book.getCategory(), "Super category");
235+
assertEquals(book.getArticleCount(), 0);
236+
assertEquals(book.getMediaCount(), 0);
237+
assertEquals(book.getSize(), 78982);
238+
Illustration[] illustrations = book.getIllustrations();
239+
assertEquals(1, illustrations.length);
240+
241+
assertEquals(book.getTagStr("video"), "");
219242

220243
// remove book from library by id
221244
lib.removeBookById(bookIds[0]);
@@ -233,7 +256,13 @@ public void testServer() throws ZimFileFormatException, JNIKiwixException {
233256
assertEquals(1, lib.getBookCount(true, true));
234257
TestServer server = new TestServer(lib);
235258
server.setPort(8080);
259+
server.setRoot("FOO");
260+
server.setAddress("127.0.0.1");
261+
server.setNbThreads(1);
262+
server.setBlockExternalLinks(true);
263+
server.setTaskbar(true, true);
236264
assertTrue(server.start());
265+
server.stop();
237266
}
238267

239268
@Test
@@ -261,6 +290,7 @@ public void testBookMark() throws ZimFileFormatException, JNIKiwixException {
261290
assertEquals(bookmark.getUrl(), book.getUrl());
262291
assertEquals(bookmark.getLanguage(), book.getLanguage());
263292
assertEquals(bookmark.getDate(), book.getDate());
293+
assertEquals(bookmark.getBookTitle(), book.getName());
264294
// remove bookmark from library
265295
lib.removeBookmark(bookmark.getBookId(), bookmark.getUrl());
266296
bookmarkArray = lib.getBookmarks(true);

0 commit comments

Comments
 (0)