Skip to content

Added new test cases for latest wrapper#30

Merged
mgautierfr merged 19 commits intomainfrom
Issue#29
May 20, 2023
Merged

Added new test cases for latest wrapper#30
mgautierfr merged 19 commits intomainfrom
Issue#29

Conversation

@MohitMaliFtechiz
Copy link
Copy Markdown
Collaborator

Fixes #29

In this PR we are adding new test cases for latest wrapper.

  • Added test cases for If archive created with invalid Zim file then it will throw error.
  • Added test case for removing book from library by id.

@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as draft March 22, 2023 09:44
@kelson42 kelson42 mentioned this pull request Mar 22, 2023
@kelson42
Copy link
Copy Markdown
Contributor

@MohitMaliFtechiz This PR has to be based on #27, I don't understand how this can work otherwise.

@MohitMaliFtechiz
Copy link
Copy Markdown
Collaborator Author

@MohitMaliFtechiz This PR has to be based on #27, I don't understand how this can work otherwise.

@kelson42 , i have made this branch from #27 and after that added new test cases in it, Once #27 is merged i'll re base this PR on main branch.

@MohitMaliFtechiz
Copy link
Copy Markdown
Collaborator Author

MohitMaliFtechiz commented Mar 23, 2023

currently test cases are failing of because Linux libzim tar file containing 0 bytes .so file, so i have open a ticket for it in libzim openzim/libzim#772 .

@MohitMaliFtechiz
Copy link
Copy Markdown
Collaborator Author

For now i have made this branch from #31 to avoid the build failure because of linux zim file.

@MohitMaliFtechiz
Copy link
Copy Markdown
Collaborator Author

@mgautierfr , I am getting some errors while adding new test cases, can you please help me out on these errors.

  • When i am getting book from library Book book = lib.getBookById(bookIds[0]); via this method . It is giving error in utils.h
/media/hp-pc03/D/java-libkiwix/lib/src/main/cpp/utils.h:71: void setPtr(JNIEnv*, jobject, std::shared_ptr<_Tp>&&, const char*) [with T = const kiwix::Book; JNIEnv = JNIEnv_; jobject = _jobject*]: Assertion `env->GetLongField(thisObj, fieldId) == 0' failed.
  • When i am making object of query to test searcher Query query = new Query("test"); it is giving error. I think it means , it is not persent in .so file but we are including query.cpp while building the .so file. Is something missing in linux.so file or we are doing something wrong here?.
java.lang.UnsatisfiedLinkError: 'long org.kiwix.libzim.Query.setNativeQuery(java.lang.String)'
	at org.kiwix.libzim.Query.setNativeQuery(Native Method)
	at org.kiwix.libzim.Query.<init>(Query.java:25)
	at test.testSearcher(test.java:216)
  • When i am using suggestionSearch.getEstimatedMatches() it is returning 0 results. But i have tried small.zim with kiwix-app and search for test, there it is showing result in search result list .

I have push all the latest test cases on this PR. Currently CI is not running, Can you please try to run these tests locally.

@kelson42
Copy link
Copy Markdown
Contributor

@mgautierfr any update?

@mgautierfr
Copy link
Copy Markdown
Contributor

@MohitMaliFtechiz First problem (setPtr) is fixed.
But there is something wrong in the build system. I've spend a lot of time try to fix a crash in java interpreter and it was because the test was using a old version of the java .class definition (I think). I suppose that buildsystem doesn't detect correctly that .class have changed and don't update the one in the test directory.

I'm looking for the two others issues.

But on my side, I face a new test failure where the illustration data is not equal to expected (test.java:137). It is probably because the String constructor interpret the bytes (and probably stop at first \0).

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (main@66ebc4e). Click here to learn what that means.
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #30   +/-   ##
=======================================
  Coverage        ?   42.39%           
  Complexity      ?       18           
=======================================
  Files           ?       24           
  Lines           ?       92           
  Branches        ?        6           
=======================================
  Hits            ?       39           
  Misses          ?       51           
  Partials        ?        2           

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@mgautierfr mgautierfr marked this pull request as ready for review May 20, 2023 15:01
MohitMaliFtechiz and others added 14 commits May 20, 2023 17:05
…st as we are generating the .so file in app/CMakeList now test/CMakeList file is unused so we are removing it
…only for running test cases, removed unnecessary check for directory in run_test.sh
…am for testing. In this commit we are compiling, running java test cases for gradle task, So we are removing the run_test.sh as it is unused now
… (libkiwix, libzim) , Now we are renameing the folders names via renameFolders method
… using the gradle tasks to compile and run test cases
…e , added remove book from library by id tests
Introduce a new set of wrapper (with a nice `2` postfix) with use a
constructor taking a handle as parameter.
It allow Book to have two constructor:
- One creating a default empty (cpp) book.
- One setting the wrapper around a exsiting cpp book.
Blob IS a `char[]`. C++ allow a char[] to be stored in a string but in
java, a String is associated to a encoding.
Content in a Blob may have no encoding so we cannot convert to a string.

Fix the test part.
Correctly include `org_kiwix_libwzim_Query.h`.
Property set the return type of setNativeQuery to void.
`Book::getIllustration(size)` return a `shared_ptr<Illustration>`.
The current `buildWrapper` was creating a wrapper on a
`shared_ptr<Illustration>` (so a `shared_ptr<shared_ptr<Illustration>>`)
but we was converting to a `shared_ptr<Illustration>` and so we were doing
wrong reads.

By specializing the buildWrapper for `shared_ptr<T>`, we avoid the
"double shared_ptr" and we are good.
`small.zim` doesn't seems to contain a xapian database, so searcher
cannot work.
@mgautierfr
Copy link
Copy Markdown
Contributor

The branch now compile and tests are passing.
Let's merge it and move on with a new iteration.

@mgautierfr mgautierfr merged commit 8cc3627 into main May 20, 2023
@mgautierfr mgautierfr deleted the Issue#29 branch May 20, 2023 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add new test cases for latest wrapper

4 participants