-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UIFR-222: Adding Java 17 Compatability #76
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.MessageSource; | ||
import org.springframework.core.Ordered; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
|
||
import java.util.Locale; | ||
|
||
|
@@ -24,7 +23,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"); | ||
|
@@ -49,25 +47,23 @@ public String toString() { | |
} | ||
|
||
@Test | ||
@DirtiesContext | ||
public void testMessage() throws Exception { | ||
MessageSource messageSource = mock(MessageSource.class); | ||
|
||
FormatterService messageFormatterService = new FormatterService(); | ||
messageFormatterService.setMessageSource(messageSource); | ||
HandlebarsFormatterFactory classFormatter = new HandlebarsFormatterFactory(); | ||
classFormatter.setForClass("org.openmrs.Obs"); | ||
classFormatter.setTemplate("{{ message 'testing.123.testing' }} something"); | ||
formatterService.addClassFormatter(classFormatter); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you get rid of the above? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't. I just changed the variable. From There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not easy to tell what exactly changed or what was necessary to make the test pass. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error I mentioned above happens because of the test leakage from the formatterService. That's why I added the method variable for it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain more what you mean by the test leackage? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we removed @DirtiesContext, changes happen to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes perfect sense! Thanks for catching that. 👍 |
||
messageFormatterService.addClassFormatter(classFormatter); | ||
|
||
Context.setLocale(Locale.ENGLISH); | ||
Formatter formatter = formatterService.getFormatter(); | ||
formatterService.setMessageSource(messageSource); | ||
Formatter formatter = messageFormatterService.getFormatter(); | ||
|
||
String result = formatter.format(new Obs(), Locale.ENGLISH); | ||
formatter.format(new Obs(), Locale.ENGLISH); | ||
verify(messageSource).getMessage("testing.123.testing", null, Locale.ENGLISH); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these really the same? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this, I got an error. So that's why I changed the test.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test was verifying that this method is invoked, and with those exact parameters. Does your change do the same? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just noticed the old test passes when run individually. It only fails when running with the other test cases. Could it be caused because I removed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Of course you can always test and confirm your theory without first seeking permission from me. 😊 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I fixed the issue. |
||
} | ||
|
||
@Test | ||
@DirtiesContext | ||
public void testOrder() throws Exception { | ||
HandlebarsFormatterFactory wrongFormatter1 = new HandlebarsFormatterFactory(); | ||
wrongFormatter1.setForClass("org.openmrs.Obs"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
|
@@ -78,6 +72,12 @@ | |
<artifactId>joda-convert</artifactId> | ||
<version>1.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.thoughtworks.xstream</groupId> | ||
<artifactId>xstream</artifactId> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you intentionally leave out scope? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added the scope |
||
<version>1.4.20</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<dependencyManagement> | ||
|
@@ -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> | ||
|
@@ -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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this change also needed by the tests to pass? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can keep this. Should I revert this? |
||
<argLine>-Xmx512m -Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
|
@@ -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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you change this accidentally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After updating to platform 2.0.0 this test failed with the following error:
That's why I updated the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. That makes sense. 😊