diff --git a/modules/10-basics/10-hello-world/Test.java b/modules/10-basics/10-hello-world/Test.java index bfc97be..0d23c54 100644 --- a/modules/10-basics/10-hello-world/Test.java +++ b/modules/10-basics/10-hello-world/Test.java @@ -1,14 +1,14 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; -import org.assertj.core.api.Assertions; +import static org.assertj.core.api.Assertions.assertThat; class Test { public static void main(final String[] args) { final var expected = "Hello, World!"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(final String[] args) { final var actual = out.toString().trim(); - Assertions.assertThat(actual).isEqualTo(expected); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/10-basics/40-testing/Test.java b/modules/10-basics/40-testing/Test.java index 192ea26..a2eff62 100644 --- a/modules/10-basics/40-testing/Test.java +++ b/modules/10-basics/40-testing/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -8,8 +10,6 @@ class Test { public static void main(String[] args) { final var expected = "420262531"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -17,8 +17,10 @@ public static void main(String[] args) { final var actual = out.toString().trim(); - assertThat(actual).isEqualTo(expected); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/10-basics/50-syntax-error/Test.java b/modules/10-basics/50-syntax-error/Test.java index adfbe03..edcf84c 100644 --- a/modules/10-basics/50-syntax-error/Test.java +++ b/modules/10-basics/50-syntax-error/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(final String[] args) { final var expected = "What Is Dead May Never Die"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(final String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/20-arithmetics/10-basics/Test.java b/modules/20-arithmetics/10-basics/Test.java index 4b9f24a..57b6077 100644 --- a/modules/20-arithmetics/10-basics/Test.java +++ b/modules/20-arithmetics/10-basics/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "9"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/20-arithmetics/20-operators/Test.java b/modules/20-arithmetics/20-operators/Test.java index 536cb22..00e23f8 100644 --- a/modules/20-arithmetics/20-operators/Test.java +++ b/modules/20-arithmetics/20-operators/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -8,8 +10,6 @@ class Test { public static void main(String[] args) { final var expected = "87"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -17,8 +17,10 @@ public static void main(String[] args) { final var actual = out.toString().trim(); - assertThat(actual).isEqualTo(expected); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/20-arithmetics/40-composition/Test.java b/modules/20-arithmetics/40-composition/Test.java index a886ea2..2f5d7e1 100644 --- a/modules/20-arithmetics/40-composition/Test.java +++ b/modules/20-arithmetics/40-composition/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "10"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/20-arithmetics/50-priority/Test.java b/modules/20-arithmetics/50-priority/Test.java index f8bc3cf..5fafc04 100644 --- a/modules/20-arithmetics/50-priority/Test.java +++ b/modules/20-arithmetics/50-priority/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "49"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/20-arithmetics/60-float/Test.java b/modules/20-arithmetics/60-float/Test.java index fee6cab..33a18ae 100644 --- a/modules/20-arithmetics/60-float/Test.java +++ b/modules/20-arithmetics/60-float/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "0.0858"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/20-arithmetics/80-linting/Test.java b/modules/20-arithmetics/80-linting/Test.java index 0ba95cf..6848de0 100644 --- a/modules/20-arithmetics/80-linting/Test.java +++ b/modules/20-arithmetics/80-linting/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "-14"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/25-strings/10-quotes/Test.java b/modules/25-strings/10-quotes/Test.java index 5b785eb..c73d1c1 100644 --- a/modules/25-strings/10-quotes/Test.java +++ b/modules/25-strings/10-quotes/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "\"Khal Drogo's favorite word is \"athjahakar\"\""; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/25-strings/20-strings-concatenation/Test.java b/modules/25-strings/20-strings-concatenation/Test.java index a71b960..a76ad85 100644 --- a/modules/25-strings/20-strings-concatenation/Test.java +++ b/modules/25-strings/20-strings-concatenation/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "Winter " + "came " + "for " + "the " + "House " + "of " + "Frey."; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/30-variables/10-definition/Test.java b/modules/30-variables/10-definition/Test.java index 38f7bf0..b52d238 100644 --- a/modules/30-variables/10-definition/Test.java +++ b/modules/30-variables/10-definition/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "What Is Dead May Never Die!"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/30-variables/12-change/Test.java b/modules/30-variables/12-change/Test.java index 6438035..5d840ca 100644 --- a/modules/30-variables/12-change/Test.java +++ b/modules/30-variables/12-change/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "anneirB"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/30-variables/13-variables-naming/Test.java b/modules/30-variables/13-variables-naming/Test.java index 625f34d..512f317 100644 --- a/modules/30-variables/13-variables-naming/Test.java +++ b/modules/30-variables/13-variables-naming/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "-110.00000000000001"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/30-variables/14-errors/Test.java b/modules/30-variables/14-errors/Test.java index ba84ccd..602a83c 100644 --- a/modules/30-variables/14-errors/Test.java +++ b/modules/30-variables/14-errors/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "Targaryen and Dragon"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/30-variables/19-naming-style/Test.java b/modules/30-variables/19-naming-style/Test.java index 28fcd6b..b3bad13 100644 --- a/modules/30-variables/19-naming-style/Test.java +++ b/modules/30-variables/19-naming-style/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "-1100"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/30-variables/19-naming-style/ru/EXERCISE.md b/modules/30-variables/19-naming-style/ru/EXERCISE.md index 1ba3540..4959e11 100644 --- a/modules/30-variables/19-naming-style/ru/EXERCISE.md +++ b/modules/30-variables/19-naming-style/ru/EXERCISE.md @@ -1,4 +1,8 @@ Создайте две переменные с именами «первое число» и «второе число» на английском языке, используя lowerCamelCase. Запишите в первую переменную число `11`, во вторую — `-100`. Выведите на экран произведение чисел, записанных в получившихся переменных. +
+-1100
+
+ Код будет работать с любыми названиями, а наша система всегда проверяет только результат на экране, поэтому выполнение этого задания — под вашу ответственность. diff --git a/modules/30-variables/20-magic-numbers/Test.java b/modules/30-variables/20-magic-numbers/Test.java index 178c10c..6d0d440 100644 --- a/modules/30-variables/20-magic-numbers/Test.java +++ b/modules/30-variables/20-magic-numbers/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "King Balon the 6th has 102 rooms."; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/33-data-types/41-data-types-basics/Test.java b/modules/33-data-types/41-data-types-basics/Test.java index 9b1078b..acb3586 100644 --- a/modules/33-data-types/41-data-types-basics/Test.java +++ b/modules/33-data-types/41-data-types-basics/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "1"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/33-data-types/45-explicit-types/Test.java b/modules/33-data-types/45-explicit-types/Test.java index 61c825d..d66e4f5 100644 --- a/modules/33-data-types/45-explicit-types/Test.java +++ b/modules/33-data-types/45-explicit-types/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -14,7 +16,8 @@ public static void main(String[] args) { final var actual = out.toString().trim(); - App.main(null); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); assertThat(actual).isEqualTo(expected); } diff --git a/modules/33-data-types/47-data-types-list/Test.java b/modules/33-data-types/47-data-types-list/Test.java index 666d60e..f5d6858 100644 --- a/modules/33-data-types/47-data-types-list/Test.java +++ b/modules/33-data-types/47-data-types-list/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "hexlet-7"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/33-data-types/50-null/Test.java b/modules/33-data-types/50-null/Test.java index daca321..8a9dd7f 100644 --- a/modules/33-data-types/50-null/Test.java +++ b/modules/33-data-types/50-null/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "Hello Hexlet!"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/35-methods-using/100-methods/Test.java b/modules/35-methods-using/100-methods/Test.java index d07b111..b1b5fca 100644 --- a/modules/35-methods-using/100-methods/Test.java +++ b/modules/35-methods-using/100-methods/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "12"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/35-methods-using/105-methods-parameters/Test.java b/modules/35-methods-using/105-methods-parameters/Test.java index 07e9d0b..280db67 100644 --- a/modules/35-methods-using/105-methods-parameters/Test.java +++ b/modules/35-methods-using/105-methods-parameters/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "h o d o r"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/35-methods-using/115-string-immutability/Test.java b/modules/35-methods-using/115-string-immutability/Test.java index 285a34b..f875d6a 100644 --- a/modules/35-methods-using/115-string-immutability/Test.java +++ b/modules/35-methods-using/115-string-immutability/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "support@hexlet.io"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/40-methods-definition/100-method-definition-static/Test.java b/modules/40-methods-definition/100-method-definition-static/Test.java index 4f4931c..9f9ad50 100644 --- a/modules/40-methods-definition/100-method-definition-static/Test.java +++ b/modules/40-methods-definition/100-method-definition-static/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "Winter is coming"; - App.printMotto(); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } } diff --git a/modules/40-methods-definition/150-method-main/Test.java b/modules/40-methods-definition/150-method-main/Test.java index fa83817..b86e413 100644 --- a/modules/40-methods-definition/150-method-main/Test.java +++ b/modules/40-methods-definition/150-method-main/Test.java @@ -1,4 +1,6 @@ import java.io.ByteArrayOutputStream; +import java.io.FileDescriptor; +import java.io.FileOutputStream; import java.io.PrintStream; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +9,6 @@ class Test { public static void main(String[] args) { final var expected = "It works!"; - App.main(null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); @@ -16,6 +16,9 @@ public static void main(String[] args) { final var actual = out.toString().trim(); + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + System.out.println(actual); + assertThat(actual).isEqualTo(expected); } }