|
21 | 21 | import java.nio.charset.StandardCharsets;
|
22 | 22 | import java.util.Arrays;
|
23 | 23 | import java.util.HashMap;
|
| 24 | +import java.util.List; |
24 | 25 | import java.util.Map;
|
25 | 26 |
|
26 | 27 | import com.fasterxml.jackson.annotation.JsonView;
|
|
33 | 34 | import org.springframework.messaging.support.MessageBuilder;
|
34 | 35 | import org.springframework.util.MimeType;
|
35 | 36 |
|
36 |
| -import static org.hamcrest.Matchers.*; |
37 |
| -import static org.junit.Assert.*; |
| 37 | +import static org.hamcrest.Matchers.contains; |
| 38 | +import static org.hamcrest.Matchers.containsString; |
| 39 | +import static org.hamcrest.Matchers.not; |
| 40 | +import static org.junit.Assert.assertArrayEquals; |
| 41 | +import static org.junit.Assert.assertEquals; |
| 42 | +import static org.junit.Assert.assertFalse; |
| 43 | +import static org.junit.Assert.assertNotNull; |
| 44 | +import static org.junit.Assert.assertNull; |
| 45 | +import static org.junit.Assert.assertThat; |
| 46 | +import static org.junit.Assert.assertTrue; |
38 | 47 |
|
39 | 48 | /**
|
40 | 49 | * Test fixture for {@link org.springframework.messaging.converter.MappingJackson2MessageConverter}.
|
@@ -127,6 +136,20 @@ public void fromMessageValidJsonWithUnknownProperty() throws IOException {
|
127 | 136 | assertEquals("string", myBean.getString());
|
128 | 137 | }
|
129 | 138 |
|
| 139 | + @Test // SPR-16252 |
| 140 | + public void fromMessageToList() throws Exception { |
| 141 | + MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter(); |
| 142 | + String payload = "[1, 2, 3, 4, 5, 6, 7, 8, 9]"; |
| 143 | + Message<?> message = MessageBuilder.withPayload(payload.getBytes(StandardCharsets.UTF_8)).build(); |
| 144 | + |
| 145 | + Method method = getClass().getDeclaredMethod("handleList", List.class); |
| 146 | + MethodParameter param = new MethodParameter(method, 0); |
| 147 | + Object actual = converter.fromMessage(message, List.class, param); |
| 148 | + |
| 149 | + assertNotNull(actual); |
| 150 | + assertEquals(Arrays.asList(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L), actual); |
| 151 | + } |
| 152 | + |
130 | 153 | @Test
|
131 | 154 | public void toMessage() throws Exception {
|
132 | 155 | MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
|
@@ -217,6 +240,8 @@ public JacksonViewBean jsonViewResponse() {
|
217 | 240 | public void jsonViewPayload(@JsonView(MyJacksonView2.class) JacksonViewBean payload) {
|
218 | 241 | }
|
219 | 242 |
|
| 243 | + void handleList(List<Long> payload) {} |
| 244 | + |
220 | 245 |
|
221 | 246 | public static class MyBean {
|
222 | 247 |
|
|
0 commit comments