diff --git a/src/wrapper/java/org/kiwix/testing/test.java b/src/wrapper/java/org/kiwix/testing/test.java index 502d8c85d..cc0879fda 100644 --- a/src/wrapper/java/org/kiwix/testing/test.java +++ b/src/wrapper/java/org/kiwix/testing/test.java @@ -10,10 +10,10 @@ static { System.loadLibrary("kiwix"); } -private static String getCatalogContent() +private static String getFileContent(String path) throws IOException { - BufferedReader reader = new BufferedReader(new FileReader("catalog.xml")); + BufferedReader reader = new BufferedReader(new FileReader(path)); String line; StringBuilder sb = new StringBuilder(); while ((line = reader.readLine()) != null) @@ -25,12 +25,29 @@ throws IOException } @Test -public void testSome() +public void testReader() +throws JNIKiwixException, IOException +{ + JNIKiwixReader reader = new JNIKiwixReader("small.zim"); + assertEquals("Test ZIM file", reader.getTitle()); + assertEquals(45, reader.getFileSize()); // The file size is in KiB + assertEquals("A/main.html", reader.getMainPage()); + String s = getFileContent("small_zimfile_data/main.html"); + byte[] c = reader.getContent(new JNIKiwixString("A/main.html"), + new JNIKiwixString(), + new JNIKiwixString(), + new JNIKiwixInt()); + assertEquals(s, new String(c)); + +} + +@Test +public void testLibrary() throws IOException { Library lib = new Library(); Manager manager = new Manager(lib); - String content = getCatalogContent(); + String content = getFileContent("catalog.xml"); manager.readOpds(content, "http://localhost"); assertEquals(lib.getBookCount(true, true), 1); String[] bookIds = lib.getBooksIds();