to be honest if have very little knowledge on the IntelliJ side as i'm mostly 
an eclipse user.
i tried it today in IntelliJ and it worked, probably because the generated 
metadata was already there.
perhaps a more experienced IntelliJ user can provide more information here.

stefan

>-----Original Message-----
>From: Roy Teeuwen <r...@teeuwen.be>
>Sent: Thursday, February 25, 2021 10:38 AM
>To: Sling Developers <dev@sling.apache.org>
>Subject: Re: No OSGi SCR metadata in Unit Tests
>
>Interesting that you mention Intellij Stefan? Because If i wouldn't do a
>mvn install first before executing the unit tests from the Intellij junit
>run configuration, it will fail with the exact reason stated. Is there an
>easy way in intellij to get those OSGi SCR xmls in a junit run
>configuration without having to triggering a maven install / bundle
>execution plugin first?
>
>> On 25 Feb 2021, at 09:48, Stefan Seifert <Stefan.Seifert@diva-
>e.com.INVALID> wrote:
>>
>> it should work quote out-of-the-box with bnd-maven-plugin integrated into
>the maven build, with an execution for the bnd-process goal. [1] shows an
>rather full-featured example, but you do not need all this for simple use
>cases.
>>
>> some IDEs may have problems generating the OSGi metadata during the build
>rightaway, test it first on the command line. IntelliJ IDEA and Eclipse
>should basically work fine.
>>
>> stefan
>>
>> [1] https://github.com/wcm-io/wcm-io-
>tooling/blob/23b28c1795a0dba9f5e51c429eecea102ae8e289/maven/aem-global-
>parent/pom.xml#L246-L306
>>
>>> -----Original Message-----
>>> From: Cris Rockwell <cmroc...@umich.edu>
>>> Sent: Thursday, February 25, 2021 12:18 AM
>>> To: dev@sling.apache.org
>>> Subject: No OSGi SCR metadata in Unit Tests
>>>
>>> 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#L1
>>> 13 <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#L1
>>> 13>
>>>
>>>
>>> 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
>>

Reply via email to