mirror of https://github.com/kiwix/libkiwix.git
Added testReader unit-test for the java wrapper
This commit is contained in:
parent
e40827fbac
commit
98d69ef59b
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue