GSoC 2020 : Upgrade Platform Core Libraries Project

Let us back up for a second and consider whether or not this ticket is actually a good idea. The webservices.rest module is pretty unique in that it supports a large number of OpenMRS versions with version-specific code. That means that each submodule ends up depending on a different version of OpenMRS core than any other submodule.

The upshot of this is that the unit tests for each submodule of webservices.rest depend on a specific version of OpenMRS with their own versions of Mockito, Hamcrest, JUnit, PowerMock, etc. So I think we’re fundamentally going to be doing the wrong thing by trying to keep a single version of the test framework that works across all submodules. Instead, what we need to do is to ensure that every submodule depends on the right version of the test classes provided by the relevant version of OpenMRS. So, for instance, the omod-1.10 version should depend on the version of the test modules bundled with OpenMRS 1.10.

That sounds like a lot of work, but it’s actually already done for us with POM entries like this (taken from the pom.xml file for omod-1.10:

<dependency>
	<groupId>org.openmrs.test</groupId>
	<artifactId>openmrs-test</artifactId>
	<type>pom</type>
	<version>${openmrs.version.1.10}</version>
</dependency>

What this does is import the dependencies and version information from the 1.10.4 version of the org.openmrs.test.openmrs-test artifact, which are defined here. This implicitly includes the versions of JUnit and Mockito that were installed for OpenMRS 1.10.4, as defined in the main pom here. So, by relying solely on importing these dependencies from a specific version of OpenMRS, we ensure each module has a consistent set of test dependencies that don’t interfere with one another. In this particular case, it means that omod-1.10 will be tested with JUnit 4.11 and PowerMock 1.5.

So, rather than try to find a magical combination of these dependencies that will work for all versions of OpenMRS (which is unlikely to be found), we should simply switch things so that the webservices.rest module does not specify any versions of JUnit, Hamcrest, Mockito, etc. In other words, I think that instead of upgrading these libraries, we should instead remove the definitions for the JUnit, Hamcrest and Mockito artifacts from the main pom.xml and remove the lines which explicitly add these dependencies to every submodule of webservices.rest.

On my local machine, when I delete lines 108-132 and 169-187, everything builds successfully. This does mean that only tests located in the omod-2.4 subdirectory will use the newest testing framework, but I actually think that’s the desired behaviour.

I hope what I’ve said above is clear. I’m sorry for all the text.

2 Likes