mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
verify encoding and content type
This commit is contained in:
@@ -81,7 +81,6 @@ public class I18nServlet extends HttpServlet {
|
|||||||
response.setCharacterEncoding("UTF-8");
|
response.setCharacterEncoding("UTF-8");
|
||||||
response.setContentType("application/json");
|
response.setContentType("application/json");
|
||||||
try (PrintWriter out = response.getWriter()) {
|
try (PrintWriter out = response.getWriter()) {
|
||||||
response.setContentType("application/json");
|
|
||||||
String path = req.getServletPath();
|
String path = req.getServletPath();
|
||||||
Function<String, Optional<JsonNode>> jsonFileProvider = usedPath -> Optional.empty();
|
Function<String, Optional<JsonNode>> jsonFileProvider = usedPath -> Optional.empty();
|
||||||
BiConsumer<String, JsonNode> createdJsonFileConsumer = (usedPath, jsonNode) -> log.debug("A json File is created from the path {}", usedPath);
|
BiConsumer<String, JsonNode> createdJsonFileConsumer = (usedPath, jsonNode) -> log.debug("A json File is created from the path {}", usedPath);
|
||||||
|
|||||||
@@ -194,6 +194,8 @@ public class I18nServletTest {
|
|||||||
assertJson(json);
|
assertJson(json);
|
||||||
verify(cache).get(path);
|
verify(cache).get(path);
|
||||||
verify(cache).put(eq(path), any());
|
verify(cache).put(eq(path), any());
|
||||||
|
|
||||||
|
verifyHeaders(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -221,6 +223,8 @@ public class I18nServletTest {
|
|||||||
verify(cache, never()).put(eq(path), any());
|
verify(cache, never()).put(eq(path), any());
|
||||||
verify(cache).get(path);
|
verify(cache).get(path);
|
||||||
assertJson(json);
|
assertJson(json);
|
||||||
|
|
||||||
|
verifyHeaders(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -234,6 +238,11 @@ public class I18nServletTest {
|
|||||||
assertJson(jsonNodeOptional.orElse(null));
|
assertJson(jsonNodeOptional.orElse(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void verifyHeaders(HttpServletResponse response) {
|
||||||
|
verify(response).setCharacterEncoding("UTF-8");
|
||||||
|
verify(response).setContentType("application/json");
|
||||||
|
}
|
||||||
|
|
||||||
public void assertJson(JsonNode actual) throws IOException {
|
public void assertJson(JsonNode actual) throws IOException {
|
||||||
assertJson(actual.toString());
|
assertJson(actual.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user