Add test to serialize/deserialize records in the execution context

This commit is contained in:
Mahmoud Ben Hassine
2022-06-02 10:40:20 +02:00
parent c4ad90b9b1
commit 08f8c75ee6
2 changed files with 18 additions and 3 deletions

View File

@@ -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<String, Object> m1 = new HashMap<>();
m1.put("foo", new Person(1, "foo"));
m1.put("bar", new Person(2, "bar"));
Map<String, Object> 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 {
}
}

View File

@@ -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;
}