Skip to content

Commit c1cfb45

Browse files
committed
UIFR-226: Update to OpenMRS platform 2.7.3 and Support Java 21
1 parent 9f0a030 commit c1cfb45

File tree

10 files changed

+56
-106
lines changed

10 files changed

+56
-106
lines changed

.github/workflows/maven.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
java-version: [8, 11, 17]
16+
java-version: [8, 11, 21, 24]
1717

1818
steps:
1919
- uses: actions/checkout@v4

api/pom.xml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@
5353
<artifactId>groovy</artifactId>
5454
</dependency>
5555

56-
<dependency>
57-
<groupId>org.springframework</groupId>
58-
<artifactId>spring-webmvc</artifactId>
59-
</dependency>
6056

6157
<dependency>
6258
<groupId>org.codehaus.jackson</groupId>
@@ -65,10 +61,10 @@
6561
<dependency>
6662
<groupId>org.codehaus.jackson</groupId>
6763
<artifactId>jackson-core-asl</artifactId>
68-
</dependency>
64+
</dependency>
6965
<dependency>
7066
<groupId>javax.servlet</groupId>
71-
<artifactId>servlet-api</artifactId>
67+
<artifactId>javax.servlet-api</artifactId>
7268
</dependency>
7369
<dependency>
7470
<groupId>com.github.jknack</groupId>

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.openmrs.Role;
2525
import org.openmrs.api.AdministrationService;
2626
import org.openmrs.User;
27-
import org.powermock.api.mockito.PowerMockito;
2827
import org.springframework.context.MessageSource;
2928

3029
import java.text.SimpleDateFormat;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
import java.util.Locale;
1414
import java.util.Map;
1515

16-
import static org.mockito.Matchers.anyString;
17-
import static org.mockito.Matchers.eq;
16+
import static org.mockito.ArgumentMatchers.anyString;
17+
import static org.mockito.ArgumentMatchers.eq;
1818
import static org.mockito.Mockito.any;
1919

2020
public class UiUtilsTest {

api/src/test/java/org/openmrs/ui/framework/fragment/FragmentFactoryTest.java

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
import groovy.text.SimpleTemplateEngine;
44
import groovy.text.Template;
5-
import org.junit.Assert;
5+
import org.hamcrest.Matchers;
66
import org.junit.Before;
77
import org.junit.Test;
8-
import org.mockito.internal.matchers.Contains;
98
import org.openmrs.ui.framework.UiFrameworkException;
109
import org.openmrs.ui.framework.fragment.action.FragmentActionResult;
1110
import org.openmrs.ui.framework.fragment.action.SuccessResult;
@@ -25,6 +24,10 @@
2524
import java.util.HashMap;
2625
import java.util.Map;
2726

27+
import static org.hamcrest.MatcherAssert.assertThat;
28+
import static org.junit.Assert.assertNotNull;
29+
import static org.junit.Assert.assertNull;
30+
2831
public class FragmentFactoryTest {
2932

3033
FragmentFactory factory;
@@ -61,9 +64,9 @@ public void configureModel(FragmentContext pageContext) {
6164
*/
6265
@Test
6366
public void getController_shouldGetAControllerFromTheSpecifiedProvider() throws Exception {
64-
Assert.assertNotNull(factory.getController(new FragmentRequest("somemodule", "somefragment")));
65-
Assert.assertNull(factory.getController(new FragmentRequest("somemodule", "otherfragment")));
66-
Assert.assertNull(factory.getController(new FragmentRequest("othermodule", "somefragment")));
67+
assertNotNull(factory.getController(new FragmentRequest("somemodule", "somefragment")));
68+
assertNull(factory.getController(new FragmentRequest("somemodule", "otherfragment")));
69+
assertNull(factory.getController(new FragmentRequest("othermodule", "somefragment")));
6770
}
6871

6972
/**
@@ -72,9 +75,9 @@ public void getController_shouldGetAControllerFromTheSpecifiedProvider() throws
7275
*/
7376
@Test
7477
public void getController_shouldGetAControllerFromAnyProviderIfNoneSpecified() throws Exception {
75-
Assert.assertNotNull(factory.getController(new FragmentRequest("*", "somefragment")));
76-
Assert.assertNotNull(factory.getController(new FragmentRequest("*", "otherfragment")));
77-
Assert.assertNull(factory.getController(new FragmentRequest("*", "nothingwiththisname")));
78+
assertNotNull(factory.getController(new FragmentRequest("*", "somefragment")));
79+
assertNotNull(factory.getController(new FragmentRequest("*", "otherfragment")));
80+
assertNull(factory.getController(new FragmentRequest("*", "nothingwiththisname")));
7881
}
7982

8083
/**
@@ -92,9 +95,9 @@ public void getController_shouldFailIfAnInvalidProviderIsSpecified() throws Exce
9295
*/
9396
@Test
9497
public void getView_shouldGetAViewFromTheRequestedProvider() throws Exception {
95-
Assert.assertNotNull(factory.getView(new FragmentRequest("somemodule", "somefragment"), null));
96-
Assert.assertNull(factory.getView(new FragmentRequest("somemodule", "otherfragment"), null));
97-
Assert.assertNull(factory.getView(new FragmentRequest("othermodule", "somefragment"), null));
98+
assertNotNull(factory.getView(new FragmentRequest("somemodule", "somefragment"), null));
99+
assertNull(factory.getView(new FragmentRequest("somemodule", "otherfragment"), null));
100+
assertNull(factory.getView(new FragmentRequest("othermodule", "somefragment"), null));
98101
}
99102

100103
/**
@@ -103,9 +106,9 @@ public void getView_shouldGetAViewFromTheRequestedProvider() throws Exception {
103106
*/
104107
@Test
105108
public void getView_shouldGetAViewFromAnyProviderIfNoneIsSpecified() throws Exception {
106-
Assert.assertNotNull(factory.getView(new FragmentRequest("*", "somefragment"), null));
107-
Assert.assertNotNull(factory.getView(new FragmentRequest("*", "otherfragment"), null));
108-
Assert.assertNull(factory.getView(new FragmentRequest("*", "nothingwiththisname"), null));
109+
assertNotNull(factory.getView(new FragmentRequest("*", "somefragment"), null));
110+
assertNotNull(factory.getView(new FragmentRequest("*", "otherfragment"), null));
111+
assertNull(factory.getView(new FragmentRequest("*", "nothingwiththisname"), null));
109112
}
110113

111114
/**
@@ -125,7 +128,7 @@ public void process_shouldSetCustomModelProperties() throws Exception {
125128
FragmentContext fragmentContext = new FragmentContext(fragmentRequest, pageContext);
126129

127130
String result = factory.process(fragmentContext);
128-
Assert.assertThat(result, new Contains("Testing Success!!!"));
131+
assertThat(result, Matchers.containsString(("Testing Success!!!")));
129132
}
130133

131134
private PageContext buildPageContext() {
@@ -322,22 +325,22 @@ public String render(FragmentContext context) throws PageAction {
322325
public class ControllerAndActionThatTakeIntegerType {
323326

324327
public void controller(Integer injected, Long notInjected) {
325-
Assert.assertNotNull("Integer argument was not injected", injected);
326-
Assert.assertNull("Long argument should not have been injected", notInjected);
328+
assertNotNull("Integer argument was not injected", injected);
329+
assertNull("Long argument should not have been injected", notInjected);
327330
}
328331

329332
public FragmentActionResult action(Integer injected, Long notInjected) {
330-
Assert.assertNotNull("Integer argument was not injected", injected);
331-
Assert.assertNull("Long argument should not have been injected", notInjected);
333+
assertNotNull("Integer argument was not injected", injected);
334+
assertNull("Long argument should not have been injected", notInjected);
332335
return new SuccessResult();
333336
}
334337
}
335338

336339
public class ActionThatTakeServletRequestResponse {
337340

338341
public FragmentActionResult action(HttpServletRequest httpRequest, HttpServletResponse httpResponse) {
339-
Assert.assertNotNull("HttpServletRequest argument was not injected", httpRequest);
340-
Assert.assertNotNull("HttpServletResponse argument was not injected", httpResponse);
342+
assertNotNull("HttpServletRequest argument was not injected", httpRequest);
343+
assertNotNull("HttpServletResponse argument was not injected", httpResponse);
341344
return new SuccessResult();
342345
}
343346
}

api/src/test/java/org/openmrs/ui/framework/page/PageFactoryTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import groovy.text.SimpleTemplateEngine;
44
import groovy.text.Template;
5+
import org.hamcrest.Matchers;
56
import org.junit.Assert;
67
import org.junit.Before;
78
import org.junit.Test;
8-
import org.mockito.internal.matchers.Contains;
99
import org.openmrs.ui.framework.ProviderAndName;
1010
import org.openmrs.ui.framework.UiFrameworkException;
1111
import org.openmrs.ui.framework.interceptor.PageRequestInterceptor;
@@ -22,7 +22,7 @@
2222
import java.util.Map;
2323
import java.util.regex.Pattern;
2424

25-
import static org.junit.Assert.assertThat;
25+
import static org.hamcrest.MatcherAssert.assertThat;
2626

2727
public class PageFactoryTest {
2828

@@ -145,7 +145,7 @@ public void process_shouldSetCustomModelProperties() throws Exception {
145145
Session session = new Session(httpSession);
146146
String result = factory.handle(
147147
new PageRequest("somemodule", "groovy", new MockHttpServletRequest(), new MockHttpServletResponse(), session));
148-
assertThat(result, new Contains("Testing Success!!!"));
148+
assertThat(result, Matchers.containsString("Testing Success!!!"));
149149
}
150150

151151
@Test

api/src/test/resources/TestingApplicationContext.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<beans xmlns="http://www.springframework.org/schema/beans"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
4-
xmlns:util="http://www.springframework.org/schema/util"
5-
xsi:schemaLocation="http://www.springframework.org/schema/beans
6-
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
7-
http://www.springframework.org/schema/context
8-
http://www.springframework.org/schema/context/spring-context-3.0.xsd
9-
http://www.springframework.org/schema/util
10-
http://www.springframework.org/schema/util/spring-util-3.0.xsd">
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.springframework.org/schema/beans
5+
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
116

127
<bean id="sessionFactory" class="org.openmrs.api.db.hibernate.HibernateSessionFactoryBean">
138
<property name="configLocations">
@@ -19,6 +14,11 @@
1914
<property name="mappingJarLocations">
2015
<ref bean="mappingJarResources"/>
2116
</property>
17+
<property name="packagesToScan">
18+
<list>
19+
<value>org.openmrs</value>
20+
</list>
21+
</property>
2222
</bean>
2323

2424
<bean id="conversionService" class="org.openmrs.module.uiframework.UiFrameworkConversionServiceFactoryBean"/>

omod/pom.xml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@
4141
<type>test-jar</type>
4242
<scope>test</scope>
4343
</dependency>
44-
44+
4545
<dependency>
4646
<groupId>org.openmrs.web</groupId>
4747
<artifactId>openmrs-web</artifactId>
4848
<type>jar</type>
49-
<scope>test</scope>
5049
</dependency>
50+
5151
<dependency>
5252
<groupId>org.openmrs.web</groupId>
5353
<artifactId>openmrs-web</artifactId>
@@ -68,19 +68,14 @@
6868
<groupId>org.codehaus.groovy</groupId>
6969
<artifactId>groovy</artifactId>
7070
</dependency>
71-
71+
7272
<dependency>
7373
<groupId>javax.servlet</groupId>
74-
<artifactId>servlet-api</artifactId>
75-
</dependency>
76-
77-
<dependency>
78-
<groupId>org.springframework</groupId>
79-
<artifactId>spring-web</artifactId>
80-
<version>${springVersion}</version>
81-
<scope>provided</scope>
74+
<artifactId>javax.servlet-api</artifactId>
8275
</dependency>
8376

77+
78+
8479
<dependency>
8580
<groupId>org.openmrs.module</groupId>
8681
<artifactId>uiframework-omod-2.0</artifactId>

omod/src/test/java/org/openmrs/ui/framework/PageControllerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.springframework.mock.web.MockHttpSession;
2929
import org.springframework.ui.ExtendedModelMap;
3030

31-
import static org.mockito.Matchers.any;
31+
import static org.mockito.ArgumentMatchers.any;
3232
import static org.mockito.Mockito.mock;
3333
import static org.mockito.Mockito.when;
3434

@@ -55,7 +55,7 @@ public void shouldHandleFileDownloadReturnType() throws Exception {
5555
controller.setPageFactory(pageFactory);
5656
controller.setSessionFactory(sessionFactory);
5757

58-
Context.setUserContext(new UserContext());
58+
Context.setUserContext(new UserContext(Context.getAuthenticationScheme()));
5959

6060
controller.handlePath("somemodule/download", request, response, new ExtendedModelMap(), session);
6161

0 commit comments

Comments
 (0)