Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Runtime error while running JUnit5 AEM Mocks test

prateekkumar
Level 2
Level 2

Hi all,

 

I am trying to use JUnit 5 AEM Mocks(wcm.io) in our existing AEM project. I have included all the required dependencies and there are no compilation errors. However, I get the below error when I try to run my test. Has anyone seen this error and how did you manage to fix it?

 

java.lang.RuntimeException: Bind method with name bindEventAdmin not found for reference 'eventAdmin' for class org.apache.sling.testing.mock.sling.MockAdapterManagerImpl
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeBindUnbindMethod(OsgiServiceUtil.java:717)
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.injectServiceReference(OsgiServiceUtil.java:646)

 

Thanks!

1 Accepted Solution
Asutosh_Jena_
Correct answer by
Community Advisor
Community Advisor

Hi @prateekkumar 

 

It looks like you have a dependency version mismatch.

 

1. put your aem-mock test dependencies first, and the uber jar AEM dependencies last in your project

2. import the dependendencies matching to the AEM version you compila against from the dependencies poms listed here http://wcm.io/tooling/maven/aem-dependencies.html

 

This will not only includes the matching uber jar, but also the versions of some sling implementation bundles required by sling mock and aem mock, matching those of the AEM version you are using.

View solution in original post

1 Reply
Asutosh_Jena_
Correct answer by
Community Advisor
Community Advisor

Hi @prateekkumar 

 

It looks like you have a dependency version mismatch.

 

1. put your aem-mock test dependencies first, and the uber jar AEM dependencies last in your project

2. import the dependendencies matching to the AEM version you compila against from the dependencies poms listed here http://wcm.io/tooling/maven/aem-dependencies.html

 

This will not only includes the matching uber jar, but also the versions of some sling implementation bundles required by sling mock and aem mock, matching those of the AEM version you are using.

View solution in original post