Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a unit test for: ModuleActivator.started()/.contextRefreshed()
not called when module is stopped/restarted or newly uploaded - TRUNK-4134
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,4 +84,37 @@ public void shouldRefreshOtherModulesOnStoppingModule() { | |
assertTrue(moduleTestData.getContextRefreshedCallCount(MODULE1_ID) == 1); | ||
assertTrue(moduleTestData.getContextRefreshedCallCount(MODULE2_ID) == 1); | ||
} | ||
|
||
@Test | ||
@NotTransactional | ||
public void shouldRefreshOtherModulesOnStartingStoppedModule() { | ||
Module module = ModuleFactory.getModuleById(MODULE3_ID); | ||
ModuleFactory.stopModule(module); | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dkayiwa
Author
Member
|
||
init(); //to initialize for the condition below: | ||
|
||
//When OpenMRS is running and you start a stopped module: | ||
// willRefreshContext() and contextRefreshed() methods get called for all started modules' activators (including the newly started module) | ||
// started() method gets called for ONLY the newly started module's activator | ||
|
||
//start module3 which was previously stopped | ||
ModuleFactory.startModule(module); | ||
WebModuleUtil.startModule(module, ((XmlWebApplicationContext) applicationContext).getServletContext(), false); | ||
|
||
assertTrue(module.isStarted()); | ||
assertTrue(ModuleFactory.isModuleStarted(module)); | ||
|
||
//module1, module2 and module3 should refresh | ||
assertTrue(moduleTestData.getWillRefreshContextCallCount(MODULE1_ID) == 1); | ||
assertTrue(moduleTestData.getWillRefreshContextCallCount(MODULE2_ID) == 1); | ||
assertTrue(moduleTestData.getWillRefreshContextCallCount(MODULE3_ID) == 1); | ||
assertTrue(moduleTestData.getContextRefreshedCallCount(MODULE1_ID) == 1); | ||
assertTrue(moduleTestData.getContextRefreshedCallCount(MODULE2_ID) == 1); | ||
assertTrue(moduleTestData.getContextRefreshedCallCount(MODULE3_ID) == 1); | ||
|
||
//started() method gets called for ONLY the newly started module's activator | ||
assertTrue(moduleTestData.getStartedCallCount(MODULE1_ID) == 0); | ||
assertTrue(moduleTestData.getStartedCallCount(MODULE2_ID) == 0); | ||
assertTrue(moduleTestData.getStartedCallCount(MODULE3_ID) == 1); | ||
} | ||
} |
I feel that calling init() spoils the test here, you shouldn't have to reset things within the same test since other activator methods have been called, aren't you supposed to be testing against the call count instead?