diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextSerializerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextSerializerTests.java index 268374df7..9fd16840f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextSerializerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractExecutionContextSerializerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -151,6 +151,17 @@ public abstract class AbstractExecutionContextSerializerTests { compareContexts(m1, m2); } + @Test + public void testSerializeRecords() throws IOException { + Map m1 = new HashMap<>(); + m1.put("foo", new Person(1, "foo")); + m1.put("bar", new Person(2, "bar")); + + Map m2 = serializationRoundTrip(m1); + + compareContexts(m1, m2); + } + @Test(expected = IllegalArgumentException.class) public void testNullSerialization() throws Exception { getSerializer().serialize(null, null); @@ -263,4 +274,7 @@ public abstract class AbstractExecutionContextSerializerTests { } + public static record Person(int id, String name) implements Serializable { + } + } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/Jackson2ExecutionContextStringSerializerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/Jackson2ExecutionContextStringSerializerTests.java index 6263008e6..2dc4df9a3 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/Jackson2ExecutionContextStringSerializerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/Jackson2ExecutionContextStringSerializerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2021 the original author or authors. + * Copyright 2008-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,8 @@ public class Jackson2ExecutionContextStringSerializerTests extends AbstractExecu @Before public void onSetUp() throws Exception { - Jackson2ExecutionContextStringSerializer serializerDeserializer = new Jackson2ExecutionContextStringSerializer(); + Jackson2ExecutionContextStringSerializer serializerDeserializer = new Jackson2ExecutionContextStringSerializer( + AbstractExecutionContextSerializerTests.Person.class.getName()); serializer = serializerDeserializer; }