|
17 | 17 | package org.springframework.http.converter.xml;
|
18 | 18 |
|
19 | 19 | import java.io.IOException;
|
20 |
| -import java.lang.reflect.Method; |
21 | 20 | import java.nio.charset.StandardCharsets;
|
22 | 21 |
|
23 | 22 | import com.fasterxml.jackson.annotation.JsonView;
|
|
27 | 26 | import org.junit.rules.ExpectedException;
|
28 | 27 |
|
29 | 28 | import org.springframework.core.io.ClassPathResource;
|
30 |
| -import org.springframework.http.HttpOutputMessage; |
31 | 29 | import org.springframework.http.MediaType;
|
32 | 30 | import org.springframework.http.MockHttpInputMessage;
|
33 | 31 | import org.springframework.http.MockHttpOutputMessage;
|
34 |
| -import org.springframework.http.converter.AbstractHttpMessageConverter; |
35 | 32 | import org.springframework.http.converter.json.MappingJacksonValue;
|
36 | 33 |
|
37 | 34 | import static org.hamcrest.CoreMatchers.*;
|
@@ -128,7 +125,7 @@ public void jsonView() throws Exception {
|
128 | 125 |
|
129 | 126 | MappingJacksonValue jacksonValue = new MappingJacksonValue(bean);
|
130 | 127 | jacksonValue.setSerializationView(MyJacksonView1.class);
|
131 |
| - this.writeInternal(jacksonValue, outputMessage); |
| 128 | + this.converter.write(jacksonValue, null, outputMessage); |
132 | 129 |
|
133 | 130 | String result = outputMessage.getBodyAsString(StandardCharsets.UTF_8);
|
134 | 131 | assertThat(result, containsString("<withView1>with</withView1>"));
|
@@ -185,14 +182,6 @@ public void readWithXmlBomb() throws IOException {
|
185 | 182 | }
|
186 | 183 |
|
187 | 184 |
|
188 |
| - private void writeInternal(Object object, HttpOutputMessage outputMessage) throws Exception { |
189 |
| - Method method = AbstractHttpMessageConverter.class.getDeclaredMethod( |
190 |
| - "writeInternal", Object.class, HttpOutputMessage.class); |
191 |
| - method.setAccessible(true); |
192 |
| - method.invoke(this.converter, object, outputMessage); |
193 |
| - } |
194 |
| - |
195 |
| - |
196 | 185 | public static class MyBean {
|
197 | 186 |
|
198 | 187 | private String string;
|
|
0 commit comments