-
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
Conversation
@@ -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()); |
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:
junit.framework.ComparisonFailure: expected:<en[]> but was:<en[_GB]>
at org.openmrs.ui.framework.converter.StringToGlobalPropertyConverterTest.convert_shouldConvertStringToGlobalProperty
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. 😊
|
||
<dependency> | ||
<groupId>com.thoughtworks.xstream</groupId> | ||
<artifactId>xstream</artifactId> |
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 intentionally leave out scope?
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.
I added the scope
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can keep this. Should I revert this?
.github/PULL_REQUEST_TEMPLATE.md
Outdated
@@ -0,0 +1,39 @@ | |||
<!--- Add a pull request title above in this format --> | |||
<!--- real example: 'RESTWS-738 Remove concept property setters from ObsResource classes' --> | |||
<!--- 'RESTWS-JiraIssueNumber JiraIssueTitle' --> |
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.
Was this also part of the changes needed to make it compile on Java 17?
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.
I tried to kill two birds with one stone :)
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 get a chance to look at this? https://opensource.com/article/18/6/anatomy-perfect-pull-request
43830ce
to
5a0ee4b
Compare
@@ -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); |
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.
Are these really the same?
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.
With this, I got an error. So that's why I changed the test.
[ERROR] org.openmrs.ui.framework.formatter.FormatterServiceTest.testMessage -- Time elapsed: 0.021 s <<< FAILURE!
Wanted but not invoked:
messageSource.getMessage(
"testing.123.testing",
null,
en
);
-> at org.openmrs.ui.framework.formatter.FormatterServiceTest.testMessage(FormatterServiceTest.java:65)
Actually, there were zero interactions with this mock.
at org.openmrs.ui.framework.formatter.FormatterServiceTest.testMessage(FormatterServiceTest.java:65)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:73)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:73)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:217)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:83)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:68)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:163)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:316)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:240)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:214)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
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.
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 comment
The 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 @DirtiesContext
?
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed the issue.
.github/PULL_REQUEST_TEMPLATE.md
Outdated
|
||
## 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 --> |
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.
Is this also required for the Java 17 compatibility?
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.
I removed this
d1767d2
to
a62eff0
Compare
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't. I just changed the variable. From formatterService
to messageFormatService
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.
It is not easy to tell what exactly changed or what was necessary to make the test pass.
For instance, why do we now instantiate the message format service like FormatterService messageFormatterService = new FormatterService()
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.
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Because we removed @DirtiesContext, changes happen to the formatterService
on the other two tests passed on to this test. This causes the test leakage. That's why I decided to use a separate FormatterService for this 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.
Makes perfect sense! Thanks for catching that. 👍
a62eff0
to
e8347ea
Compare
Thanks @wikumChamith 👍 |
Ticket: https://openmrs.atlassian.net/browse/UIFR-222