Also have a look at Sling Testing Tools [1]
Chetan Mehrotra
[1] http://sling.apache.org/documentation/development/sling-testing-tools.html


On Sat, Dec 13, 2014 at 2:05 AM, Christian Schneider
<ch...@die-schneider.net> wrote:
> You can also do this without an Activator and just DS.
>
> On the production side you have to find a way to listen for 0..n services
> that implement an interface.
> http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/scr-annotations.html
> http://www.aqute.biz/Bnd/Components
> You will need @Reference and the bind and unbind attributes. So you can
> react when test Services are published or removed.
>
> On the test side you simply publish the test class as a service
> @Component
> @Service(interfaces = TestInterface.class)
> public class Testclass implements TestInterface {
> ...
> }
>
> What you do is an implementation of the whiteboard pattern.
>
> Christian
>
> Am 12.12.2014 19:06, schrieb Dean Schulze:
>
>> I don't know what you mean when you say instantiate the class in the
>> Activator.  The Activator runs after the @Reference classes have been
>> injected.  I tried to load the test classes dynamically in the Activator,
>> but I got a ClassNotFoundException.
>>
>> In order to get the implementation below to work the production module
>> depends on the test module, but the test module depends on the production
>> module, which won't work.
>>
>> This approach probably can't be made to work.
>>
>> As an alternative I can move the test classes into their own package in
>> the
>> production module and have maven exclude that package from the production
>> binary.
>>
>> @Component
>> @Service { .....}
>> public class ProductionClass implements ... {
>>
>> private @Reference ITestClass testClass;
>>
>> @Activate
>> public void activate() {
>>
>> }
>>
>>
>> }
>>
>>
>> On Fri, Dec 12, 2014 at 7:41 AM, Christian Schneider <
>> ch...@die-schneider.net> wrote:
>>>
>>> I also recommend to use a service for this.
>>>
>>> Simply put your test class into a separate bundle. In the activator
>>> instantiate the test class and publish it as a service using the test
>>> interface you provide.
>>>
>>> The production bundle would then listen for services implementing the
>>> test
>>> interface e.g. using a service tracker and call them.
>>>
>>> This has the advantage that you do not need any system property and class
>>> loading specialities. Another advantage is that you can start the test by
>>> deploying the test bundle and stop it again by removing it.
>>> So no restart required.
>>>
>>> Christian
>>>
>>>
>>> On 12.12.2014 15:31, Achim Nierbeck wrote:
>>>
>>>> Dynamic Import?
>>>> Add a manifest header or dynamically importing your testclass in case
>>>> it's
>>>> available,
>>>> but I would actually work with a service tracker that waits for the
>>>> "testservice" to be available and trigger the "test" then.
>>>>
>>>> regards, Achim
>>>>
>>>>
>>>>
>>> --
>>> Christian Schneider
>>> http://www.liquid-reality.de
>>>
>>> Open Source Architect
>>> http://www.talend.com
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
>>> For additional commands, e-mail: users-h...@felix.apache.org
>>>
>>>
>
>
> --
>  Christian Schneider
> http://www.liquid-reality.de
>
> Open Source Architect
> Talend Application Integration Division http://www.talend.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
> For additional commands, e-mail: users-h...@felix.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
For additional commands, e-mail: users-h...@felix.apache.org

Reply via email to