Mock Configuration Admin

Avatar

Avatar

Vabs95

Avatar

Vabs95

Vabs95

07-10-2019

Hi,

I am writing Unit Test Cases for Sling Models, I have a function that gets Configurations from ConfigurationAdmin.listConfiguration() method. I'm using Junit 5 and Aem Mock for testing. How can I mock "listConfiguration()" method since currently an exception is thrown "java.lang.UnsupportedOperationException";

I tried by using spy and return mocked object whenever this function is called but still I get the same error.

Replies

Avatar

Avatar

Theo_Pendle

MVP

Avatar

Theo_Pendle

MVP

Theo_Pendle
MVP

07-10-2019

Can you share your code please? So we don't have to guess

Avatar

Avatar

bhargavraj

Avatar

bhargavraj

bhargavraj

31-05-2020

bhargavraj_0-1590941131215.png

The ConfigurationAdmin object created throws exception on calling listConfigurations method as documented at https://github.com/apache/sling-org-apache-sling-testing-osgi-mock/blob/master/core/src/main/java/or...

 

How to mock configurations here?