Skip to content

Commit

Permalink
Adding test to ensure that willStop() and stopped() are called when a
Browse files Browse the repository at this point in the history
module is unloaded - TRUNK-4134
  • Loading branch information
dkayiwa committed Nov 13, 2013
1 parent f613499 commit 0d1b89a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions api/src/test/java/org/openmrs/module/ModuleActivatorTest.java
Expand Up @@ -155,4 +155,20 @@ public void shouldExcludePrevouslyStoppedModulesOnShutdown() {
assertTrue(moduleTestData.getStoppedCallCount(MODULE2_ID) == 1);
assertTrue(moduleTestData.getStoppedCallCount(MODULE3_ID) == 1);
}

@Test
public void shouldCallWillStopAndStoppedOnUnloadModule() throws Exception {

ModuleFactory.unloadModule(ModuleFactory.getModuleById(MODULE3_ID));

//should have called willStop() and stopped() for module3
assertTrue(moduleTestData.getWillStopCallCount(MODULE3_ID) == 1);
assertTrue(moduleTestData.getStoppedCallCount(MODULE3_ID) == 1);

//should not call willStop() and stopped() for module1 and module2
assertTrue(moduleTestData.getWillStopCallCount(MODULE1_ID) == 0);
assertTrue(moduleTestData.getWillStopCallCount(MODULE2_ID) == 0);
assertTrue(moduleTestData.getStoppedCallCount(MODULE1_ID) == 0);
assertTrue(moduleTestData.getStoppedCallCount(MODULE2_ID) == 0);
}
}

0 comments on commit 0d1b89a

Please sign in to comment.