mirror of
https://github.com/kiwix/java-libkiwix.git
synced 2025-09-09 15:19:32 -04:00
Try to trigger gc to call finalize
methods.
This commit is contained in:
parent
33152da9b4
commit
ab7bbc1043
@ -171,16 +171,21 @@ public class test {
|
||||
} catch(Exception e) {
|
||||
fail("ERROR: Must be a EntryNotFoundException.");
|
||||
}
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArchiveDirect()
|
||||
throws JNIKiwixException, IOException, ZimFileFormatException, EntryNotFoundException {
|
||||
{
|
||||
TestArchive archive = new TestArchive("small.zim");
|
||||
testArchive(archive);
|
||||
assertTrue(archive.check());
|
||||
assertEquals("small.zim", archive.getFilename());
|
||||
archive.dispose();
|
||||
}
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -212,17 +217,21 @@ public class test {
|
||||
@Test
|
||||
public void testArchiveByFd()
|
||||
throws JNIKiwixException, IOException, ZimFileFormatException, EntryNotFoundException {
|
||||
{
|
||||
FileInputStream fis = new FileInputStream("small.zim");
|
||||
TestArchive archive = new TestArchive(fis.getFD());
|
||||
testArchive(archive);
|
||||
assertTrue(archive.check());
|
||||
assertEquals("", archive.getFilename());
|
||||
archive.dispose();
|
||||
}
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArchiveWithAnEmbeddedArchive()
|
||||
throws JNIKiwixException, IOException, ZimFileFormatException, EntryNotFoundException {
|
||||
{
|
||||
File plainArchive = new File("small.zim");
|
||||
FileInputStream fis = new FileInputStream("small.zim.embedded");
|
||||
TestArchive archive = new TestArchive(fis.getFD(), 8, plainArchive.length());
|
||||
@ -230,7 +239,9 @@ public class test {
|
||||
//assertTrue(archive.check());
|
||||
testArchive(archive);
|
||||
assertEquals("", archive.getFilename());
|
||||
archive.dispose();
|
||||
}
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
}
|
||||
|
||||
private void testLibrary(TestLibrary lib)
|
||||
@ -270,6 +281,7 @@ public class test {
|
||||
|
||||
@Test
|
||||
public void testLibrarySimple() throws IOException {
|
||||
{
|
||||
TestLibrary lib = new TestLibrary();
|
||||
TestManager manager = new TestManager(lib);
|
||||
manager.addBookFromPath("small.zim", "small.zim", "http://localhost/small.zim", true);
|
||||
@ -286,9 +298,13 @@ public class test {
|
||||
bookIds = lib.getBooksIds();
|
||||
assertEquals(bookIds.length, 0);
|
||||
}
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLibraryXml() throws IOException {
|
||||
{
|
||||
TestLibrary lib = new TestLibrary();
|
||||
TestManager manager = new TestManager(lib);
|
||||
manager.readFile("library.xml");
|
||||
@ -300,9 +316,13 @@ public class test {
|
||||
assertEquals(book.getHumanReadableIdFromPath(), "small");
|
||||
assertTrue(book.isPathValid());
|
||||
}
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLibraryXmlContent() throws IOException {
|
||||
{
|
||||
TestLibrary lib = new TestLibrary();
|
||||
TestManager manager = new TestManager(lib);
|
||||
String content = getTextFileContent("library.xml");
|
||||
@ -315,9 +335,13 @@ public class test {
|
||||
assertEquals(book.getHumanReadableIdFromPath(), "small");
|
||||
assertTrue(book.isPathValid());
|
||||
}
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLibraryOPDS() throws IOException {
|
||||
{
|
||||
TestLibrary lib = new TestLibrary();
|
||||
TestManager manager = new TestManager(lib);
|
||||
String content = getTextFileContent("catalog.xml");
|
||||
@ -330,9 +354,13 @@ public class test {
|
||||
assertEquals(book.getHumanReadableIdFromPath(), "");
|
||||
assertFalse(book.isPathValid());
|
||||
}
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testServer() throws ZimFileFormatException, JNIKiwixException {
|
||||
{
|
||||
TestArchive archive = new TestArchive("small.zim");
|
||||
TestLibrary lib = new TestLibrary();
|
||||
TestBook book = new TestBook();
|
||||
@ -349,9 +377,13 @@ public class test {
|
||||
assertTrue(server.start());
|
||||
server.stop();
|
||||
}
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBookMark() throws ZimFileFormatException, JNIKiwixException {
|
||||
{
|
||||
TestArchive archive = new TestArchive("small.zim");
|
||||
TestLibrary lib = new TestLibrary();
|
||||
TestBook book = new TestBook();
|
||||
@ -381,9 +413,13 @@ public class test {
|
||||
bookmarkArray = lib.getBookmarks(true);
|
||||
assertEquals(0, bookmarkArray.length);
|
||||
}
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearcher() throws Exception, ZimFileFormatException, JNIKiwixException {
|
||||
{
|
||||
TestArchive archive = new TestArchive("small.zim");
|
||||
|
||||
TestSearcher searcher = new TestSearcher(archive);
|
||||
@ -409,7 +445,6 @@ public class test {
|
||||
|
||||
query.setGeorange(50,70,50);
|
||||
assertEquals(0, searcher.search(query).getEstimatedMatches());
|
||||
searcher.dispose();
|
||||
|
||||
TestSearcher searcher2 = new TestSearcher(new TestArchive[0]);
|
||||
searcher2.addArchive(archive);
|
||||
@ -428,7 +463,9 @@ public class test {
|
||||
assertEquals("main.html", suggestionItem.getPath());
|
||||
assertTrue(suggestionItem.hasSnippet());
|
||||
assertEquals("<b>Test</b> ZIM file", suggestionItem.getSnippet());
|
||||
suggestionSearcher.dispose();
|
||||
}
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
}
|
||||
|
||||
static
|
||||
|
Loading…
x
Reference in New Issue
Block a user