Skip to content

Commit

Permalink
Add test to serialize/deserialize records in the execution context
Browse files Browse the repository at this point in the history
  • Loading branch information
fmbenhassine committed Jun 2, 2022
1 parent c4ad90b commit 08f8c75
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -151,6 +151,17 @@ public void testComplexObject() throws Exception {
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);
Expand Down Expand Up @@ -263,4 +274,7 @@ public String toString() {

}

public static record Person(int id, String name) implements Serializable {
}

}
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 08f8c75

Please sign in to comment.