Fwd: service not found by integration test

12 views
Skip to first unread message

William la Forge

unread,
May 17, 2013, 7:49:25 AM5/17/13
to AgileWikiDevelopers
Now I wait. 

---------- Forwarded message ----------
From: William la Forge <lafo...@gmail.com>
Date: Fri, May 17, 2013 at 5:18 PM
Subject: service not found by integration test
To: us...@karaf.apache.org


I have an integration test that works half the time when I set the logging level to DEBUG. So I figured I need to use @Before, but the method does not get called.

org.apache.karaf 3.0.0.RC1
org.apache.karaf.tooling.exam 3.0.0.RC1
org.ops4j.pax.exam 2.6.0



I used mavenBundle in config:

    @Configuration
    public Option[] config() {
        return new Option[]{karafDistributionConfiguration().frameworkUrl(
                maven().groupId("org.apache.karaf").artifactId("apache-karaf").type("zip").versionAsInProject())
                .karafVersion("2.2.4").name("Apache Karaf"),

                logLevel(LogLevelOption.LogLevel.INFO),

                mavenBundle("org.agilewiki.jactor", "jactor-api", "0.0.1-SNAPSHOT"),
                mavenBundle("org.agilewiki.jactor", "jactor-impl", "0.0.1-SNAPSHOT"),
                mavenBundle("org.agilewiki.jactor", "jactor-util", "0.0.1-SNAPSHOT"),
                mavenBundle("org.agilewiki.jactor", "jactor-test-iface", "0.0.1-SNAPSHOT"),
                mavenBundle("org.agilewiki.jactor", "jactor-test-service", "0.0.1-SNAPSHOT")

        };
    }

My before method is not called:

    @Before
    public void setup() throws Exception {
        Thread.sleep(10000);
    }

The result I get without DEBUG and half the time with DEBUG set is:

  test:org.apache.karaf.VersionAsInProjectKarafTest.test:KarafTestContainer{mvn:
org.apache.karaf\/apache-karaf\/3.0.0.RC1\/zip}(org.apache.karaf.VersionAsInProj
ectKarafTest): org.agilewiki.jactor.testIface.Hello not found by PAXEXAM-PROBE-e
10f1edd-464b-4800-a783-7dcfd54a2a0d [93]

I'm running on Windows 7.

Any help would be appreciated. Thanks!

Bill



William la Forge

unread,
May 17, 2013, 10:58:39 AM5/17/13
to AgileWikiDevelopers
I got an answer--severely limit the use of @Inject in the test.

---------- Forwarded message ----------
From: William la Forge <lafo...@gmail.com>
Date: Fri, May 17, 2013 at 8:27 PM
Subject: Re: service not found by integration test
To: us...@karaf.apache.org


Thanks Achim, that did help clarify things a little.

I noticed in the test you referenced that there was a wait at the start of the test. I tried doing the same, but apparently the test never even got invoked. My guess is that this is because I am using @Inject. (In the test you referenced, there is also an @Inject, but it is just for the bundle context.)

Ah. Instead of an @Inject on the desired service, a service listener is employed and a notify is used to wake up the thread doing the wait. I can do that, but that's pretty ugly, eh?

OK, so I have an answer. It is nice and solid. Just don't use @Inject! 

Quitting time for me here in India. I'll check for alternative responses in the morning before proceeding with this solution.

Thanks again Achim!


On Fri, May 17, 2013 at 8:07 PM, Achim Nierbeck <bcan...@googlemail.com> wrote:
Hi, 

take a look at how it's used in Karaf itself, maybe you're doing something slightly different. :)


regards, Achim 


2013/5/17 William la Forge <lafo...@gmail.com>
I switched to karaf 2.3.1, but there was no change



--

Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
OPS4J Pax for Vaadin <http://team.ops4j.org/wiki/display/PAXVAADIN/Home> Commiter & Project Lead
blog <http://notizblog.nierbeck.de/>


monster

unread,
May 18, 2013, 4:47:42 AM5/18/13
to agilewiki...@googlegroups.com
But the link to Karaf test uses @Inject too!?!

William la Forge

unread,
May 18, 2013, 5:59:57 AM5/18/13
to AgileWikiDevelopers
only for bundle context. That works just fine.


On Sat, May 18, 2013 at 2:17 PM, monster <skunki...@googlemail.com> wrote:
But the link to Karaf test uses @Inject too!?!

--
You received this message because you are subscribed to the Google Groups "AgileWikiDevelopers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to agilewikidevelo...@googlegroups.com.
To post to this group, send email to agilewiki...@googlegroups.com.
Visit this group at http://groups.google.com/group/agilewikidevelopers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

William la Forge

unread,
May 18, 2013, 11:07:25 AM5/18/13
to AgileWikiDevelopers
Good progress today. ktest configures the test environment and the test. It terminates the test as either successful or failed (assertTrue(success)) depending on the presence of a success service registered (or not) by kdriver.

kdriver uses JAServiceTracker to locate the test service. If it locates the service, the test is successful. This is working reliably now.

I've also realized that the JAServiceTracker interface can be simplified by making the response to the start request void. The initial response is sent as a signal, like all other status changes, but with a null event. Implementing this is next on my list.

I've also had to simplify the service test, as its operation was erratic. Fixing that is second on my todo list.

--b

William la Forge

unread,
May 20, 2013, 12:10:56 AM5/20/13
to AgileWikiDevelopers
The test is quite solid now. kdriver even installs & starts the test service and then uninstalls it when finished.

My current goal then is reinstate the code that was causing problems in test service and get it working, though it is possible that the simplified interface for JAServiceTracker already took care of that.

After that I need to look into the use of configuration files. That's important, as it will allow us to make things configurable.

William la Forge

unread,
May 20, 2013, 1:44:06 AM5/20/13
to AgileWikiDevelopers
I've reinstated the code in the test service module's Activator class and, as I had hoped, it now runs fine.

So it looks like it is time to dig into configuration files. Which is nice, as the lack of support for configuration files in the old test scenario was the reason for adding Karaf to the test environment in the first place. (Or at least, the reason for making it a priority!)
Reply all
Reply to author
Forward
0 new messages