Hi All,
I recently started using AemMocks and am still exploring. In one of the requirements, Sling models are implemented all looks fine till now. I started unit testing the same using Aem Mocks.
Problem:
I am unable to inject the service reference into the test class using 'context.registerInjectActivateService'.I have gone through numerous reference documents online but nothing is helpful.
any help is appreciated.
Thanks,
Harshith.
Solved! Go to Solution.
Hi HKesani,
Could you please give a try to below code to mock OSGi service?
Reference: https://wcm.io/testing/aem-mock/usage.html#Registering_OSGi_service
Regards,
Arpit Varshney
Hi HKesani,
Could you please give a try to below code to mock OSGi service?
Reference: https://wcm.io/testing/aem-mock/usage.html#Registering_OSGi_service
Regards,
Arpit Varshney
Unfortunately, none of these methods work if the service you want to call calls another service. In this case, the first service fails with the error:
org.apache.sling.testing.mock.osgi.ReferenceViolationException: Unable to inject mandatory reference 'secondService' for class com.mycompany.core.services.impl.FirstServiceImpl : no matching services were found.
Views
Likes
Replies
Views
Likes
Replies