Hi, I have a problem getting a resource resolver factory working in my unit
tests. The error looks like this
org.apache.sling.testing.mock.osgi.NoScrMetadataException: No OSGi SCR metadata
found for class org.apache.sling.api.resource.ResourceResolverFactory
My code looks like this
@Test
public void test_authn_request(){
BundleContext bundleContext = MockOsgi.newBundleContext();
ResourceResolverFactory mockFactory =
Mockito.mock(ResourceResolverFactory.class);
MockOsgi.injectServices(mockFactory, bundleContext); //fails
...
}
https://github.com/apache/sling-whiteboard/blob/SLING-9397/improve-test-coverage/saml-handler/src/test/java/org/apache/sling/auth/saml2/impl/OsgiSamlTest.java#L113
<https://github.com/apache/sling-whiteboard/blob/SLING-9397/improve-test-coverage/saml-handler/src/test/java/org/apache/sling/auth/saml2/impl/OsgiSamlTest.java#L113>
It’s a similar issue mentioned in
https://issues.apache.org/jira/browse/SLING-7182
The comment in SLING-7182 suggests the maven-bundle-plugin configs
http://felix.apache.org/documentation/faqs/apache-felix-bundle-plugin-faq.html#use-scr-metadata-generated-by-bnd-in-unit-tests
My project uses bnd-maven-plugin (not maven-bundle-plugin), so I’m asking if
anyone has examples of bnd.bnd or pom.xml examples that show how to configure
that for bnd-maven-plugin. Or perhaps other suggestions that will help clear
this error...
Thank you!
Cris