user1924127
user1924127

Reputation:

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 !!!

Upvotes: 1

Views: 2743

Answers (2)

alain.janinm
alain.janinm

Reputation: 20065

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.

Upvotes: 1

mkysoft
mkysoft

Reputation: 5758

Firstly it is not good way to making test while customer buying somethings on same or pre-prod server. Tenant is different concept rather than spring for hybris. hybris tenant is using multiple database-schema for same code base. You can run multiple hybris on same db with tenant. One of them is junit tenant for making test. hybris not rollback/reset db changes on junit. You need to initialize it look like normal tenant in hac or with ant.

  • You need to manually manage test data in unit test.

  • You can run test with ant or front end after start at url https://localhost:9002/test

hybris junit test documentation here.

Upvotes: 0

Related Questions