Skip to content

Commit

Permalink
UIFR-222: Adding Java 17 Compatability
Browse files Browse the repository at this point in the history
  • Loading branch information
wikumChamith committed Dec 4, 2023
1 parent fe2f74c commit 5a0ee4b
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 64 deletions.
39 changes: 39 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!--- Add a pull request title above in this format -->
<!--- real example: 'UIFR-222 Remove concept property setters from ObsResource classes' -->
<!--- 'UIFR-JiraIssueNumber JiraIssueTitle' -->
## Description of what I changed
<!--- Describe your changes in detail -->
<!--- It can simply be your commit message, which you must have -->


## Issue I worked on
<!--- This project only accepts pull requests related to open issues -->
<!--- Want a new feature or change? Discuss it in an issue first -->
<!--- Found a bug? Point us to the issue/or create one so we can reproduce it -->
<!--- Just add the issue number at the end: -->
see https://openmrs.atlassian.net/browse/UIFR-

## Checklist: I completed these to help reviewers :)
<!--- Put an `x` in the box if you did the task -->
<!--- If you forgot a task please follow the instructions below -->
- [ ] My IDE is configured to follow the [**code style**](https://wiki.openmrs.org/display/docs/Java+Conventions) of this project.

No? Unsure? -> [configure your IDE](https://wiki.openmrs.org/display/docs/How-To+Setup+And+Use+Your+IDE), format the code and add the changes with `git add . && git commit --amend`

- [ ] I have **added tests** to cover my changes. (If you refactored
existing code that was well tested you do not have to add tests)

No? -> write tests and add them to this commit `git add . && git commit --amend`

- [ ] I ran `mvn clean package` right before creating this pull request and
added all formatting changes to my commit.

No? -> execute above command

- [ ] All new and existing **tests passed**.

No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.

- [ ] My pull request is **based on the latest changes** of the master branch.

No? Unsure? -> execute command `git pull --rebase upstream master`
66 changes: 40 additions & 26 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,54 @@
# this build is designed to replicate the Travis CI workflow
name: Build with Maven
name: Java CI with Maven

on:
push:
branches: [ master ]
branches: [ "master" ]
pull_request:
branches: [ master ]
workflow_dispatch:
branches: [ "master" ]

jobs:
build:
strategy:
matrix:
platform: [ ubuntu-latest ]
java-version: [ 8 ]
java-8:

runs-on: ${{ matrix.platform }}
env:
PLATFORM: ${{ matrix.platform }}
JAVA_VERSION: ${{ matrix.java-version }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
- uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
- name: Cache local Maven repository
uses: actions/cache@v2
java-version: '8'
distribution: 'adopt'
cache: maven
- name: Build with Maven
run: mvn clean install --file pom.xml

java-11:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Install dependencies
run: mvn clean install -DskipTests=true -Dmaven.javadoc.skip=true --batch-mode --show-version --file pom.xml
java-version: '11'
distribution: 'adopt'
cache: maven
- name: Build with Maven
run: mvn test --batch-mode --file pom.xml
run: mvn clean install --file pom.xml

java-17:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
cache: maven
- name: Build with Maven
run: mvn clean install --file pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.PersonName;
import org.openmrs.layout.web.name.NameSupport;
import org.openmrs.layout.name.NameSupport;
import org.openmrs.util.OpenmrsClassLoader;

import java.lang.reflect.Method;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public void testFormattingConceptNumeric() throws Exception {
ConceptDatatype numericDatatype = new ConceptDatatype();
numericDatatype.setHl7Abbreviation("NM");
conceptNumeric.setDatatype(numericDatatype);
conceptNumeric.setPrecise(true);
conceptNumeric.setAllowDecimal(true);

Obs numericObs = new Obs();
numericObs.setConcept(conceptNumeric);
Expand All @@ -214,7 +214,7 @@ public void testFormattingConceptNumeric_shouldNotFailIfNoUnits() throws Excepti
ConceptDatatype numericDatatype = new ConceptDatatype();
numericDatatype.setHl7Abbreviation("NM");
conceptNumeric.setDatatype(numericDatatype);
conceptNumeric.setPrecise(true);
conceptNumeric.setAllowDecimal(true);

Obs numericObs = new Obs();
numericObs.setConcept(conceptNumeric);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@DirtiesContext
public class SimpleObjectTest {

private UiUtils ui;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class StringToGlobalPropertyConverterTest extends BaseModuleContextSensit
public void convert_shouldConvertStringToGlobalProperty() {
StringToGlobalPropertyConverter converter = new StringToGlobalPropertyConverter();
GlobalProperty prop = converter.convert("locale.allowed.list");
Assert.assertEquals("en", prop.getPropertyValue());
Assert.assertEquals("en_GB", prop.getPropertyValue());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.openmrs.api.context.Context;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.openmrs.ui.framework.Formatter;
import org.openmrs.ui.framework.MockMessageSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.core.Ordered;
Expand All @@ -24,7 +25,6 @@ public class FormatterServiceTest extends BaseModuleContextSensitiveTest {
private FormatterService formatterService;

@Test
@DirtiesContext
public void testFormatting() throws Exception {
HandlebarsFormatterFactory classFormatter = new HandlebarsFormatterFactory();
classFormatter.setForClass("org.openmrs.Obs");
Expand All @@ -49,9 +49,8 @@ public String toString() {
}

@Test
@DirtiesContext
public void testMessage() throws Exception {
MessageSource messageSource = mock(MessageSource.class);
MessageSource messageSource = new MockMessageSource();

HandlebarsFormatterFactory classFormatter = new HandlebarsFormatterFactory();
classFormatter.setForClass("org.openmrs.Obs");
Expand All @@ -63,11 +62,10 @@ public void testMessage() throws Exception {
formatterService.setMessageSource(messageSource);

String result = formatter.format(new Obs(), Locale.ENGLISH);
verify(messageSource).getMessage("testing.123.testing", null, Locale.ENGLISH);
assertThat(messageSource.getMessage("testing.123.testing", null, Locale.ENGLISH), is("testing.123.testing"));
}

@Test
@DirtiesContext
public void testOrder() throws Exception {
HandlebarsFormatterFactory wrongFormatter1 = new HandlebarsFormatterFactory();
wrongFormatter1.setForClass("org.openmrs.Obs");
Expand Down
43 changes: 32 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,13 @@
</modules>

<properties>
<openmrsPlatformVersion>1.9.9</openmrsPlatformVersion>
<springVersion>3.0.5.RELEASE</springVersion>
<openmrsPlatformVersion>2.0.0</openmrsPlatformVersion>
<springVersion>4.1.4.RELEASE</springVersion>
<handlebarsVersion>1.3.1</handlebarsVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
Expand All @@ -78,6 +72,12 @@
<artifactId>joda-convert</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.20</version>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
Expand Down Expand Up @@ -229,8 +229,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<target>1.6</target>
<source>1.6</source>
<target>1.7</target>
<source>1.7</source>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -262,7 +262,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<argLine>-Xmx512m -XX:MaxPermSize=512m -Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
<argLine>-Xmx512m -Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
</configuration>
</plugin>
</plugins>
Expand Down Expand Up @@ -306,4 +306,25 @@
</snapshotRepository>
</distributionManagement>

<profiles>
<profile>
<id>Java 17</id>
<activation>
<jdk>17</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>

0 comments on commit 5a0ee4b

Please sign in to comment.