Search code examples
springintegration-testingsap-commerce-cloudapplicationcontext

How Hybris is managing Application Contexts between the application and integration tests


I am currently new to Hybris and I am writing integration tests, which is awesome however it is hard for me to understand the concept of junit tenant and how Hybris is managing the application context for that tenant.

I come from a spring background, and there I can say it was easy to load a separate test configuration or any configuration, and just to test it without affecting the main run time application context that is used lets say for debugging at the same time.

However in Hybris, I am kind of confused because while the server is running you can easily swap between tenants and execute integration test at the same time when lets say some user is buying something.

Does Hybris has separate application context for junit and master tenant ? And regardless of yes or no, how is Hybris managing the application contexts between tenants ?

I first encounter this problem when I was declaring the ehCacheManager bean, and suddenly all my tests started to fail - something that the cache is in SHUTDOWN mode ... which was strange.

Is the application context shared between tenants ? Is it shared between two separate integration tests ? Is it destroyed after one test, then created for another integration test ?

I know that some of this questions might seems confusing or even stupid, but I will be glad if someone can explain me how hybris is managing the application context between tenant and tests, furthermore I will be really grateful if you can share some resources or books on this topic.

Thanks in advance !!!


Solution

  • Does Hybris has separate application context for junit and master tenant ? And regardless of yes or no, how is Hybris managing the application contexts between tenants ?

    Yes, please find below a scheme representing it (source SAP : https://help.hybris.com/1811/hcd/8c63621986691014a7e0a18695d7d410.html Cf. Figure: Hierarchy of Application Contexts.). enter image description here

    Not that in your case junit is what we call a "slave" tenant.

    Is the application context shared between tenants ? Is it shared between two separate integration tests ? Is it destroyed after one test, then created for another integration test ?

    As you can see in the scheme, the global application context is shared but web (case of ehCacheManager I think) and core application context are not shared. These don't change when you run tests.