Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!

Junit Servlet Test Using non-mocked com.adobe.granite.crypto.CryptoSupport Service

Avatar

Level 2

Hi,

 

I ve got a Servlet, which is expecting a token, which is encrypted by AEM CryptoSupport Service.

In my TestCases for that Servlet I would like to be able to dynamically create tokens which I can pass to the servlet method.

So far I ve only found examples using a mocked CryptoSupport Service, but actually I would like to actually use the real one.

Can I somehow create an instance of CryptoSupport in my Test Class ?

Thanks a lot for your support in advance.

 

--

Volker

2 Replies

Avatar

Community Advisor

Hi, 

Short answer: No. The project from wcm.io is the main mocking framework for AEM. If needed, you can examine how some of those objects are implemented to create something similar for the CryptoSupportService. But conceptually, it is acceptable not to use the real CryptoSupportService because you are not testing its functionality (what it does internally). That's the scope of a unit test.

Hope this helps.



Esteban Bustamante

Avatar

Level 2

Hi,

thanks a lot for your response.

Conceptually, I think that is a severe limitation of Adobe Servlet Testing.
A Servlet is exposing a kind of API/Contract with the "external" world and I would like to test if that contract is fulfilled by my application.
Adobe SaaS is part of my application, I only treat Third Party systems as "external" and to be mocked in Servlet tests.

But anyway it is like it is.


--
Volker