|
1 | 1 | /*
|
2 |
| - * Copyright 2008-2020 the original author or authors. |
| 2 | + * Copyright 2008-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -167,20 +167,22 @@ public static class UnmappedDomesticNumber extends UnmappedPhoneNumber{}
|
167 | 167 |
|
168 | 168 | @Test
|
169 | 169 | public void arrayAsListSerializationTest() throws IOException {
|
170 |
| - |
171 |
| - Jackson2ExecutionContextStringSerializer j = new Jackson2ExecutionContextStringSerializer(); |
| 170 | + //given |
| 171 | + List<String> list = Arrays.asList("foo", "bar"); |
| 172 | + String key = "Arrays.asList"; |
| 173 | + Jackson2ExecutionContextStringSerializer serializer = new Jackson2ExecutionContextStringSerializer(); |
172 | 174 | Map<String, Object> context = new HashMap<>(1);
|
173 |
| - context.put("Arrays.asList", Arrays.asList("foo", "bar")); |
174 |
| - |
175 |
| - ByteArrayOutputStream os = new ByteArrayOutputStream(); |
176 |
| - j.serialize(context, os); |
| 175 | + context.put(key, list); |
177 | 176 |
|
178 |
| - InputStream in = new ByteArrayInputStream(os.toByteArray()); |
| 177 | + // when |
| 178 | + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| 179 | + serializer.serialize(context, outputStream); |
| 180 | + InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); |
| 181 | + Map<String, Object> deserializedContext = serializer.deserialize(inputStream); |
179 | 182 |
|
180 |
| - context = j.deserialize(in); |
181 |
| - |
182 |
| - String[] expectedValue = { "foo", "bar" }; |
183 |
| - List<String> deserializedValue = (List<String>) context.get("Arrays.asList"); |
184 |
| - Assert.assertArrayEquals(expectedValue, deserializedValue.toArray(new String[0])); |
| 183 | + // then |
| 184 | + Object deserializedValue = deserializedContext.get(key); |
| 185 | + Assert.assertTrue(List.class.isAssignableFrom(deserializedValue.getClass())); |
| 186 | + Assert.assertTrue(((List<String>)deserializedValue).containsAll(list)); |
185 | 187 | }
|
186 | 188 | }
|
0 commit comments