Hi,

just one quick question/hint.
You are aware of the Pax Exam Testframework?
I think with it you are able to do what you are looking for.

regards, Achim


2014-12-12 6:41 GMT+01:00 Dean Schulze <dean.w.schu...@gmail.com>:

>
> I have an OSGI app consisting of several bundles.  In order to do
> functional testing I want to dynamically load test case classes when the
> -Dtest.class.name=MyTestClass property is set.  I want to keep the test
> classes in their own bundle to make it easy to exclude them from the
> production binary.  The only test artifact that will be in the
> production code bundles will be an interface that the test classes
> implement.
>
> The test bundle depends on the production bundles to access the test
> interface and because the test classes also use other classes in the
> production bundles.  The test classes themselves are POJOs.  They are
> not Serice or Component classes.  I only want to load them when the
> test.class.name property is set so I don't want Felix injecting them.
>
> I try to load the test class
>
> public class MyTestClass implements MyTestClassI {
>     ....
> }
>
> from the production bundle code like this
>
> MyTestClassI myTestClass;
>
> ....
>
> //      Inside the @Activate method
> String testClassName = System.getProperty("test.class.name");
> if (testClassName != null) {
>
>         Class c = Class.forName(testClassName);
>         myTestClass = c.newInstance();
> }
>
> This gives a ClassNotFoundException.
>
> The recommended solution that I've seen to this problem is to use the
> Bundle.loadClass() method, but I haven't seen any example code that
> actually does this.  I would have to get the test Bundle first and I
> haven't been able to find out how to do this.
>
> If anyone knows of example code to do dynamic class loading in Felix I
> would appreciate a link to it.  If this kind of dynamic loading can only
> be done form the gogo shell I could live with that since this would only
> be done by the development and test teams.
>
> Thanks.
>
> Dean
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
> For additional commands, e-mail: users-h...@felix.apache.org
>
>


-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master

Reply via email to