hello dominik.

do you have a small example project to show the problem?
from what you describe this should be no problem with osgi mocks/sling mocks - 
but i do not get the exact problem you encounter.

if you want to mock an OSGi services it's easiest to use somehing like mockito 
and register it in the mock context with the "registerService" method.

stefan

>-----Original Message-----
>From: Dominik Süß [mailto:dominik.su...@gmail.com]
>Sent: Monday, September 3, 2018 1:49 PM
>To: users@sling.apache.org
>Subject: Mock Osgi Services via Sling Mocks
>
>Hi everyone,
>in my case I would like to register a mocked version of an osgi service -
>in the past IIRC I could have scr metadata in a mock class under
>src/test/java and just register this one.
>
>With the more recent osgi annotations to generate the scr metadata there is
>an extra execution for scr generation as described in
>http://felix.apache.org/documentation/faqs/apache-felix-bundle-plugin-
>faq.html#use-scr-metadata-generated-by-bnd-in-unit-tests
>
>The problem: this will ignore classes in scr-metadata so I currently see no
>way on how to mock an osgi service for a test case without creating an own
>bundle with these mocks (along with the generated SCR metadata).
>
>Is there any way to programmatically inject a service and inject the
>corresponding metadata?
>
>Cheers
>Dominik

Reply via email to