Skip to content

Commit edeec88

Browse files
committed
Merge branch '2.19'
2 parents fefa9bb + 7169b99 commit edeec88

37 files changed

+421
-129
lines changed

guava/pom.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,15 @@ com.google.common.*;version="${version.guava.osgi}",
5353
<version>${version.guava}</version>
5454
</dependency>
5555

56-
<!-- 2025-Jan-22 joohyukkim : temporarily isolate JUnit 4 here... -->
56+
<!-- Test dependencies -->
5757
<dependency>
58-
<groupId>junit</groupId>
59-
<artifactId>junit</artifactId>
58+
<groupId>org.junit.jupiter</groupId>
59+
<artifactId>junit-jupiter</artifactId>
60+
<scope>test</scope>
61+
</dependency>
62+
<dependency>
63+
<groupId>org.junit.jupiter</groupId>
64+
<artifactId>junit-jupiter-api</artifactId>
6065
<scope>test</scope>
6166
</dependency>
6267
</dependencies>

guava/src/main/java/module-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
requires com.fasterxml.jackson.annotation;
55

66
requires tools.jackson.core;
7-
requires tools.jackson.databind;
7+
requires transitive tools.jackson.databind;
88

99
requires com.google.common;
1010

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
requires com.google.common;
1313

1414
// Additional test lib/framework dependencies
15-
requires junit; // JUnit 4
15+
requires org.junit.jupiter.api;
16+
requires org.junit.jupiter.params;
1617

1718
// Further, need to open up test packages for JUnit et al
1819

guava/src/test/java/tools/jackson/datatype/guava/CacheDeserializationTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import java.util.Map;
44
import java.util.Objects;
55

6+
import org.junit.jupiter.api.Test;
7+
68
import com.google.common.base.Optional;
79
import com.google.common.cache.Cache;
810
import com.google.common.cache.CacheBuilder;
@@ -16,6 +18,8 @@
1618
import tools.jackson.databind.ObjectMapper;
1719
import tools.jackson.databind.exc.MismatchedInputException;
1820

21+
import static org.junit.jupiter.api.Assertions.*;
22+
1923
/**
2024
* Unit tests for verifying deserialization of Guava's {@link Cache} type.
2125
*
@@ -68,6 +72,7 @@ static class CacheWrapper {
6872

6973
private final ObjectMapper MAPPER = mapperWithModule();
7074

75+
@Test
7176
public void testGuavaCacheApi() throws Exception {
7277
Cache<String, String> cache = CacheBuilder.newBuilder().build();
7378
// Cache does not allow null key
@@ -83,6 +88,7 @@ public void testGuavaCacheApi() throws Exception {
8388
} catch (NullPointerException e) {}
8489
}
8590

91+
@Test
8692
public void testCacheDeserializationSimple() throws Exception {
8793
// Create a delegate cache using CacheBuilder
8894
Cache<String, Integer> delegateCache = CacheBuilder.newBuilder().build();
@@ -95,6 +101,7 @@ public void testCacheDeserializationSimple() throws Exception {
95101
assertEquals("foo", s.getIfPresent("a"));
96102
}
97103

104+
@Test
98105
public void testCacheDeserRoundTrip() throws Exception {
99106
Cache<String, Integer> cache = CacheBuilder.newBuilder().build();
100107
cache.put("key1", 1);
@@ -111,6 +118,7 @@ public void testCacheDeserRoundTrip() throws Exception {
111118
}
112119

113120
// [datatype-collections#96]
121+
@Test
114122
public void testCacheSerialization() throws Exception {
115123
Cache<Long, Integer> cache = CacheBuilder.newBuilder().build();
116124
cache.put(1L, 1);
@@ -134,6 +142,7 @@ private void _verifySizeTwoAndContains(Map<Long, Integer> map) {
134142
assertEquals(2, map.get(2L).intValue());
135143
}
136144

145+
@Test
137146
public void testEnumKey() throws Exception {
138147
final TypeReference<Cache<MyEnum, Integer>> type = new TypeReference<Cache<MyEnum, Integer>>() {};
139148
final Cache<MyEnum, Integer> cache = CacheBuilder.newBuilder().build();
@@ -151,11 +160,13 @@ public void testEnumKey() throws Exception {
151160
deserializedCache.asMap().entrySet());
152161
}
153162

163+
@Test
154164
public void testEmptyCacheExclusion() throws Exception {
155165
String json = MAPPER.writeValueAsString(new CacheWrapper());
156166
assertEquals("{}", json);
157167
}
158168

169+
@Test
159170
public void testWithGuavaOptional() throws Exception {
160171
// set up
161172
Cache<String, Optional<Double>> cache = CacheBuilder.newBuilder().build();
@@ -175,6 +186,7 @@ public void testWithGuavaOptional() throws Exception {
175186
}
176187

177188
// [datatypes-collections#140]: handle null values
189+
@Test
178190
public void testCacheWithNulls() throws Exception {
179191
Cache<String, Integer> cache;
180192
try {

guava/src/test/java/tools/jackson/datatype/guava/CacheSerializationTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
import com.google.common.base.Objects;
1111
import com.google.common.cache.Cache;
1212
import com.google.common.cache.CacheBuilder;
13+
import org.junit.jupiter.api.Test;
1314

1415
import java.util.ArrayList;
1516
import java.util.List;
1617

18+
import static org.junit.jupiter.api.Assertions.*;
19+
1720
/**
1821
* Unit tests for verifying serialization of Guava's {@link Cache} type.
1922
*/
@@ -191,6 +194,7 @@ public String toString() {
191194
.enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS)
192195
.build();
193196

197+
@Test
194198
public void testGuavaCacheApi() throws Exception {
195199
Cache<String, String> cache = CacheBuilder.newBuilder().build();
196200
// Cache does not allow null key
@@ -206,6 +210,7 @@ public void testGuavaCacheApi() throws Exception {
206210
} catch (NullPointerException e) {}
207211
}
208212

213+
@Test
209214
public void testCacheSerialization() throws Exception {
210215
// Create a Guava Cache
211216
Cache<String, String> cache = CacheBuilder.newBuilder().build();
@@ -217,6 +222,7 @@ public void testCacheSerialization() throws Exception {
217222
ORDERED_MAPPER.writeValueAsString(cache));
218223
}
219224

225+
@Test
220226
public void testCacheSerializationIgnoreProperties() throws Exception {
221227
CacheContainerWithIgnores container = new CacheContainerWithIgnores();
222228

@@ -225,6 +231,7 @@ public void testCacheSerializationIgnoreProperties() throws Exception {
225231
ORDERED_MAPPER.writeValueAsString(container));
226232
}
227233

234+
@Test
228235
public void testCacheSerializationWithBean() throws Exception {
229236
CacheContainerWithBean container = new CacheContainerWithBean();
230237

@@ -233,6 +240,7 @@ public void testCacheSerializationWithBean() throws Exception {
233240
ORDERED_MAPPER.writeValueAsString(container));
234241
}
235242

243+
@Test
236244
public void testCacheSerializationWithList() throws Exception {
237245
CacheContainerWithList container = new CacheContainerWithList();
238246

@@ -241,6 +249,7 @@ public void testCacheSerializationWithList() throws Exception {
241249
ORDERED_MAPPER.writeValueAsString(container));
242250
}
243251

252+
@Test
244253
public void testCacheSerializationWithEmptyCache() throws Exception {
245254
Cache<String, String> cache = CacheBuilder.newBuilder().build();
246255

@@ -249,6 +258,7 @@ public void testCacheSerializationWithEmptyCache() throws Exception {
249258
ORDERED_MAPPER.writeValueAsString(cache));
250259
}
251260

261+
@Test
252262
public void testCacheSerializationBeanKey() throws Exception {
253263
Cache<BeanKey, String> cache = CacheBuilder.newBuilder().build();
254264
cache.put(new BeanKey(1), "value1");
@@ -258,6 +268,7 @@ public void testCacheSerializationBeanKey() throws Exception {
258268
ORDERED_MAPPER.writeValueAsString(cache));
259269
}
260270

271+
@Test
261272
public void testCacheSerializationBeanKeyEquals() throws Exception {
262273
Cache<BeanKeyEquals, String> cache = CacheBuilder.newBuilder().build();
263274
cache.put(new BeanKeyEquals(1), "value1");
@@ -270,12 +281,14 @@ public void testCacheSerializationBeanKeyEquals() throws Exception {
270281
}
271282

272283

284+
@Test
273285
public void testEmptyCacheExclusion() throws Exception {
274286
String json = ORDERED_MAPPER.writeValueAsString(new CacheWrapper());
275287

276288
assertEquals("{}", json);
277289
}
278290

291+
@Test
279292
public void testCacheSerializationWithTypeReference() throws Exception {
280293
final Cache<MyEnum, Integer> cache = CacheBuilder.newBuilder().build();
281294
cache.put(MyEnum.YAY, 5);
@@ -289,6 +302,7 @@ public void testCacheSerializationWithTypeReference() throws Exception {
289302
assertEquals(expected, mapperSer);
290303
}
291304

305+
@Test
292306
public void testOrderByKeyViaProperty() throws Exception {
293307
CacheOrderingBean input = new CacheOrderingBean("c", "b", "a");
294308

@@ -297,6 +311,7 @@ public void testOrderByKeyViaProperty() throws Exception {
297311
assertEquals(a2q("{'cache':{'a':3,'b':2,'c':1}}"), json);
298312
}
299313

314+
@Test
300315
public void testPolymorphicCacheSerialization() throws Exception {
301316
Cache<String, Animal> cache = CacheBuilder.newBuilder().build();
302317
cache.put("c", new Cat());
@@ -311,6 +326,7 @@ public void testPolymorphicCacheSerialization() throws Exception {
311326
"'d':{'_type':'t_dog','name':'Woof'}}}"), json);
312327
}
313328

329+
@Test
314330
public void testNestedCacheSerialization() throws Exception {
315331
Cache<String, Cache<String, String>> nestedCache = CacheBuilder.newBuilder().build();
316332
nestedCache.put("a", _buildCacheWithKeys("a_x", "a_y"));
@@ -333,13 +349,15 @@ private Cache<String, String> _buildCacheWithKeys(String... keys) {
333349
}
334350

335351
// [datatypes-collections#104]
352+
@Test
336353
public void testPolymorphicCacheEmpty() throws Exception {
337354
final Cache<String, Object> cache = CacheBuilder.newBuilder().build();
338355
cache.put("aKey", 1);
339356
_testPolymorphicCache(cache,
340357
a2q("{'aProperty':{'@type':'LocalCache$LocalManualCache','aKey':1}}"));
341358
}
342359

360+
@Test
343361
public void testPolymorphicCacheNonEmpty() throws Exception {
344362
_testPolymorphicCache(CacheBuilder.newBuilder().build(),
345363
a2q("{'aProperty':{'@type':'LocalCache$LocalManualCache'}}"));
@@ -354,6 +372,7 @@ private void _testPolymorphicCache(Cache<String, Object> cache, String expected)
354372
assertEquals(expected, json);
355373
}
356374

375+
@Test
357376
public void testCacheSerializeOrderedByKey() throws Exception {
358377
final Cache<String, String> cache = _buildCacheWithKeys("c_key", "d_key", "a_key", "e_key", "b_key");
359378

@@ -365,6 +384,7 @@ public void testCacheSerializeOrderedByKey() throws Exception {
365384
new TypeReference<Cache<String, String>>() {}).writeValueAsString(cache));
366385
}
367386

387+
@Test
368388
public void testPolymorphicCacheWrapperSerialization() throws Exception {
369389
final Cache<String, String> cache = _buildCacheWithKeys("c_key", "a_key", "e_key", "b_key", "d_key");
370390
PolymorphicWrapperBean outside = new PolymorphicWrapperBean();

guava/src/test/java/tools/jackson/datatype/guava/EmptyCollectionsTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package tools.jackson.datatype.guava;
22

3+
import org.junit.jupiter.api.Test;
4+
35
import com.fasterxml.jackson.annotation.Nulls;
46

57
import tools.jackson.databind.ObjectMapper;
68
import com.google.common.collect.ImmutableList;
79
import com.google.common.collect.ImmutableMap;
810

11+
import static org.junit.jupiter.api.Assertions.*;
12+
913
public class EmptyCollectionsTest extends ModuleTestBase
1014
{
1115
// [datatypes-collections#67]
@@ -24,6 +28,7 @@ public static class ImmutableMapContainer67 {
2428
.build();
2529

2630
// [datatypes-collections#67]
31+
@Test
2732
public void testEmptyForLists() throws Exception
2833
{
2934
ImmutableListContainer67 result;
@@ -47,6 +52,7 @@ public void testEmptyForLists() throws Exception
4752
assertEquals(0, result.lists.size());
4853
}
4954

55+
@Test
5056
public void testEmptyForMaps() throws Exception
5157
{
5258
ImmutableMapContainer67 result;

guava/src/test/java/tools/jackson/datatype/guava/FluentIterableTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
import java.util.Arrays;
44

5+
import org.junit.jupiter.api.Test;
6+
57
import com.google.common.collect.FluentIterable;
68

79
import tools.jackson.databind.ObjectMapper;
810

11+
import static org.junit.jupiter.api.Assertions.assertEquals;
12+
913
/**
1014
* Unit tests to verify serialization of {@link FluentIterable}s.
1115
*/
@@ -27,22 +31,24 @@ static FluentIterable<Integer> createFluentIterable() {
2731
* or Guava's implementation of FluentIterable changes.
2832
* @throws Exception
2933
*/
34+
@Test
3035
public void testSerializationWithoutModule() throws Exception {
3136
ObjectMapper mapper = new ObjectMapper();
3237
FluentHolder holder = new FluentHolder();
3338
String json = mapper.writeValueAsString(holder);
3439
assertEquals("{\"value\":{\"empty\":false}}", json);
3540
}
3641

42+
@Test
3743
public void testSerialization() throws Exception {
3844
String json = MAPPER.writeValueAsString(createFluentIterable());
3945
assertEquals("[1,2,3]", json);
4046
}
4147

48+
@Test
4249
public void testWrappedSerialization() throws Exception {
4350
FluentHolder holder = new FluentHolder();
4451
String json = MAPPER.writeValueAsString(holder);
4552
assertEquals("{\"value\":[1,2,3]}", json);
4653
}
47-
4854
}

guava/src/test/java/tools/jackson/datatype/guava/HashCodeTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
package tools.jackson.datatype.guava;
22

3+
import org.junit.jupiter.api.Test;
4+
5+
import com.google.common.hash.HashCode;
6+
37
import tools.jackson.databind.ObjectMapper;
48
import tools.jackson.databind.exc.MismatchedInputException;
59

6-
import com.google.common.hash.HashCode;
10+
import static org.junit.jupiter.api.Assertions.*;
711

812
public class HashCodeTest extends ModuleTestBase
913
{
1014
private final ObjectMapper MAPPER = mapperWithModule();
1115

16+
@Test
1217
public void testSerialization() throws Exception
1318
{
1419
HashCode input = HashCode.fromString("cafebabe12345678");
1520
String json = MAPPER.writeValueAsString(input);
1621
assertEquals("\"cafebabe12345678\"", json);
1722
}
1823

24+
@Test
1925
public void testDeserialization() throws Exception
2026
{
2127
// success:

0 commit comments

Comments
 (0)