3/18/12

Fuse Fabric and Camel

Prologue


I have already blogged about CamelOne which is going to take place on May 15 - 16 at Boston this year. I am really excited about it, as a lot of new things are going to be talked about there.

So I'd like to share my excitement with you and give you a small preview of "Using Fuse Fabric with Apache Camel".

Fuse Fabric

Fuse Fabric is a distributed configuration, management and provisioning system for Apache Karaf based containers such as Apache ServiceMix and Fuse ESB.


Fabric provides a distributed configuration registry and also tools for:

  • Installing and managing containers to your private or public cloud.
  • Deployment agent for configuring and provisioning distributed containers.
  • Discovery of Camel endpoints & message brokers.
  • A lot more ... 

Fuse Fabric and Camel preview

What I am going to show you, is a video that demonstrates how fabric makes it easy to:
  • Use a single host for installing containers to your local network.
  • Deploy and configure applications to distributed containers.
  • Discover & use message brokers in your camel routes.

I hope you enjoyed it! See you at CamelOne !

3/9/12

How to deal with common problems in pax-exam-karaf

Prologue
Back in January I made a post about advanced integration testing with pax-exam-karaf. That post was pretty successful, as I got tons of questions from people that started using it.

In this post I am going to write down these questions and provide some answers that I hope that will help you have a more smooth experience with integration testing in Karaf.

Where should I place my integration test module?
Quite often people want to test a single bundle. In this case having the integration tests hosted inside the bundle itself seems a reasonable choice.

Unfortunately it is not. Pax Exam in general will start a new container and will install your tests as a proper OSGi bundle. That means that it expects to find bundle, however the test phase runs before the install phase in maven. That means that when you run the tests the bundle that you are testing will not be installed yet. To avoid this issue, you better host all your integration tests as a separate module.

The bundle context is not getting injected in my test?
For injecting the bundle context in the test Pax Exam Karaf makes use of javax.inject.Inject annotation. In your classpath there will be also a org.ops4j.pax.exam.Inject annotation. Make sure that you use the javax.inject.Inject to inject the bundle context. That's very easy to get you confused so be careful.

My system properties are not visible from within the test?
Quite often people customize the behavior of their tests, using system properties. It's really common to configure maven-surefire-plugin to expose maven properties as system properties (e.g. passing credentials to a test, allocating a free port for test & more).

That's something really useful, but you have to always remember a small detail. "The test is bootstrapped by one jvm, but runs in an other". That means that specifying system properties in the surefire plugin configuration, will not automagically set these properties to the Karaf container that will be used as the host of your tests.

I usually make sure to pass the desired system properties in the target Karaf container, by adding them in the etc/system.properties file of the container:
The above snippet also shows, how you can configure Karaf config.properties. The example shows how you can add additional execution environments in your test configuration.

How can I have my test extend a class from an other module?
You should never forget that under the hood  Pax Exam will create a bundle called probe, that contains all your tests. That means that if your tests extend a class that is not present in the current module, it won't be found by your probe bundle. In older versions of  Pax Exam you could pretty easily modify the contests of the probe and include additional classes from any module visible to your project. In the 2.x series its more complicated.

The easiest way to go is to make sure your install the bundle that contains the super class to the target container. Here is an example:

How can I configure the jre.properties of my test?
That's something really common, when you want to for example to test CXF in plain Karaf and not using ServiceMix/FuseESB etc.Pax Exam Karaf allows you to replace any configuration file with the one of your choice.


That's it! I hope you found this useful! Happy testing!