From 7a9738b4bb1870bf3445c91e5810fbc3093251ba Mon Sep 17 00:00:00 2001 From: Afshin Date: Mon, 7 Oct 2019 12:20:54 +0200 Subject: [PATCH] Enhanced: reformatted code to synchronized it with the article --- .../CharacterEncodingExamplesUnitTest.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/encoding/CharacterEncodingExamplesUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/encoding/CharacterEncodingExamplesUnitTest.java index 821c434117..39152c6fb1 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/encoding/CharacterEncodingExamplesUnitTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/encoding/CharacterEncodingExamplesUnitTest.java @@ -75,23 +75,27 @@ public class CharacterEncodingExamplesUnitTest { @Test public void givenUTF8String_whenDecodeByUS_ASCII_thenIgnoreMalformedInputSequence() throws IOException { - Assertions.assertEquals("The faade pattern is a software design pattern.", - CharacterEncodingExamples.decodeText( - "The façade pattern is a software design pattern.", StandardCharsets.US_ASCII, CodingErrorAction.IGNORE)); + Assertions.assertEquals("The faade pattern is a software design pattern.", CharacterEncodingExamples.decodeText("The façade pattern is a software design pattern.", StandardCharsets.US_ASCII, CodingErrorAction.IGNORE)); } @Test public void givenUTF8String_whenDecodeByUS_ASCII_thenReplaceMalformedInputSequence() throws IOException { - Assertions.assertEquals("The fa��ade pattern is a software design pattern.", + Assertions.assertEquals( + "The fa��ade pattern is a software design pattern.", CharacterEncodingExamples.decodeText( - "The façade pattern is a software design pattern.", StandardCharsets.US_ASCII, CodingErrorAction.REPLACE)); + "The façade pattern is a software design pattern.", + StandardCharsets.US_ASCII, + CodingErrorAction.REPLACE)); } @Test public void givenUTF8String_whenDecodeByUS_ASCII_thenReportMalformedInputSequence() { - Assertions.assertThrows(MalformedInputException.class, + Assertions.assertThrows( + MalformedInputException.class, () -> CharacterEncodingExamples.decodeText( - "The façade pattern is a software design pattern.", StandardCharsets.US_ASCII, CodingErrorAction.REPORT)); + "The façade pattern is a software design pattern.", + StandardCharsets.US_ASCII, + CodingErrorAction.REPORT)); } @Test @@ -99,6 +103,7 @@ public class CharacterEncodingExamplesUnitTest { Path path = Paths.get("src/test/resources/encoding.txt"); List allCandidateCharSets = Arrays.asList( StandardCharsets.US_ASCII, StandardCharsets.UTF_8, StandardCharsets.ISO_8859_1); + List suitableCharsets = new ArrayList<>(); allCandidateCharSets.forEach(charset -> { try {