0

i really can´t find a way to junit test blueprint. With Spring DM (this dead project) was very simple to test the same spring beans with junit and some mocks. In blueprint (either aries or gemini) is nothing like SpringJUnit4ClassRunner.

Pax Exam is to complicated for unit testing and don´t produce some structural test results.

Do you have some idea, how to junit test blueprint?

pan40
  • 317
  • 1
  • 5
  • 15

2 Answers2

2

I wrote a testrunner bundle that runs every service as a JUnit test if the osgitest=junit4 service property is there. It uses the interface of the service to search for annotations.

I also wrote eosgi-maven-plugin that can start an OSGi environment during the integration-test phase of maven and run the tests with the help of the testrunner bundle.

With these tools my aim was to be really technology independent. The only requirements are that the application must run on an OSGi container and the tests must be OSGi services. The bundles are the maven dependencies of the project.

There is a step-by-step guide. It is not up-to-date the name of the plugin has been changed from maven-eosgi-plugin to eosgi-maven-plugin (as maven suggested in a warning)

I hope this is the one you are looking for :)

Balazs Zsoldos
  • 6,036
  • 2
  • 23
  • 31
  • i will try it with karaf osgi applications – pan40 Jun 17 '13 at 07:54
  • You may want to create a custom zip package for karaf that can be used in with the maven plugin. Sadly that part is not well documented yet. However, if you check with the default zip package (that uses equinox) you will see how it works. There is only one XML file in the main of the zip and everything else comes from the configuration of the XML (start command, stop command, ...). If you have any question please do not hesitate to ask. – Balazs Zsoldos Jun 18 '13 at 13:58
0

As far as I'm concerned pax-exam is still the number one test framework for osgi. And of course blueprint. You'll find also some samples for testing with Karaf. https://ops4j1.jira.com/wiki/display/PAXEXAM3/Pax+Exam

Achim Nierbeck
  • 5,265
  • 2
  • 14
  • 22
  • Pax Exam is to complicated for unit testing and don´t produce some structural test results. I know, that is the best framework for integration tests, but not for junit tests! – pan40 Jun 17 '13 at 07:52
  • Nope, it's not and actually if you will try to run with Karaf, there is the karaf container available with Pax-Exam 3.1.0 (which is still snapshot right now). This will help you a lot having a "minimal" test-setup since a lot is provided Out-Of-The-Box. – Achim Nierbeck Jun 17 '13 at 09:15
  • Besides Pax-Exam there is still PojoSR, but it'll fail with blueprint if you need to test some more complex scenarios, for example if you use JPA, it won't work anymore ... – Achim Nierbeck Jun 17 '13 at 09:16