@@ -80,6 +80,16 @@ public void readJson() throws IOException {
80
80
assertThat (result ).as ("Invalid result" ).isEqualTo (body );
81
81
}
82
82
83
+ @ Test // gh-25328
84
+ public void readJsonApi () throws IOException {
85
+ String body = "{\" result\" :\" \u0414 \u0410 \" }" ;
86
+ MockHttpInputMessage inputMessage = new MockHttpInputMessage (body .getBytes (StandardCharsets .UTF_8 ));
87
+ inputMessage .getHeaders ().setContentType (new MediaType ("application" , "vnd.api.v1+json" ));
88
+ String result = this .converter .read (String .class , inputMessage );
89
+
90
+ assertThat (result ).as ("Invalid result" ).isEqualTo (body );
91
+ }
92
+
83
93
@ Test
84
94
public void writeDefaultCharset () throws IOException {
85
95
String body = "H\u00e9 llo W\u00f6 rld" ;
@@ -94,7 +104,7 @@ public void writeDefaultCharset() throws IOException {
94
104
95
105
@ Test // gh-24123
96
106
public void writeJson () throws IOException {
97
- String body = "{\" foo \" :\" bar \" }" ;
107
+ String body = "{\" føø \" :\" bår \" }" ;
98
108
this .converter .write (body , MediaType .APPLICATION_JSON , this .outputMessage );
99
109
100
110
HttpHeaders headers = this .outputMessage .getHeaders ();
@@ -104,6 +114,19 @@ public void writeJson() throws IOException {
104
114
assertThat (headers .getAcceptCharset ().isEmpty ()).isTrue ();
105
115
}
106
116
117
+ @ Test // gh-25328
118
+ public void writeJsonApi () throws IOException {
119
+ String body = "{\" føø\" :\" bår\" }" ;
120
+ MediaType contentType = new MediaType ("application" , "vnd.api.v1+json" );
121
+ this .converter .write (body , contentType , this .outputMessage );
122
+
123
+ HttpHeaders headers = this .outputMessage .getHeaders ();
124
+ assertThat (this .outputMessage .getBodyAsString (StandardCharsets .UTF_8 )).isEqualTo (body );
125
+ assertThat (headers .getContentType ()).isEqualTo (contentType );
126
+ assertThat (headers .getContentLength ()).isEqualTo (body .getBytes (StandardCharsets .UTF_8 ).length );
127
+ assertThat (headers .getAcceptCharset ().isEmpty ()).isTrue ();
128
+ }
129
+
107
130
@ Test
108
131
public void writeUTF8 () throws IOException {
109
132
String body = "H\u00e9 llo W\u00f6 rld" ;
0 commit comments