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