You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@aries.apache.org by Jim Church <ji...@segmint.com> on 2013/03/22 15:38:30 UTC

blueprint in pax-exam: referencerecipe

I am trying to test my Blueprint reference-listeners with Pax Exam,
thinking that testing our reference-listener bind and unbind methods should
be the exact kind of work I want from integration tests.  I use blueprint
reference-listeners (shown below), and when I run the container (Felix), I
can use the Gogo shell to test that my listeners work as designed.
However, when I try to test with Pax Exam, the ServiceChanged event gets
dispatched, but due to an object identification mismatch in Blueprint, my
reference-listeners never get invoked. I don't know whether this is a
design problem/limitation of Pax Exam or Blueprint or if I'm just not
understanding some concept that has put me in the weeds.  I'd address this
problem to Pax-Exam first if I could find a way to register or post to
their mailing list.

In Pax Exam, when I stop the bundle that registers the service under test,
I can step through my debugger to see the Felix EventDispatcher invoke
various listeners, among them the Aries ReferenceRecipe, the same as when I
just run Felix/Karaf without Pax Exam.  The difference in Pax Exam is that
when Aries calls untrack() and the comparison of TrackedServiceReference to
the passed-in reference fails, so the retrack() method is not called, and
my blueprint-registered reference listeners never get invoked.

I am using Ubuntu 12.04, OpenJDK 1.7.0_15, karaf 2.2.10 felix-framework
3.2. , aries-blueprint 0.3.1, pax-exam 2.6.0, paxexam-karaf-options 1.0
(Using the karaf pax container), Eclipse Juno SR2, Maven 2, and the problem
happens every time.

Regards,
Jim Church


07:27:07,416 | DEBUG | l Console Thread | datasource-postgres
   | 144 - datasource-postgres - 1.1.0.SNAPSHOT | ServiceEvent UNREGISTERING
07:27:07,416 | DEBUG | l Console Thread | ServiceRecipe
| 10 - org.apache.aries.blueprint - 0.3.2 | Unregistering service
.component-2
07:27:07,416 | DEBUG | l Console Thread | ServiceRecipe
| 10 - org.apache.aries.blueprint - 0.3.2 | Calling listeners for service
unregistration
07:27:07,416 | DEBUG | l Console Thread | BlueprintCamelContext
| 99 - org.apache.camel.camel-blueprint - 2.10.3 | Service
org.osgi.framework.ServiceEvent[source=[javax.sql.DataSource]] changed to 4
07:27:07,417 | DEBUG | l Console Thread | AbstractServiceReferenceRecipe
| 10 - org.apache.aries.blueprint - 0.3.2 | Untracking reference
[javax.sql.DataSource] for OSGi service (&(osgi.jndi.service.name
=jdbc/pooled-postgres)(objectClass=javax.sql.DataSource))

My listener
-----------
<reference
  id="cookieDS"
  availability="mandatory"
  interface="javax.sql.DataSource"
  filter="(osgi.jndi.service.name=jdbc/pooled-postgres)">
  <reference-listener
    ref="cookieDataService"
    bind-method="bindService"
    unbind-method="unbindService"/>
</reference>

Aries untrack method:
---------------------
protected void untrack(ServiceReference ref) {
  synchronized (monitor) {
    if (trackedServiceReference == ref) {
      retrack();
    }
  }
}