Closed asd1245dss closed 8 years ago
One possible way is to use something like described here: https://davidvaleri.wordpress.com/2013/09/17/integration-testing-osgi-bundles-in-apache-karafservicemix-with-pax-exam-3/
(note, you may need to upgrade the versions of the dependencies)
I have not tried that solution myself, but it seems workable.
@alexlukichev I tried it,but failed because of missing some dependencies. So I go to the OPS4j Pax Exam offcial website, I found the following documentation for osgi unit test. Getting+Started+with+OSGi+Tests Test+Containers
I followed the tutorial But it seems still missing some configuration. maven.txt
@alexlukichev I found a unit test demo from the official karaf github repository. Just the same as the before what I tried.And I clone one demo from this repository which matain by one of the contributor of karaf.At last,it works through maven test or junit test. I try to copy the approch to our project,but still failed.What I find different betweeen these two projects is that the official demo uses the feature install not the kar file. So I refactor the project's structure and using the feature file instead kar file to install our project,but the karaf says missing some dependencies. Although it still can't work,I think if the feature install take effect,the unit test problems should be solved.
Can you please create a branch with your changes?
On Aug 18, 2016 7:24 PM, "Summer" notifications@github.com wrote:
@alexlukichev https://github.com/alexlukichev I found a unit test demo from the official karaf github repository. [image: image] https://cloud.githubusercontent.com/assets/2149974/17794611/9356643a-65e3-11e6-83ca-353bc5f83330.png [image: image] https://cloud.githubusercontent.com/assets/2149974/17794603/82490b20-65e3-11e6-9f62-8c2adf0ef272.png Just the same as the before what I tried.And I clone one demo from this repository which matain by one of the contributor of karaf.At last,it works through maven test or junit test. [image: image] https://cloud.githubusercontent.com/assets/2149974/17794671/26798292-65e4-11e6-9ae9-8b830a61c4c6.png [image: image] https://cloud.githubusercontent.com/assets/2149974/17794718/85949cd0-65e4-11e6-8942-f564c3bf201e.png I try to copy the approch to our project,but still failed.What I find different betweeen these two projects is that the official demo uses the feature install not the kar file. [image: image] https://cloud.githubusercontent.com/assets/2149974/17794765/f9a46484-65e4-11e6-8fe9-53c7dbc5b5a5.png So I refactor the project's structure and using the feature file instead kar file to install our project,but the karaf says missing some dependencies. [image: image] https://cloud.githubusercontent.com/assets/2149974/17794887/f5444818-65e5-11e6-91d0-e7e177c4ddc2.png [image: image] https://cloud.githubusercontent.com/assets/2149974/17794885/ee2890ac-65e5-11e6-874d-3bc9d8cbcf19.png [image: image] https://cloud.githubusercontent.com/assets/2149974/17794881/e49926e6-65e5-11e6-818e-455a170efe2b.png Although it still can't work,I think if the feature install take effect,the unit test problems should be solved.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wpgsh/cloud4water/issues/11#issuecomment-240896049, or mute the thread https://github.com/notifications/unsubscribe-auth/AFCdLTtCKewX9B8L22VVKnbSyRQNVLyTks5qhPfbgaJpZM4Jisf3 .
Yes,I have create the branch before.
BTW, have you considered mockito for mock objects?
(also it is not worth trying Sling OSGi Mock -- doesn't work that well)
Yes! We want to use it for our recent project test, but not very familiar with it.
I have submitted an example of mockito usage in the branch mock-sample
.
Take a look at apps/authn/bundles/net.wapwag.authn.ui/src/test
. The sample test class is AccessTokenServletTest
. I've factored out some common code into BaseServletTest
and UserDaoMock
. The latter contains the actual use of mockito tools.
In my AuthorizationServletTest class,it need user to login first before get authorization code,so how to set the login session in the jetty container or if I need to add loginservlet to jetty and mock related dao method ?
@alexlukichev I've read the sample servlet unit test,what you do there is set up one jetty server and resolve all the dependencies AccessTokenServlet class need and send the http request through the HttpURLConnection. My question is: