Reputation: 121
For a new project I'm looking at what OSGi has to offer in terms of dependency injection, and I kinda like iPOJO (pure annotation-based, not the xml backed).
However, from a testing perspective, Blueprint might be better, since then for different test cases (functionality testing) it might be enough to rewrite the blueprint configuration and there would be an other service injected right away.
What are your thoughts on this subject? Can I abandon XML-based Blueprint (I loathe XML) in favor of iPOJO without sacrificing flexibility in terms of testing?
Upvotes: 0
Views: 684
Reputation: 3192
Regarding iPOJO unit testing, you can use constructor (or constructor injection) to inject mock services and effectively test the behavior of your component:
So two choices:
If you trying to do integration testing, you can just use pax exam and deploy your bundle (in additional to iPOJO).
Upvotes: 0
Reputation: 61061
Yes. You can. I don't think you will sacrafice anything. In fact, iPOJO is more powerful then blueprint, it supports things like "Field injection", "Service lifecycle control", and "Configuration admin" - which Blueprint does not (reference).
Blueprint, however, is part of the OSGi Enterprise Specification, if that matters.
I have not worked with Blueprint, but just looking at the specification for it - unless you are a java beans guy, I would stay away. Also, I prefer iPOJO over DS, as it seems to be a lot smarter in many cases, and just does the right thing.
Upvotes: 1