I'm wondering about it too.. Unfortunately I inherited this code, and need to add this unit testing now. I prefer to not ask this to myself too :D Simply.. this code works but unit test were never implemented before. Thanks for the samples!
Il giorno lun 6 mar 2023 alle ore 16:56 Stefan Seifert <[email protected]> ha scritto: > this should not be required ... i'm wondering how your project was working > before deployed in an OSGi container (before adding unit tests) without > having bnd-maven-plugin or maven-bundle-plugin in place. > > here is an example for a bnd-maven-plugin configuration - with a lot of > extra stuff added, most is not needed for simple use cases: > > https://github.com/wcm-io/io.wcm.maven.aem-global-parent/blob/de8c3d2cdc0347b0c5d934696da9b8165fbf7d0a/pom.xml#L249-L309 > > stefan > > > -----Original Message----- > > From: Flavio <[email protected]> > > Sent: Monday, March 6, 2023 4:40 PM > > To: [email protected] > > Subject: Re: Unable to solve "No OSGi SCR metadata found for class" > > > > Hello! > > > > I have understood the root cause of the problem. > > Adding the following file solved the issue and I was able to run the test > > flawlessly: > > src/test/resources/OSGI-INF/serviceComponents.xml > > > > Thanks! > > > > Il giorno lun 6 mar 2023 alle ore 15:21 Flavio <[email protected]> ha > > scritto: > > > > > Hi Stefan! > > > > > > Thanks for replying. I'm getting this error on the command line. > > > Consider that I am adding for the first time JUnits to my osgi project > > > so I have to introduce also this bnd-maven-plugin. > > > I added the following part to my pom.xml into the plugins section but > > > still no luck: > > > > > > <plugin> > > > <groupId>biz.aQute.bnd</groupId> > > > <artifactId>bnd-maven-plugin</artifactId> > > > </plugin> > > > <plugin> > > > <groupId>org.apache.maven.plugins</groupId> > > > <artifactId>maven-jar-plugin</artifactId> > > > <configuration> > > > <archive> > > > <manifestFile>${project.build.outputDirectory}/META- > > INF/MANIFEST.MF</manifestFile> > > > </archive> > > > </configuration> > > > </plugin> > > > > > > > > > Flavio > > > > > > Il giorno lun 6 mar 2023 alle ore 15:09 Stefan Seifert > > > <[email protected]> ha scritto: > > > > > >> hello flavio. > > >> > > >> are you getting this error running maven on the command line, or only > > >> within your IDE? > > >> > > >> if you are using bnd-maven-plugin, this should work automatically. > > >> there are some required configuration options for maven-bundle-plugin > > >> [1], but this plugin is outdated and you should migrate [2]. > > >> > > >> stefan > > >> > > >> > > >> [1] https://wcm-io.atlassian.net/l/cp/vcqy50qF > > >> [2] https://wcm-io.atlassian.net/l/cp/2tPaJN0X > > >> > > >> > -----Original Message----- > > >> > From: Flavio <[email protected]> > > >> > Sent: Monday, March 6, 2023 2:29 PM > > >> > To: [email protected] > > >> > Subject: Unable to solve "No OSGi SCR metadata found for class" > > >> > > > >> > Hi Everyone, > > >> > > > >> > I know there are tons of discussions and resources on the Internet, > > >> > but after many days trying to add the missing suggested > > >> > dependencies, adjusting the pom.xml with plugins and configurations > > >> > I have no more > > >> ideas > > >> > on how to solve this. > > >> > > > >> > I would kindly ask your support in order to achieve OSGi framework > > >> > Unit testing in my project. > > >> > One of the main suggestions I have found is this one: > > >> > https://stackoverflow.com/questions/48551036/exception-on-service- > > >> > activation-in-mock-osgi-context > > >> > > > >> > Still no luck! > > >> > > > >> > Can somebody help me with this please? > > >> > > > >> > Here's the error I get once I try to build via maven: > > >> > > > >> > org.apache.sling.testing.mock.osgi.NoScrMetadataException: No OSGi > > >> > SCR metadata found for class com.test.ConfigurationService at > > >> > > > >> org.apache.sling.testing.mock.osgi.OsgiServiceUtil.activateDeactivate > > >> (Osgi > > >> > ServiceUtil.java:79) > > >> > at > > >> org.apache.sling.testing.mock.osgi.MockOsgi.activate(MockOsgi.java:31 > > >> 4) > > >> > at > > >> org.apache.sling.testing.mock.osgi.MockOsgi.activate(MockOsgi.java:32 > > >> 5) > > >> > > > >> > -- > > >> > Flavio > > >> > > > > > > > > > -- > > > Flavio > > > > > > > > > -- > > Flavio > -- Flavio
