improper utf-8 handling in json-unit-spring
See original GitHub issueDescribe the bug
- JsonUnit 2.11.0
- BringBoot 2.2.0.RELEASE
When using json-unit
with rest-assured
all works fine:
given(specification)
.with()
.accept(MediaType.APPLICATION_JSON_VALUE)
.queryParam("produktIds", PreisApiData.PRODUKT_IDS)
.when()
.get("preise")
.then()
.statusCode(HttpStatus.OK.value())
.assertThat()
.contentType(MediaType.APPLICATION_JSON_VALUE)
.body(jsonEquals(PreisApiData.PREIS_DTOS));
But writing the same test with json-unit-spring
and mock-mvc
causes encoding issues:
mockMvc.perform(get("/preise")
.accept(MediaType.APPLICATION_JSON)
.param("produktIds", PreisApiData.PRODUKT1_ID.toString(), PreisApiData.PRODUKT2_ID.toString()))
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(json().isEqualTo(PreisApiData.PREIS_DTOS));
->
Different value found in node "[0].currency", expected: <"€"> but was: <"â¬">.
Comparison Failure:
Expected :€
Actual :â¬
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Spring MVC UTF-8 Encoding - java - Stack Overflow
Thanks to McDwell, I just tried out using "\u00f6lm" instead of "ölm" in my controller and the encoding issue on the JSP page...
Read more >UTF-8: The Secret of Character Encoding - HTML Purifier
This document will walk you through determining the encoding of your system and how you should handle this information. It will stay away...
Read more >What is UTF-8 Encoding? A Guide for Non-Programmers
UTF-8 is a Unicode character encoding method. This means that UTF-8 takes the code point for a given Unicode character and translates it...
Read more >Haskell with UTF-8 - Serokell
Bad news: something is wrong. Good news: it is not necessarily an issue with your code, it can be one of the libraries...
Read more >Encoding.UTF8 Property (System.Text) - Microsoft Learn
It displays the UTF-16 code units of each character and determines the number of bytes required by a UTF-8 encoder to encode the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Good catch, thanks, will fix it.
Released as 2.11.1