Skip to content

Commit 0d1b89a

Browse files
committedNov 13, 2013
Adding test to ensure that willStop() and stopped() are called when a
module is unloaded - TRUNK-4134
1 parent f613499 commit 0d1b89a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
 

‎api/src/test/java/org/openmrs/module/ModuleActivatorTest.java

+16
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,20 @@ public void shouldExcludePrevouslyStoppedModulesOnShutdown() {
155155
assertTrue(moduleTestData.getStoppedCallCount(MODULE2_ID) == 1);
156156
assertTrue(moduleTestData.getStoppedCallCount(MODULE3_ID) == 1);
157157
}
158+
159+
@Test
160+
public void shouldCallWillStopAndStoppedOnUnloadModule() throws Exception {
161+
162+
ModuleFactory.unloadModule(ModuleFactory.getModuleById(MODULE3_ID));
163+
164+
//should have called willStop() and stopped() for module3
165+
assertTrue(moduleTestData.getWillStopCallCount(MODULE3_ID) == 1);
166+
assertTrue(moduleTestData.getStoppedCallCount(MODULE3_ID) == 1);
167+
168+
//should not call willStop() and stopped() for module1 and module2
169+
assertTrue(moduleTestData.getWillStopCallCount(MODULE1_ID) == 0);
170+
assertTrue(moduleTestData.getWillStopCallCount(MODULE2_ID) == 0);
171+
assertTrue(moduleTestData.getStoppedCallCount(MODULE1_ID) == 0);
172+
assertTrue(moduleTestData.getStoppedCallCount(MODULE2_ID) == 0);
173+
}
158174
}

0 commit comments

Comments
 (0)
Please sign in to comment.