-
1. Re: test infrastructure for OSGi
caniszczyk May 10, 2010 2:17 PM (in response to dan.j.allen)- generate an OSGi bundle with ShrinkWrap
I'm not sure how involved this is but essentially we just need to build a JAR and add metadata to the MANIFEST.MF
- implement the DeployableContainer SPI in Arquillian to start/stop the OSGi framework and deploy/undeploy the bundle
I should be able to do this in a generic fashion using the new FrameworkFactory API in OSGi so it will be framework agnostic. I will start with Equinox as my test bed as that's what I'm familiar with. Any pointers to a sample implementation that I can look at?
- implement a deployment appender to include the test case in an OSGi bundle
Is this another SPI? Can you be more specific?
-
2. Re: test infrastructure for OSGi
dan.j.allen May 11, 2010 12:15 PM (in response to caniszczyk)Chris Aniszczyk wrote:
- generate an OSGi bundle with ShrinkWrap
I'm not sure how involved this is but essentially we just need to build a JAR and add metadata to the MANIFEST.MF
Yep. As Andrew Rubinger (ALR) like to put it, this is CS 101 stuff. If you could spare some time, it would be best if someone well versed in OSGi like yourself has a hand in this just so that nothing gets overlooked.
- implement the DeployableContainer SPI in Arquillian to start/stop the OSGi framework and deploy/undeploy the bundle
I should be able to do this in a generic fashion using the new FrameworkFactory API in OSGi so it will be framework agnostic. I will start with Equinox as my test bed as that's what I'm familiar with. Any pointers to a sample implementation that I can look at?
Great!
The best example to look at is likely the embedded CDI containers (for Weld, for OpenWebBeans) since they are examples of standalone bootstrap frameworks (as opposed to application servers).
- implement a deployment appender to include the test case in an OSGi bundle
Is this another SPI? Can you be more specific?
Hmm, I'm a little fuzzy on this because OSGi is a different type of a container than what we've been dealing with so far.
Deployment appender is an implementation of this SPI:
org.jboss.arquillian.spi.AuxiliaryArchiveAppender
The purpose is to allow the Arquillian container implementation to add extra deployments into the container that are needed for the test. These fall into two catagories:
- The infrastructure for the unit testing framework (see JUnitDeploymentAppender)
- Test enrichers that are used to perform dependency injection into the test class.
I have a feeling we are going to need an OSGi version of the JUnitDeploymentAppender (or upgrade the archive it produces to an OSGi bundle). The idea is that the test runs "in-container", so you need to make the test and test framework visible to the container and then use some sort of protocol to negotiate the execution of the tests. In Java EE containers, an HTTP servlet is used. I think for OSGi we need to use a BundleActivator to kick off the test case. This is new territory for Arquillian.
Aslak can provide more details and recommendations.
-
3. Re: test infrastructure for OSGi
aslak May 12, 2010 6:33 AM (in response to caniszczyk)Welcome to the team Chris!
- generate an OSGi bundle with ShrinkWrap
I'm not sure how involved this is but essentially we just need to build a JAR and add metadata to the MANIFEST.MF
In the simplest case we support this right now. You can add your classes and add your own MANIFEST.MF. But we're looking for a bit more integrated api to the MANIFEST.MF/OSGI descriptor. If you look at what I played with a while ago you might get the general idea;
http://shrinkwrap.pastebin.com/zikd1gSD It uses the BND tools in the background to generate the descriptions etc.
You know more about the content of the MANIFEST.MF and how OSGI people build/use this stuff then me. Maybe that approach is not the ideal? My first question when i was doing it was 'where do I get the dependency versions from?'.
-
4. Re: test infrastructure for OSGi
aslak May 12, 2010 4:06 PM (in response to caniszczyk)In my play attempt I did the following:
- I used Felix and added the Arquillian core packages to the System Path in it's config
- A new DeploymentPackager that merged some of the AuxiliaryArchives with the ApplicationArchive into a new OSGi bundle.
- A new OSGi TestRunner(see ServletTestRunner) service deployed as part of the Deployment
- I also had a special ContainerMethodInvoker to forward the test case method invoke to the installed TestRunner service.
We're working on API/SPI for Arquillian managed Object to support injection of other things then just EJB/Resource/CDI Beans. e.g. InitialContext, Servlet URLs etc. As a part of this and OSGi; BundleContext, Service, ServiceReference object might be candidates.
{code:java}
@ArquillianResource
private BundelContext context;
@Test
public void shouldHandle(MyOSGIService service) throws Exception()
{
context...
service....
}
{code}