Skip to content

Commit ff12904

Browse files
authored
UIFR-222: Adding Java 17 Compatability (#76)
1 parent fe2f74c commit ff12904

8 files changed

Lines changed: 81 additions & 69 deletions

File tree

.github/workflows/maven.yml

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,54 @@
11
# this build is designed to replicate the Travis CI workflow
2-
name: Build with Maven
2+
name: Java CI with Maven
33

44
on:
55
push:
6-
branches: [ master ]
6+
branches: [ "master" ]
77
pull_request:
8-
branches: [ master ]
9-
workflow_dispatch:
8+
branches: [ "master" ]
109

1110
jobs:
12-
build:
13-
strategy:
14-
matrix:
15-
platform: [ ubuntu-latest ]
16-
java-version: [ 8 ]
11+
java-8:
1712

18-
runs-on: ${{ matrix.platform }}
19-
env:
20-
PLATFORM: ${{ matrix.platform }}
21-
JAVA_VERSION: ${{ matrix.java-version }}
13+
runs-on: ubuntu-latest
2214

2315
steps:
24-
- uses: actions/checkout@v2
25-
- name: Set up JDK
26-
uses: actions/setup-java@v1
16+
- uses: actions/checkout@v3
17+
- name: Set up JDK 8
18+
uses: actions/setup-java@v3
2719
with:
28-
java-version: ${{ matrix.java-version }}
29-
- name: Cache local Maven repository
30-
uses: actions/cache@v2
20+
java-version: '8'
21+
distribution: 'adopt'
22+
cache: maven
23+
- name: Build with Maven
24+
run: mvn clean install --file pom.xml
25+
26+
java-11:
27+
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
- uses: actions/checkout@v3
32+
- name: Set up JDK 11
33+
uses: actions/setup-java@v3
3134
with:
32-
path: ~/.m2/repository
33-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
34-
restore-keys: |
35-
${{ runner.os }}-maven-
36-
- name: Install dependencies
37-
run: mvn clean install -DskipTests=true -Dmaven.javadoc.skip=true --batch-mode --show-version --file pom.xml
35+
java-version: '11'
36+
distribution: 'adopt'
37+
cache: maven
3838
- name: Build with Maven
39-
run: mvn test --batch-mode --file pom.xml
39+
run: mvn clean install --file pom.xml
4040

41+
java-17:
42+
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
- uses: actions/checkout@v3
47+
- name: Set up JDK 17
48+
uses: actions/setup-java@v3
49+
with:
50+
java-version: '17'
51+
distribution: 'adopt'
52+
cache: maven
53+
- name: Build with Maven
54+
run: mvn clean install --file pom.xml

api/src/main/java/org/openmrs/ui/framework/NameSupportCompatibility.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import org.apache.commons.logging.Log;
44
import org.apache.commons.logging.LogFactory;
55
import org.openmrs.PersonName;
6-
import org.openmrs.layout.web.name.NameSupport;
6+
import org.openmrs.layout.name.NameSupport;
77
import org.openmrs.util.OpenmrsClassLoader;
88

99
import java.lang.reflect.Method;

api/src/main/java/org/openmrs/ui/framework/converter/StringToPatientProblemConverter.java

Lines changed: 0 additions & 17 deletions
This file was deleted.

api/src/test/java/org/openmrs/ui/framework/FormatterImplTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public void testFormattingConceptNumeric() throws Exception {
194194
ConceptDatatype numericDatatype = new ConceptDatatype();
195195
numericDatatype.setHl7Abbreviation("NM");
196196
conceptNumeric.setDatatype(numericDatatype);
197-
conceptNumeric.setPrecise(true);
197+
conceptNumeric.setAllowDecimal(true);
198198

199199
Obs numericObs = new Obs();
200200
numericObs.setConcept(conceptNumeric);
@@ -214,7 +214,7 @@ public void testFormattingConceptNumeric_shouldNotFailIfNoUnits() throws Excepti
214214
ConceptDatatype numericDatatype = new ConceptDatatype();
215215
numericDatatype.setHl7Abbreviation("NM");
216216
conceptNumeric.setDatatype(numericDatatype);
217-
conceptNumeric.setPrecise(true);
217+
conceptNumeric.setAllowDecimal(true);
218218

219219
Obs numericObs = new Obs();
220220
numericObs.setConcept(conceptNumeric);

api/src/test/java/org/openmrs/ui/framework/SimpleObjectTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.openmrs.ui.framework.formatter.FormatterService;
1212
import org.openmrs.ui.framework.fragment.FragmentActionUiUtils;
1313
import org.springframework.context.MessageSource;
14-
import org.springframework.test.annotation.DirtiesContext;
1514

1615
import java.util.Map;
1716

@@ -20,7 +19,6 @@
2019
import static org.mockito.Mockito.mock;
2120
import static org.mockito.Mockito.when;
2221

23-
@DirtiesContext
2422
public class SimpleObjectTest {
2523

2624
private UiUtils ui;

api/src/test/java/org/openmrs/ui/framework/converter/StringToGlobalPropertyConverterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class StringToGlobalPropertyConverterTest extends BaseModuleContextSensit
1111
public void convert_shouldConvertStringToGlobalProperty() {
1212
StringToGlobalPropertyConverter converter = new StringToGlobalPropertyConverter();
1313
GlobalProperty prop = converter.convert("locale.allowed.list");
14-
Assert.assertEquals("en", prop.getPropertyValue());
14+
Assert.assertEquals("en_GB", prop.getPropertyValue());
1515
}
1616

1717
@Test

api/src/test/java/org/openmrs/ui/framework/formatter/FormatterServiceTest.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.springframework.beans.factory.annotation.Autowired;
1010
import org.springframework.context.MessageSource;
1111
import org.springframework.core.Ordered;
12-
import org.springframework.test.annotation.DirtiesContext;
1312

1413
import java.util.Locale;
1514

@@ -24,7 +23,6 @@ public class FormatterServiceTest extends BaseModuleContextSensitiveTest {
2423
private FormatterService formatterService;
2524

2625
@Test
27-
@DirtiesContext
2826
public void testFormatting() throws Exception {
2927
HandlebarsFormatterFactory classFormatter = new HandlebarsFormatterFactory();
3028
classFormatter.setForClass("org.openmrs.Obs");
@@ -49,25 +47,23 @@ public String toString() {
4947
}
5048

5149
@Test
52-
@DirtiesContext
5350
public void testMessage() throws Exception {
5451
MessageSource messageSource = mock(MessageSource.class);
55-
52+
FormatterService messageFormatterService = new FormatterService();
53+
messageFormatterService.setMessageSource(messageSource);
5654
HandlebarsFormatterFactory classFormatter = new HandlebarsFormatterFactory();
5755
classFormatter.setForClass("org.openmrs.Obs");
5856
classFormatter.setTemplate("{{ message 'testing.123.testing' }} something");
59-
formatterService.addClassFormatter(classFormatter);
57+
messageFormatterService.addClassFormatter(classFormatter);
6058

6159
Context.setLocale(Locale.ENGLISH);
62-
Formatter formatter = formatterService.getFormatter();
63-
formatterService.setMessageSource(messageSource);
60+
Formatter formatter = messageFormatterService.getFormatter();
6461

65-
String result = formatter.format(new Obs(), Locale.ENGLISH);
62+
formatter.format(new Obs(), Locale.ENGLISH);
6663
verify(messageSource).getMessage("testing.123.testing", null, Locale.ENGLISH);
6764
}
6865

6966
@Test
70-
@DirtiesContext
7167
public void testOrder() throws Exception {
7268
HandlebarsFormatterFactory wrongFormatter1 = new HandlebarsFormatterFactory();
7369
wrongFormatter1.setForClass("org.openmrs.Obs");

pom.xml

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,13 @@
4343
</modules>
4444

4545
<properties>
46-
<openmrsPlatformVersion>1.9.9</openmrsPlatformVersion>
47-
<springVersion>3.0.5.RELEASE</springVersion>
46+
<openmrsPlatformVersion>2.0.0</openmrsPlatformVersion>
47+
<springVersion>4.1.4.RELEASE</springVersion>
4848
<handlebarsVersion>1.3.1</handlebarsVersion>
4949
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5050
</properties>
5151

5252
<dependencies>
53-
<dependency>
54-
<groupId>org.mockito</groupId>
55-
<artifactId>mockito-all</artifactId>
56-
<version>1.9.0</version>
57-
<scope>test</scope>
58-
</dependency>
5953
<dependency>
6054
<groupId>org.hamcrest</groupId>
6155
<artifactId>hamcrest-all</artifactId>
@@ -78,6 +72,12 @@
7872
<artifactId>joda-convert</artifactId>
7973
<version>1.2</version>
8074
</dependency>
75+
<dependency>
76+
<groupId>com.thoughtworks.xstream</groupId>
77+
<artifactId>xstream</artifactId>
78+
<version>1.4.20</version>
79+
<scope>test</scope>
80+
</dependency>
8181
</dependencies>
8282

8383
<dependencyManagement>
@@ -229,8 +229,8 @@
229229
<groupId>org.apache.maven.plugins</groupId>
230230
<artifactId>maven-compiler-plugin</artifactId>
231231
<configuration>
232-
<target>1.6</target>
233-
<source>1.6</source>
232+
<target>1.7</target>
233+
<source>1.7</source>
234234
</configuration>
235235
</plugin>
236236
<plugin>
@@ -262,7 +262,7 @@
262262
<artifactId>maven-surefire-plugin</artifactId>
263263
<version>2.22.1</version>
264264
<configuration>
265-
<argLine>-Xmx512m -XX:MaxPermSize=512m -Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
265+
<argLine>-Xmx512m -Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
266266
</configuration>
267267
</plugin>
268268
</plugins>
@@ -306,4 +306,25 @@
306306
</snapshotRepository>
307307
</distributionManagement>
308308

309+
<profiles>
310+
<profile>
311+
<id>Java 17</id>
312+
<activation>
313+
<jdk>17</jdk>
314+
</activation>
315+
<build>
316+
<plugins>
317+
<plugin>
318+
<groupId>org.apache.maven.plugins</groupId>
319+
<artifactId>maven-surefire-plugin</artifactId>
320+
<version>3.2.2</version>
321+
<configuration>
322+
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
323+
</configuration>
324+
</plugin>
325+
</plugins>
326+
</build>
327+
</profile>
328+
</profiles>
329+
309330
</project>

0 commit comments

Comments
 (0)