Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ff26467b5c8d
Choose a base ref
...
head repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 38b5c239afaa
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Nov 11, 2013

  1. Fixing problem where some test was passing when run in eclipse but

    failing when run at command line - TRUNK-4134
    dkayiwa committed Nov 11, 2013
    Copy the full SHA
    f8479db View commit details
  2. Copy the full SHA
    38b5c23 View commit details
Showing with 37 additions and 9 deletions.
  1. +37 −9 api/src/test/java/org/openmrs/module/ModuleActivatorTest.java
46 changes: 37 additions & 9 deletions api/src/test/java/org/openmrs/module/ModuleActivatorTest.java
Original file line number Diff line number Diff line change
@@ -5,11 +5,8 @@
import org.junit.Before;
import org.junit.Test;
import org.openmrs.test.BaseContextSensitiveTest;
import org.openmrs.test.StartModule;
import org.springframework.context.support.GenericApplicationContext;

@StartModule( { "org/openmrs/module/include/test3-1.0-SNAPSHOT.omod", "org/openmrs/module/include/test1-1.0-SNAPSHOT.omod",
"org/openmrs/module/include/test2-1.0-SNAPSHOT.omod" })
public class ModuleActivatorTest extends BaseContextSensitiveTest {

private static final String MODULE1_ID = "test1";
@@ -18,17 +15,19 @@ public class ModuleActivatorTest extends BaseContextSensitiveTest {

private static final String MODULE3_ID = "test3";

ModuleTestData moduleTestData;
private ModuleTestData moduleTestData;

@Before
public void beforeEachTest() {
public void beforeEachTest() throws Exception {
moduleTestData = ModuleTestData.getInstance();

ModuleUtil.shutdown();

init();

ModuleFactory.startModule(ModuleFactory.getModuleById(MODULE1_ID));
ModuleFactory.startModule(ModuleFactory.getModuleById(MODULE2_ID));
ModuleFactory.startModule(ModuleFactory.getModuleById(MODULE3_ID));
String modulesToLoad = "org/openmrs/module/include/test3-1.0-SNAPSHOT.omod org/openmrs/module/include/test1-1.0-SNAPSHOT.omod org/openmrs/module/include/test2-1.0-SNAPSHOT.omod";
runtimeProperties.setProperty(ModuleConstants.RUNTIMEPROPERTY_MODULE_LIST_TO_LOAD, modulesToLoad);
ModuleUtil.startup(runtimeProperties);
}

@Test
@@ -94,6 +93,8 @@ public void shouldCallWillStopAndStoppedOnlyForStoppedModule() throws Exception
assertTrue(moduleTestData.getStoppedCallCount(MODULE3_ID) == 1);
assertTrue(moduleTestData.getStoppedCallCount(MODULE1_ID) == 0);
assertTrue(moduleTestData.getStoppedCallCount(MODULE2_ID) == 0);

//it should also have called willRefreshContext and contextRefreshed for the remaining modules
}

@Test
@@ -133,7 +134,34 @@ public void shouldCallWillStopAndStoppedOnShutdown() throws Exception {
assertTrue(moduleTestData.getWillStopCallTime(MODULE3_ID) <= moduleTestData.getStoppedCallTime(MODULE3_ID));
}

private void init() {
@Test
public void shouldExcludePrevouslyStoppedModules() {
//since module test2 depends on test1 and test3 depends on test2
//stopping test1 should also stop both modules test2 and test3
ModuleFactory.stopModule(ModuleFactory.getModuleById(MODULE3_ID));

//should have called willStop() for only modules test1, test2 and test3
assertTrue(moduleTestData.getWillStopCallCount(MODULE1_ID) == 0);
assertTrue(moduleTestData.getWillStopCallCount(MODULE2_ID) == 0);
assertTrue(moduleTestData.getWillStopCallCount(MODULE3_ID) == 1);

assertTrue(moduleTestData.getStoppedCallCount(MODULE1_ID) == 0);
assertTrue(moduleTestData.getStoppedCallCount(MODULE2_ID) == 0);
assertTrue(moduleTestData.getStoppedCallCount(MODULE3_ID) == 1);

ModuleUtil.shutdown();

//should have called stopped() for only modules test1, test2 and test3
assertTrue(moduleTestData.getStoppedCallCount(MODULE1_ID) == 1);
assertTrue(moduleTestData.getStoppedCallCount(MODULE2_ID) == 1);
assertTrue(moduleTestData.getStoppedCallCount(MODULE3_ID) == 1);

assertTrue(moduleTestData.getStoppedCallCount(MODULE1_ID) == 1);
assertTrue(moduleTestData.getStoppedCallCount(MODULE2_ID) == 1);
assertTrue(moduleTestData.getStoppedCallCount(MODULE3_ID) == 1);
}

public void init() {
moduleTestData.init(MODULE1_ID);
moduleTestData.init(MODULE2_ID);
moduleTestData.init(MODULE3_ID);