From ed1e58c45e3e0b948be7fbe9f3e3503a1e78f687 Mon Sep 17 00:00:00 2001 From: adalagandev Date: Tue, 20 Feb 2024 15:08:05 +0100 Subject: [PATCH] BAEL-7131 version 7 --- .../com/baeldung/inputstream/InputStreamUnitTest.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/inputstream/InputStreamUnitTest.java b/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/inputstream/InputStreamUnitTest.java index e253690762..6488e91c3e 100644 --- a/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/inputstream/InputStreamUnitTest.java +++ b/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/inputstream/InputStreamUnitTest.java @@ -21,7 +21,7 @@ import org.junit.Assert; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; public class InputStreamUnitTest { - @Test //givenAStringWrittenToAFile_whenReadByX_thenY + @Test public void givenAStringWrittenToFile_whenReadWithFileInputStream_thenItShouldExitsInTheInputStream(@TempDir Path tempDir) throws IOException { Path sampleOut = tempDir.resolve("sample-out.txt"); List lines = Arrays.asList("Hello. This is just a test. Good bye."); @@ -60,19 +60,18 @@ public class InputStreamUnitTest { } } @Test - public void givenKeyValuePairsWrittenInAFile_whenPassedInOutputStreams_thenThePairsShouldExistsInObjectInputStreams( - @TempDir Path tempDir) throws IOException, ClassNotFoundException { + public void givenKeyValuePairsWrittenInAFile_whenPassedInOutputStreams_thenThePairsShouldExistsInObjectInputStreams(@TempDir Path tempDir) throws IOException, ClassNotFoundException { Path sampleOut = tempDir.resolve("sample-out.txt"); - File fileText = sampleOut.toFile(); + File textFile = sampleOut.toFile(); //Serialize a Hashmap then write it into a file. Map kv = new HashMap<>(); - try (ObjectOutputStream objectOutStream = new ObjectOutputStream(new FileOutputStream(fileText))) { + try (ObjectOutputStream objectOutStream = new ObjectOutputStream(new FileOutputStream(textFile))) { kv.put("baseURL", "baeldung.com"); kv.put("apiKey", "this_is_a_test_key"); objectOutStream.writeObject(kv); } //Deserialize the contents of a file then transform it back into a Hashmap - try (ObjectInputStream input = new ObjectInputStream(new FileInputStream(fileText))) { + try (ObjectInputStream input = new ObjectInputStream(new FileInputStream(textFile))) { HashMap inputKv = (HashMap) input.readObject(); assertThat(kv.get("baseURL")).isEqualTo( inputKv.get("baseURL")); assertThat(kv.get("apiKey")).isEqualTo( inputKv.get("apiKey"));