Skip to content

Commit 29cfa74

Browse files
committed
Merge branch '2.19'
2 parents e955c90 + f587964 commit 29cfa74

File tree

6 files changed

+61
-52
lines changed

6 files changed

+61
-52
lines changed

no-ctor-deser/pom.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@
4343
<artifactId>jackson-databind</artifactId>
4444
</dependency>
4545

46-
<!-- 20-Apr-2024, tatu: JUnit4 no longer from jackson-base -->
46+
<!-- Test dependencies -->
4747
<dependency>
48-
<groupId>junit</groupId>
49-
<artifactId>junit</artifactId>
48+
<groupId>org.junit.jupiter</groupId>
49+
<artifactId>junit-jupiter</artifactId>
50+
<scope>test</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.junit.jupiter</groupId>
54+
<artifactId>junit-jupiter-api</artifactId>
5055
<scope>test</scope>
5156
</dependency>
5257
</dependencies>

no-ctor-deser/src/test/java/module-info.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
// Additional test lib/framework dependencies
1313

14-
requires junit; // JUnit4 To Be Removed in future
14+
requires org.junit.jupiter.api;
15+
requires org.junit.jupiter.params;
1516

1617
// Further, need to open up some packages for JUnit et al
1718
opens tools.jackson.module.noctordeser;

no-ctor-deser/src/test/java/tools/jackson/module/noctordeser/BasicNoConstructorTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package tools.jackson.module.noctordeser;
22

3+
import java.util.Arrays;
4+
5+
import org.junit.jupiter.api.Test;
6+
37
import tools.jackson.databind.ObjectMapper;
48
import tools.jackson.databind.json.JsonMapper;
59

6-
import junit.framework.TestCase;
7-
8-
import java.util.Arrays;
10+
import static org.junit.jupiter.api.Assertions.*;
911

10-
public class BasicNoConstructorTest extends TestCase
12+
public class BasicNoConstructorTest
1113
{
1214
static class BeanWithoutDefaultConstructor {
1315
public String value;
@@ -40,6 +42,7 @@ protected static ObjectMapper newObjectMapper() {
4042

4143
private final ObjectMapper MAPPER = newObjectMapper();
4244

45+
@Test
4346
public void testReadValueWithoutDefaultConstructor() throws Exception
4447
{
4548
String json = MAPPER.writeValueAsString(new BeanWithoutDefaultConstructor("test"));
@@ -66,6 +69,7 @@ public void testReadValueWithoutDefaultConstructor() throws Exception
6669
assertEquals(7, result2.y);
6770
}
6871

72+
@Test
6973
public void testReadValueWithDefaultConstructor() throws Exception {
7074
BeanWithDefaultConstructor bean = new BeanWithDefaultConstructor();
7175
bean.value = "test";

osgi/pom.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,15 @@
4646
<version>${version.osgi.core}</version>
4747
</dependency>
4848

49-
<!-- 20-Apr-2024, tatu: JUnit4 no longer from jackson-base -->
49+
<!-- Test dependencies -->
5050
<dependency>
51-
<groupId>junit</groupId>
52-
<artifactId>junit</artifactId>
51+
<groupId>org.junit.jupiter</groupId>
52+
<artifactId>junit-jupiter</artifactId>
53+
<scope>test</scope>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.junit.jupiter</groupId>
57+
<artifactId>junit-jupiter-api</artifactId>
5358
<scope>test</scope>
5459
</dependency>
5560

osgi/src/test/java/module-info.java

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

1111
// Additional test lib/framework dependencies
1212

13-
requires junit;
14-
requires org.mockito;
13+
requires org.junit.jupiter.api;
14+
requires org.junit.jupiter.params;
1515

1616
// Further, need to open up some packages for JUnit et al
1717
opens tools.jackson.module.osgi;

osgi/src/test/java/tools/jackson/module/osgi/InjectOsgiServiceTest.java

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
11
package tools.jackson.module.osgi;
22

3-
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertNotNull;
5-
import static org.junit.Assert.assertNull;
6-
import static org.junit.Assert.fail;
7-
import static org.mockito.ArgumentMatchers.any;
8-
import static org.mockito.ArgumentMatchers.anyString;
9-
import static org.mockito.ArgumentMatchers.eq;
10-
import static org.mockito.Mockito.doReturn;
11-
import static org.mockito.Mockito.doThrow;
12-
import static org.mockito.Mockito.mock;
13-
import static org.mockito.Mockito.times;
14-
import static org.mockito.Mockito.when;
3+
import java.util.stream.Stream;
154

16-
import java.util.Arrays;
17-
import java.util.Collection;
5+
import org.junit.jupiter.api.BeforeEach;
6+
import org.junit.jupiter.params.ParameterizedTest;
7+
import org.junit.jupiter.params.provider.MethodSource;
188

19-
import org.junit.Before;
20-
import org.junit.Ignore;
21-
import org.junit.Test;
22-
import org.junit.runner.RunWith;
23-
import org.junit.runners.Parameterized;
24-
import org.junit.runners.Parameterized.Parameter;
25-
import org.junit.runners.Parameterized.Parameters;
269
import org.mockito.Mockito;
2710
import org.osgi.framework.BundleContext;
2811
import org.osgi.framework.Filter;
@@ -34,30 +17,39 @@
3417
import tools.jackson.databind.ObjectMapper;
3518
import tools.jackson.databind.json.JsonMapper;
3619

37-
@RunWith(value = Parameterized.class)
38-
@Ignore("Does not work on JDK 17/Mockito 5.x")
20+
import static org.junit.jupiter.api.Assertions.*;
21+
22+
import static org.mockito.ArgumentMatchers.any;
23+
import static org.mockito.ArgumentMatchers.anyString;
24+
import static org.mockito.ArgumentMatchers.eq;
25+
import static org.mockito.Mockito.doReturn;
26+
import static org.mockito.Mockito.doThrow;
27+
import static org.mockito.Mockito.mock;
28+
import static org.mockito.Mockito.times;
29+
import static org.mockito.Mockito.when;
30+
3931
public class InjectOsgiServiceTest
4032
{
4133
private static final String OSGI_FILTER = "osgi.filter";
4234

4335
private BundleContext bundleContext;
4436

4537
private ObjectMapper mapper;
46-
47-
@Parameter
48-
public Class<?> beanClass;
49-
50-
@Parameters
51-
public static Collection<Class<? extends VerifyableBean>> data() {
52-
return Arrays.asList(
53-
BeanWithServiceInConstructor.class,
54-
BeanWithFilter.class,
55-
BeanWithServiceInField.class,
56-
BeanWithNotFoundService.class);
38+
39+
public static Stream<Class<? extends VerifyableBean>> data() {
40+
// 18-Jan-2025, tatu: Looks like we'll mostly fail to inject Service
41+
// in Jackson 3.0/JDK 17/JUnit 5/JPMS (not sure which part matters most;
42+
// possibly JPMS). So comment out ones that'd fail
43+
return Stream.of(
44+
//BeanWithServiceInConstructor.class,
45+
BeanWithFilter.class
46+
//BeanWithServiceInField.class,
47+
//BeanWithNotFoundService.class
48+
);
5749
}
5850

5951
@SuppressWarnings("unchecked")
60-
@Before
52+
@BeforeEach
6153
public void setUp() throws Exception
6254
{
6355
bundleContext = mock(BundleContext.class);
@@ -73,8 +65,10 @@ public void setUp() throws Exception
7365
.build();
7466
}
7567

76-
@Test
77-
public void testServiceIsInjected() throws Exception
68+
@MethodSource("data")
69+
@ParameterizedTest
70+
public void testServiceIsInjected(Class<?> beanClass)
71+
throws Exception
7872
{
7973
// ACTION
8074
VerifyableBean result = mapper.reader().forType(beanClass)
@@ -98,7 +92,7 @@ public static abstract class VerifyableBean
9892
{
9993
public String field;
10094

101-
protected Service service;
95+
public Service service;
10296

10397
public boolean verify(BundleContext bundleContext)
10498
{
@@ -135,7 +129,7 @@ public boolean verify(BundleContext bundleContext)
135129
public static class BeanWithServiceInField extends VerifyableBean
136130
{
137131
@JacksonInject
138-
private Service service2;
132+
public Service service2;
139133

140134
@Override
141135
public boolean verify(BundleContext bundleContext)

0 commit comments

Comments
 (0)