My project's dependency of spring-boot-starter-parent was upgraded from 2.6.13 to 3.0.3, and unit tests failed two. After checking, I'm sure the problem is due to the upgrade.
-
Code:
ContentDisposition.inline().filename("default.jpg", StandardCharsets.UTF_8).build().toString()Expected:inline; filename*=UTF-8''default.jpgActual:inline; filename="=?UTF-8?Q?default.jpg?="; filename*=UTF-8''default.jpg -
Code:
this.testRestTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(null), new ParameterizedTypeReference<LongTermTaskModel<List<String>>>() {} );Error:org.springframework.web.client.UnknownContentTypeException: Could not extract response: no suitable HttpMessageConverter found for response type
My repository: https://github.com/zdu-strong/Technical_Backup/tree/springboot_3.0.3/springboot
Environmental requirements: java v17
run command: ./mvn clean test
Comment From: wilkinsona
The first change is expected. It is due to this change in Spring Framework. You should update your test accordingly.
The second appears to be due to your my custom headers: Hello, World! header. Spaces are not valid characters in the name of an HTTP header. Their presence in the response prevents the Content-Type: application/json header from being received so the default fallback of application/octet-stream is used instead. Removing this illegal header fixes the message conversion problem. I'm not sure why this illegal header name was tolerated before the upgrade and, unfortunately, the sample is far too complex for me to justify spending the time to identify the reason.
Comment From: zdu-strong
Thank you very much, it's my mistake.