meta data for this page
This is an old revision of the document!
SystemSetup Annotation: When are the methods run?
The SystemSetup annotation is used to run import data, synchronize catalogues, migrate CMS components and execute Java code during every project or essential data creation step.
In past versions the essential and project data steps weren't run during the initialization of the junit tenant. This prevented the import of test data for the integration tests if you weren't using the Areco deployment script manager as patch system. To get an updated picture of the current situation, I ran a test on the latest SAP hybris versions and here are the results:
SystemSetup.Process | INIT | UPDATE | ALL | |||||||
---|---|---|---|---|---|---|---|---|---|---|
SystemSetup.Type | ESSENTIAL | PROJECT | ALL | ESSENTIAL | PROJECT | ALL | ESSENTIAL | PROJECT | ALL | |
ant initialize -Dtenant=master | ||||||||||
ant initialize -Dtenant=junit | ||||||||||
ant yunitinit | ||||||||||
ant updatesystem -Dtenant=master1) | ||||||||||
ant updatesystem -Dtenant=junit2) | ||||||||||
On HAC, initialize of the master tenant | ||||||||||
On HAC, initialize of the master yunit | ||||||||||
On HAC, update running system of the master tenant | ||||||||||
On HAC, update running system of the master yunit |
Test description
I created a new extension based on the templa yempty and added the property “initialpassword.admin=nimda” to the local.properies. Then I create a class for the test and annotated at class level with:
@SystemSetup(extension = "ALL_EXTENSIONS") public class SystemSetupAnnotationCallsTest {
Each method contains the following code for all possible combinations of process and type:
@SystemSetup(process = SystemSetup.Process.UPDATE, type = SystemSetup.Type.ESSENTIAL) public void logUpdateEssential(final SystemSetupContext hybrisContext) { LOG.error(String.format("Called Update Essential with extension %s, process %s and type %s", hybrisContext.getExtensionName(), hybrisContext.getProcess(), hybrisContext.getType())); }
To make hybris call the methods, I had to create a bean definition in the spring application context. Autowiring without the XML bean definition wasn't working.
I ran all ant commands and process on HAC and I analysed the log afterwards:
ant initialize -Dtenant=master | tee initializeMaster.log | grep SystemSetupAnnotationCallsTest
– Based on SAP hybris 1905
Discussion