From 07cd60e8438f247c37d449f009f3168a4b9bddce Mon Sep 17 00:00:00 2001 From: Nikunj Gandhi Date: Tue, 30 Jul 2019 16:44:46 -0400 Subject: [PATCH 01/55] Selection sort implementation --- .../selectionsort/SelectionSort.java | 72 +++++++++++++++++++ .../selectionsort/SelectionSortUnitTest.java | 25 +++++++ 2 files changed, 97 insertions(+) create mode 100644 algorithms-sorting/src/main/java/com/baeldung/algorithms/selectionsort/SelectionSort.java create mode 100644 algorithms-sorting/src/test/java/com/baeldung/algorithms/selectionsort/SelectionSortUnitTest.java diff --git a/algorithms-sorting/src/main/java/com/baeldung/algorithms/selectionsort/SelectionSort.java b/algorithms-sorting/src/main/java/com/baeldung/algorithms/selectionsort/SelectionSort.java new file mode 100644 index 0000000000..1b160a492d --- /dev/null +++ b/algorithms-sorting/src/main/java/com/baeldung/algorithms/selectionsort/SelectionSort.java @@ -0,0 +1,72 @@ +package com.baeldung.algorithms.selectionsort; + +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public class SelectionSort { + + /*public static void main(final String args[]) { + int[] a = { 5, 4, 1, 6, 2 }; + + System.out.println("Unsorted array"); + System.out.println(IntStream.of(a) + .mapToObj(String::valueOf) + .collect(Collectors.joining(","))); + + a = sortAscending(a); + System.out.println("Ascending Sorted array"); + System.out.println(IntStream.of(a) + .mapToObj(String::valueOf) + .collect(Collectors.joining(","))); + + a = sortDescending(a); + System.out.println("Descending Sorted array"); + System.out.println(IntStream.of(a) + .mapToObj(String::valueOf) + .collect(Collectors.joining(","))); + }*/ + + public static void sortAscending(final int[] arr) { + for (int i = 0; i < arr.length - 1; i++) { + int minElementIndex = i; + for (int j = i + 1; j < arr.length; j++) { + if (arr[minElementIndex] > arr[j]) { + minElementIndex = j; + } + } + + if (minElementIndex != i) { + int temp = arr[i]; + arr[i] = arr[minElementIndex]; + arr[minElementIndex] = temp; + } + System.out.println("Iteration No. " + (i + 1)); + System.out.println(IntStream.of(arr) + .mapToObj(String::valueOf) + .collect(Collectors.joining(","))); + + } + } + + public static void sortDescending(final int[] arr) { + for (int i = 0; i < arr.length - 1; i++) { + int maxElementIndex = i; + for (int j = i + 1; j < arr.length; j++) { + if (arr[maxElementIndex] < arr[j]) { + maxElementIndex = j; + } + } + + if (maxElementIndex != i) { + int temp = arr[i]; + arr[i] = arr[maxElementIndex]; + arr[maxElementIndex] = temp; + } + System.out.println("Iteration No. " + (i + 1)); + System.out.println(IntStream.of(arr) + .mapToObj(String::valueOf) + .collect(Collectors.joining(","))); + + } + } +} \ No newline at end of file diff --git a/algorithms-sorting/src/test/java/com/baeldung/algorithms/selectionsort/SelectionSortUnitTest.java b/algorithms-sorting/src/test/java/com/baeldung/algorithms/selectionsort/SelectionSortUnitTest.java new file mode 100644 index 0000000000..85efd1d3da --- /dev/null +++ b/algorithms-sorting/src/test/java/com/baeldung/algorithms/selectionsort/SelectionSortUnitTest.java @@ -0,0 +1,25 @@ +package com.baeldung.algorithms.selectionsort; + +import static org.junit.Assert.*; +import static org.junit.Assert.assertArrayEquals; + +import org.junit.Test; + +public class SelectionSortUnitTest { + + @Test + public void givenUnsortedArray_whenSelectionSort_SortAscending_thenSortedAsc() { + int[] input = { 5, 4, 1, 6, 2 }; + SelectionSort.sortAscending(input); + int[] expected = {1, 2, 4, 5, 6}; + assertArrayEquals("the two arrays are not equal", expected, input); + } + + @Test + public void givenUnsortedArray_whenSelectionSort_SortDescending_thenSortedDesc() { + int[] input = { 5, 4, 1, 6, 2 }; + SelectionSort.sortDescending(input); + int[] expected = {6, 5, 4, 2, 1}; + assertArrayEquals("the two arrays are not equal", expected, input); + } +} From 01cd19d427b08bd26c27c4e0687e1d842f6a1b59 Mon Sep 17 00:00:00 2001 From: Nikunj Gandhi Date: Tue, 30 Jul 2019 16:46:22 -0400 Subject: [PATCH 02/55] Selection sort implementation --- .../selectionsort/SelectionSort.java | 34 ------------------- 1 file changed, 34 deletions(-) diff --git a/algorithms-sorting/src/main/java/com/baeldung/algorithms/selectionsort/SelectionSort.java b/algorithms-sorting/src/main/java/com/baeldung/algorithms/selectionsort/SelectionSort.java index 1b160a492d..17e95edf06 100644 --- a/algorithms-sorting/src/main/java/com/baeldung/algorithms/selectionsort/SelectionSort.java +++ b/algorithms-sorting/src/main/java/com/baeldung/algorithms/selectionsort/SelectionSort.java @@ -1,31 +1,7 @@ package com.baeldung.algorithms.selectionsort; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - public class SelectionSort { - /*public static void main(final String args[]) { - int[] a = { 5, 4, 1, 6, 2 }; - - System.out.println("Unsorted array"); - System.out.println(IntStream.of(a) - .mapToObj(String::valueOf) - .collect(Collectors.joining(","))); - - a = sortAscending(a); - System.out.println("Ascending Sorted array"); - System.out.println(IntStream.of(a) - .mapToObj(String::valueOf) - .collect(Collectors.joining(","))); - - a = sortDescending(a); - System.out.println("Descending Sorted array"); - System.out.println(IntStream.of(a) - .mapToObj(String::valueOf) - .collect(Collectors.joining(","))); - }*/ - public static void sortAscending(final int[] arr) { for (int i = 0; i < arr.length - 1; i++) { int minElementIndex = i; @@ -40,11 +16,6 @@ public class SelectionSort { arr[i] = arr[minElementIndex]; arr[minElementIndex] = temp; } - System.out.println("Iteration No. " + (i + 1)); - System.out.println(IntStream.of(arr) - .mapToObj(String::valueOf) - .collect(Collectors.joining(","))); - } } @@ -62,11 +33,6 @@ public class SelectionSort { arr[i] = arr[maxElementIndex]; arr[maxElementIndex] = temp; } - System.out.println("Iteration No. " + (i + 1)); - System.out.println(IntStream.of(arr) - .mapToObj(String::valueOf) - .collect(Collectors.joining(","))); - } } } \ No newline at end of file From f66e0d8053988a6436a6346c6a8edd06f435f33a Mon Sep 17 00:00:00 2001 From: Nikunj Gandhi Date: Sun, 8 Sep 2019 16:27:20 -0400 Subject: [PATCH 03/55] BAEL-3214 | Unit tests for class FileWriter --- .../filewriter/FileWriterExampleTest.java | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleTest.java diff --git a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleTest.java b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleTest.java new file mode 100644 index 0000000000..521a6dd477 --- /dev/null +++ b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleTest.java @@ -0,0 +1,123 @@ +package com.baeldung.filewriter; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.junit.After; +import org.junit.Test; + +public class FileWriterExampleTest { + + @After + public void tearDown() throws IOException { + Files.delete(Path.of("src/test/resources/FileWriterTest.txt")); + } + + @Test + public void testFileWriter_Constructor_With_FileName() throws IOException { + try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt")) { + fileWriter.write("Hello Folks!"); + } + + assertEquals("Hello Folks!", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); + } + + @Test + public void testFileWriter_Constructor_With_FileName_And_Charset() throws IOException { + try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt", Charset.forName("US-ASCII"))) { + fileWriter.write("Hello Folks! Let us learn the Façade design pattern"); + } + + System.out.println(new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); + assertEquals("Hello Folks! Let us learn the Fa?ade design pattern", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); + } + + @Test + public void testFileWriter_Constructor_With_FileName_And_AppendFlag() throws IOException { + try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt")) { + fileWriter.write("Hello Folks!"); + } + + try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt", true)) { + fileWriter.write("Let us learn the Façade design pattern"); + } + + assertEquals("Hello Folks!Let us learn the Façade design pattern", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); + } + + @Test + public void testFileWriter_Constructor_With_FileName_And_Charset_And_AppendFlag() throws IOException { + try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt", Charset.forName("US-ASCII"))) { + fileWriter.write("Hello Folks!"); + } + + try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt", Charset.forName("US-ASCII"), true)) { + fileWriter.write("Let us learn the Façade design pattern"); + } + + assertEquals("Hello Folks!Let us learn the Fa?ade design pattern", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); + } + + @Test + public void testFileWriter_Constructor_With_File() throws IOException { + try (FileWriter fileWriter = new FileWriter(new File("src/test/resources/FileWriterTest.txt"))) { + fileWriter.write("Hello Folks!"); + } + + assertEquals("Hello Folks!", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); + } + + @Test + public void testFileWriter_Constructor_With_File_And_Charset() throws IOException { + try (FileWriter fileWriter = new FileWriter(new File("src/test/resources/FileWriterTest.txt"), Charset.forName("US-ASCII"))) { + fileWriter.write("Hello Folks!Let us learn the Façade design pattern"); + } + + assertEquals("Hello Folks!Let us learn the Fa?ade design pattern", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); + } + + @Test + public void testFileWriter_Constructor_With_File_And_AppendFlag() throws IOException { + try (FileWriter fileWriter = new FileWriter(new File("src/test/resources/FileWriterTest.txt"))) { + fileWriter.write("Hello Folks!"); + } + + try (FileWriter fileWriter = new FileWriter(new File("src/test/resources/FileWriterTest.txt"), true)) { + fileWriter.write("Let us learn the Façade design pattern"); + } + + assertEquals("Hello Folks!Let us learn the Façade design pattern", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); + } + + @Test + public void testFileWriter_Constructor_With_File_And_Charset_And_AppendFlag() throws IOException { + try (FileWriter fileWriter = new FileWriter(new File("src/test/resources/FileWriterTest.txt"), Charset.forName("US-ASCII"))) { + fileWriter.write("Hello Folks!"); + } + + try (FileWriter fileWriter = new FileWriter(new File("src/test/resources/FileWriterTest.txt"), Charset.forName("US-ASCII"), true)) { + fileWriter.write("Let us learn the Façade design pattern"); + } + + assertEquals("Hello Folks!Let us learn the Fa?ade design pattern", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); + } + + @Test + public void testFileWriter_Constructor_With_FileDescriptor() throws FileNotFoundException, IOException { + try(FileOutputStream fos = new FileOutputStream(new File("src/test/resources/FileWriterTest.txt")); + FileWriter fileWriter = new FileWriter(fos.getFD())){ + fileWriter.write("Hello Folks!"); + } + + assertEquals("Hello Folks!", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); + } + +} From 827c97e47b3baed17ed061834b7ef36fa84a6af7 Mon Sep 17 00:00:00 2001 From: Nikunj Gandhi Date: Sun, 8 Sep 2019 16:42:03 -0400 Subject: [PATCH 04/55] Code formatted --- .../filewriter/FileWriterExampleTest.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleTest.java b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleTest.java index 521a6dd477..2147bd5ef2 100644 --- a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleTest.java +++ b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleTest.java @@ -35,9 +35,9 @@ public class FileWriterExampleTest { try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt", Charset.forName("US-ASCII"))) { fileWriter.write("Hello Folks! Let us learn the Façade design pattern"); } - + System.out.println(new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); - assertEquals("Hello Folks! Let us learn the Fa?ade design pattern", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); + assertEquals("Hello Folks! Let us learn the Fa?ade design pattern", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); } @Test @@ -62,7 +62,7 @@ public class FileWriterExampleTest { try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt", Charset.forName("US-ASCII"), true)) { fileWriter.write("Let us learn the Façade design pattern"); } - + assertEquals("Hello Folks!Let us learn the Fa?ade design pattern", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); } @@ -80,7 +80,7 @@ public class FileWriterExampleTest { try (FileWriter fileWriter = new FileWriter(new File("src/test/resources/FileWriterTest.txt"), Charset.forName("US-ASCII"))) { fileWriter.write("Hello Folks!Let us learn the Façade design pattern"); } - + assertEquals("Hello Folks!Let us learn the Fa?ade design pattern", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); } @@ -106,17 +106,16 @@ public class FileWriterExampleTest { try (FileWriter fileWriter = new FileWriter(new File("src/test/resources/FileWriterTest.txt"), Charset.forName("US-ASCII"), true)) { fileWriter.write("Let us learn the Façade design pattern"); } - + assertEquals("Hello Folks!Let us learn the Fa?ade design pattern", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); } - + @Test public void testFileWriter_Constructor_With_FileDescriptor() throws FileNotFoundException, IOException { - try(FileOutputStream fos = new FileOutputStream(new File("src/test/resources/FileWriterTest.txt")); - FileWriter fileWriter = new FileWriter(fos.getFD())){ - fileWriter.write("Hello Folks!"); + try (FileOutputStream fos = new FileOutputStream(new File("src/test/resources/FileWriterTest.txt")); FileWriter fileWriter = new FileWriter(fos.getFD())) { + fileWriter.write("Hello Folks!"); } - + assertEquals("Hello Folks!", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); } From 31be377141a553037013dbe23e701d3878f6b0aa Mon Sep 17 00:00:00 2001 From: Nikunj Gandhi Date: Sun, 15 Sep 2019 13:17:48 -0400 Subject: [PATCH 05/55] BAEL-3214 | Java FileWriter class code - 2 --- .../filewriter/FileWriterExample.java | 37 ++++++ .../filewriter/FileWriterExampleTest.java | 122 ------------------ .../filewriter/FileWriterExampleUnitTest.java | 57 ++++++++ 3 files changed, 94 insertions(+), 122 deletions(-) create mode 100644 core-java-modules/core-java-io-2/src/main/java/com/baeldung/filewriter/FileWriterExample.java delete mode 100644 core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleTest.java create mode 100644 core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleUnitTest.java diff --git a/core-java-modules/core-java-io-2/src/main/java/com/baeldung/filewriter/FileWriterExample.java b/core-java-modules/core-java-io-2/src/main/java/com/baeldung/filewriter/FileWriterExample.java new file mode 100644 index 0000000000..d60f0800ec --- /dev/null +++ b/core-java-modules/core-java-io-2/src/main/java/com/baeldung/filewriter/FileWriterExample.java @@ -0,0 +1,37 @@ +package com.baeldung.filewriter; + +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; +import java.util.List; + +public class FileWriterExample { + + public void writeString(String fileName, String strToWrite) throws IOException { + try (FileWriter fileWriter = new FileWriter(fileName)) { + fileWriter.write(strToWrite); + } + } + + public void appendString(String fileName, String stringToAppend) throws IOException { + try (FileWriter fileWriter = new FileWriter(fileName, true)) { + fileWriter.append(stringToAppend); + } + } + + public void writeCharArray(String fileName, char[] charArrToWrite) throws IOException { + try (FileWriter fileWriter = new FileWriter(fileName)) { + fileWriter.write(charArrToWrite); + } + } + + public void writeWithBufferedWriter(String fileName, List stringsToWrite) throws IOException { + try (FileWriter fileWriter = new FileWriter(fileName); BufferedWriter bufferedWriter = new BufferedWriter(fileWriter)) { + for (String stringToWrite : stringsToWrite) { + bufferedWriter.write(stringToWrite); + } + } + + } + +} diff --git a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleTest.java b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleTest.java deleted file mode 100644 index 2147bd5ef2..0000000000 --- a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleTest.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.baeldung.filewriter; - -import static org.junit.Assert.assertEquals; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.nio.charset.Charset; -import java.nio.file.Files; -import java.nio.file.Path; - -import org.junit.After; -import org.junit.Test; - -public class FileWriterExampleTest { - - @After - public void tearDown() throws IOException { - Files.delete(Path.of("src/test/resources/FileWriterTest.txt")); - } - - @Test - public void testFileWriter_Constructor_With_FileName() throws IOException { - try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt")) { - fileWriter.write("Hello Folks!"); - } - - assertEquals("Hello Folks!", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); - } - - @Test - public void testFileWriter_Constructor_With_FileName_And_Charset() throws IOException { - try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt", Charset.forName("US-ASCII"))) { - fileWriter.write("Hello Folks! Let us learn the Façade design pattern"); - } - - System.out.println(new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); - assertEquals("Hello Folks! Let us learn the Fa?ade design pattern", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); - } - - @Test - public void testFileWriter_Constructor_With_FileName_And_AppendFlag() throws IOException { - try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt")) { - fileWriter.write("Hello Folks!"); - } - - try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt", true)) { - fileWriter.write("Let us learn the Façade design pattern"); - } - - assertEquals("Hello Folks!Let us learn the Façade design pattern", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); - } - - @Test - public void testFileWriter_Constructor_With_FileName_And_Charset_And_AppendFlag() throws IOException { - try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt", Charset.forName("US-ASCII"))) { - fileWriter.write("Hello Folks!"); - } - - try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt", Charset.forName("US-ASCII"), true)) { - fileWriter.write("Let us learn the Façade design pattern"); - } - - assertEquals("Hello Folks!Let us learn the Fa?ade design pattern", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); - } - - @Test - public void testFileWriter_Constructor_With_File() throws IOException { - try (FileWriter fileWriter = new FileWriter(new File("src/test/resources/FileWriterTest.txt"))) { - fileWriter.write("Hello Folks!"); - } - - assertEquals("Hello Folks!", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); - } - - @Test - public void testFileWriter_Constructor_With_File_And_Charset() throws IOException { - try (FileWriter fileWriter = new FileWriter(new File("src/test/resources/FileWriterTest.txt"), Charset.forName("US-ASCII"))) { - fileWriter.write("Hello Folks!Let us learn the Façade design pattern"); - } - - assertEquals("Hello Folks!Let us learn the Fa?ade design pattern", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); - } - - @Test - public void testFileWriter_Constructor_With_File_And_AppendFlag() throws IOException { - try (FileWriter fileWriter = new FileWriter(new File("src/test/resources/FileWriterTest.txt"))) { - fileWriter.write("Hello Folks!"); - } - - try (FileWriter fileWriter = new FileWriter(new File("src/test/resources/FileWriterTest.txt"), true)) { - fileWriter.write("Let us learn the Façade design pattern"); - } - - assertEquals("Hello Folks!Let us learn the Façade design pattern", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); - } - - @Test - public void testFileWriter_Constructor_With_File_And_Charset_And_AppendFlag() throws IOException { - try (FileWriter fileWriter = new FileWriter(new File("src/test/resources/FileWriterTest.txt"), Charset.forName("US-ASCII"))) { - fileWriter.write("Hello Folks!"); - } - - try (FileWriter fileWriter = new FileWriter(new File("src/test/resources/FileWriterTest.txt"), Charset.forName("US-ASCII"), true)) { - fileWriter.write("Let us learn the Façade design pattern"); - } - - assertEquals("Hello Folks!Let us learn the Fa?ade design pattern", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); - } - - @Test - public void testFileWriter_Constructor_With_FileDescriptor() throws FileNotFoundException, IOException { - try (FileOutputStream fos = new FileOutputStream(new File("src/test/resources/FileWriterTest.txt")); FileWriter fileWriter = new FileWriter(fos.getFD())) { - fileWriter.write("Hello Folks!"); - } - - assertEquals("Hello Folks!", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); - } - -} diff --git a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleUnitTest.java b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleUnitTest.java new file mode 100644 index 0000000000..a1fdb5459e --- /dev/null +++ b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleUnitTest.java @@ -0,0 +1,57 @@ +package com.baeldung.filewriter; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.stream.IntStream; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Test; + +public class FileWriterExampleUnitTest { + + private static final String FILE_NAME = "src/test/resources/FileWriterTest.txt"; + private static final String STRING_TO_WRITE = "Hello Folks!"; + private static final String STRING_TO_APPEND = "Hello Folks Again!"; + private static final char[] CHAR_ARRAY_TO_WRITE = STRING_TO_WRITE.toCharArray(); + + private FileWriterExample fileWriterExample = new FileWriterExample(); + + @After + public void tearDown() throws IOException { + Files.delete(Path.of(FILE_NAME)); + } + + @Test + public void testWriteString() throws IOException { + fileWriterExample.writeString(FILE_NAME, STRING_TO_WRITE); + Assert.assertEquals(STRING_TO_WRITE, new String(Files.readAllBytes(Path.of(FILE_NAME)))); + } + + @Test + public void testAppendString() throws IOException { + fileWriterExample.writeString(FILE_NAME, STRING_TO_WRITE); + fileWriterExample.appendString(FILE_NAME, STRING_TO_APPEND); + Assert.assertEquals(STRING_TO_WRITE + STRING_TO_APPEND, new String(Files.readAllBytes(Path.of(FILE_NAME)))); + } + + @Test + public void testWriteCharArray() throws IOException { + fileWriterExample.writeCharArray(FILE_NAME, CHAR_ARRAY_TO_WRITE); + Assert.assertEquals(STRING_TO_WRITE, new String(Files.readAllBytes(Path.of(FILE_NAME)))); + } + + @Test + public void testWriteWithBufferedWriter() throws IOException{ + final List stringsToWrite = new ArrayList<>(); + for(int i=0 ; i < 10000;i++) { + stringsToWrite.add("Random string "+i); + } + fileWriterExample.writeWithBufferedWriter(FILE_NAME, stringsToWrite); + Assert.assertNotNull(new String(Files.readAllBytes(Path.of(FILE_NAME)))); + } +} From 4e063a1120afb7aec6dc9b6ff5548472bc665c5c Mon Sep 17 00:00:00 2001 From: Nikunj Gandhi Date: Thu, 19 Sep 2019 15:26:45 -0400 Subject: [PATCH 06/55] BAEL-3214 | Code review related changes - 1 --- .../filewriter/FileWriterExample.java | 37 ---------------- .../filewriter/FileWriterExampleUnitTest.java | 42 ++++++++----------- 2 files changed, 17 insertions(+), 62 deletions(-) delete mode 100644 core-java-modules/core-java-io-2/src/main/java/com/baeldung/filewriter/FileWriterExample.java diff --git a/core-java-modules/core-java-io-2/src/main/java/com/baeldung/filewriter/FileWriterExample.java b/core-java-modules/core-java-io-2/src/main/java/com/baeldung/filewriter/FileWriterExample.java deleted file mode 100644 index d60f0800ec..0000000000 --- a/core-java-modules/core-java-io-2/src/main/java/com/baeldung/filewriter/FileWriterExample.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.baeldung.filewriter; - -import java.io.BufferedWriter; -import java.io.FileWriter; -import java.io.IOException; -import java.util.List; - -public class FileWriterExample { - - public void writeString(String fileName, String strToWrite) throws IOException { - try (FileWriter fileWriter = new FileWriter(fileName)) { - fileWriter.write(strToWrite); - } - } - - public void appendString(String fileName, String stringToAppend) throws IOException { - try (FileWriter fileWriter = new FileWriter(fileName, true)) { - fileWriter.append(stringToAppend); - } - } - - public void writeCharArray(String fileName, char[] charArrToWrite) throws IOException { - try (FileWriter fileWriter = new FileWriter(fileName)) { - fileWriter.write(charArrToWrite); - } - } - - public void writeWithBufferedWriter(String fileName, List stringsToWrite) throws IOException { - try (FileWriter fileWriter = new FileWriter(fileName); BufferedWriter bufferedWriter = new BufferedWriter(fileWriter)) { - for (String stringToWrite : stringsToWrite) { - bufferedWriter.write(stringToWrite); - } - } - - } - -} diff --git a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleUnitTest.java b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleUnitTest.java index a1fdb5459e..5a8dfcc381 100644 --- a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleUnitTest.java +++ b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleUnitTest.java @@ -1,12 +1,9 @@ package com.baeldung.filewriter; +import java.io.FileWriter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.stream.IntStream; import org.junit.After; import org.junit.Assert; @@ -15,11 +12,6 @@ import org.junit.Test; public class FileWriterExampleUnitTest { private static final String FILE_NAME = "src/test/resources/FileWriterTest.txt"; - private static final String STRING_TO_WRITE = "Hello Folks!"; - private static final String STRING_TO_APPEND = "Hello Folks Again!"; - private static final char[] CHAR_ARRAY_TO_WRITE = STRING_TO_WRITE.toCharArray(); - - private FileWriterExample fileWriterExample = new FileWriterExample(); @After public void tearDown() throws IOException { @@ -28,30 +20,30 @@ public class FileWriterExampleUnitTest { @Test public void testWriteString() throws IOException { - fileWriterExample.writeString(FILE_NAME, STRING_TO_WRITE); - Assert.assertEquals(STRING_TO_WRITE, new String(Files.readAllBytes(Path.of(FILE_NAME)))); + try (FileWriter fileWriter = new FileWriter(FILE_NAME)) { + fileWriter.write("Hello Folks!"); + } + Assert.assertEquals("Hello Folks!", new String(Files.readAllBytes(Path.of(FILE_NAME)))); } @Test public void testAppendString() throws IOException { - fileWriterExample.writeString(FILE_NAME, STRING_TO_WRITE); - fileWriterExample.appendString(FILE_NAME, STRING_TO_APPEND); - Assert.assertEquals(STRING_TO_WRITE + STRING_TO_APPEND, new String(Files.readAllBytes(Path.of(FILE_NAME)))); + try (FileWriter fileWriter = new FileWriter(FILE_NAME)) { + fileWriter.write("Hello Folks!"); + } + // using another try with resources to reopen the file in append mode + try (FileWriter fileWriter = new FileWriter(FILE_NAME, true)) { + fileWriter.write("Hello Folks Again!"); + } + + Assert.assertEquals("Hello Folks!" + "Hello Folks Again!", new String(Files.readAllBytes(Path.of(FILE_NAME)))); } @Test public void testWriteCharArray() throws IOException { - fileWriterExample.writeCharArray(FILE_NAME, CHAR_ARRAY_TO_WRITE); - Assert.assertEquals(STRING_TO_WRITE, new String(Files.readAllBytes(Path.of(FILE_NAME)))); - } - - @Test - public void testWriteWithBufferedWriter() throws IOException{ - final List stringsToWrite = new ArrayList<>(); - for(int i=0 ; i < 10000;i++) { - stringsToWrite.add("Random string "+i); + try (FileWriter fileWriter = new FileWriter(FILE_NAME)) { + fileWriter.write("Hello Folks!".toCharArray()); } - fileWriterExample.writeWithBufferedWriter(FILE_NAME, stringsToWrite); - Assert.assertNotNull(new String(Files.readAllBytes(Path.of(FILE_NAME)))); + Assert.assertEquals("Hello Folks!", new String(Files.readAllBytes(Path.of(FILE_NAME)))); } } From 52934fdb209d773c3360067b397ab38406473a01 Mon Sep 17 00:00:00 2001 From: Nikunj Gandhi Date: Thu, 19 Sep 2019 15:31:48 -0400 Subject: [PATCH 07/55] BAEL-3214 | Code review related changes - 2 --- .../filewriter/FileWriterExampleUnitTest.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleUnitTest.java b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleUnitTest.java index 5a8dfcc381..f94a73b023 100644 --- a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleUnitTest.java +++ b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/filewriter/FileWriterExampleUnitTest.java @@ -11,39 +11,37 @@ import org.junit.Test; public class FileWriterExampleUnitTest { - private static final String FILE_NAME = "src/test/resources/FileWriterTest.txt"; - @After public void tearDown() throws IOException { - Files.delete(Path.of(FILE_NAME)); + Files.delete(Path.of("src/test/resources/FileWriterTest.txt")); } @Test public void testWriteString() throws IOException { - try (FileWriter fileWriter = new FileWriter(FILE_NAME)) { + try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt")) { fileWriter.write("Hello Folks!"); } - Assert.assertEquals("Hello Folks!", new String(Files.readAllBytes(Path.of(FILE_NAME)))); + Assert.assertEquals("Hello Folks!", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); } @Test public void testAppendString() throws IOException { - try (FileWriter fileWriter = new FileWriter(FILE_NAME)) { + try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt")) { fileWriter.write("Hello Folks!"); } // using another try with resources to reopen the file in append mode - try (FileWriter fileWriter = new FileWriter(FILE_NAME, true)) { + try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt", true)) { fileWriter.write("Hello Folks Again!"); } - Assert.assertEquals("Hello Folks!" + "Hello Folks Again!", new String(Files.readAllBytes(Path.of(FILE_NAME)))); + Assert.assertEquals("Hello Folks!" + "Hello Folks Again!", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); } @Test public void testWriteCharArray() throws IOException { - try (FileWriter fileWriter = new FileWriter(FILE_NAME)) { + try (FileWriter fileWriter = new FileWriter("src/test/resources/FileWriterTest.txt")) { fileWriter.write("Hello Folks!".toCharArray()); } - Assert.assertEquals("Hello Folks!", new String(Files.readAllBytes(Path.of(FILE_NAME)))); + Assert.assertEquals("Hello Folks!", new String(Files.readAllBytes(Path.of("src/test/resources/FileWriterTest.txt")))); } } From 42ef916c8058d31e9ba60653d77a02c25d33b55a Mon Sep 17 00:00:00 2001 From: Laurentiu Delcea Date: Fri, 20 Sep 2019 23:19:35 +0300 Subject: [PATCH 08/55] BAEL-3165 Integrate Kinesis with Spring Binder --- .../spring-cloud-stream-kinesis/pom.xml | 48 +++++++++++++++++++ .../java/com/baeldung/KinesisApplication.java | 30 ++++++++++++ .../src/main/resources/application.properties | 11 +++++ .../KinesisApplicationIntegrationTest.java | 15 ++++++ .../src/test/resources/application.properties | 2 + 5 files changed, 106 insertions(+) create mode 100644 spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/pom.xml create mode 100644 spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/src/main/java/com/baeldung/KinesisApplication.java create mode 100644 spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/src/main/resources/application.properties create mode 100644 spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/src/test/java/com/baeldung/KinesisApplicationIntegrationTest.java create mode 100644 spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/src/test/resources/application.properties diff --git a/spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/pom.xml b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/pom.xml new file mode 100644 index 0000000000..3817f2747a --- /dev/null +++ b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + spring-cloud-stream-kinesis + spring-cloud-stream-kinesis + + + org.springframework.boot + spring-boot-starter-parent + 2.1.8.RELEASE + + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.cloud + spring-cloud-stream-binder-kinesis + ${spring-cloud-stream-kinesis-binder.version} + + + + com.amazonaws + aws-java-sdk-kinesis + ${aws-sdk.version} + + + + org.springframework.cloud + spring-cloud-stream-test-support + ${spring-cloud-stream-test.version} + test + + + + + 1.11.632 + 1.2.1.RELEASE + 2.2.1.RELEASE + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/src/main/java/com/baeldung/KinesisApplication.java b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/src/main/java/com/baeldung/KinesisApplication.java new file mode 100644 index 0000000000..c863cd8fe2 --- /dev/null +++ b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/src/main/java/com/baeldung/KinesisApplication.java @@ -0,0 +1,30 @@ +package com.baeldung; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.stream.annotation.EnableBinding; +import org.springframework.cloud.stream.annotation.StreamListener; +import org.springframework.cloud.stream.messaging.Processor; +import org.springframework.messaging.support.MessageBuilder; + +@SpringBootApplication +@EnableBinding(Processor.class) +public class KinesisApplication { + + public static void main(String[] args) { + SpringApplication.run(KinesisApplication.class, args); + } + + @Autowired + private Processor processor; + + @StreamListener(Processor.INPUT) + public void consume(String val) { + System.out.println(val); + } + + public void produce(String val) { + processor.output().send(MessageBuilder.withPayload(val).build()); + } +} \ No newline at end of file diff --git a/spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/src/main/resources/application.properties b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/src/main/resources/application.properties new file mode 100644 index 0000000000..1a966c64fb --- /dev/null +++ b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/src/main/resources/application.properties @@ -0,0 +1,11 @@ +cloud.aws.credentials.access-key=aws-key +cloud.aws.credentials.secret-key=aws-secret +cloud.aws.region.static=eu-central-1 +cloud.aws.stack.auto=false + +spring.cloud.stream.bindings.output.destination=myStream +spring.cloud.stream.bindings.output.content-type=text/plain + +spring.cloud.stream.bindings.input.destination=myStream +spring.cloud.stream.bindings.input.group=myStream-group +spring.cloud.stream.bindings.input.content-type=text/plain \ No newline at end of file diff --git a/spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/src/test/java/com/baeldung/KinesisApplicationIntegrationTest.java b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/src/test/java/com/baeldung/KinesisApplicationIntegrationTest.java new file mode 100644 index 0000000000..4e1c281cfb --- /dev/null +++ b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/src/test/java/com/baeldung/KinesisApplicationIntegrationTest.java @@ -0,0 +1,15 @@ +package com.baeldung; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = KinesisApplication.class) +public class KinesisApplicationIntegrationTest { + @Test + public void whenSpringContextIsBootstrapped_thenNoExceptions() { + + } +} \ No newline at end of file diff --git a/spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/src/test/resources/application.properties b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/src/test/resources/application.properties new file mode 100644 index 0000000000..48005616ec --- /dev/null +++ b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kinesis/src/test/resources/application.properties @@ -0,0 +1,2 @@ +cloud.aws.region.static=eu-central-1 +cloud.aws.stack.auto=false \ No newline at end of file From cc827908e0080d81bdfd080438472d2406769413 Mon Sep 17 00:00:00 2001 From: at508 Date: Sun, 22 Sep 2019 22:46:13 -0400 Subject: [PATCH 09/55] [BAEL-2998] - Adding example for @DirtiesContext --- testing-modules/spring-testing/pom.xml | 10 ++++- .../SpringDataRestApplication.java | 13 ++++++ .../com/baeldung/dirtiescontext/User.java | 9 ++++ .../baeldung/dirtiescontext/UserCache.java | 30 ++++++++++++++ .../dirtiescontext/DirtiesContextTest.java | 41 +++++++++++++++++++ 5 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 testing-modules/spring-testing/src/main/java/com/baeldung/dirtiescontext/SpringDataRestApplication.java create mode 100644 testing-modules/spring-testing/src/main/java/com/baeldung/dirtiescontext/User.java create mode 100644 testing-modules/spring-testing/src/main/java/com/baeldung/dirtiescontext/UserCache.java create mode 100644 testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextTest.java diff --git a/testing-modules/spring-testing/pom.xml b/testing-modules/spring-testing/pom.xml index 6f2700e2df..bb7d54218a 100644 --- a/testing-modules/spring-testing/pom.xml +++ b/testing-modules/spring-testing/pom.xml @@ -15,18 +15,26 @@ - org.hamcrest java-hamcrest ${hamcrest.version} + + org.projectlombok + lombok + ${lombok.version} + provided + + org.springframework.boot spring-boot-starter LATEST + + org.springframework.boot spring-boot-starter-test diff --git a/testing-modules/spring-testing/src/main/java/com/baeldung/dirtiescontext/SpringDataRestApplication.java b/testing-modules/spring-testing/src/main/java/com/baeldung/dirtiescontext/SpringDataRestApplication.java new file mode 100644 index 0000000000..ab784532a7 --- /dev/null +++ b/testing-modules/spring-testing/src/main/java/com/baeldung/dirtiescontext/SpringDataRestApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.dirtiescontext; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringDataRestApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringDataRestApplication.class, args); + } + +} diff --git a/testing-modules/spring-testing/src/main/java/com/baeldung/dirtiescontext/User.java b/testing-modules/spring-testing/src/main/java/com/baeldung/dirtiescontext/User.java new file mode 100644 index 0000000000..4d453c5e91 --- /dev/null +++ b/testing-modules/spring-testing/src/main/java/com/baeldung/dirtiescontext/User.java @@ -0,0 +1,9 @@ +package com.baeldung.dirtiescontext; + +public class User { + + String firstName; + + String lastName; + +} diff --git a/testing-modules/spring-testing/src/main/java/com/baeldung/dirtiescontext/UserCache.java b/testing-modules/spring-testing/src/main/java/com/baeldung/dirtiescontext/UserCache.java new file mode 100644 index 0000000000..f03eee3bb8 --- /dev/null +++ b/testing-modules/spring-testing/src/main/java/com/baeldung/dirtiescontext/UserCache.java @@ -0,0 +1,30 @@ +package com.baeldung.dirtiescontext; + +import java.util.HashSet; +import java.util.Set; + +import org.springframework.stereotype.Component; + +import lombok.Getter; +import lombok.ToString; + +@ToString +@Component +public class UserCache { + + @Getter + private Set userList = new HashSet<>(); + + public boolean addUser(String user) { + return userList.add(user); + } + + public boolean removeUser(String user) { + return userList.remove(user); + } + + public void printUserList(String message) { + System.out.println(message + ": " + userList); + } + +} \ No newline at end of file diff --git a/testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextTest.java b/testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextTest.java new file mode 100644 index 0000000000..6248f758ce --- /dev/null +++ b/testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextTest.java @@ -0,0 +1,41 @@ +package com.baeldung.dirtiescontext; + +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.MethodMode; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@SpringBootTest(classes = SpringDataRestApplication.class) +class DirtiesContextTest { + + @Autowired + protected UserCache userCache; + + @DirtiesContext(methodMode = MethodMode.AFTER_METHOD) + @Test + void testOne() { + userCache.addUser("John Doe"); + userCache.printUserList("Test One"); + } + + @Test + void testTwo() { + userCache.printUserList("Test Two"); + } + + @Test + void testThree() { + userCache.addUser("Jane Doe"); + userCache.printUserList("Test Three"); + } + + @Test + void testFour() { + userCache.printUserList("Test Four"); + } + +} From bb71b1ec070ff5ec2d2edc4960166074825235b5 Mon Sep 17 00:00:00 2001 From: at508 Date: Mon, 23 Sep 2019 07:04:22 -0400 Subject: [PATCH 10/55] [BAEL-2998] - Updating unit test name to match convention --- ...rtiesContextTest.java => DirtiesContextIntegrationTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/{DirtiesContextTest.java => DirtiesContextIntegrationTest.java} (96%) diff --git a/testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextTest.java b/testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextIntegrationTest.java similarity index 96% rename from testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextTest.java rename to testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextIntegrationTest.java index 6248f758ce..b4f3fa773f 100644 --- a/testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextTest.java +++ b/testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextIntegrationTest.java @@ -10,7 +10,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = SpringDataRestApplication.class) -class DirtiesContextTest { +class DirtiesContextIntegrationTest { @Autowired protected UserCache userCache; From ee66ea0013fa2050404ec7333adfbf5ee11a120c Mon Sep 17 00:00:00 2001 From: Alessio Stalla Date: Thu, 26 Sep 2019 11:11:22 +0200 Subject: [PATCH 11/55] #BAEL-17505 Add README descriptions to several modules. --- persistence-modules/hibernate-mapping/README.md | 5 ++++- persistence-modules/spring-data-dynamodb/README.MD | 4 ++++ persistence-modules/spring-data-eclipselink/README.md | 4 ++++ persistence-modules/spring-data-solr/README.md | 4 ++++ persistence-modules/spring-hibernate-5/README.md | 6 +++++- spring-security-thymeleaf/README.MD | 2 +- spring-session/spring-session-jdbc/README.md | 7 +++++-- 7 files changed, 27 insertions(+), 5 deletions(-) diff --git a/persistence-modules/hibernate-mapping/README.md b/persistence-modules/hibernate-mapping/README.md index 99374f9135..658f758709 100644 --- a/persistence-modules/hibernate-mapping/README.md +++ b/persistence-modules/hibernate-mapping/README.md @@ -1,7 +1,10 @@ +## Hibernate Mapping + +This module contains articles about Object-Relational Mapping with Hibernate. ### Relevant Articles: - [Persisting Maps with Hibernate](https://www.baeldung.com/hibernate-persisting-maps) - [Difference Between @Size, @Length, and @Column(length=value)](https://www.baeldung.com/jpa-size-length-column-differences) - [Hibernate Validator Specific Constraints](https://www.baeldung.com/hibernate-validator-constraints) -- [Hibernate One to Many Annotation Tutorial](http://www.baeldung.com/hibernate-one-to-many) \ No newline at end of file +- [Hibernate One to Many Annotation Tutorial](http://www.baeldung.com/hibernate-one-to-many) diff --git a/persistence-modules/spring-data-dynamodb/README.MD b/persistence-modules/spring-data-dynamodb/README.MD index 9a6855ea0b..9f6cdfdb17 100644 --- a/persistence-modules/spring-data-dynamodb/README.MD +++ b/persistence-modules/spring-data-dynamodb/README.MD @@ -1,2 +1,6 @@ +## Spring Data with DynamoDB + +This module contains articles about Spring Data with DynamoDB. + ### Relevant Articles: - [DynamoDB in a Spring Boot Application Using Spring Data](http://www.baeldung.com/spring-data-dynamodb) diff --git a/persistence-modules/spring-data-eclipselink/README.md b/persistence-modules/spring-data-eclipselink/README.md index 7981470488..af99bf9cf2 100644 --- a/persistence-modules/spring-data-eclipselink/README.md +++ b/persistence-modules/spring-data-eclipselink/README.md @@ -1,3 +1,7 @@ +## Spring Data with EclipseLink + +This module contains articles about Spring Data with EclipseLink. + ### Relevant articles - [A Guide to EclipseLink with Spring](http://www.baeldung.com/spring-eclipselink) diff --git a/persistence-modules/spring-data-solr/README.md b/persistence-modules/spring-data-solr/README.md index fbce5280e3..c282fd2ce7 100644 --- a/persistence-modules/spring-data-solr/README.md +++ b/persistence-modules/spring-data-solr/README.md @@ -1,2 +1,6 @@ +## Spring Data with Solr + +This module contains articles about Spring Data with Solr. + ### Relevant Articles: - [Introduction to Spring Data Solr](http://www.baeldung.com/spring-data-solr) diff --git a/persistence-modules/spring-hibernate-5/README.md b/persistence-modules/spring-hibernate-5/README.md index 7a18761a7b..a74600a47f 100644 --- a/persistence-modules/spring-hibernate-5/README.md +++ b/persistence-modules/spring-hibernate-5/README.md @@ -1,3 +1,7 @@ +## Hibernate 5 with Spring + +This module contains articles about Hibernate 5 with Spring. + ### Relevant articles - [Hibernate Many to Many Annotation Tutorial](http://www.baeldung.com/hibernate-many-to-many) @@ -7,4 +11,4 @@ - [@DynamicUpdate with Spring Data JPA](https://www.baeldung.com/spring-data-jpa-dynamicupdate) - [Hibernate Second-Level Cache](http://www.baeldung.com/hibernate-second-level-cache) - [Deleting Objects with Hibernate](http://www.baeldung.com/delete-with-hibernate) -- [Spring, Hibernate and a JNDI Datasource](http://www.baeldung.com/spring-persistence-jpa-jndi-datasource) \ No newline at end of file +- [Spring, Hibernate and a JNDI Datasource](http://www.baeldung.com/spring-persistence-jpa-jndi-datasource) diff --git a/spring-security-thymeleaf/README.MD b/spring-security-thymeleaf/README.MD index 67b811fac8..c9bae791e2 100644 --- a/spring-security-thymeleaf/README.MD +++ b/spring-security-thymeleaf/README.MD @@ -1,6 +1,6 @@ ## Spring Security Thymeleaf -This module contains articles about Spring Security with Thymeleaf +This module contains articles about Spring Security with Thymeleaf. ### Relevant Articles: diff --git a/spring-session/spring-session-jdbc/README.md b/spring-session/spring-session-jdbc/README.md index 94fd1cd3e7..a31ee044e8 100644 --- a/spring-session/spring-session-jdbc/README.md +++ b/spring-session/spring-session-jdbc/README.md @@ -1,4 +1,7 @@ -This module is for Spring Session with JDBC tutorial. -Jira BAEL-1911 +## Spring Session with JDBC + +This module contains articles about Spring Session with JDBC. ### Relevant Articles: + +- [Spring Session with JDBC](https://www.baeldung.com/spring-session-jdbc) From e25f50fa1b0445b73b3bd1675435d1485866cb95 Mon Sep 17 00:00:00 2001 From: at508 Date: Thu, 26 Sep 2019 22:58:21 -0400 Subject: [PATCH 12/55] [BAEL-2998] - rearranging test order --- .../baeldung/dirtiescontext/UserCache.java | 2 -- .../DirtiesContextIntegrationTest.java | 33 ++++++++++--------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/testing-modules/spring-testing/src/main/java/com/baeldung/dirtiescontext/UserCache.java b/testing-modules/spring-testing/src/main/java/com/baeldung/dirtiescontext/UserCache.java index f03eee3bb8..f4fba1f310 100644 --- a/testing-modules/spring-testing/src/main/java/com/baeldung/dirtiescontext/UserCache.java +++ b/testing-modules/spring-testing/src/main/java/com/baeldung/dirtiescontext/UserCache.java @@ -6,9 +6,7 @@ import java.util.Set; import org.springframework.stereotype.Component; import lombok.Getter; -import lombok.ToString; -@ToString @Component public class UserCache { diff --git a/testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextIntegrationTest.java b/testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextIntegrationTest.java index b4f3fa773f..7fad754b8f 100644 --- a/testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextIntegrationTest.java +++ b/testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextIntegrationTest.java @@ -1,13 +1,16 @@ package com.baeldung.dirtiescontext; +import org.junit.FixMethodOrder; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.MethodMode; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +@FixMethodOrder(MethodSorters.NAME_ASCENDING) @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = SpringDataRestApplication.class) class DirtiesContextIntegrationTest { @@ -15,27 +18,27 @@ class DirtiesContextIntegrationTest { @Autowired protected UserCache userCache; + @Test + void testA() { + userCache.addUser("Jane Doe"); + userCache.printUserList("Test A"); + } + + @Test + void testB() { + userCache.printUserList("Test B"); + } + @DirtiesContext(methodMode = MethodMode.AFTER_METHOD) @Test - void testOne() { + void testC() { userCache.addUser("John Doe"); - userCache.printUserList("Test One"); + userCache.printUserList("Test C"); } @Test - void testTwo() { - userCache.printUserList("Test Two"); - } - - @Test - void testThree() { - userCache.addUser("Jane Doe"); - userCache.printUserList("Test Three"); - } - - @Test - void testFour() { - userCache.printUserList("Test Four"); + void testD() { + userCache.printUserList("Test D"); } } From c5693676ee6e4002d5bf82f8909c2063821e8db3 Mon Sep 17 00:00:00 2001 From: Alessio Stalla Date: Sat, 28 Sep 2019 12:40:03 +0200 Subject: [PATCH 13/55] #BAEL-17506 Add README descriptions to several modules. --- .../core-java-concurrency-advanced/README.md | 4 ++-- core-kotlin-2/README.md | 7 ++++++- core-kotlin-io/README.md | 6 +++++- core-kotlin/README.md | 7 ++++++- jenkins/README.md | 1 + jenkins/hello-world/README.md | 6 +++++- jhipster/README.md | 9 +++++++++ jws/README.md | 4 ++++ libraries/README.md | 15 +++++++++------ persistence-modules/hibernate-mapping/README.md | 2 +- persistence-modules/hibernate5/README.md | 6 +++++- persistence-modules/java-jpa-2/README.md | 7 ++++++- persistence-modules/java-jpa/README.md | 7 ++++++- 13 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 jhipster/README.md diff --git a/core-java-modules/core-java-concurrency-advanced/README.md b/core-java-modules/core-java-concurrency-advanced/README.md index 8e99858693..f76e68757a 100644 --- a/core-java-modules/core-java-concurrency-advanced/README.md +++ b/core-java-modules/core-java-concurrency-advanced/README.md @@ -1,7 +1,7 @@ -========= - ## Core Java Concurrency Advanced Examples +This module contains articles about advanced concurrency in core Java. + ### Relevant Articles: - [Introduction to Thread Pools in Java](http://www.baeldung.com/thread-pool-java-and-guava) - [Guide to CountDownLatch in Java](http://www.baeldung.com/java-countdown-latch) diff --git a/core-kotlin-2/README.md b/core-kotlin-2/README.md index d75dd2208a..ecf16c2c91 100644 --- a/core-kotlin-2/README.md +++ b/core-kotlin-2/README.md @@ -1,4 +1,8 @@ -## Relevant articles: +## Core Kotlin + +This module contains articles about core Kotlin. + +### Relevant articles: - [Void Type in Kotlin](https://www.baeldung.com/kotlin-void-type) - [How to use Kotlin Range Expressions](https://www.baeldung.com/kotlin-ranges) @@ -8,3 +12,4 @@ - [Split a List into Parts in Kotlin](https://www.baeldung.com/kotlin-split-list-into-parts) - [String Comparison in Kotlin](https://www.baeldung.com/kotlin-string-comparison) - [Guide to JVM Platform Annotations in Kotlin](https://www.baeldung.com/kotlin-jvm-annotations) +- More articles: [[<-- prev]](/core-kotlin) diff --git a/core-kotlin-io/README.md b/core-kotlin-io/README.md index cb4dac7e4d..ad4c503895 100644 --- a/core-kotlin-io/README.md +++ b/core-kotlin-io/README.md @@ -1,4 +1,8 @@ -## Relevant articles: +## Core Kotlin I/O + +This module contains articles about core Kotlin I/O. + +### Relevant articles: - [InputStream to String in Kotlin](https://www.baeldung.com/kotlin-inputstream-to-string) - [Console I/O in Kotlin](https://www.baeldung.com/kotlin-console-io) diff --git a/core-kotlin/README.md b/core-kotlin/README.md index 3392db9171..8d42a32e91 100644 --- a/core-kotlin/README.md +++ b/core-kotlin/README.md @@ -1,4 +1,8 @@ -## Relevant articles: +## Core Kotlin + +This module contains articles about core Kotlin. + +### Relevant articles: - [Introduction to the Kotlin Language](http://www.baeldung.com/kotlin) - [Guide to the “when{}” Block in Kotlin](http://www.baeldung.com/kotlin-when) @@ -56,3 +60,4 @@ - [Static Methods Behavior in Kotlin](https://www.baeldung.com/kotlin-static-methods) - [Inline Functions in Kotlin](https://www.baeldung.com/kotlin-inline-functions) - [Delegation Pattern in Kotlin](https://www.baeldung.com/kotlin-delegation-pattern) +- More articles: [[next -->]](/core-kotlin-2) diff --git a/jenkins/README.md b/jenkins/README.md index 6b28b61277..ba3e13cc95 100644 --- a/jenkins/README.md +++ b/jenkins/README.md @@ -1,2 +1,3 @@ +## Jenkins This is an aggregator modules for Jenkins-related modules. diff --git a/jenkins/hello-world/README.md b/jenkins/hello-world/README.md index da60e556df..5f6b9f364a 100644 --- a/jenkins/hello-world/README.md +++ b/jenkins/hello-world/README.md @@ -1,3 +1,7 @@ -## Relevant articles: +## Jenkins Plugins + +This module contains articles about Jenkins plugins. + +### Relevant articles: - [Writing a Jenkins Plugin](http://www.baeldung.com/jenkins-custom-plugin) diff --git a/jhipster/README.md b/jhipster/README.md new file mode 100644 index 0000000000..1bb31951f0 --- /dev/null +++ b/jhipster/README.md @@ -0,0 +1,9 @@ +## JHipster + +This module contains articles about JHipster. + +### Relevant articles: + +- [JHipster with a Microservice Architecture](https://www.baeldung.com/jhipster-microservices) +- [Intro to JHipster](https://www.baeldung.com/jhipster) +- [Building a Basic UAA-Secured JHipster Microservice](https://www.baeldung.com/jhipster-uaa-secured-micro-service) diff --git a/jws/README.md b/jws/README.md index 428d8b650d..5916efad24 100644 --- a/jws/README.md +++ b/jws/README.md @@ -1,3 +1,7 @@ +## Java Web Start + +This module contains articles about Java Web Start. + ### Relevant articles - [A Guide to the Java Web Start](http://www.baeldung.com/java-web-start) diff --git a/libraries/README.md b/libraries/README.md index ebf087ccd8..5bd53731f1 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -1,3 +1,12 @@ +## Libraries + +This module contains articles about various Java libraries. +These are small libraries that are relatively easy to use and does not require any separate module of their own. + +The code examples related to different libraries should go in a new package. + +Remember, for advanced libraries like JUnit, Jackson, etc. we already have separate modules. Please make sure to have a look at the existing modules in such cases. + ### Relevant articles - [Introduction to Javatuples](http://www.baeldung.com/java-tuples) @@ -37,9 +46,3 @@ - [Implementing a FTP-Client in Java](http://www.baeldung.com/java-ftp-client) - [Introduction to Functional Java](https://www.baeldung.com/java-functional-library) - [A Guide to the Reflections Library](https://www.baeldung.com/reflections-library) - -The libraries module contains examples related to small libraries that are relatively easy to use and does not require any separate module of its own. - -The code examples related to different libraries should go in a new package. - -Remember, for advanced libraries like JUnit, Jackson, etc. we already have separate modules. Please make sure to have a look at the existing modules in such cases. diff --git a/persistence-modules/hibernate-mapping/README.md b/persistence-modules/hibernate-mapping/README.md index 99374f9135..c227620324 100644 --- a/persistence-modules/hibernate-mapping/README.md +++ b/persistence-modules/hibernate-mapping/README.md @@ -4,4 +4,4 @@ - [Persisting Maps with Hibernate](https://www.baeldung.com/hibernate-persisting-maps) - [Difference Between @Size, @Length, and @Column(length=value)](https://www.baeldung.com/jpa-size-length-column-differences) - [Hibernate Validator Specific Constraints](https://www.baeldung.com/hibernate-validator-constraints) -- [Hibernate One to Many Annotation Tutorial](http://www.baeldung.com/hibernate-one-to-many) \ No newline at end of file +- [Hibernate One to Many Annotation Tutorial](http://www.baeldung.com/hibernate-one-to-many) diff --git a/persistence-modules/hibernate5/README.md b/persistence-modules/hibernate5/README.md index 65322f0cea..a8e2eae38b 100644 --- a/persistence-modules/hibernate5/README.md +++ b/persistence-modules/hibernate5/README.md @@ -1,4 +1,8 @@ -## Relevant articles: +## Hibernate 5 + +This module contains articles about Hibernate 5. + +### Relevant articles: - [Dynamic Mapping with Hibernate](http://www.baeldung.com/hibernate-dynamic-mapping) - [An Overview of Identifiers in Hibernate](http://www.baeldung.com/hibernate-identifiers) diff --git a/persistence-modules/java-jpa-2/README.md b/persistence-modules/java-jpa-2/README.md index 579dcbdab0..9a677901c2 100644 --- a/persistence-modules/java-jpa-2/README.md +++ b/persistence-modules/java-jpa-2/README.md @@ -1,4 +1,9 @@ -# Relevant Articles +## JPA in Java + +This module contains articles about JPA (Java Persistence API) in Java. + +### Relevant Articles - [JPA Query Parameters Usage](http://www.baeldung.com/jpa-query-parameters-usage) - [Mapping Entitiy Class Names to SQL Table Names with JPA](https://www.baeldung.com/jpa-entity-table-names) +- More articles: [[<-- prev]](/java-jpa) diff --git a/persistence-modules/java-jpa/README.md b/persistence-modules/java-jpa/README.md index 5a99217f45..640753c2f2 100644 --- a/persistence-modules/java-jpa/README.md +++ b/persistence-modules/java-jpa/README.md @@ -1,4 +1,8 @@ -# Relevant Articles +## JPA in Java + +This module contains articles about JPA (Java Persistence API) in Java. + +### Relevant Articles - [A Guide to SqlResultSetMapping](http://www.baeldung.com/jpa-sql-resultset-mapping) - [A Guide to Stored Procedures with JPA](http://www.baeldung.com/jpa-stored-procedures) @@ -14,3 +18,4 @@ - [JPA @Basic Annotation](https://www.baeldung.com/jpa-basic-annotation) - [Default Column Values in JPA](https://www.baeldung.com/jpa-default-column-values) - [Persisting Enums in JPA](https://www.baeldung.com/jpa-persisting-enums-in-jpa) +- More articles: [[next -->]](/java-jpa-2) From abe15c28fe5c26c8ec9e30609f9718cf756c5e3c Mon Sep 17 00:00:00 2001 From: Alessio Stalla Date: Sat, 28 Sep 2019 12:49:21 +0200 Subject: [PATCH 14/55] #BAEL-17505 Add README descriptions to several modules. --- .../spring-swagger-codegen-api-client/README.md | 4 +++- spring-swagger-codegen/spring-swagger-codegen-app/README.md | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 spring-swagger-codegen/spring-swagger-codegen-app/README.md diff --git a/spring-swagger-codegen/spring-swagger-codegen-api-client/README.md b/spring-swagger-codegen/spring-swagger-codegen-api-client/README.md index 455a69b2f3..cffab6b9c7 100644 --- a/spring-swagger-codegen/spring-swagger-codegen-api-client/README.md +++ b/spring-swagger-codegen/spring-swagger-codegen-api-client/README.md @@ -1,4 +1,6 @@ -# spring-swagger-codegen-api-client +## Spring Swagger Codegen API Client + +This module contains the code for [Generate Spring Boot REST Client with Swagger](http://www.baeldung.com/spring-boot-rest-client-swagger-codegen). ## Requirements diff --git a/spring-swagger-codegen/spring-swagger-codegen-app/README.md b/spring-swagger-codegen/spring-swagger-codegen-app/README.md new file mode 100644 index 0000000000..1cb9e35d99 --- /dev/null +++ b/spring-swagger-codegen/spring-swagger-codegen-app/README.md @@ -0,0 +1,3 @@ +## Spring Swagger Codegen App + +This module contains the code for [Generate Spring Boot REST Client with Swagger](http://www.baeldung.com/spring-boot-rest-client-swagger-codegen). From 58244611f06bd2733df1873cdcb352bfebacf330 Mon Sep 17 00:00:00 2001 From: Alessio Stalla Date: Sun, 29 Sep 2019 08:58:41 +0200 Subject: [PATCH 15/55] #BAEL-17505 minor change in Hibernate mapping description. --- persistence-modules/hibernate-mapping/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/hibernate-mapping/README.md b/persistence-modules/hibernate-mapping/README.md index 658f758709..3271f0c1b6 100644 --- a/persistence-modules/hibernate-mapping/README.md +++ b/persistence-modules/hibernate-mapping/README.md @@ -1,6 +1,6 @@ ## Hibernate Mapping -This module contains articles about Object-Relational Mapping with Hibernate. +This module contains articles about Object-relational Mapping (ORM) with Hibernate. ### Relevant Articles: From dad2aeba0f1437f8ee12eeeb79902eef9e5713dc Mon Sep 17 00:00:00 2001 From: Alessio Stalla Date: Sun, 29 Sep 2019 09:30:37 +0200 Subject: [PATCH 16/55] #BAEL-17506 include libraries-2 and slightly edit a few descriptions --- libraries-2/README.md | 11 ++++++++++- libraries/README.md | 7 ++++--- persistence-modules/java-jpa-2/README.md | 2 +- persistence-modules/java-jpa/README.md | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/libraries-2/README.md b/libraries-2/README.md index 7d7fc67fa7..ea95b18d72 100644 --- a/libraries-2/README.md +++ b/libraries-2/README.md @@ -1,5 +1,13 @@ -## Relevant Articles: +## Libraries +This module contains articles about various Java libraries. +These are small libraries that are relatively easy to use and do not require any separate module of their own. + +The code examples related to different libraries are each in their own module. + +Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-modules) we already have separate modules. Please make sure to have a look at the existing modules in such cases. + +### Relevant articles - [A Guide to jBPM with Java](https://www.baeldung.com/jbpm-java) - [Guide to Classgraph Library](https://www.baeldung.com/classgraph) - [Create a Java Command Line Program with Picocli](https://www.baeldung.com/java-picocli-create-command-line-program) @@ -10,3 +18,4 @@ - [Key Value Store with Chronicle Map](https://www.baeldung.com/java-chronicle-map) - [Guide to MapDB](https://www.baeldung.com/mapdb) - [A Guide to Apache Mesos](https://www.baeldung.com/apache-mesos) +- More articles [[<-- prev]](/libraries) diff --git a/libraries/README.md b/libraries/README.md index 5bd53731f1..5d44247728 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -1,11 +1,11 @@ ## Libraries This module contains articles about various Java libraries. -These are small libraries that are relatively easy to use and does not require any separate module of their own. +These are small libraries that are relatively easy to use and do not require any separate module of their own. -The code examples related to different libraries should go in a new package. +The code examples related to different libraries are each in their own module. -Remember, for advanced libraries like JUnit, Jackson, etc. we already have separate modules. Please make sure to have a look at the existing modules in such cases. +Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-modules) we already have separate modules. Please make sure to have a look at the existing modules in such cases. ### Relevant articles @@ -46,3 +46,4 @@ Remember, for advanced libraries like JUnit, Jackson, etc. we already have separ - [Implementing a FTP-Client in Java](http://www.baeldung.com/java-ftp-client) - [Introduction to Functional Java](https://www.baeldung.com/java-functional-library) - [A Guide to the Reflections Library](https://www.baeldung.com/reflections-library) +- More articles [[next -->]](/libraries-2) diff --git a/persistence-modules/java-jpa-2/README.md b/persistence-modules/java-jpa-2/README.md index 9a677901c2..c3be046fc0 100644 --- a/persistence-modules/java-jpa-2/README.md +++ b/persistence-modules/java-jpa-2/README.md @@ -1,6 +1,6 @@ ## JPA in Java -This module contains articles about JPA (Java Persistence API) in Java. +This module contains articles about the Java Persistence API (JPA) in Java. ### Relevant Articles diff --git a/persistence-modules/java-jpa/README.md b/persistence-modules/java-jpa/README.md index 640753c2f2..b28aec5afb 100644 --- a/persistence-modules/java-jpa/README.md +++ b/persistence-modules/java-jpa/README.md @@ -1,6 +1,6 @@ ## JPA in Java -This module contains articles about JPA (Java Persistence API) in Java. +This module contains articles about the Java Persistence API (JPA) in Java. ### Relevant Articles From fcf0841011fa904444ca70bf2935b0caca069f8e Mon Sep 17 00:00:00 2001 From: fejera Date: Sun, 29 Sep 2019 15:05:42 +0200 Subject: [PATCH 17/55] changed all article links from http to https in spring-5-reactive --- spring-5-reactive/README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/spring-5-reactive/README.md b/spring-5-reactive/README.md index 89ff4fea9f..fd8b4c9ad4 100644 --- a/spring-5-reactive/README.md +++ b/spring-5-reactive/README.md @@ -3,20 +3,21 @@ This module contains articles about reactive Spring 5 ### The Course -The "REST With Spring" Classes: http://bit.ly/restwithspring +The "REST With Spring" Classes: https://bit.ly/restwithspring ### Relevant Articles -- [Introduction to the Functional Web Framework in Spring 5](http://www.baeldung.com/spring-5-functional-web) -- [Spring 5 WebClient](http://www.baeldung.com/spring-5-webclient) -- [Exploring the Spring 5 WebFlux URL Matching](http://www.baeldung.com/spring-5-mvc-url-matching) -- [Reactive WebSockets with Spring 5](http://www.baeldung.com/spring-5-reactive-websockets) -- [Spring Webflux Filters](http://www.baeldung.com/spring-webflux-filters) -- [How to Set a Header on a Response with Spring 5](http://www.baeldung.com/spring-response-header) -- [Spring Webflux and CORS](http://www.baeldung.com/spring-webflux-cors) -- [Handling Errors in Spring WebFlux](http://www.baeldung.com/spring-webflux-errors) +- [Introduction to the Functional Web Framework in Spring 5](https://www.baeldung.com/spring-5-functional-web) +- [Spring 5 WebClient](https://www.baeldung.com/spring-5-webclient) +- [Exploring the Spring 5 WebFlux URL Matching](https://www.baeldung.com/spring-5-mvc-url-matching) +- [Reactive WebSockets with Spring 5](https://www.baeldung.com/spring-5-reactive-websockets) +- [Spring Webflux Filters](https://www.baeldung.com/spring-webflux-filters) +- [How to Set a Header on a Response with Spring 5](https://www.baeldung.com/spring-response-header) +- [Spring Webflux and CORS](https://www.baeldung.com/spring-webflux-cors) +- [Handling Errors in Spring WebFlux](https://www.baeldung.com/spring-webflux-errors) - [Server-Sent Events in Spring](https://www.baeldung.com/spring-server-sent-events) - [A Guide to Spring Session Reactive Support: WebSession](https://www.baeldung.com/spring-session-reactive) + - [Validation for Functional Endpoints in Spring 5](https://www.baeldung.com/spring-functional-endpoints-validation) - [Logging a Reactive Sequence](https://www.baeldung.com/spring-reactive-sequence-logging) - [Testing Reactive Streams Using StepVerifier and TestPublisher](https://www.baeldung.com/reactive-streams-step-verifier-test-publisher) From 4c3af61952a52886164ee4448d6e54de65eaca30 Mon Sep 17 00:00:00 2001 From: fejera Date: Sun, 29 Sep 2019 15:22:55 +0200 Subject: [PATCH 18/55] fixed FunctionalEndpointValidationsLiveTest --- .../handlers/impl/AnnotatedRequestEntityValidationHandler.java | 1 - .../functional/FunctionalEndpointValidationsLiveTest.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-5-reactive/src/main/java/com/baeldung/validations/functional/handlers/impl/AnnotatedRequestEntityValidationHandler.java b/spring-5-reactive/src/main/java/com/baeldung/validations/functional/handlers/impl/AnnotatedRequestEntityValidationHandler.java index 2011679741..9fec15142e 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/validations/functional/handlers/impl/AnnotatedRequestEntityValidationHandler.java +++ b/spring-5-reactive/src/main/java/com/baeldung/validations/functional/handlers/impl/AnnotatedRequestEntityValidationHandler.java @@ -1,7 +1,6 @@ package com.baeldung.validations.functional.handlers.impl; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import org.springframework.validation.Validator; diff --git a/spring-5-reactive/src/test/java/com/baeldung/validations/functional/FunctionalEndpointValidationsLiveTest.java b/spring-5-reactive/src/test/java/com/baeldung/validations/functional/FunctionalEndpointValidationsLiveTest.java index 73968cdf05..92257f2850 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/validations/functional/FunctionalEndpointValidationsLiveTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/validations/functional/FunctionalEndpointValidationsLiveTest.java @@ -11,7 +11,7 @@ import com.baeldung.validations.functional.model.CustomRequestEntity; import reactor.core.publisher.Mono; -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) public class FunctionalEndpointValidationsLiveTest { private static final String BASE_URL = "http://localhost:8080"; From 79cc747844781ffe97f978adf8f213a79ca99f40 Mon Sep 17 00:00:00 2001 From: fejera Date: Sun, 29 Sep 2019 15:35:59 +0200 Subject: [PATCH 19/55] moved functional validation examples from spring-5-reactive to spring-5-reactive-2 --- spring-5-reactive-2/README.md | 1 + spring-5-reactive-2/pom.xml | 10 ++++++++-- .../functional/FunctionalValidationsApplication.java | 0 .../handlers/AbstractValidationHandler.java | 0 .../functional/handlers/FunctionalHandler.java | 0 .../AnnotatedRequestEntityValidationHandler.java | 0 .../impl/CustomRequestEntityValidationHandler.java | 0 .../handlers/impl/OtherEntityValidationHandler.java | 0 .../functional/model/AnnotatedRequestEntity.java | 0 .../functional/model/CustomRequestEntity.java | 0 .../validations/functional/model/OtherEntity.java | 0 .../functional/routers/ValidationsRouters.java | 0 .../validators/CustomRequestEntityValidator.java | 0 .../functional/validators/OtherEntityValidator.java | 0 .../com/baeldung/webclient/WebClientApplication.java | 12 ++++++++++++ .../FunctionalEndpointValidationsLiveTest.java | 0 spring-5-reactive/README.md | 1 - 17 files changed, 21 insertions(+), 3 deletions(-) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/validations/functional/FunctionalValidationsApplication.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/validations/functional/handlers/AbstractValidationHandler.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/validations/functional/handlers/FunctionalHandler.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/validations/functional/handlers/impl/AnnotatedRequestEntityValidationHandler.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/validations/functional/handlers/impl/CustomRequestEntityValidationHandler.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/validations/functional/handlers/impl/OtherEntityValidationHandler.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/validations/functional/model/AnnotatedRequestEntity.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/validations/functional/model/CustomRequestEntity.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/validations/functional/model/OtherEntity.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/validations/functional/routers/ValidationsRouters.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/validations/functional/validators/CustomRequestEntityValidator.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/validations/functional/validators/OtherEntityValidator.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/test/java/com/baeldung/validations/functional/FunctionalEndpointValidationsLiveTest.java (100%) diff --git a/spring-5-reactive-2/README.md b/spring-5-reactive-2/README.md index 1d21425fb8..15eba8d0d9 100644 --- a/spring-5-reactive-2/README.md +++ b/spring-5-reactive-2/README.md @@ -3,4 +3,5 @@ This module contains articles about reactive Spring 5 - [Spring WebClient vs. RestTemplate](https://www.baeldung.com/spring-webclient-resttemplate) +- [Validation for Functional Endpoints in Spring 5](https://www.baeldung.com/spring-functional-endpoints-validation) - More articles: [[<-- prev]](/spring-5-reactive) diff --git a/spring-5-reactive-2/pom.xml b/spring-5-reactive-2/pom.xml index f1407ee1ad..edda43747c 100644 --- a/spring-5-reactive-2/pom.xml +++ b/spring-5-reactive-2/pom.xml @@ -23,9 +23,9 @@ org.springframework.boot - spring-boot-starter-test - test + spring-boot-starter-security + org.projectlombok lombok @@ -33,6 +33,12 @@ provided + + org.springframework.boot + spring-boot-starter-test + test + + com.github.tomakehurst wiremock-jre8 diff --git a/spring-5-reactive/src/main/java/com/baeldung/validations/functional/FunctionalValidationsApplication.java b/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/FunctionalValidationsApplication.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/validations/functional/FunctionalValidationsApplication.java rename to spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/FunctionalValidationsApplication.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/validations/functional/handlers/AbstractValidationHandler.java b/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/AbstractValidationHandler.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/validations/functional/handlers/AbstractValidationHandler.java rename to spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/AbstractValidationHandler.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/validations/functional/handlers/FunctionalHandler.java b/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/FunctionalHandler.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/validations/functional/handlers/FunctionalHandler.java rename to spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/FunctionalHandler.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/validations/functional/handlers/impl/AnnotatedRequestEntityValidationHandler.java b/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/AnnotatedRequestEntityValidationHandler.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/validations/functional/handlers/impl/AnnotatedRequestEntityValidationHandler.java rename to spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/AnnotatedRequestEntityValidationHandler.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/validations/functional/handlers/impl/CustomRequestEntityValidationHandler.java b/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/CustomRequestEntityValidationHandler.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/validations/functional/handlers/impl/CustomRequestEntityValidationHandler.java rename to spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/CustomRequestEntityValidationHandler.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/validations/functional/handlers/impl/OtherEntityValidationHandler.java b/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/OtherEntityValidationHandler.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/validations/functional/handlers/impl/OtherEntityValidationHandler.java rename to spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/OtherEntityValidationHandler.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/validations/functional/model/AnnotatedRequestEntity.java b/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/model/AnnotatedRequestEntity.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/validations/functional/model/AnnotatedRequestEntity.java rename to spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/model/AnnotatedRequestEntity.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/validations/functional/model/CustomRequestEntity.java b/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/model/CustomRequestEntity.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/validations/functional/model/CustomRequestEntity.java rename to spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/model/CustomRequestEntity.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/validations/functional/model/OtherEntity.java b/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/model/OtherEntity.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/validations/functional/model/OtherEntity.java rename to spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/model/OtherEntity.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/validations/functional/routers/ValidationsRouters.java b/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/routers/ValidationsRouters.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/validations/functional/routers/ValidationsRouters.java rename to spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/routers/ValidationsRouters.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/validations/functional/validators/CustomRequestEntityValidator.java b/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/validators/CustomRequestEntityValidator.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/validations/functional/validators/CustomRequestEntityValidator.java rename to spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/validators/CustomRequestEntityValidator.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/validations/functional/validators/OtherEntityValidator.java b/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/validators/OtherEntityValidator.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/validations/functional/validators/OtherEntityValidator.java rename to spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/validators/OtherEntityValidator.java diff --git a/spring-5-reactive-2/src/main/java/com/baeldung/webclient/WebClientApplication.java b/spring-5-reactive-2/src/main/java/com/baeldung/webclient/WebClientApplication.java index 751e3a9487..3c53a2c1d3 100644 --- a/spring-5-reactive-2/src/main/java/com/baeldung/webclient/WebClientApplication.java +++ b/spring-5-reactive-2/src/main/java/com/baeldung/webclient/WebClientApplication.java @@ -2,10 +2,22 @@ package com.baeldung.webclient; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.security.config.web.server.ServerHttpSecurity; +import org.springframework.security.web.server.SecurityWebFilterChain; @SpringBootApplication public class WebClientApplication { public static void main(String[] args) { SpringApplication.run(WebClientApplication.class, args); } + + @Bean + public SecurityWebFilterChain functionalValidationsSpringSecurityFilterChain(ServerHttpSecurity http) { + http.authorizeExchange() + .anyExchange() + .permitAll(); + http.csrf().disable(); + return http.build(); + } } diff --git a/spring-5-reactive/src/test/java/com/baeldung/validations/functional/FunctionalEndpointValidationsLiveTest.java b/spring-5-reactive-2/src/test/java/com/baeldung/validations/functional/FunctionalEndpointValidationsLiveTest.java similarity index 100% rename from spring-5-reactive/src/test/java/com/baeldung/validations/functional/FunctionalEndpointValidationsLiveTest.java rename to spring-5-reactive-2/src/test/java/com/baeldung/validations/functional/FunctionalEndpointValidationsLiveTest.java diff --git a/spring-5-reactive/README.md b/spring-5-reactive/README.md index fd8b4c9ad4..a8d4436049 100644 --- a/spring-5-reactive/README.md +++ b/spring-5-reactive/README.md @@ -18,7 +18,6 @@ The "REST With Spring" Classes: https://bit.ly/restwithspring - [Server-Sent Events in Spring](https://www.baeldung.com/spring-server-sent-events) - [A Guide to Spring Session Reactive Support: WebSession](https://www.baeldung.com/spring-session-reactive) -- [Validation for Functional Endpoints in Spring 5](https://www.baeldung.com/spring-functional-endpoints-validation) - [Logging a Reactive Sequence](https://www.baeldung.com/spring-reactive-sequence-logging) - [Testing Reactive Streams Using StepVerifier and TestPublisher](https://www.baeldung.com/reactive-streams-step-verifier-test-publisher) - [Debugging Reactive Streams in Spring 5](https://www.baeldung.com/spring-debugging-reactive-streams) From 6b346d3f5f16a802fd3cd224dcfb5d9c49e2301c Mon Sep 17 00:00:00 2001 From: fejera Date: Sun, 29 Sep 2019 15:40:57 +0200 Subject: [PATCH 20/55] moved reactive logging examples from spring-5-reactive to spring-5-reactive-2 --- spring-5-reactive-2/README.md | 1 + .../java/com/baeldung/webflux/logging/WebFluxLoggingExample.java | 0 spring-5-reactive/README.md | 1 - 3 files changed, 1 insertion(+), 1 deletion(-) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/webflux/logging/WebFluxLoggingExample.java (100%) diff --git a/spring-5-reactive-2/README.md b/spring-5-reactive-2/README.md index 15eba8d0d9..ffa101ba47 100644 --- a/spring-5-reactive-2/README.md +++ b/spring-5-reactive-2/README.md @@ -4,4 +4,5 @@ This module contains articles about reactive Spring 5 - [Spring WebClient vs. RestTemplate](https://www.baeldung.com/spring-webclient-resttemplate) - [Validation for Functional Endpoints in Spring 5](https://www.baeldung.com/spring-functional-endpoints-validation) +- [Logging a Reactive Sequence](https://www.baeldung.com/spring-reactive-sequence-logging) - More articles: [[<-- prev]](/spring-5-reactive) diff --git a/spring-5-reactive/src/main/java/com/baeldung/webflux/logging/WebFluxLoggingExample.java b/spring-5-reactive-2/src/main/java/com/baeldung/webflux/logging/WebFluxLoggingExample.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/webflux/logging/WebFluxLoggingExample.java rename to spring-5-reactive-2/src/main/java/com/baeldung/webflux/logging/WebFluxLoggingExample.java diff --git a/spring-5-reactive/README.md b/spring-5-reactive/README.md index a8d4436049..d77283d4b7 100644 --- a/spring-5-reactive/README.md +++ b/spring-5-reactive/README.md @@ -18,7 +18,6 @@ The "REST With Spring" Classes: https://bit.ly/restwithspring - [Server-Sent Events in Spring](https://www.baeldung.com/spring-server-sent-events) - [A Guide to Spring Session Reactive Support: WebSession](https://www.baeldung.com/spring-session-reactive) -- [Logging a Reactive Sequence](https://www.baeldung.com/spring-reactive-sequence-logging) - [Testing Reactive Streams Using StepVerifier and TestPublisher](https://www.baeldung.com/reactive-streams-step-verifier-test-publisher) - [Debugging Reactive Streams in Spring 5](https://www.baeldung.com/spring-debugging-reactive-streams) - [Static Content in Spring WebFlux](https://www.baeldung.com/spring-webflux-static-content) From 8a3b8a7e18a394e07f429c9e1526bde799484868 Mon Sep 17 00:00:00 2001 From: fejera Date: Sun, 29 Sep 2019 15:48:52 +0200 Subject: [PATCH 21/55] moved stepverifier examples from spring-5-reactive to spring-5-reactive-2 --- spring-5-reactive-2/README.md | 1 + spring-5-reactive-2/pom.xml | 12 +++++++++++- .../stepverifier/PostExecutionUnitTest.java | 0 .../stepverifier/StepByStepUnitTest.java | 0 .../TestingTestPublisherUnitTest.java | 0 .../baeldung/stepverifier/TimeBasedUnitTest.java | 0 spring-5-reactive/README.md | 1 - spring-5-reactive/pom.xml | 16 ---------------- 8 files changed, 12 insertions(+), 18 deletions(-) rename {spring-5-reactive => spring-5-reactive-2}/src/test/java/com/baeldung/stepverifier/PostExecutionUnitTest.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/test/java/com/baeldung/stepverifier/StepByStepUnitTest.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/test/java/com/baeldung/stepverifier/TestingTestPublisherUnitTest.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/test/java/com/baeldung/stepverifier/TimeBasedUnitTest.java (100%) diff --git a/spring-5-reactive-2/README.md b/spring-5-reactive-2/README.md index ffa101ba47..78a70078f5 100644 --- a/spring-5-reactive-2/README.md +++ b/spring-5-reactive-2/README.md @@ -5,4 +5,5 @@ This module contains articles about reactive Spring 5 - [Spring WebClient vs. RestTemplate](https://www.baeldung.com/spring-webclient-resttemplate) - [Validation for Functional Endpoints in Spring 5](https://www.baeldung.com/spring-functional-endpoints-validation) - [Logging a Reactive Sequence](https://www.baeldung.com/spring-reactive-sequence-logging) +- [Testing Reactive Streams Using StepVerifier and TestPublisher](https://www.baeldung.com/reactive-streams-step-verifier-test-publisher) - More articles: [[<-- prev]](/spring-5-reactive) diff --git a/spring-5-reactive-2/pom.xml b/spring-5-reactive-2/pom.xml index edda43747c..37c9ad3579 100644 --- a/spring-5-reactive-2/pom.xml +++ b/spring-5-reactive-2/pom.xml @@ -25,11 +25,15 @@ org.springframework.boot spring-boot-starter-security + + org.projectreactor + reactor-spring + ${reactor-spring.version} + org.projectlombok lombok - ${lombok.version} provided @@ -45,6 +49,11 @@ ${wiremock.version} test + + io.projectreactor + reactor-test + test + @@ -61,6 +70,7 @@ + 1.0.1.RELEASE 2.24.0 diff --git a/spring-5-reactive/src/test/java/com/baeldung/stepverifier/PostExecutionUnitTest.java b/spring-5-reactive-2/src/test/java/com/baeldung/stepverifier/PostExecutionUnitTest.java similarity index 100% rename from spring-5-reactive/src/test/java/com/baeldung/stepverifier/PostExecutionUnitTest.java rename to spring-5-reactive-2/src/test/java/com/baeldung/stepverifier/PostExecutionUnitTest.java diff --git a/spring-5-reactive/src/test/java/com/baeldung/stepverifier/StepByStepUnitTest.java b/spring-5-reactive-2/src/test/java/com/baeldung/stepverifier/StepByStepUnitTest.java similarity index 100% rename from spring-5-reactive/src/test/java/com/baeldung/stepverifier/StepByStepUnitTest.java rename to spring-5-reactive-2/src/test/java/com/baeldung/stepverifier/StepByStepUnitTest.java diff --git a/spring-5-reactive/src/test/java/com/baeldung/stepverifier/TestingTestPublisherUnitTest.java b/spring-5-reactive-2/src/test/java/com/baeldung/stepverifier/TestingTestPublisherUnitTest.java similarity index 100% rename from spring-5-reactive/src/test/java/com/baeldung/stepverifier/TestingTestPublisherUnitTest.java rename to spring-5-reactive-2/src/test/java/com/baeldung/stepverifier/TestingTestPublisherUnitTest.java diff --git a/spring-5-reactive/src/test/java/com/baeldung/stepverifier/TimeBasedUnitTest.java b/spring-5-reactive-2/src/test/java/com/baeldung/stepverifier/TimeBasedUnitTest.java similarity index 100% rename from spring-5-reactive/src/test/java/com/baeldung/stepverifier/TimeBasedUnitTest.java rename to spring-5-reactive-2/src/test/java/com/baeldung/stepverifier/TimeBasedUnitTest.java diff --git a/spring-5-reactive/README.md b/spring-5-reactive/README.md index d77283d4b7..cb0ec65246 100644 --- a/spring-5-reactive/README.md +++ b/spring-5-reactive/README.md @@ -18,7 +18,6 @@ The "REST With Spring" Classes: https://bit.ly/restwithspring - [Server-Sent Events in Spring](https://www.baeldung.com/spring-server-sent-events) - [A Guide to Spring Session Reactive Support: WebSession](https://www.baeldung.com/spring-session-reactive) -- [Testing Reactive Streams Using StepVerifier and TestPublisher](https://www.baeldung.com/reactive-streams-step-verifier-test-publisher) - [Debugging Reactive Streams in Spring 5](https://www.baeldung.com/spring-debugging-reactive-streams) - [Static Content in Spring WebFlux](https://www.baeldung.com/spring-webflux-static-content) - More articles: [[next -->]](/spring-5-reactive-2) \ No newline at end of file diff --git a/spring-5-reactive/pom.xml b/spring-5-reactive/pom.xml index 99cdd11f24..e6690baf54 100644 --- a/spring-5-reactive/pom.xml +++ b/spring-5-reactive/pom.xml @@ -29,11 +29,6 @@ org.springframework.boot spring-boot-starter-webflux - - org.projectreactor - reactor-spring - ${reactor-spring.version} - javax.json.bind javax.json.bind-api @@ -112,18 +107,10 @@ io.reactivex.rxjava2 rxjava - ${rxjava-version} - - - io.projectreactor - reactor-test - ${project-reactor-test} - test org.apache.httpcomponents httpclient - ${httpclient.version} @@ -165,13 +152,10 @@ 1.0.1.RELEASE - 2.1.12 1.1.3 1.0 1.0 4.1 - 3.2.3.RELEASE - 4.5.8 From c4c59a08ddbaf61cf6a4e03049923daa26291fa3 Mon Sep 17 00:00:00 2001 From: fejera Date: Sun, 29 Sep 2019 16:08:53 +0200 Subject: [PATCH 22/55] moved reactive debugging examples from spring-5-reactive to spring-5-reactive-2 --- spring-5-reactive-2/README.md | 1 + .../debugging/consumer/ConsumerDebuggingApplication.java | 1 + .../com/baeldung/debugging/consumer/chronjobs/ChronJobs.java | 0 .../controllers/ReactiveConfigsToggleRestController.java | 0 .../main/java/com/baeldung/debugging/consumer/model/Foo.java | 4 ---- .../java/com/baeldung/debugging/consumer/model/FooDto.java | 0 .../baeldung/debugging/consumer/service/FooNameHelper.java | 0 .../debugging/consumer/service/FooQuantityHelper.java | 0 .../com/baeldung/debugging/consumer/service/FooReporter.java | 0 .../com/baeldung/debugging/consumer/service/FooService.java | 0 .../baeldung/debugging/server/ServerDebuggingApplication.java | 0 .../com/baeldung/debugging/server/handlers/ServerHandler.java | 0 .../main/java/com/baeldung/debugging/server/model/Foo.java | 3 --- .../com/baeldung/debugging/server/routers/ServerRouter.java | 0 .../debugging/consumer/ConsumerFooServiceIntegrationTest.java | 0 .../debugging/consumer/ConsumerFooServiceLiveTest.java | 0 .../com/baeldung/debugging/consumer/utils/ListAppender.java | 0 .../src/test/resources/logback-test.xml | 0 spring-5-reactive/README.md | 1 - 19 files changed, 2 insertions(+), 8 deletions(-) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/debugging/consumer/ConsumerDebuggingApplication.java (97%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/debugging/consumer/chronjobs/ChronJobs.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/debugging/consumer/controllers/ReactiveConfigsToggleRestController.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/debugging/consumer/model/Foo.java (89%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/debugging/consumer/model/FooDto.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/debugging/consumer/service/FooNameHelper.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/debugging/consumer/service/FooQuantityHelper.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/debugging/consumer/service/FooReporter.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/debugging/consumer/service/FooService.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/debugging/server/ServerDebuggingApplication.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/debugging/server/handlers/ServerHandler.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/debugging/server/model/Foo.java (77%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/debugging/server/routers/ServerRouter.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/test/java/com/baeldung/debugging/consumer/ConsumerFooServiceIntegrationTest.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/test/java/com/baeldung/debugging/consumer/ConsumerFooServiceLiveTest.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/test/java/com/baeldung/debugging/consumer/utils/ListAppender.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/test/resources/logback-test.xml (100%) diff --git a/spring-5-reactive-2/README.md b/spring-5-reactive-2/README.md index 78a70078f5..57190f077b 100644 --- a/spring-5-reactive-2/README.md +++ b/spring-5-reactive-2/README.md @@ -6,4 +6,5 @@ This module contains articles about reactive Spring 5 - [Validation for Functional Endpoints in Spring 5](https://www.baeldung.com/spring-functional-endpoints-validation) - [Logging a Reactive Sequence](https://www.baeldung.com/spring-reactive-sequence-logging) - [Testing Reactive Streams Using StepVerifier and TestPublisher](https://www.baeldung.com/reactive-streams-step-verifier-test-publisher) +- [Debugging Reactive Streams in Spring 5](https://www.baeldung.com/spring-debugging-reactive-streams) - More articles: [[<-- prev]](/spring-5-reactive) diff --git a/spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/ConsumerDebuggingApplication.java b/spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/ConsumerDebuggingApplication.java similarity index 97% rename from spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/ConsumerDebuggingApplication.java rename to spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/ConsumerDebuggingApplication.java index 486c5e77eb..3f01310006 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/ConsumerDebuggingApplication.java +++ b/spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/ConsumerDebuggingApplication.java @@ -28,6 +28,7 @@ public class ConsumerDebuggingApplication { http.authorizeExchange() .anyExchange() .permitAll(); + http.csrf().disable(); return http.build(); } } diff --git a/spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/chronjobs/ChronJobs.java b/spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/chronjobs/ChronJobs.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/chronjobs/ChronJobs.java rename to spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/chronjobs/ChronJobs.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/controllers/ReactiveConfigsToggleRestController.java b/spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/controllers/ReactiveConfigsToggleRestController.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/controllers/ReactiveConfigsToggleRestController.java rename to spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/controllers/ReactiveConfigsToggleRestController.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/model/Foo.java b/spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/model/Foo.java similarity index 89% rename from spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/model/Foo.java rename to spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/model/Foo.java index ac5093c261..916ca93bfc 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/model/Foo.java +++ b/spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/model/Foo.java @@ -2,10 +2,7 @@ package com.baeldung.debugging.consumer.model; import java.util.concurrent.ThreadLocalRandom; -import org.springframework.data.annotation.Id; - import lombok.AllArgsConstructor; -import lombok.Data; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -16,7 +13,6 @@ import lombok.Setter; @AllArgsConstructor public class Foo { - @Id private Integer id; private String formattedName; private Integer quantity; diff --git a/spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/model/FooDto.java b/spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/model/FooDto.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/model/FooDto.java rename to spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/model/FooDto.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/service/FooNameHelper.java b/spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/service/FooNameHelper.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/service/FooNameHelper.java rename to spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/service/FooNameHelper.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/service/FooQuantityHelper.java b/spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/service/FooQuantityHelper.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/service/FooQuantityHelper.java rename to spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/service/FooQuantityHelper.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/service/FooReporter.java b/spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/service/FooReporter.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/service/FooReporter.java rename to spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/service/FooReporter.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/service/FooService.java b/spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/service/FooService.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/debugging/consumer/service/FooService.java rename to spring-5-reactive-2/src/main/java/com/baeldung/debugging/consumer/service/FooService.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/debugging/server/ServerDebuggingApplication.java b/spring-5-reactive-2/src/main/java/com/baeldung/debugging/server/ServerDebuggingApplication.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/debugging/server/ServerDebuggingApplication.java rename to spring-5-reactive-2/src/main/java/com/baeldung/debugging/server/ServerDebuggingApplication.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/debugging/server/handlers/ServerHandler.java b/spring-5-reactive-2/src/main/java/com/baeldung/debugging/server/handlers/ServerHandler.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/debugging/server/handlers/ServerHandler.java rename to spring-5-reactive-2/src/main/java/com/baeldung/debugging/server/handlers/ServerHandler.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/debugging/server/model/Foo.java b/spring-5-reactive-2/src/main/java/com/baeldung/debugging/server/model/Foo.java similarity index 77% rename from spring-5-reactive/src/main/java/com/baeldung/debugging/server/model/Foo.java rename to spring-5-reactive-2/src/main/java/com/baeldung/debugging/server/model/Foo.java index a60e468e7f..2d9491f3dd 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/debugging/server/model/Foo.java +++ b/spring-5-reactive-2/src/main/java/com/baeldung/debugging/server/model/Foo.java @@ -1,7 +1,5 @@ package com.baeldung.debugging.server.model; -import org.springframework.data.annotation.Id; - import lombok.AllArgsConstructor; import lombok.Data; @@ -9,7 +7,6 @@ import lombok.Data; @AllArgsConstructor public class Foo { - @Id private Long id; private String name; diff --git a/spring-5-reactive/src/main/java/com/baeldung/debugging/server/routers/ServerRouter.java b/spring-5-reactive-2/src/main/java/com/baeldung/debugging/server/routers/ServerRouter.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/debugging/server/routers/ServerRouter.java rename to spring-5-reactive-2/src/main/java/com/baeldung/debugging/server/routers/ServerRouter.java diff --git a/spring-5-reactive/src/test/java/com/baeldung/debugging/consumer/ConsumerFooServiceIntegrationTest.java b/spring-5-reactive-2/src/test/java/com/baeldung/debugging/consumer/ConsumerFooServiceIntegrationTest.java similarity index 100% rename from spring-5-reactive/src/test/java/com/baeldung/debugging/consumer/ConsumerFooServiceIntegrationTest.java rename to spring-5-reactive-2/src/test/java/com/baeldung/debugging/consumer/ConsumerFooServiceIntegrationTest.java diff --git a/spring-5-reactive/src/test/java/com/baeldung/debugging/consumer/ConsumerFooServiceLiveTest.java b/spring-5-reactive-2/src/test/java/com/baeldung/debugging/consumer/ConsumerFooServiceLiveTest.java similarity index 100% rename from spring-5-reactive/src/test/java/com/baeldung/debugging/consumer/ConsumerFooServiceLiveTest.java rename to spring-5-reactive-2/src/test/java/com/baeldung/debugging/consumer/ConsumerFooServiceLiveTest.java diff --git a/spring-5-reactive/src/test/java/com/baeldung/debugging/consumer/utils/ListAppender.java b/spring-5-reactive-2/src/test/java/com/baeldung/debugging/consumer/utils/ListAppender.java similarity index 100% rename from spring-5-reactive/src/test/java/com/baeldung/debugging/consumer/utils/ListAppender.java rename to spring-5-reactive-2/src/test/java/com/baeldung/debugging/consumer/utils/ListAppender.java diff --git a/spring-5-reactive/src/test/resources/logback-test.xml b/spring-5-reactive-2/src/test/resources/logback-test.xml similarity index 100% rename from spring-5-reactive/src/test/resources/logback-test.xml rename to spring-5-reactive-2/src/test/resources/logback-test.xml diff --git a/spring-5-reactive/README.md b/spring-5-reactive/README.md index cb0ec65246..74156a993e 100644 --- a/spring-5-reactive/README.md +++ b/spring-5-reactive/README.md @@ -18,6 +18,5 @@ The "REST With Spring" Classes: https://bit.ly/restwithspring - [Server-Sent Events in Spring](https://www.baeldung.com/spring-server-sent-events) - [A Guide to Spring Session Reactive Support: WebSession](https://www.baeldung.com/spring-session-reactive) -- [Debugging Reactive Streams in Spring 5](https://www.baeldung.com/spring-debugging-reactive-streams) - [Static Content in Spring WebFlux](https://www.baeldung.com/spring-webflux-static-content) - More articles: [[next -->]](/spring-5-reactive-2) \ No newline at end of file From c391435c3cc4c8b95d3621f98dde547ee4266dc2 Mon Sep 17 00:00:00 2001 From: fejera Date: Sun, 29 Sep 2019 16:19:12 +0200 Subject: [PATCH 23/55] moved webflux static content examples from spring-5-reactive to spring-5-reactive-2 --- spring-5-reactive-2/README.md | 1 + .../staticcontent/StaticContentApplication.java | 0 .../baeldung/staticcontent/StaticContentConfig.java | 0 .../application-assets-custom-location.properties | 0 .../StaticContentCustomLocationIntegrationTest.java | 0 ...StaticContentDefaultLocationIntegrationTest.java | 0 .../src/test/resources/assets}/index.html | 0 .../src/test}/resources/img/example-image.png | Bin .../src/test/resources/public/index.html | 10 ++++++++++ spring-5-reactive/README.md | 2 -- 10 files changed, 11 insertions(+), 2 deletions(-) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/staticcontent/StaticContentApplication.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/java/com/baeldung/staticcontent/StaticContentConfig.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/main/resources/application-assets-custom-location.properties (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/test/java/com/baeldung/staticcontent/StaticContentCustomLocationIntegrationTest.java (100%) rename {spring-5-reactive => spring-5-reactive-2}/src/test/java/com/baeldung/staticcontent/StaticContentDefaultLocationIntegrationTest.java (100%) rename {spring-5-reactive/src/main/resources/public => spring-5-reactive-2/src/test/resources/assets}/index.html (100%) rename {spring-5-reactive/src/main => spring-5-reactive-2/src/test}/resources/img/example-image.png (100%) create mode 100644 spring-5-reactive-2/src/test/resources/public/index.html diff --git a/spring-5-reactive-2/README.md b/spring-5-reactive-2/README.md index 57190f077b..31483c5c0e 100644 --- a/spring-5-reactive-2/README.md +++ b/spring-5-reactive-2/README.md @@ -7,4 +7,5 @@ This module contains articles about reactive Spring 5 - [Logging a Reactive Sequence](https://www.baeldung.com/spring-reactive-sequence-logging) - [Testing Reactive Streams Using StepVerifier and TestPublisher](https://www.baeldung.com/reactive-streams-step-verifier-test-publisher) - [Debugging Reactive Streams in Spring 5](https://www.baeldung.com/spring-debugging-reactive-streams) +- [Static Content in Spring WebFlux](https://www.baeldung.com/spring-webflux-static-content) - More articles: [[<-- prev]](/spring-5-reactive) diff --git a/spring-5-reactive/src/main/java/com/baeldung/staticcontent/StaticContentApplication.java b/spring-5-reactive-2/src/main/java/com/baeldung/staticcontent/StaticContentApplication.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/staticcontent/StaticContentApplication.java rename to spring-5-reactive-2/src/main/java/com/baeldung/staticcontent/StaticContentApplication.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/staticcontent/StaticContentConfig.java b/spring-5-reactive-2/src/main/java/com/baeldung/staticcontent/StaticContentConfig.java similarity index 100% rename from spring-5-reactive/src/main/java/com/baeldung/staticcontent/StaticContentConfig.java rename to spring-5-reactive-2/src/main/java/com/baeldung/staticcontent/StaticContentConfig.java diff --git a/spring-5-reactive/src/main/resources/application-assets-custom-location.properties b/spring-5-reactive-2/src/main/resources/application-assets-custom-location.properties similarity index 100% rename from spring-5-reactive/src/main/resources/application-assets-custom-location.properties rename to spring-5-reactive-2/src/main/resources/application-assets-custom-location.properties diff --git a/spring-5-reactive/src/test/java/com/baeldung/staticcontent/StaticContentCustomLocationIntegrationTest.java b/spring-5-reactive-2/src/test/java/com/baeldung/staticcontent/StaticContentCustomLocationIntegrationTest.java similarity index 100% rename from spring-5-reactive/src/test/java/com/baeldung/staticcontent/StaticContentCustomLocationIntegrationTest.java rename to spring-5-reactive-2/src/test/java/com/baeldung/staticcontent/StaticContentCustomLocationIntegrationTest.java diff --git a/spring-5-reactive/src/test/java/com/baeldung/staticcontent/StaticContentDefaultLocationIntegrationTest.java b/spring-5-reactive-2/src/test/java/com/baeldung/staticcontent/StaticContentDefaultLocationIntegrationTest.java similarity index 100% rename from spring-5-reactive/src/test/java/com/baeldung/staticcontent/StaticContentDefaultLocationIntegrationTest.java rename to spring-5-reactive-2/src/test/java/com/baeldung/staticcontent/StaticContentDefaultLocationIntegrationTest.java diff --git a/spring-5-reactive/src/main/resources/public/index.html b/spring-5-reactive-2/src/test/resources/assets/index.html similarity index 100% rename from spring-5-reactive/src/main/resources/public/index.html rename to spring-5-reactive-2/src/test/resources/assets/index.html diff --git a/spring-5-reactive/src/main/resources/img/example-image.png b/spring-5-reactive-2/src/test/resources/img/example-image.png similarity index 100% rename from spring-5-reactive/src/main/resources/img/example-image.png rename to spring-5-reactive-2/src/test/resources/img/example-image.png diff --git a/spring-5-reactive-2/src/test/resources/public/index.html b/spring-5-reactive-2/src/test/resources/public/index.html new file mode 100644 index 0000000000..7a3b9413cd --- /dev/null +++ b/spring-5-reactive-2/src/test/resources/public/index.html @@ -0,0 +1,10 @@ + + + + + Baeldung: Static Content in Spring WebFlux + + +Example HTML file + + \ No newline at end of file diff --git a/spring-5-reactive/README.md b/spring-5-reactive/README.md index 74156a993e..997795ca9a 100644 --- a/spring-5-reactive/README.md +++ b/spring-5-reactive/README.md @@ -17,6 +17,4 @@ The "REST With Spring" Classes: https://bit.ly/restwithspring - [Handling Errors in Spring WebFlux](https://www.baeldung.com/spring-webflux-errors) - [Server-Sent Events in Spring](https://www.baeldung.com/spring-server-sent-events) - [A Guide to Spring Session Reactive Support: WebSession](https://www.baeldung.com/spring-session-reactive) - -- [Static Content in Spring WebFlux](https://www.baeldung.com/spring-webflux-static-content) - More articles: [[next -->]](/spring-5-reactive-2) \ No newline at end of file From 83e27dd408840939e20b80fee628aed8e05e2a24 Mon Sep 17 00:00:00 2001 From: Sjmillington Date: Sun, 29 Sep 2019 17:47:21 +0100 Subject: [PATCH 24/55] Add README descriptions 26 --- apache-tika/README.md | 6 +++++- apache-velocity/README.md | 6 +++++- apache-zookeeper/README.md | 6 +++++- asciidoctor/README.md | 6 +++++- asm/README.md | 4 ++++ atomix/README.md | 6 +++++- autovalue/README.md | 5 +++++ aws-lambda/README.md | 4 ++++ aws/README.md | 4 ++++ axon/README.md | 4 ++++ 10 files changed, 46 insertions(+), 5 deletions(-) diff --git a/apache-tika/README.md b/apache-tika/README.md index b92a7bebf1..02d60c3dd6 100644 --- a/apache-tika/README.md +++ b/apache-tika/README.md @@ -1,3 +1,7 @@ -## Relevant articles: +## Apache Tika + +This module contains articles about Apache Tika + +### Relevant articles: - [Content Analysis with Apache Tika](http://www.baeldung.com/apache-tika) diff --git a/apache-velocity/README.md b/apache-velocity/README.md index 53c67f847e..f3b1a0fb29 100644 --- a/apache-velocity/README.md +++ b/apache-velocity/README.md @@ -1,3 +1,7 @@ -## Relevant articles: +## Apache Velocity + +This module contains articles about Apache Velocity + +### Relevant articles: - [Introduction to Apache Velocity](http://www.baeldung.com/apache-velocity) diff --git a/apache-zookeeper/README.md b/apache-zookeeper/README.md index 6bddcfd5a8..039d935767 100644 --- a/apache-zookeeper/README.md +++ b/apache-zookeeper/README.md @@ -1,3 +1,7 @@ -## Relevant articles: +## Apache Zookeeper + +This module contains articles about Apache Zookeeper + +### Relevant articles: - [Getting Started with Java and Zookeeper](http://www.baeldung.com/java-zookeeper) diff --git a/asciidoctor/README.md b/asciidoctor/README.md index 2124907e87..0619a4d272 100644 --- a/asciidoctor/README.md +++ b/asciidoctor/README.md @@ -1,4 +1,8 @@ -### Relevant articles +## Asciidoctor + +This module contains articles about Asciidoctor + +### Relevant articles: - [Generating a Book with Asciidoctor](http://www.baeldung.com/asciidoctor-book) - [Introduction to Asciidoctor in Java](http://www.baeldung.com/asciidoctor) diff --git a/asm/README.md b/asm/README.md index 50d9c34324..679ce89ec2 100644 --- a/asm/README.md +++ b/asm/README.md @@ -1,3 +1,7 @@ +## ASM + +This module contains articles about ASM + ### Relevant Articles: - [A Guide to Java Bytecode Manipulation with ASM](http://www.baeldung.com/java-asm) diff --git a/atomix/README.md b/atomix/README.md index fb22eec8dc..e0aa618ed7 100644 --- a/atomix/README.md +++ b/atomix/README.md @@ -1,3 +1,7 @@ -## Relevant articles: +## Atomix + +This module contains articles about Atomix + +### Relevant articles: - [Introduction to Atomix](http://www.baeldung.com/atomix) diff --git a/autovalue/README.md b/autovalue/README.md index f33ff6899f..51d508907e 100644 --- a/autovalue/README.md +++ b/autovalue/README.md @@ -1,4 +1,9 @@ +## AutoValue + +This module contains articles about automatic code generation + ### Relevant Articles: + - [Introduction to AutoValue](http://www.baeldung.com/introduction-to-autovalue) - [Introduction to AutoFactory](http://www.baeldung.com/autofactory) - [Google AutoService](https://www.baeldung.com/google-autoservice) diff --git a/aws-lambda/README.md b/aws-lambda/README.md index 921b699bdd..ce67756dcf 100644 --- a/aws-lambda/README.md +++ b/aws-lambda/README.md @@ -1,3 +1,7 @@ +## AWS Lambda + +This module contains articles about AWS Lambda + ### Relevant Articles: - [Using AWS Lambda with API Gateway](http://www.baeldung.com/aws-lambda-api-gateway) - [Introduction to AWS Serverless Application Model](http://www.baeldung.com/aws-serverless) diff --git a/aws/README.md b/aws/README.md index d14ea8a75e..37707cb30c 100644 --- a/aws/README.md +++ b/aws/README.md @@ -1,3 +1,7 @@ +## AWS + +This module contains articles about AWS + ### Relevant articles - [AWS Lambda Using DynamoDB With Java](http://www.baeldung.com/aws-lambda-dynamodb-java) diff --git a/axon/README.md b/axon/README.md index f1ae5d00d8..38c03e8418 100644 --- a/axon/README.md +++ b/axon/README.md @@ -1,3 +1,7 @@ +## Axon + +This module contains articles about Axon + ### Relevant articles - [A Guide to the Axon Framework](http://www.baeldung.com/axon-cqrs-event-sourcing) From 4881c701fd60ba7daad0d7578f2cfce8588d1ce1 Mon Sep 17 00:00:00 2001 From: at508 Date: Sun, 29 Sep 2019 23:39:09 -0400 Subject: [PATCH 25/55] [BAEL-2998] - ordering and renaming tests for @DirtiesContext example --- testing-modules/spring-testing/pom.xml | 22 ++++++++++--- .../DirtiesContextIntegrationTest.java | 33 +++++++++++-------- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/testing-modules/spring-testing/pom.xml b/testing-modules/spring-testing/pom.xml index bb7d54218a..8a76dc903c 100644 --- a/testing-modules/spring-testing/pom.xml +++ b/testing-modules/spring-testing/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.baeldung spring-testing @@ -21,7 +22,7 @@ ${hamcrest.version} - + org.projectlombok lombok ${lombok.version} @@ -33,7 +34,7 @@ spring-boot-starter LATEST - + org.springframework.boot @@ -52,7 +53,7 @@ LATEST - org.springframework + org.springframework spring-webmvc ${spring.version} @@ -72,6 +73,17 @@ ${junit.jupiter.version} test + + org.junit.jupiter + junit-jupiter-engine + ${junit.jupiter.version} + + + org.junit.jupiter + junit-jupiter-api + ${junit.jupiter.version} + test + org.awaitility awaitility diff --git a/testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextIntegrationTest.java b/testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextIntegrationTest.java index 7fad754b8f..f3e7b8c228 100644 --- a/testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextIntegrationTest.java +++ b/testing-modules/spring-testing/src/test/java/com/baeldung/dirtiescontext/DirtiesContextIntegrationTest.java @@ -1,17 +1,18 @@ package com.baeldung.dirtiescontext; -import org.junit.FixMethodOrder; +import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; +import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; -import org.junit.runners.MethodSorters; +import org.junit.jupiter.api.TestMethodOrder; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.MethodMode; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -@RunWith(SpringJUnit4ClassRunner.class) +@TestMethodOrder(OrderAnnotation.class) +@ExtendWith(SpringExtension.class) @SpringBootTest(classes = SpringDataRestApplication.class) class DirtiesContextIntegrationTest { @@ -19,26 +20,30 @@ class DirtiesContextIntegrationTest { protected UserCache userCache; @Test - void testA() { + @Order(1) + void addJaneDoeAndPrintCache() { userCache.addUser("Jane Doe"); - userCache.printUserList("Test A"); + userCache.printUserList("addJaneDoeAndPrintCache"); } @Test - void testB() { - userCache.printUserList("Test B"); + @Order(2) + void printCache() { + userCache.printUserList("printCache"); } @DirtiesContext(methodMode = MethodMode.AFTER_METHOD) @Test - void testC() { + @Order(3) + void addJohnDoeAndPrintCache() { userCache.addUser("John Doe"); - userCache.printUserList("Test C"); + userCache.printUserList("addJohnDoeAndPrintCache"); } @Test - void testD() { - userCache.printUserList("Test D"); + @Order(4) + void printCacheAgain() { + userCache.printUserList("printCacheAgain"); } } From ccb9aea14f2bc34490263651372b39266b3378f2 Mon Sep 17 00:00:00 2001 From: Sjmillington Date: Tue, 1 Oct 2019 16:16:00 +0100 Subject: [PATCH 26/55] Add README descriptions 30 --- core-java-modules/README.md | 4 ++++ core-java-modules/core-java-lang-2/README.md | 7 ++++--- core-java-modules/core-java-lang-oop-2/README.md | 7 ++++--- core-java-modules/core-java-lang-oop-3/README.md | 7 ++++--- core-java-modules/core-java-lang-oop/README.md | 5 +++-- core-java-modules/core-java-lang-syntax/README.md | 5 +++-- core-java-modules/core-java-lang/README.md | 5 +++-- core-java-modules/core-java-networking-2/README.md | 5 +++++ core-java-modules/core-java-networking/README.md | 5 +++-- core-java-modules/core-java-perf/README.md | 2 ++ core-java-modules/core-java-sun/README.md | 5 +++-- core-scala/README.md | 4 ++++ 12 files changed, 42 insertions(+), 19 deletions(-) diff --git a/core-java-modules/README.md b/core-java-modules/README.md index 9ce6057f32..55dacca916 100644 --- a/core-java-modules/README.md +++ b/core-java-modules/README.md @@ -1,3 +1,7 @@ +## Core Java Modules + +This module contains modules about core Java + ## Relevant articles: - [Multi-Module Maven Application with Java Modules](https://www.baeldung.com/maven-multi-module-project-java-jpms) diff --git a/core-java-modules/core-java-lang-2/README.md b/core-java-modules/core-java-lang-2/README.md index d925e81d87..b03abe38f4 100644 --- a/core-java-modules/core-java-lang-2/README.md +++ b/core-java-modules/core-java-lang-2/README.md @@ -1,6 +1,7 @@ -========= +## Core Java Lang (Part 2) -## Core Java Lang Cookbooks and Examples +This module contains articles about core Java language ### Relevant Articles: -- [Java Primitives versus Objects](https://www.baeldung.com/java-primitives-vs-objects) \ No newline at end of file +- [Java Primitives versus Objects](https://www.baeldung.com/java-primitives-vs-objects) +- [[<-- Prev]](/core-java-modules/core-java-lang) \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-2/README.md b/core-java-modules/core-java-lang-oop-2/README.md index 096e4ee002..80f97221d5 100644 --- a/core-java-modules/core-java-lang-oop-2/README.md +++ b/core-java-modules/core-java-lang-oop-2/README.md @@ -1,6 +1,6 @@ -========= +## Core Java Lang OOP (Part 2) -## Core Java Lang OOP 2 Cookbooks and Examples +This module contains articles about Object-oriented programming (OOP) in Java ### Relevant Articles: - [Generic Constructors in Java](https://www.baeldung.com/java-generic-constructors) @@ -13,4 +13,5 @@ - [Immutable Objects in Java](https://www.baeldung.com/java-immutable-object) - [Inheritance and Composition (Is-a vs Has-a relationship) in Java](https://www.baeldung.com/java-inheritance-composition) - [A Guide to Constructors in Java](https://www.baeldung.com/java-constructors) -- [Static and Default Methods in Interfaces in Java](https://www.baeldung.com/java-static-default-methods) \ No newline at end of file +- [Static and Default Methods in Interfaces in Java](https://www.baeldung.com/java-static-default-methods) +- [[<-- Prev]](/core-java-modules/core-java-lang-oop)[[More -->]](/core-java-modules/core-java-lang-oop-3) \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-3/README.md b/core-java-modules/core-java-lang-oop-3/README.md index 15876d124f..c3a32124b5 100644 --- a/core-java-modules/core-java-lang-oop-3/README.md +++ b/core-java-modules/core-java-lang-oop-3/README.md @@ -1,6 +1,6 @@ -========= +## Core Java Lang OOP (Part 3) -## Core Java Lang OOP 3 Cookbooks and Examples +This module contains articles about Object-oriented programming (OOP) in Java ### Relevant Articles: - [Pass-By-Value as a Parameter Passing Mechanism in Java](https://www.baeldung.com/java-pass-by-value-or-pass-by-reference) @@ -8,4 +8,5 @@ - [Guide to the super Java Keyword](https://www.baeldung.com/java-super) - [Guide to the this Java Keyword](https://www.baeldung.com/java-this) - [Java Public Access Modifier](https://www.baeldung.com/java-public-keyword) -- [Composition, Aggregation and Association in Java](https://www.baeldung.com/java-composition-aggregation-association) \ No newline at end of file +- [Composition, Aggregation and Association in Java](https://www.baeldung.com/java-composition-aggregation-association) +- [[<-- Prev]](/core-java-modules/core-java-lang-oop-2) \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop/README.md b/core-java-modules/core-java-lang-oop/README.md index 2e7fa4d689..0fb044138d 100644 --- a/core-java-modules/core-java-lang-oop/README.md +++ b/core-java-modules/core-java-lang-oop/README.md @@ -1,6 +1,6 @@ -========= +## Core Java Lang OOP -## Core Java Lang OOP Cookbooks and Examples +This module contains articles about Object-oriented programming (OOP) in Java ### Relevant Articles: - [Guide to hashCode() in Java](https://www.baeldung.com/java-hashcode) @@ -13,3 +13,4 @@ - [The “final” Keyword in Java](https://www.baeldung.com/java-final) - [Type Erasure in Java Explained](https://www.baeldung.com/java-type-erasure) - [Variable and Method Hiding in Java](https://www.baeldung.com/java-variable-method-hiding) +- [[More -->]](/core-java-modules/core-java-lang-oop-2) diff --git a/core-java-modules/core-java-lang-syntax/README.md b/core-java-modules/core-java-lang-syntax/README.md index 3293e9b23d..1c95997bd5 100644 --- a/core-java-modules/core-java-lang-syntax/README.md +++ b/core-java-modules/core-java-lang-syntax/README.md @@ -1,6 +1,6 @@ -========= +## Core Java Lang Syntax -## Core Java Lang Syntax Cookbooks and Examples +This module contains articles about core Java syntax ### Relevant Articles: - [The Basics of Java Generics](http://www.baeldung.com/java-generics) @@ -19,3 +19,4 @@ - [Ternary Operator In Java](https://www.baeldung.com/java-ternary-operator) - [Java instanceof Operator](https://www.baeldung.com/java-instanceof) - [Breaking Out of Nested Loops](https://www.baeldung.com/java-breaking-out-nested-loop) +- [[More -->]](/core-java-modules/core-java-lang-syntax-2) diff --git a/core-java-modules/core-java-lang/README.md b/core-java-modules/core-java-lang/README.md index f3b6d3d8e5..312423ecee 100644 --- a/core-java-modules/core-java-lang/README.md +++ b/core-java-modules/core-java-lang/README.md @@ -1,6 +1,6 @@ -========= +## Core Java Lang -## Core Java Lang Cookbooks and Examples +This module contains articles about core Java language ### Relevant Articles: @@ -38,3 +38,4 @@ - [Attaching Values to Java Enum](https://www.baeldung.com/java-enum-values) - [Variable Scope in Java](https://www.baeldung.com/java-variable-scope) - [Java Classes and Objects](https://www.baeldung.com/java-classes-objects) +- [[More --> ]](/core-java-modules/core-java-lang-2) diff --git a/core-java-modules/core-java-networking-2/README.md b/core-java-modules/core-java-networking-2/README.md index 62dec41356..8fac91a0ae 100644 --- a/core-java-modules/core-java-networking-2/README.md +++ b/core-java-modules/core-java-networking-2/README.md @@ -1,3 +1,7 @@ +## Core Java Networking (Part 2) + +This module contains articles about core Java networking + ### Relevant Articles - [Checking if a URL Exists in Java](https://www.baeldung.com/java-check-url-exists) @@ -5,3 +9,4 @@ - [Using Curl in Java](https://www.baeldung.com/java-curl) - [Do a Simple HTTP Request in Java](http://www.baeldung.com/java-http-request) - [Sending Emails with Java](http://www.baeldung.com/java-email) +- [[<-- Prev]](/core-java-modules/core-java-networking) diff --git a/core-java-modules/core-java-networking/README.md b/core-java-modules/core-java-networking/README.md index 33fc3684a3..c766e5d635 100644 --- a/core-java-modules/core-java-networking/README.md +++ b/core-java-modules/core-java-networking/README.md @@ -1,7 +1,7 @@ -========= - ## Core Java Networking +This module contains articles about core Java networking + ### Relevant Articles - [Connecting Through Proxy Servers in Core Java](https://www.baeldung.com/java-connect-via-proxy-server) @@ -14,3 +14,4 @@ - [Guide to Java URL Encoding/Decoding](http://www.baeldung.com/java-url-encoding-decoding) - [Difference between URL and URI](http://www.baeldung.com/java-url-vs-uri) - [Read an InputStream using the Java Server Socket](https://www.baeldung.com/java-inputstream-server-socket) +- [[More -->]](/core-java-modules/core-java-networking-2) diff --git a/core-java-modules/core-java-perf/README.md b/core-java-modules/core-java-perf/README.md index 1b3b590bf8..e644c73eea 100644 --- a/core-java-modules/core-java-perf/README.md +++ b/core-java-modules/core-java-perf/README.md @@ -1,5 +1,7 @@ ## Core Java Performance +This module contains articles about core Java performance + ### Relevant Articles: - [Verbose Garbage Collection in Java](https://www.baeldung.com/java-verbose-gc) - [Different Ways to Capture Java Heap Dumps](https://www.baeldung.com/java-heap-dump-capture) diff --git a/core-java-modules/core-java-sun/README.md b/core-java-modules/core-java-sun/README.md index e2dba76b41..107035cbe8 100644 --- a/core-java-modules/core-java-sun/README.md +++ b/core-java-modules/core-java-sun/README.md @@ -1,7 +1,8 @@ -========= +## Core Java Sun -## Core Java Cookbooks and Examples +This module contains articles about the sun package ### Relevant Articles: + - [Creating a Java Compiler Plugin](http://www.baeldung.com/java-build-compiler-plugin) - [Guide to sun.misc.Unsafe](http://www.baeldung.com/java-unsafe) \ No newline at end of file diff --git a/core-scala/README.md b/core-scala/README.md index eed344193f..cfdb0c44ed 100644 --- a/core-scala/README.md +++ b/core-scala/README.md @@ -1,3 +1,7 @@ +## Core Scala + +This module contains articles about core Scala + ### Relevant Articles: - [Introduction to Scala](https://www.baeldung.com/scala-intro) From 160fd28fddaa07e7f2a09596484a380f48dd5ba3 Mon Sep 17 00:00:00 2001 From: Catalin Burcea Date: Thu, 3 Oct 2019 06:33:18 +0300 Subject: [PATCH 27/55] Split or move testing-modules/junit-5 module (#7879) --- testing-modules/junit-5/README.md | 16 ++---- testing-modules/junit-5/pom.xml | 5 -- .../DynamicTestsUnitTest.java} | 6 +- .../com/baeldung/dynamictests/Employee.java | 38 +++++++++++++ .../baeldung/dynamictests/EmployeeDao.java | 16 ++++++ testing-modules/junit5-annotations/README.md | 9 +++ testing-modules/junit5-annotations/pom.xml | 57 +++++++++++++++++++ .../registerextension/LoggingExtension.java | 18 ++++++ .../RegisterExtensionSampleExtension.java | 2 +- .../RepeatedTestAnnotationUnitTest.java} | 4 +- .../ConditionalAnnotationsUnitTest.java | 2 +- .../BlankStringsArgumentsProvider.java | 2 +- .../junit5}/parameterized/EnumsUnitTest.java | 2 +- .../parameterized/LocalDateUnitTest.java | 2 +- .../junit5}/parameterized/Numbers.java | 2 +- .../parameterized/NumbersUnitTest.java | 2 +- .../junit5}/parameterized/Person.java | 2 +- .../parameterized/PersonAggregator.java | 2 +- .../junit5}/parameterized/PersonUnitTest.java | 2 +- .../parameterized/SlashyDateConverter.java | 2 +- .../junit5}/parameterized/StringParams.java | 2 +- .../junit5}/parameterized/Strings.java | 2 +- .../parameterized/StringsUnitTest.java | 4 +- .../VariableArgumentsProvider.java | 2 +- .../junit5}/parameterized/VariableSource.java | 2 +- .../RegisterExtensionUnitTest.java | 4 +- .../src/test/resources/data.csv | 0 testing-modules/junit5-migration/README.md | 6 +- .../baeldung/junit5vstestng/Calculator.java | 0 .../junit5vstestng/DivideByZeroException.java | 0 .../junit4vstestng/SortedUnitTest.java | 0 .../SummationServiceIntegrationTest.java | 0 .../Junit4AssertionsUnitTest.java} | 4 +- .../Junit5AssertionsUnitTest.java} | 4 +- .../junit5vstestng/CalculatorUnitTest.java | 0 .../junit5vstestng/Class1UnitTest.java | 0 .../junit5vstestng/Class2UnitTest.java | 0 .../junit5vstestng/CustomNameUnitTest.java | 0 .../junit5vstestng/ParameterizedUnitTest.java | 0 .../junit5vstestng/PizzaDeliveryStrategy.java | 0 .../SelectClassesSuiteUnitTest.java | 0 .../SelectPackagesSuiteUnitTest.java | 0 .../SummationServiceUnitTest.java | 0 testing-modules/pom.xml | 1 + 44 files changed, 176 insertions(+), 46 deletions(-) rename testing-modules/junit-5/src/test/java/com/baeldung/{DynamicTestsExample.java => dynamictests/DynamicTestsUnitTest.java} (97%) create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/Employee.java create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/EmployeeDao.java create mode 100644 testing-modules/junit5-annotations/README.md create mode 100644 testing-modules/junit5-annotations/pom.xml create mode 100644 testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/registerextension/LoggingExtension.java rename testing-modules/{junit-5/src/test/java/com/baeldung/extensions => junit5-annotations/src/main/java/com/baeldung/junit5/registerextension}/RegisterExtensionSampleExtension.java (95%) rename testing-modules/{junit-5/src/test/java/com/baeldung/RepeatedTestExample.java => junit5-annotations/src/test/java/com/baeldung/junit5/RepeatedTestAnnotationUnitTest.java} (95%) rename testing-modules/{junit-5/src/test/java/com/baeldung => junit5-annotations/src/test/java/com/baeldung/junit5}/conditional/ConditionalAnnotationsUnitTest.java (98%) rename testing-modules/{junit-5/src/test/java/com/baeldung => junit5-annotations/src/test/java/com/baeldung/junit5}/parameterized/BlankStringsArgumentsProvider.java (92%) rename testing-modules/{junit-5/src/test/java/com/baeldung => junit5-annotations/src/test/java/com/baeldung/junit5}/parameterized/EnumsUnitTest.java (97%) rename testing-modules/{junit-5/src/test/java/com/baeldung => junit5-annotations/src/test/java/com/baeldung/junit5}/parameterized/LocalDateUnitTest.java (92%) rename testing-modules/{junit-5/src/test/java/com/baeldung => junit5-annotations/src/test/java/com/baeldung/junit5}/parameterized/Numbers.java (72%) rename testing-modules/{junit-5/src/test/java/com/baeldung => junit5-annotations/src/test/java/com/baeldung/junit5}/parameterized/NumbersUnitTest.java (89%) rename testing-modules/{junit-5/src/test/java/com/baeldung => junit5-annotations/src/test/java/com/baeldung/junit5}/parameterized/Person.java (92%) rename testing-modules/{junit-5/src/test/java/com/baeldung => junit5-annotations/src/test/java/com/baeldung/junit5}/parameterized/PersonAggregator.java (93%) rename testing-modules/{junit-5/src/test/java/com/baeldung => junit5-annotations/src/test/java/com/baeldung/junit5}/parameterized/PersonUnitTest.java (96%) rename testing-modules/{junit-5/src/test/java/com/baeldung => junit5-annotations/src/test/java/com/baeldung/junit5}/parameterized/SlashyDateConverter.java (95%) rename testing-modules/{junit-5/src/test/java/com/baeldung => junit5-annotations/src/test/java/com/baeldung/junit5}/parameterized/StringParams.java (78%) rename testing-modules/{junit-5/src/test/java/com/baeldung => junit5-annotations/src/test/java/com/baeldung/junit5}/parameterized/Strings.java (74%) rename testing-modules/{junit-5/src/test/java/com/baeldung => junit5-annotations/src/test/java/com/baeldung/junit5}/parameterized/StringsUnitTest.java (97%) rename testing-modules/{junit-5/src/test/java/com/baeldung => junit5-annotations/src/test/java/com/baeldung/junit5}/parameterized/VariableArgumentsProvider.java (96%) rename testing-modules/{junit-5/src/test/java/com/baeldung => junit5-annotations/src/test/java/com/baeldung/junit5}/parameterized/VariableSource.java (90%) rename testing-modules/{junit-5/src/test/java/com/baeldung => junit5-annotations/src/test/java/com/baeldung/junit5/registerextension}/RegisterExtensionUnitTest.java (86%) rename testing-modules/{junit-5 => junit5-annotations}/src/test/resources/data.csv (100%) rename testing-modules/{junit-5 => junit5-migration}/src/main/java/com/baeldung/junit5vstestng/Calculator.java (100%) rename testing-modules/{junit-5 => junit5-migration}/src/main/java/com/baeldung/junit5vstestng/DivideByZeroException.java (100%) rename testing-modules/{junit-5 => junit5-migration}/src/test/java/com/baeldung/junit4vstestng/SortedUnitTest.java (100%) rename testing-modules/{junit-5 => junit5-migration}/src/test/java/com/baeldung/junit4vstestng/SummationServiceIntegrationTest.java (100%) rename testing-modules/{junit-4/src/test/java/com/baeldung/junit/AssertionsUnitTest.java => junit5-migration/src/test/java/com/baeldung/junit5vsjunit4assertions/Junit4AssertionsUnitTest.java} (96%) rename testing-modules/{junit-5/src/test/java/com/baeldung/AssertionUnitTest.java => junit5-migration/src/test/java/com/baeldung/junit5vsjunit4assertions/Junit5AssertionsUnitTest.java} (98%) rename testing-modules/{junit-5 => junit5-migration}/src/test/java/com/baeldung/junit5vstestng/CalculatorUnitTest.java (100%) rename testing-modules/{junit-5 => junit5-migration}/src/test/java/com/baeldung/junit5vstestng/Class1UnitTest.java (100%) rename testing-modules/{junit-5 => junit5-migration}/src/test/java/com/baeldung/junit5vstestng/Class2UnitTest.java (100%) rename testing-modules/{junit-5 => junit5-migration}/src/test/java/com/baeldung/junit5vstestng/CustomNameUnitTest.java (100%) rename testing-modules/{junit-5 => junit5-migration}/src/test/java/com/baeldung/junit5vstestng/ParameterizedUnitTest.java (100%) rename testing-modules/{junit-5 => junit5-migration}/src/test/java/com/baeldung/junit5vstestng/PizzaDeliveryStrategy.java (100%) rename testing-modules/{junit-5 => junit5-migration}/src/test/java/com/baeldung/junit5vstestng/SelectClassesSuiteUnitTest.java (100%) rename testing-modules/{junit-5 => junit5-migration}/src/test/java/com/baeldung/junit5vstestng/SelectPackagesSuiteUnitTest.java (100%) rename testing-modules/{junit-5 => junit5-migration}/src/test/java/com/baeldung/junit5vstestng/SummationServiceUnitTest.java (100%) diff --git a/testing-modules/junit-5/README.md b/testing-modules/junit-5/README.md index 14e018a5f9..676d2f2f03 100644 --- a/testing-modules/junit-5/README.md +++ b/testing-modules/junit-5/README.md @@ -1,14 +1,8 @@ ### Relevant Articles: -- [A Guide to @RepeatedTest in Junit 5](http://www.baeldung.com/junit-5-repeated-test) -- [Guide to Dynamic Tests in Junit 5](http://www.baeldung.com/junit5-dynamic-tests) -- [A Guide to JUnit 5 Extensions](http://www.baeldung.com/junit-5-extensions) -- [Inject Parameters into JUnit Jupiter Unit Tests](http://www.baeldung.com/junit-5-parameters) -- [Mockito and JUnit 5 – Using ExtendWith](http://www.baeldung.com/mockito-junit-5-extension) -- [JUnit5 Programmatic Extension Registration with @RegisterExtension](http://www.baeldung.com/junit-5-registerextension-annotation) -- [The Order of Tests in JUnit](http://www.baeldung.com/junit-5-test-order) +- [A Guide to JUnit 5 Extensions](https://www.baeldung.com/junit-5-extensions) +- [Inject Parameters into JUnit Jupiter Unit Tests](https://www.baeldung.com/junit-5-parameters) +- [Mockito and JUnit 5 – Using ExtendWith](https://www.baeldung.com/mockito-junit-5-extension) +- [The Order of Tests in JUnit](https://www.baeldung.com/junit-5-test-order) - [Running JUnit Tests Programmatically, from a Java Application](https://www.baeldung.com/junit-tests-run-programmatically-from-java) - [Testing an Abstract Class With JUnit](https://www.baeldung.com/junit-test-abstract-class) -- [A Quick JUnit vs TestNG Comparison](http://www.baeldung.com/junit-vs-testng) -- [Guide to JUnit 5 Parameterized Tests](https://www.baeldung.com/parameterized-tests-junit-5) -- [JUnit 5 Conditional Test Execution with Annotations](https://www.baeldung.com/junit-5-conditional-test-execution) -- [Assertions in JUnit 4 and JUnit 5](http://www.baeldung.com/junit-assertions) +- [Guide to Dynamic Tests in Junit 5](https://www.baeldung.com/junit5-dynamic-tests) diff --git a/testing-modules/junit-5/pom.xml b/testing-modules/junit-5/pom.xml index b3074635a7..96944b4dc6 100644 --- a/testing-modules/junit-5/pom.xml +++ b/testing-modules/junit-5/pom.xml @@ -26,11 +26,6 @@ junit-jupiter-engine ${junit.jupiter.version} - - org.junit.jupiter - junit-jupiter-params - ${junit.jupiter.version} - org.junit.jupiter junit-jupiter-api diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/DynamicTestsExample.java b/testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/DynamicTestsUnitTest.java similarity index 97% rename from testing-modules/junit-5/src/test/java/com/baeldung/DynamicTestsExample.java rename to testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/DynamicTestsUnitTest.java index b684f3603f..8b3087497b 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/DynamicTestsExample.java +++ b/testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/DynamicTestsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.dynamictests; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -17,10 +17,8 @@ import org.junit.jupiter.api.DynamicTest; import org.junit.jupiter.api.TestFactory; import org.junit.jupiter.api.function.ThrowingConsumer; -import com.baeldung.helpers.Employee; -import com.baeldung.helpers.EmployeeDao; -public class DynamicTestsExample { +public class DynamicTestsUnitTest { @TestFactory Collection dynamicTestsWithCollection() { diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/Employee.java b/testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/Employee.java new file mode 100644 index 0000000000..4b58a71135 --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/Employee.java @@ -0,0 +1,38 @@ +package com.baeldung.dynamictests; + +public class Employee { + + private long id; + private String firstName; + + public Employee(long id) { + this.id = id; + this.firstName = ""; + } + + public Employee(long id, String firstName) { + this.id = id; + this.firstName = firstName; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + @Override + public String toString() { + return "Employee [id=" + id + ", firstName=" + firstName + "]"; + } +} diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/EmployeeDao.java b/testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/EmployeeDao.java new file mode 100644 index 0000000000..4e2d9a5140 --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/EmployeeDao.java @@ -0,0 +1,16 @@ +package com.baeldung.dynamictests; + +public class EmployeeDao { + + public Employee save(long id) { + return new Employee(id); + } + + public Employee save(long id, String firstName) { + return new Employee(id, firstName); + } + + public Employee update(Employee employee) { + return employee; + } +} diff --git a/testing-modules/junit5-annotations/README.md b/testing-modules/junit5-annotations/README.md new file mode 100644 index 0000000000..53819dbec5 --- /dev/null +++ b/testing-modules/junit5-annotations/README.md @@ -0,0 +1,9 @@ +## Junit 5 Annotations + +This module contains articles about Junit 5 Annotations + +### Relevant Articles: +- [A Guide to @RepeatedTest in Junit 5](https://www.baeldung.com/junit-5-repeated-test) +- [JUnit 5 Conditional Test Execution with Annotations](https://www.baeldung.com/junit-5-conditional-test-execution) +- [JUnit5 Programmatic Extension Registration with @RegisterExtension](https://www.baeldung.com/junit-5-registerextension-annotation) +- [Guide to JUnit 5 Parameterized Tests](https://www.baeldung.com/parameterized-tests-junit-5) diff --git a/testing-modules/junit5-annotations/pom.xml b/testing-modules/junit5-annotations/pom.xml new file mode 100644 index 0000000000..c8abfe909d --- /dev/null +++ b/testing-modules/junit5-annotations/pom.xml @@ -0,0 +1,57 @@ + + + 4.0.0 + junit5-annotations + 1.0-SNAPSHOT + junit5-annotations + Intro to JUnit 5 + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../../ + + + + + org.junit.platform + junit-platform-engine + ${junit.platform.version} + + + org.junit.jupiter + junit-jupiter-engine + ${junit.jupiter.version} + + + org.junit.jupiter + junit-jupiter-params + ${junit.jupiter.version} + + + org.junit.jupiter + junit-jupiter-api + ${junit.jupiter.version} + + + org.apache.logging.log4j + log4j-core + ${log4j2.version} + + + org.junit.platform + junit-platform-runner + ${junit.platform.version} + test + + + + + 5.4.2 + 1.4.2 + 2.8.2 + + + diff --git a/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/registerextension/LoggingExtension.java b/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/registerextension/LoggingExtension.java new file mode 100644 index 0000000000..5de49e028b --- /dev/null +++ b/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/registerextension/LoggingExtension.java @@ -0,0 +1,18 @@ +package com.baeldung.junit5.registerextension; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.TestInstancePostProcessor; + +public class LoggingExtension implements TestInstancePostProcessor { + + @Override + public void postProcessTestInstance(Object testInstance, ExtensionContext context) throws Exception { + Logger logger = LogManager.getLogger(testInstance.getClass()); + testInstance.getClass() + .getMethod("setLogger", Logger.class) + .invoke(testInstance, logger); + } + +} diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/extensions/RegisterExtensionSampleExtension.java b/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/registerextension/RegisterExtensionSampleExtension.java similarity index 95% rename from testing-modules/junit-5/src/test/java/com/baeldung/extensions/RegisterExtensionSampleExtension.java rename to testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/registerextension/RegisterExtensionSampleExtension.java index 64f4d8fd3e..5339f98875 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/extensions/RegisterExtensionSampleExtension.java +++ b/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/registerextension/RegisterExtensionSampleExtension.java @@ -1,4 +1,4 @@ -package com.baeldung.extensions; +package com.baeldung.junit5.registerextension; import org.junit.jupiter.api.extension.BeforeAllCallback; import org.junit.jupiter.api.extension.BeforeEachCallback; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/RepeatedTestExample.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/RepeatedTestAnnotationUnitTest.java similarity index 95% rename from testing-modules/junit-5/src/test/java/com/baeldung/RepeatedTestExample.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/RepeatedTestAnnotationUnitTest.java index 749d7064bc..f9121d8790 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/RepeatedTestExample.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/RepeatedTestAnnotationUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.junit5; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -8,7 +8,7 @@ import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.RepetitionInfo; import org.junit.jupiter.api.TestInfo; -public class RepeatedTestExample { +public class RepeatedTestAnnotationUnitTest { @BeforeEach void beforeEachTest() { diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/conditional/ConditionalAnnotationsUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/conditional/ConditionalAnnotationsUnitTest.java similarity index 98% rename from testing-modules/junit-5/src/test/java/com/baeldung/conditional/ConditionalAnnotationsUnitTest.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/conditional/ConditionalAnnotationsUnitTest.java index ec76bd1488..ddceb78cac 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/conditional/ConditionalAnnotationsUnitTest.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/conditional/ConditionalAnnotationsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.conditional; +package com.baeldung.junit5.conditional; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/BlankStringsArgumentsProvider.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/BlankStringsArgumentsProvider.java similarity index 92% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/BlankStringsArgumentsProvider.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/BlankStringsArgumentsProvider.java index 1d2c76d37b..6c626efa40 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/BlankStringsArgumentsProvider.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/BlankStringsArgumentsProvider.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.params.provider.Arguments; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/EnumsUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/EnumsUnitTest.java similarity index 97% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/EnumsUnitTest.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/EnumsUnitTest.java index 0b2068dbf1..1e3bbcc772 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/EnumsUnitTest.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/EnumsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/LocalDateUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/LocalDateUnitTest.java similarity index 92% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/LocalDateUnitTest.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/LocalDateUnitTest.java index 95487705f5..d411fcb7e2 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/LocalDateUnitTest.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/LocalDateUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.converter.ConvertWith; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Numbers.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Numbers.java similarity index 72% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Numbers.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Numbers.java index 8a9b229aac..094da6de05 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Numbers.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Numbers.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; public class Numbers { diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/NumbersUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/NumbersUnitTest.java similarity index 89% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/NumbersUnitTest.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/NumbersUnitTest.java index b3a3371bb2..76ebf93f93 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/NumbersUnitTest.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/NumbersUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Person.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Person.java similarity index 92% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Person.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Person.java index 225f11ba29..c635b2e4da 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Person.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Person.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; class Person { diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonAggregator.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/PersonAggregator.java similarity index 93% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonAggregator.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/PersonAggregator.java index df2ddc9e66..c899115df8 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonAggregator.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/PersonAggregator.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.api.extension.ParameterContext; import org.junit.jupiter.params.aggregator.ArgumentsAccessor; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/PersonUnitTest.java similarity index 96% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonUnitTest.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/PersonUnitTest.java index b30ecc748e..62a2f32a63 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonUnitTest.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/PersonUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.aggregator.AggregateWith; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/SlashyDateConverter.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/SlashyDateConverter.java similarity index 95% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/SlashyDateConverter.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/SlashyDateConverter.java index 40773d29a9..d96fbce121 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/SlashyDateConverter.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/SlashyDateConverter.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.api.extension.ParameterContext; import org.junit.jupiter.params.converter.ArgumentConversionException; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringParams.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/StringParams.java similarity index 78% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringParams.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/StringParams.java index bc9f881bd4..022fb797a4 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringParams.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/StringParams.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import java.util.stream.Stream; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Strings.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Strings.java similarity index 74% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Strings.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Strings.java index f8e29f6b7f..5ee29339d7 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Strings.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Strings.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; class Strings { diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringsUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/StringsUnitTest.java similarity index 97% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringsUnitTest.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/StringsUnitTest.java index 6aea7668f1..064f305295 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringsUnitTest.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/StringsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.*; @@ -44,7 +44,7 @@ class StringsUnitTest { } @ParameterizedTest - @MethodSource("com.baeldung.parameterized.StringParams#blankStrings") + @MethodSource("com.baeldung.junit5.parameterized.StringParams#blankStrings") void isBlank_ShouldReturnTrueForNullOrBlankStringsExternalSource(String input) { assertTrue(Strings.isBlank(input)); } diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableArgumentsProvider.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/VariableArgumentsProvider.java similarity index 96% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableArgumentsProvider.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/VariableArgumentsProvider.java index a96d01e854..af10860f6a 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableArgumentsProvider.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/VariableArgumentsProvider.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.params.provider.Arguments; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableSource.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/VariableSource.java similarity index 90% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableSource.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/VariableSource.java index 9c1d07c1be..11187a4865 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableSource.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/VariableSource.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.params.provider.ArgumentsSource; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/RegisterExtensionUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/registerextension/RegisterExtensionUnitTest.java similarity index 86% rename from testing-modules/junit-5/src/test/java/com/baeldung/RegisterExtensionUnitTest.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/registerextension/RegisterExtensionUnitTest.java index 721cfdb013..7b787f96d0 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/RegisterExtensionUnitTest.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/registerextension/RegisterExtensionUnitTest.java @@ -1,6 +1,6 @@ -package com.baeldung; +package com.baeldung.junit5.registerextension; -import com.baeldung.extensions.RegisterExtensionSampleExtension; +import com.baeldung.junit5.registerextension.RegisterExtensionSampleExtension; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/testing-modules/junit-5/src/test/resources/data.csv b/testing-modules/junit5-annotations/src/test/resources/data.csv similarity index 100% rename from testing-modules/junit-5/src/test/resources/data.csv rename to testing-modules/junit5-annotations/src/test/resources/data.csv diff --git a/testing-modules/junit5-migration/README.md b/testing-modules/junit5-migration/README.md index b97ff8255c..e6ad4f376c 100644 --- a/testing-modules/junit5-migration/README.md +++ b/testing-modules/junit5-migration/README.md @@ -1,2 +1,6 @@ - This is the code for the Junit 4 - Junit 5 Migration E-book. + +### Relevant Articles: +- [Junit 5 Migration](https://www.baeldung.com/junit-5-migration) +- [A Quick JUnit vs TestNG Comparison](https://www.baeldung.com/junit-vs-testng) +- [Assertions in JUnit 4 and JUnit 5](https://www.baeldung.com/junit-assertions) diff --git a/testing-modules/junit-5/src/main/java/com/baeldung/junit5vstestng/Calculator.java b/testing-modules/junit5-migration/src/main/java/com/baeldung/junit5vstestng/Calculator.java similarity index 100% rename from testing-modules/junit-5/src/main/java/com/baeldung/junit5vstestng/Calculator.java rename to testing-modules/junit5-migration/src/main/java/com/baeldung/junit5vstestng/Calculator.java diff --git a/testing-modules/junit-5/src/main/java/com/baeldung/junit5vstestng/DivideByZeroException.java b/testing-modules/junit5-migration/src/main/java/com/baeldung/junit5vstestng/DivideByZeroException.java similarity index 100% rename from testing-modules/junit-5/src/main/java/com/baeldung/junit5vstestng/DivideByZeroException.java rename to testing-modules/junit5-migration/src/main/java/com/baeldung/junit5vstestng/DivideByZeroException.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit4vstestng/SortedUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit4vstestng/SortedUnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit4vstestng/SortedUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit4vstestng/SortedUnitTest.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit4vstestng/SummationServiceIntegrationTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit4vstestng/SummationServiceIntegrationTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit4vstestng/SummationServiceIntegrationTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit4vstestng/SummationServiceIntegrationTest.java diff --git a/testing-modules/junit-4/src/test/java/com/baeldung/junit/AssertionsUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vsjunit4assertions/Junit4AssertionsUnitTest.java similarity index 96% rename from testing-modules/junit-4/src/test/java/com/baeldung/junit/AssertionsUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vsjunit4assertions/Junit4AssertionsUnitTest.java index b0209b01aa..7e74c2dace 100644 --- a/testing-modules/junit-4/src/test/java/com/baeldung/junit/AssertionsUnitTest.java +++ b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vsjunit4assertions/Junit4AssertionsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.junit; +package com.baeldung.junit5vsjunit4assertions; import org.junit.Test; @@ -10,7 +10,7 @@ import static org.junit.Assert.*; /** * Unit test that demonstrate the different assertions available within JUnit 4 */ -public class AssertionsUnitTest { +public class Junit4AssertionsUnitTest { @Test public void whenAssertingEquality_thenEqual() { diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/AssertionUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vsjunit4assertions/Junit5AssertionsUnitTest.java similarity index 98% rename from testing-modules/junit-5/src/test/java/com/baeldung/AssertionUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vsjunit4assertions/Junit5AssertionsUnitTest.java index f1f7c531f2..40b9143a71 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/AssertionUnitTest.java +++ b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vsjunit4assertions/Junit5AssertionsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.junit5vsjunit4assertions; import static java.time.Duration.ofSeconds; import static java.util.Arrays.asList; @@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test; * Unit test that demonstrate the different assertions available within JUnit 4 */ @DisplayName("Test case for assertions") -public class AssertionUnitTest { +public class Junit5AssertionsUnitTest { @Test @DisplayName("Arrays should be equals") diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/CalculatorUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/CalculatorUnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/CalculatorUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/CalculatorUnitTest.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/Class1UnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/Class1UnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/Class1UnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/Class1UnitTest.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/Class2UnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/Class2UnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/Class2UnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/Class2UnitTest.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/CustomNameUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/CustomNameUnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/CustomNameUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/CustomNameUnitTest.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/ParameterizedUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/ParameterizedUnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/ParameterizedUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/ParameterizedUnitTest.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/PizzaDeliveryStrategy.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/PizzaDeliveryStrategy.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/PizzaDeliveryStrategy.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/PizzaDeliveryStrategy.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/SelectClassesSuiteUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/SelectClassesSuiteUnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/SelectClassesSuiteUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/SelectClassesSuiteUnitTest.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/SelectPackagesSuiteUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/SelectPackagesSuiteUnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/SelectPackagesSuiteUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/SelectPackagesSuiteUnitTest.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/SummationServiceUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/SummationServiceUnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/SummationServiceUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/SummationServiceUnitTest.java diff --git a/testing-modules/pom.xml b/testing-modules/pom.xml index 5934db00ff..aad709cfe9 100644 --- a/testing-modules/pom.xml +++ b/testing-modules/pom.xml @@ -19,6 +19,7 @@ gatling groovy-spock junit-5 + junit5-annotations junit5-migration load-testing-comparison mockito From aa88f134d31c8c3198590dcbb4f1ee3fe13d7231 Mon Sep 17 00:00:00 2001 From: Sam Millington Date: Thu, 3 Oct 2019 04:43:24 +0100 Subject: [PATCH 28/55] [BAEL-17476] - Added README descriptions (#7904) --- spring-cloud/spring-cloud-archaius/README.md | 6 ++++-- .../spring-cloud-bootstrap/{README.MD => README.md} | 6 ++++++ spring-cloud/spring-cloud-contract/README.md | 4 ++++ spring-cloud/spring-cloud-gateway/{README.MD => README.md} | 4 ++++ spring-cloud/spring-cloud-kubernetes/README.md | 4 ++++ spring-cloud/spring-cloud-rest/README.md | 3 +++ spring-cloud/spring-cloud-ribbon-client/README.md | 4 ++++ 7 files changed, 29 insertions(+), 2 deletions(-) rename spring-cloud/spring-cloud-bootstrap/{README.MD => README.md} (87%) rename spring-cloud/spring-cloud-gateway/{README.MD => README.md} (57%) diff --git a/spring-cloud/spring-cloud-archaius/README.md b/spring-cloud/spring-cloud-archaius/README.md index ae853c6ef0..3b5ed16373 100644 --- a/spring-cloud/spring-cloud-archaius/README.md +++ b/spring-cloud/spring-cloud-archaius/README.md @@ -1,10 +1,12 @@ +# Spring Cloud Archaius + +This module contains articles about Spring Cloud with Netflix Archaius + # Relevant Articles - [Introduction to Netflix Archaius with Spring Cloud](https://www.baeldung.com/netflix-archaius-spring-cloud-integration) - [Netflix Archaius with Various Database Configurations](https://www.baeldung.com/netflix-archaius-database-configurations) -# Spring Cloud Archaius - #### Basic Config This service has the basic, out-of-the-box Spring Cloud Netflix Archaius configuration. diff --git a/spring-cloud/spring-cloud-bootstrap/README.MD b/spring-cloud/spring-cloud-bootstrap/README.md similarity index 87% rename from spring-cloud/spring-cloud-bootstrap/README.MD rename to spring-cloud/spring-cloud-bootstrap/README.md index 7a3a94c8e3..01998ccf51 100644 --- a/spring-cloud/spring-cloud-bootstrap/README.MD +++ b/spring-cloud/spring-cloud-bootstrap/README.md @@ -1,3 +1,7 @@ +## Spring Cloud Bootstrap + +This module contains articles about bootstrapping Spring Cloud applications + ### Relevant Articles: - [Spring Cloud – Bootstrapping](http://www.baeldung.com/spring-cloud-bootstrapping) - [Spring Cloud – Securing Services](http://www.baeldung.com/spring-cloud-securing-services) @@ -5,6 +9,8 @@ - [Spring Cloud Series – The Gateway Pattern](http://www.baeldung.com/spring-cloud-gateway-pattern) - [Spring Cloud – Adding Angular 4](http://www.baeldung.com/spring-cloud-angular) +### Running the Project + - To run the project: - copy the appliction-config folder to c:\Users\{username}\ on Windows or /home/{username}/ on *nix. Then open a git bash terminal in application-config and run: - git init diff --git a/spring-cloud/spring-cloud-contract/README.md b/spring-cloud/spring-cloud-contract/README.md index 70e056757b..72a3627e30 100644 --- a/spring-cloud/spring-cloud-contract/README.md +++ b/spring-cloud/spring-cloud-contract/README.md @@ -1,2 +1,6 @@ +## Spring Cloud Contract + +This module contains articles about Spring Cloud Contract + ### Relevant Articles: - [An Intro to Spring Cloud Contract](http://www.baeldung.com/spring-cloud-contract) diff --git a/spring-cloud/spring-cloud-gateway/README.MD b/spring-cloud/spring-cloud-gateway/README.md similarity index 57% rename from spring-cloud/spring-cloud-gateway/README.MD rename to spring-cloud/spring-cloud-gateway/README.md index d945ae949c..e87bc547e1 100644 --- a/spring-cloud/spring-cloud-gateway/README.MD +++ b/spring-cloud/spring-cloud-gateway/README.md @@ -1,2 +1,6 @@ +## Spring Cloud Gateway + +This module contains articles about Spring Cloud Gateway + ### Relevant Articles: - [Exploring the new Spring Cloud Gateway](http://www.baeldung.com/spring-cloud-gateway) diff --git a/spring-cloud/spring-cloud-kubernetes/README.md b/spring-cloud/spring-cloud-kubernetes/README.md index 32bcbc59b8..b64ad65ef9 100644 --- a/spring-cloud/spring-cloud-kubernetes/README.md +++ b/spring-cloud/spring-cloud-kubernetes/README.md @@ -1,3 +1,7 @@ +## Spring Cloud Kubernetes + +This moudle contains articles about Spring Cloud Kubernetes + ### Relevant Articles: - [Running Spring Boot Applications With Minikube](https://www.baeldung.com/spring-boot-minikube) diff --git a/spring-cloud/spring-cloud-rest/README.md b/spring-cloud/spring-cloud-rest/README.md index a650004708..25d62007b6 100644 --- a/spring-cloud/spring-cloud-rest/README.md +++ b/spring-cloud/spring-cloud-rest/README.md @@ -1,2 +1,5 @@ +## Spring Cloud REST + +This module contains articles about RESTful APIs with Spring Cloud Code for an ebook - "A REST API with Spring Boot and Spring Cloud" diff --git a/spring-cloud/spring-cloud-ribbon-client/README.md b/spring-cloud/spring-cloud-ribbon-client/README.md index 596b3226c8..d22b8ec8f8 100644 --- a/spring-cloud/spring-cloud-ribbon-client/README.md +++ b/spring-cloud/spring-cloud-ribbon-client/README.md @@ -1,2 +1,6 @@ +## Spring Cloud Ribbon Client + +This module contains articles about Spring Cloud with Netflix Ribbon + ### Relevant Articles: - [Introduction to Spring Cloud Rest Client with Netflix Ribbon](http://www.baeldung.com/spring-cloud-rest-client-with-netflix-ribbon) From 6cb034c1d80ce0f53d4ff31a5041f5aea5e567d0 Mon Sep 17 00:00:00 2001 From: Catalin Burcea Date: Thu, 3 Oct 2019 07:02:53 +0300 Subject: [PATCH 29/55] Move articles out of core-java-lang part 1 (#7908) --- .../core-java-exceptions/README.md | 19 ++- .../core-java-exceptions/pom.xml | 91 +++++------ .../com/baeldung/exceptions/Arithmetic.java | 20 --- .../exceptions/ArrayIndexOutOfBounds.java | 24 --- .../CheckedUncheckedExceptions.java | 43 ----- .../com/baeldung/exceptions/ClassCast.java | 36 ---- .../com/baeldung/exceptions/FileNotFound.java | 25 --- .../exceptions/GlobalExceptionHandler.java | 28 ---- .../baeldung/exceptions/IllegalArgument.java | 18 -- .../com/baeldung/exceptions/IllegalState.java | 32 ---- .../IncorrectFileNameException.java | 13 -- .../InterruptedExceptionExample.java | 28 ---- .../com/baeldung/exceptions/MalformedURL.java | 25 --- .../exceptions/NullOrEmptyException.java | 14 -- .../com/baeldung/exceptions/NullPointer.java | 36 ---- .../com/baeldung/exceptions/NumberFormat.java | 23 --- .../exceptions/ParseExceptionExample.java | 25 --- .../baeldung/exceptions/RootCauseFinder.java | 98 ----------- .../exceptions/StackTraceToString.java | 30 ---- .../exceptions/StringIndexOutOfBounds.java | 23 --- .../chainedexception/LogWithChain.java | 10 +- .../chainedexception/LogWithoutChain.java | 10 +- .../GirlFriendOfManagerUpsetException.java | 2 +- .../exceptions/ManagerUpsetException.java | 2 +- .../exceptions/NoLeaveGrantedException.java | 2 +- .../exceptions/TeamLeadUpsetException.java | 2 +- .../customexception/FileManager.java | 2 +- .../IncorrectFileExtensionException.java | 2 +- .../IncorrectFileNameException.java | 2 +- .../exceptionhandling/Exceptions.java | 2 +- .../exceptionhandling/MyException.java | 5 + .../exceptions}/exceptionhandling/Player.java | 2 +- .../PlayerLoadException.java | 2 +- .../PlayerScoreException.java | 2 +- .../exceptionhandling/TimeoutException.java | 2 +- .../keywords/finalize/FinalizeObject.java | 2 +- .../keywords/finalkeyword/Child.java | 2 +- .../keywords/finalkeyword/GrandChild.java | 2 +- .../keywords/finalkeyword/Parent.java | 2 +- .../finallykeyword/FinallyExample.java | 2 +- .../ClassWithInitErrors.java | 2 +- .../NoClassDefFoundErrorExample.java | 2 +- .../sneakythrows/SneakyRunnable.java | 2 +- .../sneakythrows/SneakyThrows.java | 2 +- .../stackoverflowerror/AccountHolder.java | 2 +- .../stackoverflowerror/ClassOne.java | 2 +- .../stackoverflowerror/ClassTwo.java | 2 +- ...niteRecursionWithTerminationCondition.java | 2 +- ...ursionWithCorrectTerminationCondition.java | 2 +- .../UnintendedInfiniteRecursion.java | 2 +- .../throwvsthrows}/DataAccessException.java | 2 +- .../exceptions/throwvsthrows}/Main.java | 2 +- .../throwvsthrows}/PersonRepository.java | 2 +- .../throwvsthrows}/SimpleService.java | 2 +- .../exceptions/throwvsthrows}/TryCatch.java | 2 +- .../baeldung/optional/PersonRepository.java | 9 - .../error/ErrorGeneratorUnitTest.java | 25 --- .../NumberFormatExceptionUnitTest.java | 154 ------------------ .../CheckedUncheckedExceptionsUnitTest.java | 55 ------- .../GlobalExceptionHandlerUnitTest.java | 64 -------- .../exceptions/RootCauseFinderUnitTest.java | 114 ------------- .../ClassNotFoundExceptionUnitTest.java | 2 +- ...correctFileExtensionExceptionUnitTest.java | 2 +- .../IncorrectFileNameExceptionUnitTest.java | 2 +- .../exceptionhandling/ExceptionsUnitTest.java | 2 +- .../NoClassDefFoundErrorUnitTest.java | 2 +- .../sneakythrows/SneakyRunnableUnitTest.java | 2 +- .../sneakythrows/SneakyThrowsUnitTest.java | 2 +- .../AccountHolderManualTest.java | 2 +- .../CyclicDependancyManualTest.java | 2 +- ...ionWithTerminationConditionManualTest.java | 2 +- ...CorrectTerminationConditionManualTest.java | 2 +- ...UnintendedInfiniteRecursionManualTest.java | 2 +- .../throwvsthrows}/SimpleServiceUnitTest.java | 2 +- ...vaTryWithResourcesLongRunningUnitTest.java | 92 ----------- .../optional/PersonRepositoryUnitTest.java | 43 ----- .../correctFileNameWithoutProperExtension | 0 core-java-modules/core-java-lang/README.md | 34 ++-- core-java-modules/core-java-lang/pom.xml | 14 -- .../exceptionhandling/MyException.java | 5 - core-java-modules/pom.xml | 1 - pom.xml | 2 + 82 files changed, 128 insertions(+), 1250 deletions(-) delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/Arithmetic.java delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ArrayIndexOutOfBounds.java delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/CheckedUncheckedExceptions.java delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ClassCast.java delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/FileNotFound.java delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/GlobalExceptionHandler.java delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IllegalArgument.java delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IllegalState.java delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IncorrectFileNameException.java delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/InterruptedExceptionExample.java delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/MalformedURL.java delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NullOrEmptyException.java delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NullPointer.java delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NumberFormat.java delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ParseExceptionExample.java delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/RootCauseFinder.java delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/StackTraceToString.java delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/StringIndexOutOfBounds.java rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/chainedexception/LogWithChain.java (73%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/chainedexception/LogWithoutChain.java (75%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/chainedexception/exceptions/GirlFriendOfManagerUpsetException.java (82%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/chainedexception/exceptions/ManagerUpsetException.java (80%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/chainedexception/exceptions/NoLeaveGrantedException.java (80%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/chainedexception/exceptions/TeamLeadUpsetException.java (80%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/customexception/FileManager.java (96%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/customexception/IncorrectFileExtensionException.java (83%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/customexception/IncorrectFileNameException.java (82%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/exceptionhandling/Exceptions.java (99%) create mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/MyException.java rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/exceptionhandling/Player.java (72%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/exceptionhandling/PlayerLoadException.java (75%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/exceptionhandling/PlayerScoreException.java (71%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/exceptionhandling/TimeoutException.java (71%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/keywords/finalize/FinalizeObject.java (88%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/keywords/finalkeyword/Child.java (78%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/keywords/finalkeyword/GrandChild.java (56%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/keywords/finalkeyword/Parent.java (87%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/keywords/finallykeyword/FinallyExample.java (92%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/noclassdeffounderror/ClassWithInitErrors.java (55%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/noclassdeffounderror/NoClassDefFoundErrorExample.java (86%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/sneakythrows/SneakyRunnable.java (90%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/sneakythrows/SneakyThrows.java (90%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/stackoverflowerror/AccountHolder.java (74%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/stackoverflowerror/ClassOne.java (86%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/stackoverflowerror/ClassTwo.java (86%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java (78%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/stackoverflowerror/RecursionWithCorrectTerminationCondition.java (78%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung => core-java-exceptions/src/main/java/com/baeldung/exceptions}/stackoverflowerror/UnintendedInfiniteRecursion.java (75%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung/throwsexception => core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows}/DataAccessException.java (78%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung/throwsexception => core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows}/Main.java (95%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung/throwsexception => core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows}/PersonRepository.java (79%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung/throwsexception => core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows}/SimpleService.java (90%) rename core-java-modules/{core-java-lang/src/main/java/com/baeldung/throwsexception => core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows}/TryCatch.java (85%) delete mode 100644 core-java-modules/core-java-exceptions/src/main/java/com/baeldung/optional/PersonRepository.java delete mode 100644 core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exception/error/ErrorGeneratorUnitTest.java delete mode 100644 core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exception/numberformat/NumberFormatExceptionUnitTest.java delete mode 100644 core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/CheckedUncheckedExceptionsUnitTest.java delete mode 100644 core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/GlobalExceptionHandlerUnitTest.java delete mode 100644 core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/RootCauseFinderUnitTest.java rename core-java-modules/{core-java-lang/src/test/java/com/baeldung => core-java-exceptions/src/test/java/com/baeldung/exceptions}/classnotfoundexception/ClassNotFoundExceptionUnitTest.java (84%) rename core-java-modules/{core-java-lang/src/test/java/com/baeldung => core-java-exceptions/src/test/java/com/baeldung/exceptions}/customexception/IncorrectFileExtensionExceptionUnitTest.java (95%) rename core-java-modules/{core-java-lang/src/test/java/com/baeldung => core-java-exceptions/src/test/java/com/baeldung/exceptions}/customexception/IncorrectFileNameExceptionUnitTest.java (92%) rename core-java-modules/{core-java-lang/src/test/java/com/baeldung => core-java-exceptions/src/test/java/com/baeldung/exceptions}/exceptionhandling/ExceptionsUnitTest.java (97%) rename core-java-modules/{core-java-lang/src/test/java/com/baeldung => core-java-exceptions/src/test/java/com/baeldung/exceptions}/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java (85%) rename core-java-modules/{core-java-lang/src/test/java/com/baeldung => core-java-exceptions/src/test/java/com/baeldung/exceptions}/sneakythrows/SneakyRunnableUnitTest.java (89%) rename core-java-modules/{core-java-lang/src/test/java/com/baeldung => core-java-exceptions/src/test/java/com/baeldung/exceptions}/sneakythrows/SneakyThrowsUnitTest.java (89%) rename core-java-modules/{core-java-lang/src/test/java/com/baeldung => core-java-exceptions/src/test/java/com/baeldung/exceptions}/stackoverflowerror/AccountHolderManualTest.java (82%) rename core-java-modules/{core-java-lang/src/test/java/com/baeldung => core-java-exceptions/src/test/java/com/baeldung/exceptions}/stackoverflowerror/CyclicDependancyManualTest.java (81%) rename core-java-modules/{core-java-lang/src/test/java/com/baeldung => core-java-exceptions/src/test/java/com/baeldung/exceptions}/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java (95%) rename core-java-modules/{core-java-lang/src/test/java/com/baeldung => core-java-exceptions/src/test/java/com/baeldung/exceptions}/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java (89%) rename core-java-modules/{core-java-lang/src/test/java/com/baeldung => core-java-exceptions/src/test/java/com/baeldung/exceptions}/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java (94%) rename core-java-modules/{core-java-lang/src/test/java/com/baeldung/throwsexception => core-java-exceptions/src/test/java/com/baeldung/exceptions/throwvsthrows}/SimpleServiceUnitTest.java (92%) delete mode 100644 core-java-modules/core-java-exceptions/src/test/java/com/baeldung/java8/JavaTryWithResourcesLongRunningUnitTest.java delete mode 100644 core-java-modules/core-java-exceptions/src/test/java/com/baeldung/optional/PersonRepositoryUnitTest.java rename core-java-modules/{core-java-lang => core-java-exceptions}/src/test/resources/correctFileNameWithoutProperExtension (100%) delete mode 100644 core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/MyException.java diff --git a/core-java-modules/core-java-exceptions/README.md b/core-java-modules/core-java-exceptions/README.md index 78599c6b7b..0120b970c3 100644 --- a/core-java-modules/core-java-exceptions/README.md +++ b/core-java-modules/core-java-exceptions/README.md @@ -1,8 +1,13 @@ -## Relevant Articles: +## Core Java Exceptions -- [Will an Error Be Caught by Catch Block in Java?](https://www.baeldung.com/java-error-catch) -- [Java Global Exception Handler](http://www.baeldung.com/java-global-exception-handler) -- [Common Java Exceptions](http://www.baeldung.com/java-common-exceptions) -- [Throw Exception in Optional in Java 8](https://www.baeldung.com/java-optional-throw-exception) -- [How to Find an Exception’s Root Cause in Java](https://www.baeldung.com/java-exception-root-cause) -- [Java – Try with Resources](https://www.baeldung.com/java-try-with-resources) +This module contains articles about core java exceptions + +### Relevant articles: +- [Chained Exceptions in Java](https://www.baeldung.com/java-chained-exceptions) +- [ClassNotFoundException vs NoClassDefFoundError](https://www.baeldung.com/java-classnotfoundexception-and-noclassdeffounderror) +- [Create a Custom Exception in Java](https://www.baeldung.com/java-new-custom-exception) +- [Exception Handling in Java](https://www.baeldung.com/java-exceptions) +- [Differences Between Final, Finally and Finalize in Java](https://www.baeldung.com/java-final-finally-finalize) +- [Difference Between Throw and Throws in Java](https://www.baeldung.com/java-throw-throws) +- [“Sneaky Throws” in Java](https://www.baeldung.com/java-sneaky-throws) +- [The StackOverflowError in Java](https://www.baeldung.com/java-stack-overflow-error) diff --git a/core-java-modules/core-java-exceptions/pom.xml b/core-java-modules/core-java-exceptions/pom.xml index 43c4e31033..da5ec76622 100644 --- a/core-java-modules/core-java-exceptions/pom.xml +++ b/core-java-modules/core-java-exceptions/pom.xml @@ -1,55 +1,46 @@ + - 4.0.0 - com.baeldung.exception.numberformat - core-java-exceptions - 0.0.1-SNAPSHOT - core-java-exceptions + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + com.baeldung.exceptions + 4.0.0 + core-java-exceptions + 0.1.0-SNAPSHOT + core-java-exceptions + jar - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../../parent-java - + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../../parent-java + - - - junit - junit - ${junit.version} - test - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - org.openjdk.jmh - jmh-core - ${jmh-core.version} - - - org.openjdk.jmh - jmh-generator-annprocess - ${jmh-generator-annprocess.version} - - - - org.assertj - assertj-core - ${assertj-core.version} - test - - + + + javax.mail + mail + ${javax.mail.version} + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + - - 3.9 - 1.19 - 3.10.0 - 1.19 - + + 1.5.0-b01 + + 3.10.0 + - + \ No newline at end of file diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/Arithmetic.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/Arithmetic.java deleted file mode 100644 index 138916ec60..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/Arithmetic.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Arithmetic { - - private static Logger LOGGER = LoggerFactory.getLogger(Arithmetic.class); - - public static void main(String[] args) { - - try { - int result = 30 / 0; // Trying to divide by zero - } catch (ArithmeticException e) { - LOGGER.error("ArithmeticException caught!"); - } - - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ArrayIndexOutOfBounds.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ArrayIndexOutOfBounds.java deleted file mode 100644 index 93b53f284c..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ArrayIndexOutOfBounds.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ArrayIndexOutOfBounds { - - private static Logger LOGGER = LoggerFactory.getLogger(ArrayIndexOutOfBounds.class); - - public static void main(String[] args) { - - int[] nums = new int[] { 1, 2, 3 }; - - try { - int numFromNegativeIndex = nums[-1]; // Trying to access at negative index - int numFromGreaterIndex = nums[4]; // Trying to access at greater index - int numFromLengthIndex = nums[3]; // Trying to access at index equal to size of the array - } catch (ArrayIndexOutOfBoundsException e) { - LOGGER.error("ArrayIndexOutOfBoundsException caught"); - } - - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/CheckedUncheckedExceptions.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/CheckedUncheckedExceptions.java deleted file mode 100644 index 780189b654..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/CheckedUncheckedExceptions.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.baeldung.exceptions; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; - -public class CheckedUncheckedExceptions { - public static void checkedExceptionWithThrows() throws FileNotFoundException { - File file = new File("not_existing_file.txt"); - FileInputStream stream = new FileInputStream(file); - } - - public static void checkedExceptionWithTryCatch() { - File file = new File("not_existing_file.txt"); - try { - FileInputStream stream = new FileInputStream(file); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - } - - public static int divideByZero() { - int numerator = 1; - int denominator = 0; - return numerator / denominator; - } - - public static void checkFile(String fileName) throws IncorrectFileNameException { - if (fileName == null || fileName.isEmpty()) { - throw new NullOrEmptyException("The filename is null."); - } - if (!isCorrectFileName(fileName)) { - throw new IncorrectFileNameException("Incorrect filename : " + fileName); - } - } - - private static boolean isCorrectFileName(String fileName) { - if (fileName.equals("wrongFileName.txt")) - return false; - else - return true; - } -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ClassCast.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ClassCast.java deleted file mode 100644 index 183f8f54a3..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ClassCast.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -class Animal { - -} - -class Dog extends Animal { - -} - -class Lion extends Animal { - -} - -public class ClassCast { - - private static Logger LOGGER = LoggerFactory.getLogger(ClassCast.class); - - public static void main(String[] args) { - - try { - Animal animalOne = new Dog(); // At runtime the instance is dog - Dog bruno = (Dog) animalOne; // Downcasting - - Animal animalTwo = new Lion(); // At runtime the instance is animal - Dog tommy = (Dog) animalTwo; // Downcasting - } catch (ClassCastException e) { - LOGGER.error("ClassCastException caught!"); - } - - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/FileNotFound.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/FileNotFound.java deleted file mode 100644 index bb9e0bf4ac..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/FileNotFound.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.exceptions; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class FileNotFound { - - private static Logger LOGGER = LoggerFactory.getLogger(FileNotFound.class); - - public static void main(String[] args) { - - BufferedReader reader = null; - try { - reader = new BufferedReader(new FileReader(new File("/invalid/file/location"))); - } catch (FileNotFoundException e) { - LOGGER.error("FileNotFoundException caught!"); - } - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/GlobalExceptionHandler.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/GlobalExceptionHandler.java deleted file mode 100644 index ab46c83da4..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/GlobalExceptionHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class GlobalExceptionHandler { - - public static void main(String[] args) { - - Handler globalExceptionHandler = new Handler(); - Thread.setDefaultUncaughtExceptionHandler(globalExceptionHandler); - new GlobalExceptionHandler().performArithmeticOperation(10, 0); - } - - public int performArithmeticOperation(int num1, int num2) { - return num1/num2; - } - -} - -class Handler implements Thread.UncaughtExceptionHandler { - - private static Logger LOGGER = LoggerFactory.getLogger(Handler.class); - - public void uncaughtException(Thread t, Throwable e) { - LOGGER.info("Unhandled exception caught!"); - } -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IllegalArgument.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IllegalArgument.java deleted file mode 100644 index 801536cb2d..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IllegalArgument.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class IllegalArgument { - - private static Logger LOGGER = LoggerFactory.getLogger(IllegalArgument.class); - - public static void main(String[] args) { - try { - Thread.sleep(-1000); - } catch (InterruptedException e) { - LOGGER.error("IllegalArgumentException caught!"); - } - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IllegalState.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IllegalState.java deleted file mode 100644 index e8ddcea3c2..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IllegalState.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.exceptions; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class IllegalState { - - private static Logger LOGGER = LoggerFactory.getLogger(IllegalState.class); - - public static void main(String[] args) { - - List intList = new ArrayList<>(); - - for (int i = 0; i < 10; i++) { - intList.add(i); - } - - Iterator intListIterator = intList.iterator(); // Initialized with index at -1 - - try { - intListIterator.remove(); // IllegalStateException - } catch (IllegalStateException e) { - LOGGER.error("IllegalStateException caught!"); - } - - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IncorrectFileNameException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IncorrectFileNameException.java deleted file mode 100644 index 9877fe25ca..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IncorrectFileNameException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.baeldung.exceptions; - -public class IncorrectFileNameException extends Exception { - private static final long serialVersionUID = 1L; - - public IncorrectFileNameException(String errorMessage) { - super(errorMessage); - } - - public IncorrectFileNameException(String errorMessage, Throwable thr) { - super(errorMessage, thr); - } -} \ No newline at end of file diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/InterruptedExceptionExample.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/InterruptedExceptionExample.java deleted file mode 100644 index 319fd33591..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/InterruptedExceptionExample.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -class ChildThread extends Thread { - - private static Logger LOGGER = LoggerFactory.getLogger(ChildThread.class); - - public void run() { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - LOGGER.error("InterruptedException caught!"); - } - } - -} - -public class InterruptedExceptionExample { - - public static void main(String[] args) throws InterruptedException { - ChildThread childThread = new ChildThread(); - childThread.start(); - childThread.interrupt(); - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/MalformedURL.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/MalformedURL.java deleted file mode 100644 index 57fcddf76b..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/MalformedURL.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.exceptions; - -import java.net.MalformedURLException; -import java.net.URL; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class MalformedURL { - - private static Logger LOGGER = LoggerFactory.getLogger(MalformedURL.class); - - public static void main(String[] args) { - - URL baeldungURL = null; - - try { - baeldungURL = new URL("malformedurl"); - } catch (MalformedURLException e) { - LOGGER.error("MalformedURLException caught!"); - } - - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NullOrEmptyException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NullOrEmptyException.java deleted file mode 100644 index d4ee9c0d6f..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NullOrEmptyException.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.baeldung.exceptions; - -public class NullOrEmptyException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public NullOrEmptyException(String errorMessage) { - super(errorMessage); - } - - public NullOrEmptyException(String errorMessage, Throwable thr) { - super(errorMessage, thr); - } -} \ No newline at end of file diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NullPointer.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NullPointer.java deleted file mode 100644 index 2402a786a9..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NullPointer.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class NullPointer { - - private static Logger LOGGER = LoggerFactory.getLogger(NullPointer.class); - - public static void main(String[] args) { - - Person personObj = null; - - try { - String name = personObj.personName; // Accessing the field of a null object - personObj.personName = "Jon Doe"; // Modifying the field of a null object - } catch (NullPointerException e) { - LOGGER.error("NullPointerException caught!"); - } - - } -} - -class Person { - - public String personName; - - public String getPersonName() { - return personName; - } - - public void setPersonName(String personName) { - this.personName = personName; - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NumberFormat.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NumberFormat.java deleted file mode 100644 index 7050e70aee..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NumberFormat.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class NumberFormat { - - private static Logger LOGGER = LoggerFactory.getLogger(NumberFormat.class); - - public static void main(String[] args) { - - String str1 = "100ABCD"; - - try { - int x = Integer.parseInt(str1); // Converting string with inappropriate format - int y = Integer.valueOf(str1); - } catch (NumberFormatException e) { - LOGGER.error("NumberFormatException caught!"); - } - - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ParseExceptionExample.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ParseExceptionExample.java deleted file mode 100644 index f7fb4c91e4..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ParseExceptionExample.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.exceptions; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ParseExceptionExample { - - private static Logger LOGGER = LoggerFactory.getLogger(ParseExceptionExample.class); - - public static void main(String[] args) { - - DateFormat format = new SimpleDateFormat("MM, dd, yyyy"); - - try { - format.parse("01, , 2010"); - } catch (ParseException e) { - LOGGER.error("ParseException caught!"); - } - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/RootCauseFinder.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/RootCauseFinder.java deleted file mode 100644 index cf449110e6..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/RootCauseFinder.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.baeldung.exceptions; - -import java.time.LocalDate; -import java.time.Period; -import java.time.format.DateTimeParseException; -import java.util.Objects; - -/** - * Utility class to find root cause exceptions. - */ -public class RootCauseFinder { - - private RootCauseFinder() { - } - - public static Throwable findCauseUsingPlainJava(Throwable throwable) { - Objects.requireNonNull(throwable); - Throwable rootCause = throwable; - while (rootCause.getCause() != null && rootCause.getCause() != rootCause) { - rootCause = rootCause.getCause(); - } - return rootCause; - } - - /** - * Calculates the age of a person from a given date. - */ - static class AgeCalculator { - - private AgeCalculator() { - } - - public static int calculateAge(String birthDate) { - if (birthDate == null || birthDate.isEmpty()) { - throw new IllegalArgumentException(); - } - - try { - return Period - .between(parseDate(birthDate), LocalDate.now()) - .getYears(); - } catch (DateParseException ex) { - throw new CalculationException(ex); - } - } - - private static LocalDate parseDate(String birthDateAsString) { - - LocalDate birthDate; - try { - birthDate = LocalDate.parse(birthDateAsString); - } catch (DateTimeParseException ex) { - throw new InvalidFormatException(birthDateAsString, ex); - } - - if (birthDate.isAfter(LocalDate.now())) { - throw new DateOutOfRangeException(birthDateAsString); - } - - return birthDate; - } - - } - - static class CalculationException extends RuntimeException { - - CalculationException(DateParseException ex) { - super(ex); - } - } - - static class DateParseException extends RuntimeException { - - DateParseException(String input) { - super(input); - } - - DateParseException(String input, Throwable thr) { - super(input, thr); - } - } - - static class InvalidFormatException extends DateParseException { - - InvalidFormatException(String input, Throwable thr) { - super("Invalid date format: " + input, thr); - } - } - - static class DateOutOfRangeException extends DateParseException { - - DateOutOfRangeException(String date) { - super("Date out of range: " + date); - } - - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/StackTraceToString.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/StackTraceToString.java deleted file mode 100644 index c6bf915996..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/StackTraceToString.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.baeldung.exceptions; - -import org.apache.commons.lang3.exception.ExceptionUtils; - -import java.io.PrintWriter; -import java.io.StringWriter; - -public class StackTraceToString { - - public static void main(String[] args) { - // Convert a StackTrace to String using core java - try { - throw new NullPointerException(); - } catch (Exception e) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - e.printStackTrace(pw); - - System.out.println(sw.toString()); - } - - // Convert a StackTrace to String using Apache Commons - try { - throw new IndexOutOfBoundsException(); - } catch (Exception e) { - System.out.println(ExceptionUtils.getStackTrace(e)); - } - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/StringIndexOutOfBounds.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/StringIndexOutOfBounds.java deleted file mode 100644 index bc297be498..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/StringIndexOutOfBounds.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class StringIndexOutOfBounds { - - private static Logger LOGGER = LoggerFactory.getLogger(StringIndexOutOfBounds.class); - - public static void main(String[] args) { - - String str = "Hello World"; - - try { - char charAtNegativeIndex = str.charAt(-1); // Trying to access at negative index - char charAtLengthIndex = str.charAt(11); // Trying to access at index equal to size of the string - } catch (StringIndexOutOfBoundsException e) { - LOGGER.error("StringIndexOutOfBoundsException caught"); - } - - } - -} diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithChain.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/LogWithChain.java similarity index 73% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithChain.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/LogWithChain.java index 3d66c2b535..a2eae50108 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithChain.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/LogWithChain.java @@ -1,9 +1,9 @@ -package com.baeldung.chainedexception; +package com.baeldung.exceptions.chainedexception; -import com.baeldung.chainedexception.exceptions.GirlFriendOfManagerUpsetException; -import com.baeldung.chainedexception.exceptions.ManagerUpsetException; -import com.baeldung.chainedexception.exceptions.NoLeaveGrantedException; -import com.baeldung.chainedexception.exceptions.TeamLeadUpsetException; +import com.baeldung.exceptions.chainedexception.exceptions.GirlFriendOfManagerUpsetException; +import com.baeldung.exceptions.chainedexception.exceptions.ManagerUpsetException; +import com.baeldung.exceptions.chainedexception.exceptions.NoLeaveGrantedException; +import com.baeldung.exceptions.chainedexception.exceptions.TeamLeadUpsetException; public class LogWithChain { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithoutChain.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/LogWithoutChain.java similarity index 75% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithoutChain.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/LogWithoutChain.java index 7556e30663..8c37db0307 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithoutChain.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/LogWithoutChain.java @@ -1,9 +1,9 @@ -package com.baeldung.chainedexception; +package com.baeldung.exceptions.chainedexception; -import com.baeldung.chainedexception.exceptions.GirlFriendOfManagerUpsetException; -import com.baeldung.chainedexception.exceptions.ManagerUpsetException; -import com.baeldung.chainedexception.exceptions.NoLeaveGrantedException; -import com.baeldung.chainedexception.exceptions.TeamLeadUpsetException; +import com.baeldung.exceptions.chainedexception.exceptions.GirlFriendOfManagerUpsetException; +import com.baeldung.exceptions.chainedexception.exceptions.ManagerUpsetException; +import com.baeldung.exceptions.chainedexception.exceptions.NoLeaveGrantedException; +import com.baeldung.exceptions.chainedexception.exceptions.TeamLeadUpsetException; public class LogWithoutChain { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/GirlFriendOfManagerUpsetException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/GirlFriendOfManagerUpsetException.java similarity index 82% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/GirlFriendOfManagerUpsetException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/GirlFriendOfManagerUpsetException.java index e20c58ea5b..91537b58d4 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/GirlFriendOfManagerUpsetException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/GirlFriendOfManagerUpsetException.java @@ -1,4 +1,4 @@ -package com.baeldung.chainedexception.exceptions; +package com.baeldung.exceptions.chainedexception.exceptions; public class GirlFriendOfManagerUpsetException extends Exception { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/ManagerUpsetException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/ManagerUpsetException.java similarity index 80% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/ManagerUpsetException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/ManagerUpsetException.java index e95a3921a4..351521a522 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/ManagerUpsetException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/ManagerUpsetException.java @@ -1,4 +1,4 @@ -package com.baeldung.chainedexception.exceptions; +package com.baeldung.exceptions.chainedexception.exceptions; public class ManagerUpsetException extends Exception { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/NoLeaveGrantedException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/NoLeaveGrantedException.java similarity index 80% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/NoLeaveGrantedException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/NoLeaveGrantedException.java index b9521858b3..dd84baae74 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/NoLeaveGrantedException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/NoLeaveGrantedException.java @@ -1,4 +1,4 @@ -package com.baeldung.chainedexception.exceptions; +package com.baeldung.exceptions.chainedexception.exceptions; public class NoLeaveGrantedException extends Exception { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/TeamLeadUpsetException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/TeamLeadUpsetException.java similarity index 80% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/TeamLeadUpsetException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/TeamLeadUpsetException.java index f874620f00..4ea8c3db7a 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/TeamLeadUpsetException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/TeamLeadUpsetException.java @@ -1,4 +1,4 @@ -package com.baeldung.chainedexception.exceptions; +package com.baeldung.exceptions.chainedexception.exceptions; public class TeamLeadUpsetException extends Exception { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/FileManager.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/FileManager.java similarity index 96% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/FileManager.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/FileManager.java index b6f4d960aa..adc1b1613c 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/FileManager.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/FileManager.java @@ -1,4 +1,4 @@ -package com.baeldung.customexception; +package com.baeldung.exceptions.customexception; import java.io.File; import java.io.FileNotFoundException; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileExtensionException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/IncorrectFileExtensionException.java similarity index 83% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileExtensionException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/IncorrectFileExtensionException.java index c6dc6d6964..4e8fece145 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileExtensionException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/IncorrectFileExtensionException.java @@ -1,4 +1,4 @@ -package com.baeldung.customexception; +package com.baeldung.exceptions.customexception; public class IncorrectFileExtensionException extends RuntimeException{ private static final long serialVersionUID = 1L; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileNameException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/IncorrectFileNameException.java similarity index 82% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileNameException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/IncorrectFileNameException.java index a804cadb84..f7f6a9dd8c 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileNameException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/IncorrectFileNameException.java @@ -1,4 +1,4 @@ -package com.baeldung.customexception; +package com.baeldung.exceptions.customexception; public class IncorrectFileNameException extends Exception { private static final long serialVersionUID = 1L; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Exceptions.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/Exceptions.java similarity index 99% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Exceptions.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/Exceptions.java index 32d88cfd12..14483b3489 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Exceptions.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/Exceptions.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptionhandling; +package com.baeldung.exceptions.exceptionhandling; import java.io.File; import java.io.FileNotFoundException; diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/MyException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/MyException.java new file mode 100644 index 0000000000..bc2c6baffb --- /dev/null +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/MyException.java @@ -0,0 +1,5 @@ +package com.baeldung.exceptions.exceptionhandling; + +public class MyException extends Throwable { + +} diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Player.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/Player.java similarity index 72% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Player.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/Player.java index e866802fe3..1251cd58e6 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Player.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/Player.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptionhandling; +package com.baeldung.exceptions.exceptionhandling; public class Player { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerLoadException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/PlayerLoadException.java similarity index 75% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerLoadException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/PlayerLoadException.java index d92edeebbd..432232c23e 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerLoadException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/PlayerLoadException.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptionhandling; +package com.baeldung.exceptions.exceptionhandling; import java.io.IOException; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerScoreException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/PlayerScoreException.java similarity index 71% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerScoreException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/PlayerScoreException.java index 299370ee86..ba2a6d74e4 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerScoreException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/PlayerScoreException.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptionhandling; +package com.baeldung.exceptions.exceptionhandling; public class PlayerScoreException extends Exception { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/TimeoutException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/TimeoutException.java similarity index 71% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/TimeoutException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/TimeoutException.java index 0211284e5d..0f926ccf58 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/TimeoutException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/TimeoutException.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptionhandling; +package com.baeldung.exceptions.exceptionhandling; public class TimeoutException extends Exception { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalize/FinalizeObject.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalize/FinalizeObject.java similarity index 88% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalize/FinalizeObject.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalize/FinalizeObject.java index af0449c0da..9e5e7461ea 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalize/FinalizeObject.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalize/FinalizeObject.java @@ -1,4 +1,4 @@ -package com.baeldung.keywords.finalize; +package com.baeldung.exceptions.keywords.finalize; public class FinalizeObject { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Child.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/Child.java similarity index 78% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Child.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/Child.java index 8615c78652..b006850199 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Child.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/Child.java @@ -1,4 +1,4 @@ -package com.baeldung.keywords.finalkeyword; +package com.baeldung.exceptions.keywords.finalkeyword; public final class Child extends Parent { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/GrandChild.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/GrandChild.java similarity index 56% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/GrandChild.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/GrandChild.java index 1530c5037f..f8adf27914 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/GrandChild.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/GrandChild.java @@ -1,4 +1,4 @@ -package com.baeldung.keywords.finalkeyword; +package com.baeldung.exceptions.keywords.finalkeyword; /*public class GrandChild extends Child { // Compilation error diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Parent.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/Parent.java similarity index 87% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Parent.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/Parent.java index 5cd2996e7a..2a5d19a32f 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Parent.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/Parent.java @@ -1,4 +1,4 @@ -package com.baeldung.keywords.finalkeyword; +package com.baeldung.exceptions.keywords.finalkeyword; public class Parent { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finallykeyword/FinallyExample.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finallykeyword/FinallyExample.java similarity index 92% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finallykeyword/FinallyExample.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finallykeyword/FinallyExample.java index 3c0aee3196..8f9d9a29d2 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finallykeyword/FinallyExample.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finallykeyword/FinallyExample.java @@ -1,4 +1,4 @@ -package com.baeldung.keywords.finallykeyword; +package com.baeldung.exceptions.keywords.finallykeyword; public class FinallyExample { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/ClassWithInitErrors.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/noclassdeffounderror/ClassWithInitErrors.java similarity index 55% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/ClassWithInitErrors.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/noclassdeffounderror/ClassWithInitErrors.java index b5b357a322..a82f430959 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/ClassWithInitErrors.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/noclassdeffounderror/ClassWithInitErrors.java @@ -1,4 +1,4 @@ -package com.baeldung.noclassdeffounderror; +package com.baeldung.exceptions.noclassdeffounderror; public class ClassWithInitErrors { static int data = 1 / 0; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorExample.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/noclassdeffounderror/NoClassDefFoundErrorExample.java similarity index 86% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorExample.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/noclassdeffounderror/NoClassDefFoundErrorExample.java index 7bcefbdbd3..0dc74a9d01 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorExample.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/noclassdeffounderror/NoClassDefFoundErrorExample.java @@ -1,4 +1,4 @@ -package com.baeldung.noclassdeffounderror; +package com.baeldung.exceptions.noclassdeffounderror; public class NoClassDefFoundErrorExample { public ClassWithInitErrors getClassWithInitErrors() { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyRunnable.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/sneakythrows/SneakyRunnable.java similarity index 90% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyRunnable.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/sneakythrows/SneakyRunnable.java index 88a8696053..06b587d0e0 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyRunnable.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/sneakythrows/SneakyRunnable.java @@ -1,4 +1,4 @@ -package com.baeldung.sneakythrows; +package com.baeldung.exceptions.sneakythrows; import lombok.SneakyThrows; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyThrows.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/sneakythrows/SneakyThrows.java similarity index 90% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyThrows.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/sneakythrows/SneakyThrows.java index 847aaa7249..e86ef53733 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyThrows.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/sneakythrows/SneakyThrows.java @@ -1,4 +1,4 @@ -package com.baeldung.sneakythrows; +package com.baeldung.exceptions.sneakythrows; import java.io.IOException; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/AccountHolder.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/AccountHolder.java similarity index 74% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/AccountHolder.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/AccountHolder.java index 91b8a3bbb0..5beac1cd04 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/AccountHolder.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/AccountHolder.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; public class AccountHolder { private String firstName; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassOne.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/ClassOne.java similarity index 86% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassOne.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/ClassOne.java index 3b95fd1368..e290a1fe38 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassOne.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/ClassOne.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; public class ClassOne { private int oneValue; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassTwo.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/ClassTwo.java similarity index 86% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassTwo.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/ClassTwo.java index 0adf075b43..fc6a89e1fb 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassTwo.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/ClassTwo.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; public class ClassTwo { private int twoValue; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java similarity index 78% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java index c67eeb30d1..858871cb9d 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; public class InfiniteRecursionWithTerminationCondition { public int calculateFactorial(final int number) { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationCondition.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/RecursionWithCorrectTerminationCondition.java similarity index 78% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationCondition.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/RecursionWithCorrectTerminationCondition.java index 8d10c65dcc..69b1c0b5ab 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationCondition.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/RecursionWithCorrectTerminationCondition.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; public class RecursionWithCorrectTerminationCondition { public int calculateFactorial(final int number) { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursion.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/UnintendedInfiniteRecursion.java similarity index 75% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursion.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/UnintendedInfiniteRecursion.java index 0b7fb3cf94..c07fdcb01b 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursion.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/UnintendedInfiniteRecursion.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; public class UnintendedInfiniteRecursion { public int calculateFactorial(int number) { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/DataAccessException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/DataAccessException.java similarity index 78% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/DataAccessException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/DataAccessException.java index 0b371dcedb..448c8e2213 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/DataAccessException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/DataAccessException.java @@ -1,4 +1,4 @@ -package com.baeldung.throwsexception; +package com.baeldung.exceptions.throwvsthrows; public class DataAccessException extends RuntimeException { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/Main.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/Main.java similarity index 95% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/Main.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/Main.java index 17fbf5a582..dfe8fcbd5a 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/Main.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/Main.java @@ -1,4 +1,4 @@ -package com.baeldung.throwsexception; +package com.baeldung.exceptions.throwvsthrows; import com.sun.mail.iap.ConnectionException; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/PersonRepository.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/PersonRepository.java similarity index 79% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/PersonRepository.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/PersonRepository.java index 7d8345c3c1..73453f4fc0 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/PersonRepository.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/PersonRepository.java @@ -1,4 +1,4 @@ -package com.baeldung.throwsexception; +package com.baeldung.exceptions.throwvsthrows; import java.sql.SQLException; import java.util.List; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/SimpleService.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/SimpleService.java similarity index 90% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/SimpleService.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/SimpleService.java index 6bb8b90bf1..605d900633 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/SimpleService.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/SimpleService.java @@ -1,4 +1,4 @@ -package com.baeldung.throwsexception; +package com.baeldung.exceptions.throwvsthrows; import java.sql.SQLException; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/TryCatch.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/TryCatch.java similarity index 85% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/TryCatch.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/TryCatch.java index 2fd87f124d..f8a603f013 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/TryCatch.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/TryCatch.java @@ -1,4 +1,4 @@ -package com.baeldung.throwsexception; +package com.baeldung.exceptions.throwvsthrows; import com.sun.mail.iap.ConnectionException; diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/optional/PersonRepository.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/optional/PersonRepository.java deleted file mode 100644 index 46018faf80..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/optional/PersonRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.optional; - -public class PersonRepository { - - public String findNameById(String id) { - return id == null ? null : "Name"; - } - -} diff --git a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exception/error/ErrorGeneratorUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exception/error/ErrorGeneratorUnitTest.java deleted file mode 100644 index 6dcd0d72e0..0000000000 --- a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exception/error/ErrorGeneratorUnitTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.exception.error; - -import org.junit.Assert; -import org.junit.Test; - -public class ErrorGeneratorUnitTest { - - @Test(expected = AssertionError.class) - public void whenError_thenIsNotCaughtByCatchException() { - try { - throw new AssertionError(); - } catch (Exception e) { - Assert.fail(); // errors are not caught by catch exception - } - } - - @Test - public void whenError_thenIsCaughtByCatchError() { - try { - throw new AssertionError(); - } catch (Error e) { - // caught! -> test pass - } - } -} \ No newline at end of file diff --git a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exception/numberformat/NumberFormatExceptionUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exception/numberformat/NumberFormatExceptionUnitTest.java deleted file mode 100644 index cb26bf451a..0000000000 --- a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exception/numberformat/NumberFormatExceptionUnitTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.baeldung.exception.numberformat; - -import static org.junit.Assert.assertEquals; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.text.NumberFormat; -import java.text.ParseException; -import java.util.Locale; -import java.util.logging.Logger; - -import org.junit.Test; - -/** - * A set of examples tested to show cases where NumberFormatException is thrown and not thrown. - */ -public class NumberFormatExceptionUnitTest { - - Logger LOG = Logger.getLogger(NumberFormatExceptionUnitTest.class.getName()); - - /* ---INTEGER FAIL CASES--- */ - @Test(expected = NumberFormatException.class) - public void givenByteConstructor_whenAlphabetAsInput_thenFail() { - Byte byteInt = new Byte("one"); - } - - @Test(expected = NumberFormatException.class) - public void givenShortConstructor_whenSpaceInInput_thenFail() { - Short shortInt = new Short("2 "); - } - - @Test(expected = NumberFormatException.class) - public void givenParseIntMethod_whenSpaceInInput_thenFail() { - Integer aIntPrim = Integer.parseInt("6000 "); - } - - @Test(expected = NumberFormatException.class) - public void givenParseIntMethod_whenUnderscoreInInput_thenFail() { - int bIntPrim = Integer.parseInt("_6000"); - } - - @Test(expected = NumberFormatException.class) - public void givenIntegerValueOfMethod_whenCommaInInput_thenFail() { - Integer cIntPrim = Integer.valueOf("6,000"); - } - - @Test(expected = NumberFormatException.class) - public void givenBigIntegerConstructor_whenDecimalInInput_thenFail() { - BigInteger bigInteger = new BigInteger("4.0"); - } - - @Test(expected = NumberFormatException.class) - public void givenDecodeMethod_whenAlphabetInInput_thenFail() { - Long decodedLong = Long.decode("64403L"); - } - - /* ---INTEGER PASS CASES--- */ - @Test - public void givenInvalidNumberInputs_whenOptimized_thenPass() { - Byte byteInt = new Byte("1"); - assertEquals(1, byteInt.intValue()); - - Short shortInt = new Short("2 ".trim()); - assertEquals(2, shortInt.intValue()); - - Integer aIntObj = Integer.valueOf("6"); - assertEquals(6, aIntObj.intValue()); - - BigInteger bigInteger = new BigInteger("4"); - assertEquals(4, bigInteger.intValue()); - - int aIntPrim = Integer.parseInt("6000 ".trim()); - assertEquals(6000, aIntPrim); - - int bIntPrim = Integer.parseInt("_6000".replaceAll("_", "")); - assertEquals(6000, bIntPrim); - - int cIntPrim = Integer.parseInt("-6000"); - assertEquals(-6000, cIntPrim); - - Long decodeInteger = Long.decode("644032334"); - assertEquals(644032334L, decodeInteger.longValue()); - } - - /* ---DOUBLE FAIL CASES--- */ - @Test(expected = NumberFormatException.class) - public void givenFloatConstructor_whenAlphabetInInput_thenFail() { - Float floatDecimalObj = new Float("one.1"); - } - - @Test(expected = NumberFormatException.class) - public void givenDoubleConstructor_whenAlphabetInInput_thenFail() { - Double doubleDecimalObj = new Double("two.2"); - } - - @Test(expected = NumberFormatException.class) - public void givenBigDecimalConstructor_whenSpecialCharsInInput_thenFail() { - BigDecimal bigDecimalObj = new BigDecimal("3_0.3"); - } - - @Test(expected = NumberFormatException.class) - public void givenParseDoubleMethod_whenCommaInInput_thenFail() { - double aDoublePrim = Double.parseDouble("4000,1"); - } - - /* ---DOUBLE PASS CASES--- */ - @Test - public void givenDoubleConstructor_whenDecimalInInput_thenPass() { - Double doubleDecimalObj = new Double("2.2"); - assertEquals(2.2, doubleDecimalObj.doubleValue(), 0); - } - - @Test - public void givenDoubleValueOfMethod_whenMinusInInput_thenPass() { - Double aDoubleObj = Double.valueOf("-6000"); - assertEquals(-6000, aDoubleObj.doubleValue(), 0); - } - - @Test - public void givenUsDecimalNumber_whenParsedWithNumberFormat_thenPass() throws ParseException { - Number parsedNumber = parseNumberWithLocale("4000.1", Locale.US); - assertEquals(4000.1, parsedNumber); - assertEquals(4000.1, parsedNumber.doubleValue(), 0); - assertEquals(4000, parsedNumber.intValue()); - } - - /** - * In most European countries (for example, France), comma is used as decimal in place of period. - * @throws ParseException if the input string contains special characters other than comma or decimal. - * In this test case, anything after decimal (period) is dropped when a European locale is set. - */ - @Test - public void givenEuDecimalNumberHasComma_whenParsedWithNumberFormat_thenPass() throws ParseException { - Number parsedNumber = parseNumberWithLocale("4000,1", Locale.FRANCE); - LOG.info("Number parsed is: " + parsedNumber); - assertEquals(4000.1, parsedNumber); - assertEquals(4000.1, parsedNumber.doubleValue(), 0); - assertEquals(4000, parsedNumber.intValue()); - } - - /** - * Converts a string into a number retaining all decimals, and symbols valid in a locale. - * @param number the input string for a number. - * @param locale the locale to consider while parsing a number. - * @return the generic number object which can represent multiple number types. - * @throws ParseException when input contains invalid characters. - */ - private Number parseNumberWithLocale(String number, Locale locale) throws ParseException { - locale = locale == null ? Locale.getDefault() : locale; - NumberFormat numberFormat = NumberFormat.getInstance(locale); - return numberFormat.parse(number); - } - -} diff --git a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/CheckedUncheckedExceptionsUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/CheckedUncheckedExceptionsUnitTest.java deleted file mode 100644 index d82b1349d8..0000000000 --- a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/CheckedUncheckedExceptionsUnitTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.baeldung.exceptions; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -import java.io.FileNotFoundException; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Tests the {@link CheckedUncheckedExceptions}. - */ -public class CheckedUncheckedExceptionsUnitTest { - - @Test - public void whenFileNotExist_thenThrowException() { - assertThrows(FileNotFoundException.class, () -> { - CheckedUncheckedExceptions.checkedExceptionWithThrows(); - }); - } - - @Test - public void whenTryCatchExcetpion_thenSuccess() { - try { - CheckedUncheckedExceptions.checkedExceptionWithTryCatch(); - } catch (Exception e) { - Assertions.fail(e.getMessage()); - } - } - - @Test - public void whenDivideByZero_thenThrowException() { - assertThrows(ArithmeticException.class, () -> { - CheckedUncheckedExceptions.divideByZero(); - }); - } - - @Test - public void whenInvalidFile_thenThrowException() { - - assertThrows(IncorrectFileNameException.class, () -> { - CheckedUncheckedExceptions.checkFile("wrongFileName.txt"); - }); - } - - @Test - public void whenNullOrEmptyFile_thenThrowException() { - assertThrows(NullOrEmptyException.class, () -> { - CheckedUncheckedExceptions.checkFile(null); - }); - assertThrows(NullOrEmptyException.class, () -> { - CheckedUncheckedExceptions.checkFile(""); - }); - } -} diff --git a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/GlobalExceptionHandlerUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/GlobalExceptionHandlerUnitTest.java deleted file mode 100644 index 394de9c576..0000000000 --- a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/GlobalExceptionHandlerUnitTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.baeldung.exceptions; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.slf4j.LoggerFactory; -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.classic.spi.LoggingEvent; -import ch.qos.logback.core.Appender; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; - -@RunWith(MockitoJUnitRunner.class) -public class GlobalExceptionHandlerUnitTest { - - @Mock - private Appender mockAppender; - - @Captor - private ArgumentCaptor captorLoggingEvent; - - @Before - public void setup() { - final Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); - logger.addAppender(mockAppender); - - Handler globalExceptionHandler = new Handler(); - Thread.setDefaultUncaughtExceptionHandler(globalExceptionHandler); - } - - @After - public void teardown() { - final Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); - logger.detachAppender(mockAppender); - } - - @Test - public void whenArithmeticException_thenUseUncaughtExceptionHandler() throws InterruptedException { - - Thread globalExceptionHandlerThread = new Thread() { - public void run() { - GlobalExceptionHandler globalExceptionHandlerObj = new GlobalExceptionHandler(); - globalExceptionHandlerObj.performArithmeticOperation(99, 0); - } - }; - - globalExceptionHandlerThread.start(); - globalExceptionHandlerThread.join(); - - verify(mockAppender).doAppend(captorLoggingEvent.capture()); - LoggingEvent loggingEvent = captorLoggingEvent.getValue(); - - assertThat(loggingEvent.getLevel()).isEqualTo(Level.INFO); - assertThat(loggingEvent.getFormattedMessage()).isEqualTo("Unhandled exception caught!"); - } - -} diff --git a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/RootCauseFinderUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/RootCauseFinderUnitTest.java deleted file mode 100644 index 5d0f3b9c3e..0000000000 --- a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/RootCauseFinderUnitTest.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.baeldung.exceptions; - -import com.google.common.base.Throwables; -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import java.time.LocalDate; -import java.time.format.DateTimeParseException; -import java.time.temporal.ChronoUnit; - -import static com.baeldung.exceptions.RootCauseFinder.*; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Tests the {@link RootCauseFinder}. - */ -public class RootCauseFinderUnitTest { - - @Test - public void givenBirthDate_whenCalculatingAge_thenAgeReturned() { - try { - int age = AgeCalculator.calculateAge("1990-01-01"); - Assertions.assertEquals(1990, LocalDate - .now() - .minus(age, ChronoUnit.YEARS) - .getYear()); - } catch (CalculationException e) { - Assertions.fail(e.getMessage()); - } - } - - @Test - public void givenWrongFormatDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("010102"); - } catch (CalculationException ex) { - assertTrue(findCauseUsingPlainJava(ex) instanceof DateTimeParseException); - } - } - - @Test - public void givenOutOfRangeDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("2020-04-04"); - } catch (CalculationException ex) { - assertTrue(findCauseUsingPlainJava(ex) instanceof DateOutOfRangeException); - } - } - - @Test - public void givenNullDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { - try { - AgeCalculator.calculateAge(null); - } catch (Exception ex) { - assertTrue(findCauseUsingPlainJava(ex) instanceof IllegalArgumentException); - } - } - - @Test - public void givenWrongFormatDate_whenFindingRootCauseUsingApacheCommons_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("010102"); - } catch (CalculationException ex) { - assertTrue(ExceptionUtils.getRootCause(ex) instanceof DateTimeParseException); - } - } - - @Test - public void givenOutOfRangeDate_whenFindingRootCauseUsingApacheCommons_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("2020-04-04"); - } catch (CalculationException ex) { - assertTrue(ExceptionUtils.getRootCause(ex) instanceof DateOutOfRangeException); - } - } - - @Test - public void givenNullDate_whenFindingRootCauseUsingApacheCommons_thenRootCauseNotFound() { - try { - AgeCalculator.calculateAge(null); - } catch (Exception ex) { - assertTrue(ExceptionUtils.getRootCause(ex) instanceof IllegalArgumentException); - } - } - - @Test - public void givenWrongFormatDate_whenFindingRootCauseUsingGuava_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("010102"); - } catch (CalculationException ex) { - assertTrue(Throwables.getRootCause(ex) instanceof DateTimeParseException); - } - } - - @Test - public void givenOutOfRangeDate_whenFindingRootCauseUsingGuava_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("2020-04-04"); - } catch (CalculationException ex) { - assertTrue(Throwables.getRootCause(ex) instanceof DateOutOfRangeException); - } - } - - @Test - public void givenNullDate_whenFindingRootCauseUsingGuava_thenRootCauseFound() { - try { - AgeCalculator.calculateAge(null); - } catch (Exception ex) { - assertTrue(Throwables.getRootCause(ex) instanceof IllegalArgumentException); - } - } - -} diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/classnotfoundexception/ClassNotFoundExceptionUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/classnotfoundexception/ClassNotFoundExceptionUnitTest.java similarity index 84% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/classnotfoundexception/ClassNotFoundExceptionUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/classnotfoundexception/ClassNotFoundExceptionUnitTest.java index 59605fb1c9..9311a9d886 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/classnotfoundexception/ClassNotFoundExceptionUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/classnotfoundexception/ClassNotFoundExceptionUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.classnotfoundexception; +package com.baeldung.exceptions.classnotfoundexception; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileExtensionExceptionUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/customexception/IncorrectFileExtensionExceptionUnitTest.java similarity index 95% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileExtensionExceptionUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/customexception/IncorrectFileExtensionExceptionUnitTest.java index 230698f719..80787daaaa 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileExtensionExceptionUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/customexception/IncorrectFileExtensionExceptionUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.customexception; +package com.baeldung.exceptions.customexception; import static org.assertj.core.api.Assertions.assertThat; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileNameExceptionUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/customexception/IncorrectFileNameExceptionUnitTest.java similarity index 92% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileNameExceptionUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/customexception/IncorrectFileNameExceptionUnitTest.java index acb05eb763..8e135c1cec 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileNameExceptionUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/customexception/IncorrectFileNameExceptionUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.customexception; +package com.baeldung.exceptions.customexception; import static org.assertj.core.api.Assertions.assertThat; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/exceptionhandling/ExceptionsUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/exceptionhandling/ExceptionsUnitTest.java similarity index 97% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/exceptionhandling/ExceptionsUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/exceptionhandling/ExceptionsUnitTest.java index 29c690133d..3551de3631 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/exceptionhandling/ExceptionsUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/exceptionhandling/ExceptionsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptionhandling; +package com.baeldung.exceptions.exceptionhandling; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java similarity index 85% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java index 521c50098a..135a51f9dd 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.noclassdeffounderror; +package com.baeldung.exceptions.noclassdeffounderror; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyRunnableUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/sneakythrows/SneakyRunnableUnitTest.java similarity index 89% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyRunnableUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/sneakythrows/SneakyRunnableUnitTest.java index 8d8e4f14fe..086c4eaef0 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyRunnableUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/sneakythrows/SneakyRunnableUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.sneakythrows; +package com.baeldung.exceptions.sneakythrows; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyThrowsUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/sneakythrows/SneakyThrowsUnitTest.java similarity index 89% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyThrowsUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/sneakythrows/SneakyThrowsUnitTest.java index da1b2e617b..3b70128a9b 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyThrowsUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/sneakythrows/SneakyThrowsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.sneakythrows; +package com.baeldung.exceptions.sneakythrows; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/AccountHolderManualTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/AccountHolderManualTest.java similarity index 82% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/AccountHolderManualTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/AccountHolderManualTest.java index 180b7723ac..dac8698bf8 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/AccountHolderManualTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/AccountHolderManualTest.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/CyclicDependancyManualTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/CyclicDependancyManualTest.java similarity index 81% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/CyclicDependancyManualTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/CyclicDependancyManualTest.java index 95164ac935..db6b1d45f8 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/CyclicDependancyManualTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/CyclicDependancyManualTest.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java similarity index 95% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java index ccf8c25271..2c7289cd5c 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java similarity index 89% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java index 40c2c4799e..e7fb0874ea 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java similarity index 94% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java index f4e2e5221a..0f1d71034d 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/throwsexception/SimpleServiceUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/throwvsthrows/SimpleServiceUnitTest.java similarity index 92% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/throwsexception/SimpleServiceUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/throwvsthrows/SimpleServiceUnitTest.java index b9a658a960..87f6224217 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/throwsexception/SimpleServiceUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/throwvsthrows/SimpleServiceUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.throwsexception; +package com.baeldung.exceptions.throwvsthrows; import org.junit.jupiter.api.Test; diff --git a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/java8/JavaTryWithResourcesLongRunningUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/java8/JavaTryWithResourcesLongRunningUnitTest.java deleted file mode 100644 index 32879aed0c..0000000000 --- a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/java8/JavaTryWithResourcesLongRunningUnitTest.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.baeldung.java8; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.Scanner; - -import org.junit.Assert; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class JavaTryWithResourcesLongRunningUnitTest { - - private static final Logger LOG = LoggerFactory.getLogger(JavaTryWithResourcesLongRunningUnitTest.class); - - private static final String TEST_STRING_HELLO_WORLD = "Hello World"; - private Date resource1Date, resource2Date; - - // tests - - /* Example for using Try_with_resources */ - @Test - public void whenWritingToStringWriter_thenCorrectlyWritten() { - final StringWriter sw = new StringWriter(); - try (PrintWriter pw = new PrintWriter(sw, true)) { - pw.print(TEST_STRING_HELLO_WORLD); - } - - Assert.assertEquals(sw.getBuffer() - .toString(), TEST_STRING_HELLO_WORLD); - } - - /* Example for using multiple resources */ - @Test - public void givenStringToScanner_whenWritingToStringWriter_thenCorrectlyWritten() { - - final StringWriter sw = new StringWriter(); - try (Scanner sc = new Scanner(TEST_STRING_HELLO_WORLD); PrintWriter pw = new PrintWriter(sw, true)) { - while (sc.hasNext()) { - pw.print(sc.nextLine()); - } - } - - Assert.assertEquals(sw.getBuffer() - .toString(), TEST_STRING_HELLO_WORLD); - } - - /* Example to show order in which the resources are closed */ - @Test - public void whenFirstAutoClosableResourceIsinitializedFirst_thenFirstAutoClosableResourceIsReleasedFirst() throws Exception { - try (AutoCloseableResourcesFirst af = new AutoCloseableResourcesFirst(); AutoCloseableResourcesSecond as = new AutoCloseableResourcesSecond()) { - af.doSomething(); - as.doSomething(); - } - Assert.assertTrue(resource1Date.after(resource2Date)); - } - - class AutoCloseableResourcesFirst implements AutoCloseable { - public AutoCloseableResourcesFirst() { - LOG.debug("Constructor -> AutoCloseableResources_First"); - } - - public void doSomething() { - LOG.debug("Something -> AutoCloseableResources_First"); - } - - @Override - public void close() throws Exception { - LOG.debug("Closed AutoCloseableResources_First"); - resource1Date = new Date(); - } - } - - class AutoCloseableResourcesSecond implements AutoCloseable { - public AutoCloseableResourcesSecond() { - LOG.debug("Constructor -> AutoCloseableResources_Second"); - } - - public void doSomething() { - LOG.debug("Something -> AutoCloseableResources_Second"); - } - - @Override - public void close() throws Exception { - LOG.debug("Closed AutoCloseableResources_Second"); - resource2Date = new Date(); - Thread.sleep(10000); - } - } - -} \ No newline at end of file diff --git a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/optional/PersonRepositoryUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/optional/PersonRepositoryUnitTest.java deleted file mode 100644 index 4efa625ccd..0000000000 --- a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/optional/PersonRepositoryUnitTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.baeldung.optional; - -import org.junit.Test; - -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - -public class PersonRepositoryUnitTest { - - PersonRepository personRepository = new PersonRepository(); - - @Test - public void whenIdIsNull_thenExceptionIsThrown() { - assertThrows(IllegalArgumentException.class, - () -> - Optional - .ofNullable(personRepository.findNameById(null)) - .orElseThrow(IllegalArgumentException::new)); - } - - @Test - public void whenIdIsNonNull_thenNoExceptionIsThrown() { - assertAll( - () -> - Optional - .ofNullable(personRepository.findNameById("id")) - .orElseThrow(RuntimeException::new)); - } - - @Test - public void whenIdNonNull_thenReturnsNameUpperCase() { - String name = Optional - .ofNullable(personRepository.findNameById("id")) - .map(String::toUpperCase) - .orElseThrow(RuntimeException::new); - - assertEquals("NAME", name); - } - -} \ No newline at end of file diff --git a/core-java-modules/core-java-lang/src/test/resources/correctFileNameWithoutProperExtension b/core-java-modules/core-java-exceptions/src/test/resources/correctFileNameWithoutProperExtension similarity index 100% rename from core-java-modules/core-java-lang/src/test/resources/correctFileNameWithoutProperExtension rename to core-java-modules/core-java-exceptions/src/test/resources/correctFileNameWithoutProperExtension diff --git a/core-java-modules/core-java-lang/README.md b/core-java-modules/core-java-lang/README.md index ac91751600..6e619c1c4e 100644 --- a/core-java-modules/core-java-lang/README.md +++ b/core-java-modules/core-java-lang/README.md @@ -4,30 +4,22 @@ ### Relevant Articles: -- [Generate equals() and hashCode() with Eclipse](http://www.baeldung.com/java-eclipse-equals-and-hashcode) -- [Chained Exceptions in Java](http://www.baeldung.com/java-chained-exceptions) -- [Iterating Over Enum Values in Java](http://www.baeldung.com/java-enum-iteration) -- [Java Double Brace Initialization](http://www.baeldung.com/java-double-brace-initialization) -- [Guide to the Diamond Operator in Java](http://www.baeldung.com/java-diamond-operator) -- [Comparator and Comparable in Java](http://www.baeldung.com/java-comparator-comparable) -- [The Java continue and break Keywords](http://www.baeldung.com/java-continue-and-break) -- [Nested Classes in Java](http://www.baeldung.com/java-nested-classes) -- [A Guide to Inner Interfaces in Java](http://www.baeldung.com/java-inner-interfaces) -- [Recursion In Java](http://www.baeldung.com/java-recursion) -- [A Guide to the finalize Method in Java](http://www.baeldung.com/java-finalize) -- [Infinite Loops in Java](http://www.baeldung.com/infinite-loops-java) -- [Quick Guide to java.lang.System](http://www.baeldung.com/java-lang-system) -- [Using Java Assertions](http://www.baeldung.com/java-assert) -- [ClassNotFoundException vs NoClassDefFoundError](http://www.baeldung.com/java-classnotfoundexception-and-noclassdeffounderror) -- [The StackOverflowError in Java](http://www.baeldung.com/java-stack-overflow-error) -- [Create a Custom Exception in Java](http://www.baeldung.com/java-new-custom-exception) -- [Exception Handling in Java](http://www.baeldung.com/java-exceptions) -- [Differences Between Final, Finally and Finalize in Java](https://www.baeldung.com/java-final-finally-finalize) +- [Generate equals() and hashCode() with Eclipse](https://www.baeldung.com/java-eclipse-equals-and-hashcode) +- [Iterating Over Enum Values in Java](https://www.baeldung.com/java-enum-iteration) +- [Java Double Brace Initialization](https://www.baeldung.com/java-double-brace-initialization) +- [Guide to the Diamond Operator in Java](https://www.baeldung.com/java-diamond-operator) +- [Comparator and Comparable in Java](https://www.baeldung.com/java-comparator-comparable) +- [The Java continue and break Keywords](https://www.baeldung.com/java-continue-and-break) +- [Nested Classes in Java](https://www.baeldung.com/java-nested-classes) +- [A Guide to Inner Interfaces in Java](https://www.baeldung.com/java-inner-interfaces) +- [Recursion In Java](https://www.baeldung.com/java-recursion) +- [A Guide to the finalize Method in Java](https://www.baeldung.com/java-finalize) +- [Infinite Loops in Java](https://www.baeldung.com/infinite-loops-java) +- [Quick Guide to java.lang.System](https://www.baeldung.com/java-lang-system) +- [Using Java Assertions](https://www.baeldung.com/java-assert) - [Static and Dynamic Binding in Java](https://www.baeldung.com/java-static-dynamic-binding) -- [Difference Between Throw and Throws in Java](https://www.baeldung.com/java-throw-throws) - [Synthetic Constructs in Java](https://www.baeldung.com/java-synthetic) - [How to Separate Double into Integer and Decimal Parts](https://www.baeldung.com/java-separate-double-into-integer-decimal-parts) -- [“Sneaky Throws” in Java](http://www.baeldung.com/java-sneaky-throws) - [Retrieving a Class Name in Java](https://www.baeldung.com/java-class-name) - [Java Compound Operators](https://www.baeldung.com/java-compound-operators) - [Guide to Java Packages](https://www.baeldung.com/java-packages) diff --git a/core-java-modules/core-java-lang/pom.xml b/core-java-modules/core-java-lang/pom.xml index 8311636873..1a2b86f872 100644 --- a/core-java-modules/core-java-lang/pom.xml +++ b/core-java-modules/core-java-lang/pom.xml @@ -43,12 +43,6 @@ log4j-over-slf4j ${org.slf4j.version} - - org.projectlombok - lombok - ${lombok.version} - provided - org.assertj @@ -56,11 +50,6 @@ ${assertj-core.version} test - - javax.mail - mail - ${javax.mail.version} - @@ -75,9 +64,6 @@ 2.8.2 - - 1.5.0-b01 - 3.10.0 diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/MyException.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/MyException.java deleted file mode 100644 index c2908b7278..0000000000 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/MyException.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.baeldung.exceptionhandling; - -public class MyException extends Throwable { - -} diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 082ffbef53..68ece1c473 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -15,7 +15,6 @@ pre-jpms - core-java-exceptions core-java-optional core-java-lang-operators core-java-networking-2 diff --git a/pom.xml b/pom.xml index 4f40f8261f..733aaad056 100644 --- a/pom.xml +++ b/pom.xml @@ -415,6 +415,7 @@ core-java-modules/core-java-io-files core-java-modules/core-java-nio core-java-modules/core-java-security + core-java-modules/core-java-exceptions core-java-modules/core-java-lang-syntax core-java-modules/core-java-lang-syntax-2 core-java-modules/core-java-lang @@ -1162,6 +1163,7 @@ core-java-modules/core-java-io-files core-java-modules/core-java-nio core-java-modules/core-java-security + core-java-modules/core-java-exceptions core-java-modules/core-java-lang-syntax core-java-modules/core-java-lang-syntax-2 core-java-modules/core-java-lang From e4ef23d7b971c8e77cfe71ed6a1f828c42d193ff Mon Sep 17 00:00:00 2001 From: Sam Millington Date: Thu, 3 Oct 2019 05:19:05 +0100 Subject: [PATCH 30/55] Add README descriptions 28! (#7917) --- core-groovy-collections/README.md | 4 +++- core-java-modules/core-java-10/README.md | 3 +++ core-java-modules/core-java-11/README.md | 4 ++++ core-java-modules/core-java-8-2/README.md | 5 +++-- core-java-modules/core-java-8/README.md | 5 +++-- core-java-modules/core-java-9/README.md | 6 ++---- .../core-java-arrays-2/{README.MD => README.md} | 5 +++++ core-java-modules/core-java-arrays/README.md | 5 +++-- core-java-modules/core-java-collections/README.md | 5 +++-- core-java-modules/core-java-os/README.md | 7 ++++--- 10 files changed, 33 insertions(+), 16 deletions(-) rename core-java-modules/core-java-arrays-2/{README.MD => README.md} (85%) diff --git a/core-groovy-collections/README.md b/core-groovy-collections/README.md index aeba8933be..4afd214e7d 100644 --- a/core-groovy-collections/README.md +++ b/core-groovy-collections/README.md @@ -1,4 +1,6 @@ -# Groovy +## Core Groovy Collections + +This module contains articles about Groovy core collections ## Relevant articles: diff --git a/core-java-modules/core-java-10/README.md b/core-java-modules/core-java-10/README.md index 8fb4f8a7dd..2b57ec9064 100644 --- a/core-java-modules/core-java-10/README.md +++ b/core-java-modules/core-java-10/README.md @@ -1,3 +1,6 @@ +## Core Java 10 + +This module contains articles about Java 10 core features ### Relevant Articles: diff --git a/core-java-modules/core-java-11/README.md b/core-java-modules/core-java-11/README.md index 11c7d9d388..514f24a4ae 100644 --- a/core-java-modules/core-java-11/README.md +++ b/core-java-modules/core-java-11/README.md @@ -1,3 +1,7 @@ +## Core Java 11 + +This module contains articles about Java 11 core features + ### Relevant articles - [Java 11 Single File Source Code](https://www.baeldung.com/java-single-file-source-code) diff --git a/core-java-modules/core-java-8-2/README.md b/core-java-modules/core-java-8-2/README.md index 4952cf4eb7..9201add1d7 100644 --- a/core-java-modules/core-java-8-2/README.md +++ b/core-java-modules/core-java-8-2/README.md @@ -1,6 +1,6 @@ -========= +## Core Java 8 (part 2) -## Core Java 8 Cookbooks and Examples (part 2) +This module contains articles about Java 8 core features ### Relevant Articles: - [Anonymous Classes in Java](http://www.baeldung.com/) @@ -8,3 +8,4 @@ - [Run a Java Application from the Command Line](https://www.baeldung.com/java-run-jar-with-arguments) - [Java 8 Stream skip() vs limit()](https://www.baeldung.com/java-stream-skip-vs-limit) - [Guide to Java BiFunction Interface](https://www.baeldung.com/java-bifunction-interface) +- [[<-- Prev]](/core-java-modules/core-java-8) \ No newline at end of file diff --git a/core-java-modules/core-java-8/README.md b/core-java-modules/core-java-8/README.md index 6d69d30d00..72bdafe5fa 100644 --- a/core-java-modules/core-java-8/README.md +++ b/core-java-modules/core-java-8/README.md @@ -1,6 +1,6 @@ -========= +## Core Java 8 -## Core Java 8 Cookbooks and Examples +This module contains articles about Java 8 core features ### Relevant Articles: - [New Features in Java 8](https://www.baeldung.com/java-8-new-features) @@ -12,3 +12,4 @@ - [Finding Min/Max in an Array with Java](https://www.baeldung.com/java-array-min-max) - [Internationalization and Localization in Java 8](https://www.baeldung.com/java-8-localization) - [Generalized Target-Type Inference in Java](https://www.baeldung.com/java-generalized-target-type-inference) +- [[More -->]](/core-java-modules/core-java-8-2) diff --git a/core-java-modules/core-java-9/README.md b/core-java-modules/core-java-9/README.md index 8b52ce79b4..f4939ae1e1 100644 --- a/core-java-modules/core-java-9/README.md +++ b/core-java-modules/core-java-9/README.md @@ -1,8 +1,6 @@ -========= +## Core Java 9 -## Core Java 9 Examples - -[Java 9 New Features](http://www.baeldung.com/new-java-9) +This module contains articles about Java 9 core features ### Relevant Articles: diff --git a/core-java-modules/core-java-arrays-2/README.MD b/core-java-modules/core-java-arrays-2/README.md similarity index 85% rename from core-java-modules/core-java-arrays-2/README.MD rename to core-java-modules/core-java-arrays-2/README.md index 952770a2da..5fa2f2bf4c 100644 --- a/core-java-modules/core-java-arrays-2/README.MD +++ b/core-java-modules/core-java-arrays-2/README.md @@ -1,3 +1,7 @@ +## Core Java Arrays (Part 2) + +This module contains articles about Java arrays + ## Relevant Articles - [Extending an Array’s Length](https://www.baeldung.com/java-array-add-element-at-the-end) @@ -8,3 +12,4 @@ - [Intersection Between two Integer Arrays](https://www.baeldung.com/java-array-intersection) - [Removing an Element from an Array in Java](https://www.baeldung.com/java-array-remove-element) - [Removing the First Element of an Array](https://www.baeldung.com/java-array-remove-first-element) +- [[<-- Prev]](/core-java-modules/core-java-arrays) diff --git a/core-java-modules/core-java-arrays/README.md b/core-java-modules/core-java-arrays/README.md index 36d2d4c4ad..42fe3f83a1 100644 --- a/core-java-modules/core-java-arrays/README.md +++ b/core-java-modules/core-java-arrays/README.md @@ -1,6 +1,6 @@ -========= +## Core Java Arrays -## Core Java Arrays Cookbooks and Examples +This module contains articles about Java arrays ### Relevant Articles: - [How to Copy an Array in Java](https://www.baeldung.com/java-array-copy) @@ -14,3 +14,4 @@ - [How to Reverse an Array in Java](http://www.baeldung.com/java-invert-array) - [Sorting Arrays in Java](https://www.baeldung.com/java-sorting-arrays) - [Checking If an Array Is Sorted in Java](https://www.baeldung.com/java-check-sorted-array) +- [[More -->]](/core-java-modules/core-java-arrays-2) diff --git a/core-java-modules/core-java-collections/README.md b/core-java-modules/core-java-collections/README.md index 7be7d02b3f..340c2b286e 100644 --- a/core-java-modules/core-java-collections/README.md +++ b/core-java-modules/core-java-collections/README.md @@ -1,6 +1,6 @@ -========= +## Core Java Collections -## Core Java Collections Cookbooks and Examples +This module contains articles about Java collections ### Relevant Articles: - [Collect a Java Stream to an Immutable Collection](https://www.baeldung.com/java-stream-immutable-collection) @@ -13,3 +13,4 @@ - [Defining a Char Stack in Java](https://www.baeldung.com/java-char-stack) - [Guide to the Java Queue Interface](https://www.baeldung.com/java-queue) - [An Introduction to Synchronized Java Collections](https://www.baeldung.com/java-synchronized-collections) +- [[More -->]](/core-java-modules/core-java-collections-2) \ No newline at end of file diff --git a/core-java-modules/core-java-os/README.md b/core-java-modules/core-java-os/README.md index 697af5e4d6..9205628a87 100644 --- a/core-java-modules/core-java-os/README.md +++ b/core-java-modules/core-java-os/README.md @@ -1,10 +1,11 @@ -========= +## Core Java OS -This module uses Java 9, so make sure to have the JDK 9 installed to run it. +This module contains articles about working with the operating system (OS) in Java -## ### Relevant Articles: - [Java 9 Process API Improvements](http://www.baeldung.com/java-9-process-api) - [Guide to java.lang.Process API](https://www.baeldung.com/java-process-api) - [Guide to java.lang.ProcessBuilder API](https://www.baeldung.com/java-lang-processbuilder-api) - [Get the Current Working Directory in Java](https://www.baeldung.com/java-current-directory) + +This module uses Java 9, so make sure to have the JDK 9 installed to run it. \ No newline at end of file From 4a04af8ebfdbc083bbf3e5246800cbdca448d505 Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Thu, 3 Oct 2019 09:53:05 +0530 Subject: [PATCH 31/55] BAEL-17956 Fix the integrations tests in vertx (#7889) * BAEL-17956 Fix the integrations tests in vertx * BAEL-17956 Fix the integrations tests in vertx -Added random port logic --- vertx/pom.xml | 5 +- .../RestServiceVerticleIntegrationTest.java | 46 ------------- .../baeldung/RestServiceVerticleUnitTest.java | 66 +++++++++++++++++++ .../SimpleServerVerticleIntegrationTest.java | 44 ------------- .../SimpleServerVerticleUnitTest.java | 55 ++++++++++++++++ 5 files changed, 123 insertions(+), 93 deletions(-) delete mode 100644 vertx/src/test/java/com/baeldung/RestServiceVerticleIntegrationTest.java create mode 100644 vertx/src/test/java/com/baeldung/RestServiceVerticleUnitTest.java delete mode 100644 vertx/src/test/java/com/baeldung/SimpleServerVerticleIntegrationTest.java create mode 100644 vertx/src/test/java/com/baeldung/SimpleServerVerticleUnitTest.java diff --git a/vertx/pom.xml b/vertx/pom.xml index befd4c45bb..c566681073 100644 --- a/vertx/pom.xml +++ b/vertx/pom.xml @@ -64,9 +64,8 @@ - 3.0.0 - 6.10 - 2.3 + 3.8.1 + 3.2.1 diff --git a/vertx/src/test/java/com/baeldung/RestServiceVerticleIntegrationTest.java b/vertx/src/test/java/com/baeldung/RestServiceVerticleIntegrationTest.java deleted file mode 100644 index 40fa6c7220..0000000000 --- a/vertx/src/test/java/com/baeldung/RestServiceVerticleIntegrationTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.baeldung; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import com.baeldung.rest.RestServiceVerticle; - -import io.vertx.core.Vertx; -import io.vertx.ext.unit.Async; -import io.vertx.ext.unit.TestContext; -import io.vertx.ext.unit.junit.VertxUnitRunner; - -@RunWith(VertxUnitRunner.class) -public class RestServiceVerticleIntegrationTest { - - private Vertx vertx; - - @Before - public void setup(TestContext testContext) { - vertx = Vertx.vertx(); - - vertx.deployVerticle(RestServiceVerticle.class.getName(), testContext.asyncAssertSuccess()); - } - - @After - public void tearDown(TestContext testContext) { - vertx.close(testContext.asyncAssertSuccess()); - } - - @Test - public void givenId_whenReceivedArticle_thenSuccess(TestContext testContext) { - final Async async = testContext.async(); - - vertx.createHttpClient() - .getNow(8080, "localhost", "/api/baeldung/articles/article/12345", response -> { - response.handler(responseBody -> { - testContext.assertTrue(responseBody.toString() - .contains("\"id\" : \"12345\"")); - async.complete(); - }); - }); - } - -} diff --git a/vertx/src/test/java/com/baeldung/RestServiceVerticleUnitTest.java b/vertx/src/test/java/com/baeldung/RestServiceVerticleUnitTest.java new file mode 100644 index 0000000000..aab841f5bb --- /dev/null +++ b/vertx/src/test/java/com/baeldung/RestServiceVerticleUnitTest.java @@ -0,0 +1,66 @@ +package com.baeldung; + +import java.io.IOException; +import java.net.ServerSocket; + +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.baeldung.rest.RestServiceVerticle; + +import io.vertx.core.DeploymentOptions; +import io.vertx.core.Vertx; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.unit.Async; +import io.vertx.ext.unit.TestContext; +import io.vertx.ext.unit.junit.VertxUnitRunner; + +@RunWith(VertxUnitRunner.class) +public class RestServiceVerticleUnitTest { + + private Vertx vertx; + + private int port = 8081; + + @BeforeClass + public static void beforeClass() { + + } + + @Before + public void setup(TestContext testContext) throws IOException { + vertx = Vertx.vertx(); + + // Pick an available and random + ServerSocket socket = new ServerSocket(0); + port = socket.getLocalPort(); + socket.close(); + + DeploymentOptions options = new DeploymentOptions().setConfig(new JsonObject().put("http.port", port)); + + vertx.deployVerticle(RestServiceVerticle.class.getName(), options, testContext.asyncAssertSuccess()); + } + + @After + public void tearDown(TestContext testContext) { + vertx.close(testContext.asyncAssertSuccess()); + } + + @Test + public void givenId_whenReceivedArticle_thenSuccess(TestContext testContext) { + final Async async = testContext.async(); + + vertx.createHttpClient() + .getNow(port, "localhost", "/api/baeldung/articles/article/12345", response -> { + response.handler(responseBody -> { + testContext.assertTrue(responseBody.toString() + .contains("\"id\" : \"12345\"")); + async.complete(); + }); + }); + } + +} diff --git a/vertx/src/test/java/com/baeldung/SimpleServerVerticleIntegrationTest.java b/vertx/src/test/java/com/baeldung/SimpleServerVerticleIntegrationTest.java deleted file mode 100644 index 194f403e25..0000000000 --- a/vertx/src/test/java/com/baeldung/SimpleServerVerticleIntegrationTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.baeldung; - -import io.vertx.core.Vertx; -import io.vertx.ext.unit.Async; -import io.vertx.ext.unit.TestContext; -import io.vertx.ext.unit.junit.VertxUnitRunner; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(VertxUnitRunner.class) -public class SimpleServerVerticleIntegrationTest { - private Vertx vertx; - - @Before - public void setup(TestContext testContext) { - vertx = Vertx.vertx(); - - vertx.deployVerticle(SimpleServerVerticle.class.getName(), testContext.asyncAssertSuccess()); - } - - @After - public void tearDown(TestContext testContext) { - vertx.close(testContext.asyncAssertSuccess()); - } - - @Test - public void whenReceivedResponse_thenSuccess(TestContext testContext) { - final Async async = testContext.async(); - - vertx - .createHttpClient() - .getNow(8080, "localhost", "/", - response -> response.handler(responseBody -> { - testContext.assertTrue(responseBody - .toString() - .contains("Welcome")); - async.complete(); - })); - } - -} - diff --git a/vertx/src/test/java/com/baeldung/SimpleServerVerticleUnitTest.java b/vertx/src/test/java/com/baeldung/SimpleServerVerticleUnitTest.java new file mode 100644 index 0000000000..761577d5f3 --- /dev/null +++ b/vertx/src/test/java/com/baeldung/SimpleServerVerticleUnitTest.java @@ -0,0 +1,55 @@ +package com.baeldung; + +import io.vertx.core.DeploymentOptions; +import io.vertx.core.Vertx; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.unit.Async; +import io.vertx.ext.unit.TestContext; +import io.vertx.ext.unit.junit.VertxUnitRunner; + +import java.io.IOException; +import java.net.ServerSocket; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(VertxUnitRunner.class) +public class SimpleServerVerticleUnitTest { + private Vertx vertx; + + private int port = 8081; + + @Before + public void setup(TestContext testContext) throws IOException { + vertx = Vertx.vertx(); + + // Pick an available and random + ServerSocket socket = new ServerSocket(0); + port = socket.getLocalPort(); + socket.close(); + + DeploymentOptions options = new DeploymentOptions().setConfig(new JsonObject().put("http.port", port)); + + vertx.deployVerticle(SimpleServerVerticle.class.getName(), options, testContext.asyncAssertSuccess()); + } + + @After + public void tearDown(TestContext testContext) { + vertx.close(testContext.asyncAssertSuccess()); + } + + @Test + public void whenReceivedResponse_thenSuccess(TestContext testContext) { + final Async async = testContext.async(); + + vertx.createHttpClient() + .getNow(port, "localhost", "/", response -> response.handler(responseBody -> { + testContext.assertTrue(responseBody.toString() + .contains("Welcome")); + async.complete(); + })); + } + +} From 68b080e1c540091d6b3a3b003398f05170966ab7 Mon Sep 17 00:00:00 2001 From: Sam Millington Date: Thu, 3 Oct 2019 05:48:02 +0100 Subject: [PATCH 32/55] [BAEL-17476] Add readme descriptions 19 (#7905) --- persistence-modules/spring-data-keyvalue/README.md | 4 ++++ persistence-modules/spring-hibernate-3/README.md | 9 ++++----- spring-cloud-data-flow/README.md | 5 ++--- spring-cloud/spring-cloud-security/README.md | 4 ++++ spring-cloud/spring-cloud-stream/README.md | 4 ++++ spring-cloud/spring-cloud-task/README.md | 4 ++++ spring-cloud/spring-cloud-zookeeper/README.md | 4 ++++ 7 files changed, 26 insertions(+), 8 deletions(-) diff --git a/persistence-modules/spring-data-keyvalue/README.md b/persistence-modules/spring-data-keyvalue/README.md index f76cf4d5ac..9f53a11b2c 100644 --- a/persistence-modules/spring-data-keyvalue/README.md +++ b/persistence-modules/spring-data-keyvalue/README.md @@ -1,2 +1,6 @@ +## Spring Data Key-Value + +This module contains articles about Spring Data Key-Value + ### Relevant Articles: - [A Guide to Spring Data Key Value](http://www.baeldung.com/spring-data-key-value) diff --git a/persistence-modules/spring-hibernate-3/README.md b/persistence-modules/spring-hibernate-3/README.md index ac840b6f66..898c6522a9 100644 --- a/persistence-modules/spring-hibernate-3/README.md +++ b/persistence-modules/spring-hibernate-3/README.md @@ -1,13 +1,12 @@ -========= +## Spring with Hibernate 3 -## Spring with Hibernate 3 Example Project +This module contains articles about Spring with Hibernate 3 + +### Relevant Articles: - -### Relevant ArticleS: - [Hibernate 3 with Spring](http://www.baeldung.com/hibernate3-spring) - [HibernateException: No Hibernate Session Bound to Thread in Hibernate 3](http://www.baeldung.com/no-hibernate-session-bound-to-thread-exception) - ### Quick Start ``` diff --git a/spring-cloud-data-flow/README.md b/spring-cloud-data-flow/README.md index 40e1db6840..c9b6891b54 100644 --- a/spring-cloud-data-flow/README.md +++ b/spring-cloud-data-flow/README.md @@ -1,4 +1,3 @@ -## Spring Cloud Data Flow - -This module contains modules about Spring Cloud Data Flow +## Spring Cloud Data Flow +This is an aggregator module for Spring Cloud Data Flow modules. diff --git a/spring-cloud/spring-cloud-security/README.md b/spring-cloud/spring-cloud-security/README.md index 7099406614..0f3b39c98b 100644 --- a/spring-cloud/spring-cloud-security/README.md +++ b/spring-cloud/spring-cloud-security/README.md @@ -1,2 +1,6 @@ +## Spring Cloud Security + +This module contains articles about Spring Cloud Security + ### Relevant Articles: - [An Intro to Spring Cloud Security](http://www.baeldung.com/spring-cloud-security) diff --git a/spring-cloud/spring-cloud-stream/README.md b/spring-cloud/spring-cloud-stream/README.md index 5ecb852df5..fd1eeccfda 100644 --- a/spring-cloud/spring-cloud-stream/README.md +++ b/spring-cloud/spring-cloud-stream/README.md @@ -1,2 +1,6 @@ +## Spring Cloud Stream + +This module contains articles about Spring Cloud Stream + ## Relevant Articles - [Introduction to Spring Cloud Stream](http://www.baeldung.com/spring-cloud-stream) diff --git a/spring-cloud/spring-cloud-task/README.md b/spring-cloud/spring-cloud-task/README.md index cabc1ac854..8f6ee26099 100644 --- a/spring-cloud/spring-cloud-task/README.md +++ b/spring-cloud/spring-cloud-task/README.md @@ -1,2 +1,6 @@ +## Spring Cloud Task + +This module contains articles about Spring Cloud Task + ### Relevant Articles: - [An Intro to Spring Cloud Task](http://www.baeldung.com/spring-cloud-task) diff --git a/spring-cloud/spring-cloud-zookeeper/README.md b/spring-cloud/spring-cloud-zookeeper/README.md index a49a448833..2bef63ef9f 100644 --- a/spring-cloud/spring-cloud-zookeeper/README.md +++ b/spring-cloud/spring-cloud-zookeeper/README.md @@ -1,2 +1,6 @@ +## Spring Cloud Zookeeper + +This module contains articles about Spring Cloud Zookeeper + ### Relevant Articles: - [An Intro to Spring Cloud Zookeeper](http://www.baeldung.com/spring-cloud-zookeeper) From 476dbbc01aaeec8e09613b0a204b34edc4c8b972 Mon Sep 17 00:00:00 2001 From: Alessio Stalla Date: Thu, 3 Oct 2019 08:36:36 +0200 Subject: [PATCH 33/55] #BAEL-17518 add README descriptions --- httpclient-simple/README.md | 7 +++++-- hystrix/README.md | 4 ++++ image-processing/README.md | 4 ++++ immutables/README.md | 4 ++++ jackson-2/README.md | 5 +++-- jackson-simple/README.md | 3 ++- jackson/README.md | 5 +++-- java-collections-conversions/README.md | 4 ++-- java-collections-maps-2/README.md | 7 ++++++- java-collections-maps/README.md | 5 +++-- 10 files changed, 36 insertions(+), 12 deletions(-) diff --git a/httpclient-simple/README.md b/httpclient-simple/README.md index 13a539d794..098d5f278e 100644 --- a/httpclient-simple/README.md +++ b/httpclient-simple/README.md @@ -1,5 +1,8 @@ -========= -## This module contains articles that are part of the HTTPClient Ebook +## HTTPClient Ebook + +This module contains articles about HTTPClient that are part of the HTTPClient Ebook. + +### Relevant Articles - [HttpClient 4 – Get the Status Code](https://www.baeldung.com/httpclient-status-code) - [HttpClient with SSL](https://www.baeldung.com/httpclient-ssl) diff --git a/hystrix/README.md b/hystrix/README.md index f35518bce3..d53baee957 100644 --- a/hystrix/README.md +++ b/hystrix/README.md @@ -1,3 +1,7 @@ +## Hystrix + +This module contains articles about Hystrix. + ### Relevant Articles: - [Hystrix Integration with Existing Spring Application](https://www.baeldung.com/hystrix-integration-with-spring-aop) - [Introduction to Hystrix](https://www.baeldung.com/introduction-to-hystrix) diff --git a/image-processing/README.md b/image-processing/README.md index 2dd74d7c47..adb35c2318 100644 --- a/image-processing/README.md +++ b/image-processing/README.md @@ -1,2 +1,6 @@ +## Image Processing + +This module contains articles about image processing. + ### Relevant Articles: - [Working with Images in Java](https://www.baeldung.com/java-images) diff --git a/immutables/README.md b/immutables/README.md index 2ea4f4fe50..a93a342f9c 100644 --- a/immutables/README.md +++ b/immutables/README.md @@ -1,2 +1,6 @@ +## Immutables + +This module contains articles about the Immutables library. + ### Relevant Articles: - [Introduction to Immutables](https://www.baeldung.com/immutables) diff --git a/jackson-2/README.md b/jackson-2/README.md index 920eaa91e8..5e0cb4ec37 100644 --- a/jackson-2/README.md +++ b/jackson-2/README.md @@ -1,7 +1,7 @@ -========= - ## Jackson Cookbooks and Examples +This module contains articles about Jackson. + ### The Course The "REST With Spring" Classes: http://bit.ly/restwithspring @@ -12,3 +12,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Converting JSON to CSV in Java](https://www.baeldung.com/java-converting-json-to-csv) - [Compare Two JSON Objects with Jackson](https://www.baeldung.com/jackson-compare-two-json-objects) - [Calling Default Serializer from Custom Serializer in Jackson](https://www.baeldung.com/jackson-call-default-serializer-from-custom-serializer) +- More articles: [[<-- prev]](/../jackson) diff --git a/jackson-simple/README.md b/jackson-simple/README.md index 79538c6929..302fcb5b05 100644 --- a/jackson-simple/README.md +++ b/jackson-simple/README.md @@ -1,6 +1,7 @@ -========= ### Jackson Articles that are also part of the e-book +This module contains articles about Jackson that are also part of the Jackson Ebook. + ###The Course The "REST With Spring" Classes: http://bit.ly/restwithspring diff --git a/jackson/README.md b/jackson/README.md index fb7f6c4127..f96a569617 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -1,7 +1,7 @@ -========= - ## Jackson Cookbooks and Examples +This module contains articles about Jackson. + ###The Course The "REST With Spring" Classes: http://bit.ly/restwithspring @@ -32,4 +32,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Convert XML to JSON Using Jackson](https://www.baeldung.com/jackson-convert-xml-json) - [Deserialize Immutable Objects with Jackson](https://www.baeldung.com/jackson-deserialize-immutable-objects) - [Mapping a Dynamic JSON Object with Jackson](https://www.baeldung.com/jackson-mapping-dynamic-object) +- More articles: [[next -->]](/../jackson-2) diff --git a/java-collections-conversions/README.md b/java-collections-conversions/README.md index e80f29f519..6d4f6ddb3a 100644 --- a/java-collections-conversions/README.md +++ b/java-collections-conversions/README.md @@ -1,7 +1,7 @@ -========= - ## Java Collections Cookbooks and Examples +This module contains articles about conversions among Collection types and arrays in Java. + ### Relevant Articles: - [Converting between an Array and a List in Java](https://www.baeldung.com/convert-array-to-list-and-list-to-array) - [Converting between an Array and a Set in Java](https://www.baeldung.com/convert-array-to-set-and-set-to-array) diff --git a/java-collections-maps-2/README.md b/java-collections-maps-2/README.md index 09c4b4fbb3..0db83fbae7 100644 --- a/java-collections-maps-2/README.md +++ b/java-collections-maps-2/README.md @@ -1,4 +1,8 @@ -## Relevant Articles: +## Java Collections Cookbooks and Examples + +This module contains articles about Map data structures in Java. + +### Relevant Articles: - [Map of Primitives in Java](https://www.baeldung.com/java-map-primitives) - [Copying a HashMap in Java](https://www.baeldung.com/java-copy-hashmap) - [Guide to Java HashMap]() @@ -10,3 +14,4 @@ - [Finding the Highest Value in a Java Map](https://www.baeldung.com/java-find-map-max) - [Initialize a HashMap in Java](https://www.baeldung.com/java-initialize-hashmap) - [Java TreeMap vs HashMap](https://www.baeldung.com/java-treemap-vs-hashmap) +- More articles: [[<-- prev>]](/../java-collections-maps) diff --git a/java-collections-maps/README.md b/java-collections-maps/README.md index 3a6ad1d10c..87fefe1b9d 100644 --- a/java-collections-maps/README.md +++ b/java-collections-maps/README.md @@ -1,7 +1,7 @@ -========= - ## Java Collections Cookbooks and Examples +This module contains articles about Map data structures in Java. + ### Relevant Articles: - [Guide to the Guava BiMap](https://www.baeldung.com/guava-bimap) - [The Java HashMap Under the Hood](https://www.baeldung.com/java-hashmap) @@ -13,3 +13,4 @@ - [Comparing Two HashMaps in Java](https://www.baeldung.com/java-compare-hashmaps) - [Immutable Map Implementations in Java](https://www.baeldung.com/java-immutable-maps) - [Guide to Apache Commons MultiValuedMap](https://www.baeldung.com/apache-commons-multi-valued-map) +- More articles: [[next -->]](/../java-collections-maps-2) From 4a9cae5e851b602b205508b58f4156ae9044538a Mon Sep 17 00:00:00 2001 From: Alessio Stalla Date: Thu, 3 Oct 2019 08:58:43 +0200 Subject: [PATCH 34/55] #BAEL-17520 add README descriptions --- java-strings-2/README.md | 7 ++++++- java-strings-3/README.md | 7 ++++++- java-strings-ops/README.md | 4 ++-- java-strings/README.md | 5 +++-- java-vavr-stream/README.md | 3 +++ java-websocket/README.md | 4 ++++ javafx/README.md | 4 ++++ javax-servlets/README.md | 4 ++++ javaxval/README.md | 4 ++-- jaxb/README.md | 4 ++++ 10 files changed, 38 insertions(+), 8 deletions(-) diff --git a/java-strings-2/README.md b/java-strings-2/README.md index 166a8a2b1f..82f33997c5 100644 --- a/java-strings-2/README.md +++ b/java-strings-2/README.md @@ -1,4 +1,8 @@ -## Relevant Articles: +## Java Strings Cookbooks and Examples + +This module contains articles about strings in Java. + +### Relevant Articles: - [Java Localization – Formatting Messages](https://www.baeldung.com/java-localization-messages-formatting) - [Check If a String Contains a Substring](https://www.baeldung.com/java-string-contains-substring) @@ -25,3 +29,4 @@ - [How to Reverse a String in Java](https://www.baeldung.com/java-reverse-string) - [String toLowerCase and toUpperCase Methods in Java](https://www.baeldung.com/java-string-convert-case) - [Guide to StreamTokenizer](https://www.baeldung.com/java-streamtokenizer) +- More articles: [[<-- prev>]](/java-strings) [[next -->]](/java-strings-3) diff --git a/java-strings-3/README.md b/java-strings-3/README.md index 6c2339028f..f0aaddefcb 100644 --- a/java-strings-3/README.md +++ b/java-strings-3/README.md @@ -1,3 +1,8 @@ -## Relevant Articles: +## Java Strings Cookbooks and Examples + +This module contains articles about strings in Java. + +### Relevant Articles: - [Converting Java String to Double](https://www.baeldung.com/java-string-to-double) +- More articles: [[<-- prev>]](/java-strings-2) diff --git a/java-strings-ops/README.md b/java-strings-ops/README.md index d9c28dab0d..31c5f48022 100644 --- a/java-strings-ops/README.md +++ b/java-strings-ops/README.md @@ -1,7 +1,7 @@ -========= - ## Java Strings Cookbooks and Examples +This module contains articles about operations on strings in Java. + ### Relevant Articles: - [Convert char to String in Java](https://www.baeldung.com/java-convert-char-to-string) - [Convert String to int or Integer in Java](https://www.baeldung.com/java-convert-string-to-int-or-integer) diff --git a/java-strings/README.md b/java-strings/README.md index 5b2a327877..1faa11f606 100644 --- a/java-strings/README.md +++ b/java-strings/README.md @@ -1,7 +1,7 @@ -========= - ## Java Strings Cookbooks and Examples +This module contains articles about strings in Java. + ### Relevant Articles: - [String Operations with Java Streams](https://www.baeldung.com/java-stream-operations-on-strings) - [Converting String to Stream of chars](https://www.baeldung.com/java-string-to-stream) @@ -21,3 +21,4 @@ - [Adding a Newline Character to a String in Java](https://www.baeldung.com/java-string-newline) - [Remove or Replace part of a String in Java](https://www.baeldung.com/java-remove-replace-string-part) - [Replace a Character at a Specific Index in a String in Java](https://www.baeldung.com/java-replace-character-at-index) +- More articles: [[next -->]](/java-strings-2) diff --git a/java-vavr-stream/README.md b/java-vavr-stream/README.md index 901978a1d8..4e8b5ccd66 100644 --- a/java-vavr-stream/README.md +++ b/java-vavr-stream/README.md @@ -1,3 +1,6 @@ +## Vavr Streams + +This module contains articles about streams in Vavr. ### Relevant Articles: diff --git a/java-websocket/README.md b/java-websocket/README.md index 87cbb3fa5c..f48b8c6804 100644 --- a/java-websocket/README.md +++ b/java-websocket/README.md @@ -1,3 +1,7 @@ +## Java WebSocket + +This module contains articles about WebSocket in Java. + ### Relevant articles - [A Guide to the Java API for WebSocket](https://www.baeldung.com/java-websockets) diff --git a/javafx/README.md b/javafx/README.md index 7214321141..80c4f49026 100644 --- a/javafx/README.md +++ b/javafx/README.md @@ -1,3 +1,7 @@ +## JavaFX + +This module contains articles about JavaFX. + ### Relevant Articles: -[Introduction to JavaFX](https://www.baeldung.com/javafx) diff --git a/javax-servlets/README.md b/javax-servlets/README.md index 8254a78c4c..085cc04f87 100644 --- a/javax-servlets/README.md +++ b/javax-servlets/README.md @@ -1,3 +1,7 @@ +## Servlets + +This module contains articles about Servlets. + ### Relevant Articles: - [Introduction to Java Servlets](https://www.baeldung.com/intro-to-servlets) - [An MVC Example with Servlets and JSP](https://www.baeldung.com/mvc-servlet-jsp) diff --git a/javaxval/README.md b/javaxval/README.md index b141bc7859..46b7deab2a 100644 --- a/javaxval/README.md +++ b/javaxval/README.md @@ -1,7 +1,7 @@ -========= - ## Java Bean Validation Examples +This module contains articles about Bean Validation. + ### Relevant Articles: - [Java Bean Validation Basics](https://www.baeldung.com/javax-validation) - [Validating Container Elements with Bean Validation 2.0](https://www.baeldung.com/bean-validation-container-elements) diff --git a/jaxb/README.md b/jaxb/README.md index bdaef90279..aca078af15 100644 --- a/jaxb/README.md +++ b/jaxb/README.md @@ -1,2 +1,6 @@ +## JAXB + +This module contains articles about JAXB. + ### Relevant Articles: - [Guide to JAXB](https://www.baeldung.com/jaxb) From c138b81fa46dbe31cae864850d8da63e78c48546 Mon Sep 17 00:00:00 2001 From: catalin-burcea Date: Thu, 3 Oct 2019 10:57:18 +0300 Subject: [PATCH 35/55] Split or move testing-modules/junit-5 module - update readmes --- testing-modules/junit-5/README.md | 2 +- testing-modules/junit5-annotations/README.md | 6 +++--- testing-modules/junit5-migration/README.md | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/testing-modules/junit-5/README.md b/testing-modules/junit-5/README.md index 676d2f2f03..ede60c45a9 100644 --- a/testing-modules/junit-5/README.md +++ b/testing-modules/junit-5/README.md @@ -5,4 +5,4 @@ - [The Order of Tests in JUnit](https://www.baeldung.com/junit-5-test-order) - [Running JUnit Tests Programmatically, from a Java Application](https://www.baeldung.com/junit-tests-run-programmatically-from-java) - [Testing an Abstract Class With JUnit](https://www.baeldung.com/junit-test-abstract-class) -- [Guide to Dynamic Tests in Junit 5](https://www.baeldung.com/junit5-dynamic-tests) +- [Guide to Dynamic Tests in JUnit 5](https://www.baeldung.com/junit5-dynamic-tests) diff --git a/testing-modules/junit5-annotations/README.md b/testing-modules/junit5-annotations/README.md index 53819dbec5..02d4cd652a 100644 --- a/testing-modules/junit5-annotations/README.md +++ b/testing-modules/junit5-annotations/README.md @@ -1,9 +1,9 @@ -## Junit 5 Annotations +## JUnit 5 Annotations -This module contains articles about Junit 5 Annotations +This module contains articles about JUnit 5 Annotations ### Relevant Articles: -- [A Guide to @RepeatedTest in Junit 5](https://www.baeldung.com/junit-5-repeated-test) +- [A Guide to @RepeatedTest in JUnit 5](https://www.baeldung.com/junit-5-repeated-test) - [JUnit 5 Conditional Test Execution with Annotations](https://www.baeldung.com/junit-5-conditional-test-execution) - [JUnit5 Programmatic Extension Registration with @RegisterExtension](https://www.baeldung.com/junit-5-registerextension-annotation) - [Guide to JUnit 5 Parameterized Tests](https://www.baeldung.com/parameterized-tests-junit-5) diff --git a/testing-modules/junit5-migration/README.md b/testing-modules/junit5-migration/README.md index e6ad4f376c..84e540b466 100644 --- a/testing-modules/junit5-migration/README.md +++ b/testing-modules/junit5-migration/README.md @@ -1,6 +1,10 @@ -This is the code for the Junit 4 - Junit 5 Migration E-book. +## JUnit 5 migration + +This module contains articles about migrating to JUnit 5. + +The code for the JUnit 4 - JUnit 5 E-book is in `com.baeldung.junit4` and `com.baeldung.junit5`. ### Relevant Articles: -- [Junit 5 Migration](https://www.baeldung.com/junit-5-migration) +- [JUnit 5 Migration](https://www.baeldung.com/junit-5-migration) - [A Quick JUnit vs TestNG Comparison](https://www.baeldung.com/junit-vs-testng) - [Assertions in JUnit 4 and JUnit 5](https://www.baeldung.com/junit-assertions) From b53d41f9779c4591be79d3ee030523ded514cb12 Mon Sep 17 00:00:00 2001 From: Tapan Avasthi Date: Sun, 15 Sep 2019 11:59:29 +0530 Subject: [PATCH 36/55] BAEL-3223: Excluding URLs for a Filter in a Spring Web Application --- .../exclude_urls_filter/Application.java | 17 ++++++++++ .../controller/FAQController.java | 32 +++++++++++++++++++ .../exclude_urls_filter/controller/Ping.java | 22 +++++++++++++ .../filter/FilterRegistrationConfig.java | 26 +++++++++++++++ .../filter/HeaderValidatorFilter.java | 30 +++++++++++++++++ .../exclude_urls_filter/filter/LogFilter.java | 25 +++++++++++++++ .../service/FAQService.java | 5 +++ .../service/FAQServiceImpl.java | 15 +++++++++ 8 files changed, 172 insertions(+) create mode 100644 spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/Application.java create mode 100644 spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/controller/FAQController.java create mode 100644 spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/controller/Ping.java create mode 100644 spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/FilterRegistrationConfig.java create mode 100644 spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java create mode 100644 spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/LogFilter.java create mode 100644 spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/service/FAQService.java create mode 100644 spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/service/FAQServiceImpl.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/Application.java b/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/Application.java new file mode 100644 index 0000000000..4fb6938694 --- /dev/null +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/Application.java @@ -0,0 +1,17 @@ +package com.baeldung.exclude_urls_filter; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@ComponentScan(basePackages = "com.baeldung.exclude_urls_filter") +@Configuration +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/controller/FAQController.java b/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/controller/FAQController.java new file mode 100644 index 0000000000..1463af6bfd --- /dev/null +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/controller/FAQController.java @@ -0,0 +1,32 @@ +package com.baeldung.exclude_urls_filter.controller; + +import com.baeldung.exclude_urls_filter.service.FAQService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class FAQController { + + private final FAQService faqService; + + @Autowired + public FAQController(FAQService faqService) { + this.faqService = faqService; + } + + @RequestMapping(value = "/faq/helpline", method = RequestMethod.GET) + public ResponseEntity getHelpLineNumber() { + String helplineNumber = faqService.getHelpLineNumber(); + if (helplineNumber != null) { + return new ResponseEntity(helplineNumber, HttpStatus.OK); + } else { + return new ResponseEntity("Unavailable", HttpStatus.NOT_FOUND); + } + } + + +} diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/controller/Ping.java b/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/controller/Ping.java new file mode 100644 index 0000000000..c8a0723ba6 --- /dev/null +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/controller/Ping.java @@ -0,0 +1,22 @@ +package com.baeldung.exclude_urls_filter.controller; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class Ping { + + @RequestMapping(value = "/health", method = RequestMethod.GET) + public ResponseEntity pingGet() { + return new ResponseEntity("pong", HttpStatus.OK); + } + + @RequestMapping(value = "/health", method = RequestMethod.POST) + public ResponseEntity pingPost() { + return new ResponseEntity("pong", HttpStatus.OK); + } + +} diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/FilterRegistrationConfig.java b/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/FilterRegistrationConfig.java new file mode 100644 index 0000000000..ff99b4cc25 --- /dev/null +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/FilterRegistrationConfig.java @@ -0,0 +1,26 @@ +package com.baeldung.exclude_urls_filter.filter; + +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class FilterRegistrationConfig { + + @Bean + public FilterRegistrationBean logFilter() { + FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); + registrationBean.setFilter(new LogFilter()); + registrationBean.addUrlPatterns("/health", "/faq/*"); + return registrationBean; + } + + + @Bean + public FilterRegistrationBean headerValidatorFilter() { + FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); + registrationBean.setFilter(new HeaderValidatorFilter()); + registrationBean.addUrlPatterns("*"); + return registrationBean; + } +} \ No newline at end of file diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java b/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java new file mode 100644 index 0000000000..2af90badae --- /dev/null +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java @@ -0,0 +1,30 @@ +package com.baeldung.exclude_urls_filter.filter; + +import org.springframework.core.annotation.Order; +import org.springframework.http.HttpStatus; +import org.springframework.web.filter.OncePerRequestFilter; + +import javax.servlet.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Order(1) +public class HeaderValidatorFilter extends OncePerRequestFilter { + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) + throws ServletException, IOException { + String path = request.getRequestURI(); + if ("/health".equals(path)) { + filterChain.doFilter(request, response); + return; + } + String countryCode = request.getHeader("X-Country-Code"); + if (!"US".equals(countryCode)) { + response.sendError(HttpStatus.BAD_REQUEST.value(), "Invalid Locale"); + return; + } + + filterChain.doFilter(request, response); + } +} \ No newline at end of file diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/LogFilter.java b/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/LogFilter.java new file mode 100644 index 0000000000..fcde4f7f8f --- /dev/null +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/LogFilter.java @@ -0,0 +1,25 @@ +package com.baeldung.exclude_urls_filter.filter; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.annotation.Order; +import org.springframework.web.filter.OncePerRequestFilter; + +import javax.servlet.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Order(1) +public class LogFilter extends OncePerRequestFilter { + private final Logger logger = LoggerFactory.getLogger(LogFilter.class); + + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, + FilterChain filterChain) throws ServletException, IOException { + String path = request.getRequestURI(); + String contentType = request.getContentType(); + logger.info("Request URL path : {}, Request content type: {}", path, contentType); + filterChain.doFilter(request, response); + } +} \ No newline at end of file diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/service/FAQService.java b/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/service/FAQService.java new file mode 100644 index 0000000000..a2949ea0a2 --- /dev/null +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/service/FAQService.java @@ -0,0 +1,5 @@ +package com.baeldung.exclude_urls_filter.service; + +public interface FAQService { + String getHelpLineNumber(); +} \ No newline at end of file diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/service/FAQServiceImpl.java b/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/service/FAQServiceImpl.java new file mode 100644 index 0000000000..6f841e4ec1 --- /dev/null +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/service/FAQServiceImpl.java @@ -0,0 +1,15 @@ +package com.baeldung.exclude_urls_filter.service; + +import org.springframework.stereotype.Service; + +@Service +public class FAQServiceImpl implements FAQService { + + private static final String HELPLINE_NUMBER = "+1 888-777-66"; + + @Override + public String getHelpLineNumber() { + return HELPLINE_NUMBER; + } + +} From e6b5f14c49f44434767a357bbb0f7c445959edd3 Mon Sep 17 00:00:00 2001 From: Sjmillington Date: Thu, 3 Oct 2019 16:21:23 +0100 Subject: [PATCH 37/55] Add readme descriptions 24 --- algorithms-miscellaneous-3/README.md | 6 ++++++ algorithms-sorting/README.md | 6 +++++- animal-sniffer-mvn-plugin/README.md | 6 +++++- annotations/{readme.md => README.md} | 5 +++++ antlr/README.md | 4 ++++ apache-avro/README.md | 4 ++++ apache-bval/README.md | 5 +++++ apache-curator/README.md | 4 ++++ apache-cxf/README.md | 4 ++++ apache-fop/README.md | 4 ++-- 10 files changed, 44 insertions(+), 4 deletions(-) rename annotations/{readme.md => README.md} (66%) diff --git a/algorithms-miscellaneous-3/README.md b/algorithms-miscellaneous-3/README.md index d2d73ec8a1..9748595a34 100644 --- a/algorithms-miscellaneous-3/README.md +++ b/algorithms-miscellaneous-3/README.md @@ -1,3 +1,8 @@ +## Algorithms - Miscellaneous + +This module contains articles about algorithms. Some classes of algorithms, e.g., [sorting](/algorithms-sorting) and +[genetic algorithms](/algorithms-genetic), have their own dedicated modules. + ## Relevant Articles: - [Java Two Pointer Technique](https://www.baeldung.com/java-two-pointer-technique) @@ -9,3 +14,4 @@ - [A Guide to the Folding Technique in Java](https://www.baeldung.com/folding-hashing-technique) - [Creating a Triangle with for Loops in Java](https://www.baeldung.com/java-print-triangle) - [Efficient Word Frequency Calculator in Java](https://www.baeldung.com/java-word-frequency) +- More articles: [[<-- prev]](/algorithms-miscellaneous-2) [[next -->]](/algorithms-miscellaneous-4) \ No newline at end of file diff --git a/algorithms-sorting/README.md b/algorithms-sorting/README.md index 903865046a..f19705f113 100644 --- a/algorithms-sorting/README.md +++ b/algorithms-sorting/README.md @@ -1,4 +1,8 @@ -## Relevant articles: +## Algorithms - Sorting + +This module contains articles about sorting algorithms. + +### Relevant articles: - [Bubble Sort in Java](https://www.baeldung.com/java-bubble-sort) - [Merge Sort in Java](https://www.baeldung.com/java-merge-sort) diff --git a/animal-sniffer-mvn-plugin/README.md b/animal-sniffer-mvn-plugin/README.md index e292fe29ca..52e319b399 100644 --- a/animal-sniffer-mvn-plugin/README.md +++ b/animal-sniffer-mvn-plugin/README.md @@ -1,3 +1,7 @@ -## Relevant articles: +## Animal Sniffer Maven Plugin + +This module contains articles about the Animal Sniffer Maven Plugin + +### Relevant articles: [Introduction to Animal Sniffer Maven Plugin](https://www.baeldung.com/maven-animal-sniffer) diff --git a/annotations/readme.md b/annotations/README.md similarity index 66% rename from annotations/readme.md rename to annotations/README.md index dc40a7e116..ec4005fc5e 100644 --- a/annotations/readme.md +++ b/annotations/README.md @@ -1,2 +1,7 @@ +## Annotations + +This module contains articles about Java annotations + ### Relevant Articles: + - [Java Annotation Processing and Creating a Builder](https://www.baeldung.com/java-annotation-processing-builder) diff --git a/antlr/README.md b/antlr/README.md index b6dac4aa4b..1f394125c6 100644 --- a/antlr/README.md +++ b/antlr/README.md @@ -1,3 +1,7 @@ +## ANTLR + +This module contains articles about ANTLR + ### Relevant Articles: - [Java with ANTLR](https://www.baeldung.com/java-antlr) diff --git a/apache-avro/README.md b/apache-avro/README.md index 45ae6e2b9b..b338e8e565 100644 --- a/apache-avro/README.md +++ b/apache-avro/README.md @@ -1,2 +1,6 @@ +## Apache Avro + +This module contains articles about Apache Avro + ### Relevant Articles: - [Guide to Apache Avro](https://www.baeldung.com/java-apache-avro) diff --git a/apache-bval/README.md b/apache-bval/README.md index a9b3979828..e856810378 100644 --- a/apache-bval/README.md +++ b/apache-bval/README.md @@ -1,2 +1,7 @@ +## Apache BVal + +This module contains articles about Apache BVal + ### Relevant Articles: + - [Intro to Apache BVal](https://www.baeldung.com/apache-bval) diff --git a/apache-curator/README.md b/apache-curator/README.md index 30336d7cdc..4fef6a138e 100644 --- a/apache-curator/README.md +++ b/apache-curator/README.md @@ -1,3 +1,7 @@ +## Apache Curator + +This module contains articles about Apache Curator + ### Relevant Articles: - [Introduction to Apache Curator](https://www.baeldung.com/apache-curator) diff --git a/apache-cxf/README.md b/apache-cxf/README.md index 87413df8c9..f825b85bb3 100644 --- a/apache-cxf/README.md +++ b/apache-cxf/README.md @@ -1,3 +1,7 @@ +## Apache CXF + +This module contains articles about Apache CXF + ## Relevant Articles: - [Introduction to Apache CXF Aegis Data Binding](https://www.baeldung.com/aegis-data-binding-in-apache-cxf) - [Apache CXF Support for RESTful Web Services](https://www.baeldung.com/apache-cxf-rest-api) diff --git a/apache-fop/README.md b/apache-fop/README.md index 1e734a5f36..2adc593026 100644 --- a/apache-fop/README.md +++ b/apache-fop/README.md @@ -1,5 +1,5 @@ -========= +## Apache FOP -## Core Java Cookbooks and Examples +This module contains articles about Apache FOP ### Relevant Articles: From 6be36874d9b3c0016b2be3c1c8b92a68c5c68d33 Mon Sep 17 00:00:00 2001 From: Alessio Stalla Date: Thu, 3 Oct 2019 17:54:31 +0200 Subject: [PATCH 38/55] #BAEL-17523 add README descriptions --- lagom/README.md | 19 ++++++++++--------- libraries-apache-commons/README.md | 4 ++++ libraries-data-2/README.md | 5 +++++ libraries-data/README.md | 5 +++++ libraries-http/README.md | 3 +++ libraries-security/README.md | 4 ++++ libraries-server/README.md | 6 +++++- libraries-testing/README.md | 4 ++++ linkrest/README.md | 6 +++++- logging-modules/README.md | 3 ++- 10 files changed, 47 insertions(+), 12 deletions(-) diff --git a/lagom/README.md b/lagom/README.md index a8070c047c..1453b511e8 100644 --- a/lagom/README.md +++ b/lagom/README.md @@ -1,11 +1,12 @@ +## Lagom + +This module contains articles about the Lagom framework. + ### Relevant articles - [Guide to Reactive Microservices Using Lagom Framework](https://www.baeldung.com/lagom-reactive-microservices) - - - -Steps to setup from scratch +### Steps to setup from scratch 1) Create sbt build file "build.sbt" 2) Create plugins file project/plugins.sbt @@ -35,13 +36,13 @@ Steps to setup from scratch 10) Run project: sbt lagom:runAll -Sample Run: -curl http://localhost:9000/api/greeting/Nikhil; +### Sample Run: +``` +$ curl http://localhost:9000/api/greeting/Nikhil; Hello Nikhil! Today's weather stats: Going to be very humid, Take Water -curl http://localhost:9000/api/greeting/Nikhil; +$ curl http://localhost:9000/api/greeting/Nikhil; Hello Again Nikhil! Today's weather stats: Going to Rain, Take Umbrella - - +``` diff --git a/libraries-apache-commons/README.md b/libraries-apache-commons/README.md index 7d1f5b8333..439587266b 100644 --- a/libraries-apache-commons/README.md +++ b/libraries-apache-commons/README.md @@ -1,3 +1,7 @@ +## Apache Commons + +This module contains articles about Apache Commons libraries. + ### Relevant articles - [Array Processing with Apache Commons Lang 3](https://www.baeldung.com/array-processing-commons-lang) diff --git a/libraries-data-2/README.md b/libraries-data-2/README.md index ae113e7f70..25d9fe177e 100644 --- a/libraries-data-2/README.md +++ b/libraries-data-2/README.md @@ -1,3 +1,7 @@ +## Data Libraries + +This module contains articles about libraries for data processing in Java. + ### Relevant articles - [Introduction to Apache Flink with Java](https://www.baeldung.com/apache-flink) - [Guide to the HyperLogLog Algorithm](https://www.baeldung.com/java-hyperloglog) @@ -8,4 +12,5 @@ - [Introduction To OpenCSV](https://www.baeldung.com/opencsv) - [Introduction to Smooks](https://www.baeldung.com/smooks) - [A Guide to Infinispan in Java](https://www.baeldung.com/infinispan) +- More articles: [[<-- prev>]](/libraries-data) diff --git a/libraries-data/README.md b/libraries-data/README.md index e1d3c40222..be8f2b2525 100644 --- a/libraries-data/README.md +++ b/libraries-data/README.md @@ -1,3 +1,7 @@ +## Data Libraries + +This module contains articles about libraries for data processing in Java. + ### Relevant articles - [Introduction to Reladomo](https://www.baeldung.com/reladomo) - [Introduction to ORMLite](https://www.baeldung.com/ormlite) @@ -15,3 +19,4 @@ - [Introduction to Kafka Connectors](https://www.baeldung.com/kafka-connectors-guide) - [Kafka Connect Example with MQTT and MongoDB](https://www.baeldung.com/kafka-connect-mqtt-mongodb) - [Building a Data Pipeline with Flink and Kafka](https://www.baeldung.com/kafka-flink-data-pipeline) +- More articles: [[next -->]](/libraries-data-2) diff --git a/libraries-http/README.md b/libraries-http/README.md index 436268e707..f5afb2d277 100644 --- a/libraries-http/README.md +++ b/libraries-http/README.md @@ -1,3 +1,6 @@ +## HTTP + +This module contains articles about HTTP libraries. ### Relevant Articles: diff --git a/libraries-security/README.md b/libraries-security/README.md index 96f3fcdac6..68badcf12d 100644 --- a/libraries-security/README.md +++ b/libraries-security/README.md @@ -1,3 +1,7 @@ +## Security + +This module contains articles about security libraries. + ### Relevant Articles: - [Guide to ScribeJava](https://www.baeldung.com/scribejava) diff --git a/libraries-server/README.md b/libraries-server/README.md index 5245b98139..d9e6b8b206 100644 --- a/libraries-server/README.md +++ b/libraries-server/README.md @@ -1,4 +1,8 @@ -## Relevant Articles: +## Server + +This module contains articles about server libraries. + +### Relevant Articles: - [Embedded Jetty Server in Java](https://www.baeldung.com/jetty-embedded) - [Introduction to Netty](https://www.baeldung.com/netty) diff --git a/libraries-testing/README.md b/libraries-testing/README.md index 3f1904dc50..332debfe18 100644 --- a/libraries-testing/README.md +++ b/libraries-testing/README.md @@ -1,3 +1,7 @@ +## Testing + +This module contains articles about test libraries. + ### Relevant articles - [Introduction to Serenity BDD](https://www.baeldung.com/serenity-bdd) diff --git a/linkrest/README.md b/linkrest/README.md index 8297b14bb5..5402d9db96 100644 --- a/linkrest/README.md +++ b/linkrest/README.md @@ -1,3 +1,7 @@ -## Relevant articles: +## LinkRest + +This module contains articles about LinkRest. + +### Relevant articles: - [Guide to LinkRest](https://www.baeldung.com/linkrest) diff --git a/logging-modules/README.md b/logging-modules/README.md index f5a1acaac1..b763f6baaf 100644 --- a/logging-modules/README.md +++ b/logging-modules/README.md @@ -1,6 +1,7 @@ - ## Logging Modules +This module contains articles about logging libraries. + ### Relevant Articles: - [Creating a Custom Logback Appender](https://www.baeldung.com/custom-logback-appender) From b36f5ef72f64c7fc36970cfbaf7d2a80f545a429 Mon Sep 17 00:00:00 2001 From: Sam Millington Date: Fri, 4 Oct 2019 06:34:10 +0100 Subject: [PATCH 39/55] [BAEL-17476] Add README descriptions 25 (#7911) --- apache-geode/README.md | 4 ++++ apache-meecrowave/README.md | 8 ++++++-- apache-olingo/README.md | 6 +++++- apache-opennlp/README.md | 4 ++++ apache-poi/README.md | 4 ++++ apache-pulsar/README.md | 4 ++++ apache-shiro/README.md | 9 +++++++-- apache-solrj/README.md | 9 ++++++--- apache-spark/README.md | 6 +++++- apache-thrift/README.md | 6 +++++- 10 files changed, 50 insertions(+), 10 deletions(-) diff --git a/apache-geode/README.md b/apache-geode/README.md index 2f04418825..86629f7a82 100644 --- a/apache-geode/README.md +++ b/apache-geode/README.md @@ -1,3 +1,7 @@ +## Apache Geode + +This module contains articles about Apache Geode + ### Relevant Articles: - [A Quick Guide to Apache Geode](https://www.baeldung.com/apache-geode) diff --git a/apache-meecrowave/README.md b/apache-meecrowave/README.md index 0dea60816b..d360af13af 100644 --- a/apache-meecrowave/README.md +++ b/apache-meecrowave/README.md @@ -1,3 +1,7 @@ +## Apache Meecrowave + +This module contains articles about Apache Meecrowave + ### Relevant Articles: -================================ -- [Building a Microservice with Apache Meecrowave](https://www.baeldung.com/apache-meecrowave) + +- [Building a Microservice with Apache Meecrowave](https://www.baeldung.com/apache-meecrowave) \ No newline at end of file diff --git a/apache-olingo/README.md b/apache-olingo/README.md index 22fa6b3b51..2f4e86d5a2 100644 --- a/apache-olingo/README.md +++ b/apache-olingo/README.md @@ -1,4 +1,8 @@ -## Relevant articles: +## Apache Olingo + +This module contains articles about Apache Olingo + +### Relevant articles: - [OData Protocol Guide](https://www.baeldung.com/odata) - [Intro to OData with Olingo](https://www.baeldung.com/olingo) diff --git a/apache-opennlp/README.md b/apache-opennlp/README.md index 006ca588f2..4b1fa36540 100644 --- a/apache-opennlp/README.md +++ b/apache-opennlp/README.md @@ -1,3 +1,7 @@ +## Apache OpenNLP + +This module contains articles about Apache OpenNLP + ### Relevant Articles - [Intro to Apache OpenNLP](https://www.baeldung.com/apache-open-nlp) diff --git a/apache-poi/README.md b/apache-poi/README.md index 8ffd8ef517..b7b8bf5f6a 100644 --- a/apache-poi/README.md +++ b/apache-poi/README.md @@ -1,3 +1,7 @@ +## Apache POI + +This module contains articles about Apache POI + ### Relevant Articles: - [Microsoft Word Processing in Java with Apache POI](https://www.baeldung.com/java-microsoft-word-with-apache-poi) - [Working with Microsoft Excel in Java](https://www.baeldung.com/java-microsoft-excel) diff --git a/apache-pulsar/README.md b/apache-pulsar/README.md index 2970bc3d88..c44849a490 100644 --- a/apache-pulsar/README.md +++ b/apache-pulsar/README.md @@ -1,3 +1,7 @@ +## Apache Pulsar + +This module contains articles about Apache Pulsar + ### Relevant Articles: - [Introduction to Apache Pulsar](https://www.baeldung.com/apache-pulsar) diff --git a/apache-shiro/README.md b/apache-shiro/README.md index 85f2a99a59..553eeecc69 100644 --- a/apache-shiro/README.md +++ b/apache-shiro/README.md @@ -1,2 +1,7 @@ -### Relevant articles -- [Introduction to Apache Shiro](https://www.baeldung.com/apache-shiro) +## Apache Shiro + +This module contains articles about Apache Shiro + +### Relevant articles: + +- [Introduction to Apache Shiro](https://www.baeldung.com/apache-shiro) \ No newline at end of file diff --git a/apache-solrj/README.md b/apache-solrj/README.md index 55f35b90a7..803db393e9 100644 --- a/apache-solrj/README.md +++ b/apache-solrj/README.md @@ -1,4 +1,7 @@ -## Apache Solrj Tutorials Project +## Apache Solrj -### Relevant Articles -- [Guide to Solr in Java with Apache Solrj](https://www.baeldung.com/apache-solrj) +This module contains articles about Apache Solrj + +### Relevant Articles: + +- [Guide to Solr in Java with Apache Solrj](https://www.baeldung.com/apache-solrj) \ No newline at end of file diff --git a/apache-spark/README.md b/apache-spark/README.md index a867fd57ff..360a18f095 100644 --- a/apache-spark/README.md +++ b/apache-spark/README.md @@ -1,4 +1,8 @@ -### Relevant articles +## Apache Spark + +This module contains articles about Apache Spark + +### Relevant articles: - [Introduction to Apache Spark](https://www.baeldung.com/apache-spark) - [Building a Data Pipeline with Kafka, Spark Streaming and Cassandra](https://www.baeldung.com/kafka-spark-data-pipeline) diff --git a/apache-thrift/README.md b/apache-thrift/README.md index b90192f342..4508939de6 100644 --- a/apache-thrift/README.md +++ b/apache-thrift/README.md @@ -1,3 +1,7 @@ -## Relevant articles: +## Apache Thrift + +This module contains articles about Apache Thrift + +### Relevant articles: - [Working with Apache Thrift](https://www.baeldung.com/apache-thrift) From f7e63a836b9d748e2adf7a1d3b31600f91ae691f Mon Sep 17 00:00:00 2001 From: Sam Millington Date: Fri, 4 Oct 2019 06:49:29 +0100 Subject: [PATCH 40/55] Add README descriptions 29 (#7923) * Add README descriptions 29 * Fixed collections-list links --- .../core-java-collections-array-list/README.md | 4 ++-- core-java-modules/core-java-collections-list-2/README.md | 7 ++++--- core-java-modules/core-java-collections-list-3/README.md | 5 +++-- core-java-modules/core-java-collections-list/README.md | 5 +++-- core-java-modules/core-java-collections-set/README.md | 4 ++-- core-java-modules/core-java-concurrency-basic/README.md | 5 +++-- .../core-java-concurrency-collections/README.md | 4 ++-- core-java-modules/core-java-io/README.md | 5 +++-- core-java-modules/core-java-nio/README.md | 4 ++++ core-java-modules/core-java-security/README.md | 2 ++ 10 files changed, 28 insertions(+), 17 deletions(-) diff --git a/core-java-modules/core-java-collections-array-list/README.md b/core-java-modules/core-java-collections-array-list/README.md index 3d1cdd5085..4423a77c78 100644 --- a/core-java-modules/core-java-collections-array-list/README.md +++ b/core-java-modules/core-java-collections-array-list/README.md @@ -1,6 +1,6 @@ -========= +## Core Java Collections ArrayList -## Core Java Collections Array List Cookbooks and Examples +This module contains articles about the Java ArrayList collection ### Relevant Articles: - [Immutable ArrayList in Java](http://www.baeldung.com/java-immutable-list) diff --git a/core-java-modules/core-java-collections-list-2/README.md b/core-java-modules/core-java-collections-list-2/README.md index 6192442edd..fada9d96ac 100644 --- a/core-java-modules/core-java-collections-list-2/README.md +++ b/core-java-modules/core-java-collections-list-2/README.md @@ -1,6 +1,6 @@ -========= +## Core Java Collections List (Part 2) -## Core Java Collections List Cookbooks and Examples +This module contains articles about the Java List collection ### Relevant Articles: - [Check If Two Lists are Equal in Java](http://www.baeldung.com/java-test-a-list-for-ordinality-and-equality) @@ -10,4 +10,5 @@ - [Java List Initialization in One Line](https://www.baeldung.com/java-init-list-one-line) - [Ways to Iterate Over a List in Java](https://www.baeldung.com/java-iterate-list) - [Flattening Nested Collections in Java](http://www.baeldung.com/java-flatten-nested-collections) -- [Intersection of Two Lists in Java](https://www.baeldung.com/java-lists-intersection) \ No newline at end of file +- [Intersection of Two Lists in Java](https://www.baeldung.com/java-lists-intersection) +- [[<-- Prev]](/core-java-modules/core-java-collections-list)[[Next -->]](/core-java-modules/core-java-collections-list-3) \ No newline at end of file diff --git a/core-java-modules/core-java-collections-list-3/README.md b/core-java-modules/core-java-collections-list-3/README.md index 267996044c..3d4004de6f 100644 --- a/core-java-modules/core-java-collections-list-3/README.md +++ b/core-java-modules/core-java-collections-list-3/README.md @@ -1,6 +1,6 @@ -========= +## Core Java Collections List (Part 3) -## Core Java Collections List Cookbooks and Examples +This module contains articles about the Java List collection ### Relevant Articles: - [Collections.emptyList() vs. New List Instance](https://www.baeldung.com/java-collections-emptylist-new-list) @@ -9,3 +9,4 @@ - [List of Primitive Integer Values in Java](https://www.baeldung.com/java-list-primitive-int) - [Performance Comparison of Primitive Lists in Java](https://www.baeldung.com/java-list-primitive-performance) - [Filtering a Java Collection by a List](https://www.baeldung.com/java-filter-collection-by-list) +- [[<-- Prev]](/core-java-modules/core-java-collections-list-2) diff --git a/core-java-modules/core-java-collections-list/README.md b/core-java-modules/core-java-collections-list/README.md index 367f62780d..ff7a9876a2 100644 --- a/core-java-modules/core-java-collections-list/README.md +++ b/core-java-modules/core-java-collections-list/README.md @@ -1,6 +1,6 @@ -========= +## Core Java Collections List -## Core Java Collections List Cookbooks and Examples +This module contains articles about the Java List collection ### Relevant Articles: - [Java – Get Random Item/Element From a List](http://www.baeldung.com/java-random-list-element) @@ -12,3 +12,4 @@ - [How to Find an Element in a List with Java](http://www.baeldung.com/find-list-element-java) - [Finding Max/Min of a List or Collection](http://www.baeldung.com/java-collection-min-max) - [Remove All Occurrences of a Specific Value from a List](https://www.baeldung.com/java-remove-value-from-list) +- [[Next -->]](/core-java-modules/core-java-collections-list-2) diff --git a/core-java-modules/core-java-collections-set/README.md b/core-java-modules/core-java-collections-set/README.md index 618b4e932c..2b34ef3449 100644 --- a/core-java-modules/core-java-collections-set/README.md +++ b/core-java-modules/core-java-collections-set/README.md @@ -1,6 +1,6 @@ -========= +## Core Java Collections Set -## Core Java Sets Cookbooks and Examples +This module contains articles about the Java Set collection ### Relevant Articles: - [Set Operations in Java](http://www.baeldung.com/set-operations-in-java) diff --git a/core-java-modules/core-java-concurrency-basic/README.md b/core-java-modules/core-java-concurrency-basic/README.md index 2f9d014103..846687b8dd 100644 --- a/core-java-modules/core-java-concurrency-basic/README.md +++ b/core-java-modules/core-java-concurrency-basic/README.md @@ -1,6 +1,6 @@ -========= +## Core Java Concurrency Basic -## Core Java Concurrency Basic Examples +This module contains articles about basic Java concurrency ### Relevant Articles: - [Guide To CompletableFuture](https://www.baeldung.com/java-completablefuture) @@ -13,3 +13,4 @@ - [Runnable vs. Callable in Java](https://www.baeldung.com/java-runnable-callable) - [What is Thread-Safety and How to Achieve it?](https://www.baeldung.com/java-thread-safety) - [How to Start a Thread in Java](https://www.baeldung.com/java-start-thread) +- [[Next -->]](/core-java-modules/core-java-concurrency-basic-2) diff --git a/core-java-modules/core-java-concurrency-collections/README.md b/core-java-modules/core-java-concurrency-collections/README.md index b982a91861..80a21ee533 100644 --- a/core-java-modules/core-java-concurrency-collections/README.md +++ b/core-java-modules/core-java-concurrency-collections/README.md @@ -1,6 +1,6 @@ -========= +## Core Java Concurrency Collections -## Core Java Concurrency Collections Examples +This module contains articles about concurrent Java collections ### Relevant Articles: - [Guide to java.util.concurrent.BlockingQueue](http://www.baeldung.com/java-blocking-queue) diff --git a/core-java-modules/core-java-io/README.md b/core-java-modules/core-java-io/README.md index 6737ad6eb9..023d7d64b5 100644 --- a/core-java-modules/core-java-io/README.md +++ b/core-java-modules/core-java-io/README.md @@ -1,6 +1,6 @@ -========= +## Core Java IO -## Core Java IO Cookbooks and Examples +This module contains articles about core Java input and output (IO) ### Relevant Articles: - [How to Read a Large File Efficiently with Java](http://www.baeldung.com/java-read-lines-large-file) @@ -41,3 +41,4 @@ - [List Files in a Directory in Java](https://www.baeldung.com/java-list-directory-files) - [Java InputStream to Byte Array and ByteBuffer](https://www.baeldung.com/convert-input-stream-to-array-of-bytes) - [Introduction to the Java NIO Selector](https://www.baeldung.com/java-nio-selector) +- [[More -->]](/core-java-modules/core-java-io-2) diff --git a/core-java-modules/core-java-nio/README.md b/core-java-modules/core-java-nio/README.md index 1ac3b6c089..efa58671b5 100644 --- a/core-java-modules/core-java-nio/README.md +++ b/core-java-modules/core-java-nio/README.md @@ -1,3 +1,7 @@ +## Core Java NIO + +This module contains articles about core Java non-blocking input and output (IO) + ## Relevant Articles: - [Determine File Creation Date in Java](https://www.baeldung.com/java-file-creation-date) diff --git a/core-java-modules/core-java-security/README.md b/core-java-modules/core-java-security/README.md index 00449575b0..48fd071396 100644 --- a/core-java-modules/core-java-security/README.md +++ b/core-java-modules/core-java-security/README.md @@ -1,5 +1,7 @@ ## Core Java Security +This module contains articles about core Java Security + ### Relevant Articles: - [MD5 Hashing in Java](http://www.baeldung.com/java-md5) - [Guide to the Cipher Class](http://www.baeldung.com/java-cipher-class) From 416b6c7e1ebc729af417390ec6b0855dabe85e79 Mon Sep 17 00:00:00 2001 From: Josh Cummings Date: Fri, 4 Oct 2019 00:18:16 -0600 Subject: [PATCH 41/55] Update README.md --- spring-5-reactive/README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spring-5-reactive/README.md b/spring-5-reactive/README.md index 2190258981..41d831632a 100644 --- a/spring-5-reactive/README.md +++ b/spring-5-reactive/README.md @@ -17,9 +17,4 @@ The "REST With Spring" Classes: https://bit.ly/restwithspring - [Handling Errors in Spring WebFlux](https://www.baeldung.com/spring-webflux-errors) - [Server-Sent Events in Spring](https://www.baeldung.com/spring-server-sent-events) - [A Guide to Spring Session Reactive Support: WebSession](https://www.baeldung.com/spring-session-reactive) -- [Validation for Functional Endpoints in Spring 5](https://www.baeldung.com/spring-functional-endpoints-validation) -- [Logging a Reactive Sequence](https://www.baeldung.com/spring-reactive-sequence-logging) -- [Testing Reactive Streams Using StepVerifier and TestPublisher](https://www.baeldung.com/reactive-streams-step-verifier-test-publisher) -- [Debugging Reactive Streams in Spring 5](https://www.baeldung.com/spring-debugging-reactive-streams) -- [Static Content in Spring WebFlux](https://www.baeldung.com/spring-webflux-static-content) - More articles: [[next -->]](/spring-5-reactive-2) From 7490fb6aed5d64a94194b031568ca9b042049f74 Mon Sep 17 00:00:00 2001 From: Sam Millington Date: Fri, 4 Oct 2019 07:52:16 +0100 Subject: [PATCH 42/55] Add README descriptions 27 (#7913) --- azure/README.md | 4 ++++ bazel/README.md | 6 +++++- bootique/README.md | 4 ++++ cas/README.md | 7 +++++++ cdi/README.md | 4 ++++ checker-plugin/README.md | 4 ++++ cloud-foundry-uaa/README.md | 6 +++++- core-groovy-2/README.md | 5 ++++- core-groovy/README.md | 5 ++++- 9 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 cas/README.md diff --git a/azure/README.md b/azure/README.md index 3c70622b85..4da8481502 100644 --- a/azure/README.md +++ b/azure/README.md @@ -1,3 +1,7 @@ +## Azure + +This module contains articles about Azure + ### Relevant Articles: - [Deploy a Spring Boot App to Azure](https://www.baeldung.com/spring-boot-azure) diff --git a/bazel/README.md b/bazel/README.md index d1f8f1af5b..af4f901f49 100644 --- a/bazel/README.md +++ b/bazel/README.md @@ -1,3 +1,7 @@ -## Relevant Articles: +## Bazel + +This module contains articles about Bazel + +### Relevant Articles: - [Building Java Applications with Bazel](https://www.baeldung.com/bazel-build-tool) diff --git a/bootique/README.md b/bootique/README.md index beb61c2a78..0d4076201e 100644 --- a/bootique/README.md +++ b/bootique/README.md @@ -1,2 +1,6 @@ +## Bootique + +This module contains articles about Bootique + ### Relevant Articles: - [Introduction to Bootique](https://www.baeldung.com/bootique) diff --git a/cas/README.md b/cas/README.md new file mode 100644 index 0000000000..16775a8a02 --- /dev/null +++ b/cas/README.md @@ -0,0 +1,7 @@ +## CAS + +This module contains articles about the Central Authentication Service (CAS) + +### Relevant Articles: + +- [CAS SSO With Spring Security](baeldung.com/spring-security-cas-sso) \ No newline at end of file diff --git a/cdi/README.md b/cdi/README.md index 69ce285d7b..13169698a2 100644 --- a/cdi/README.md +++ b/cdi/README.md @@ -1,3 +1,7 @@ +## CDI + +This module contains articles about Contexts and Dependency Injection (CDI) + ### Relevant Articles: - [CDI Interceptor vs Spring AspectJ](https://www.baeldung.com/cdi-interceptor-vs-spring-aspectj) - [An Introduction to CDI (Contexts and Dependency Injection) in Java](https://www.baeldung.com/java-ee-cdi) diff --git a/checker-plugin/README.md b/checker-plugin/README.md index 5c73b86f91..59dc2878a2 100644 --- a/checker-plugin/README.md +++ b/checker-plugin/README.md @@ -1,3 +1,7 @@ +## Checker Plugin + +This module contains articles about the Checker Plugin + ### Relevant articles - [The Checker Framework – Pluggable Type Systems for Java](https://www.baeldung.com/checker-framework) diff --git a/cloud-foundry-uaa/README.md b/cloud-foundry-uaa/README.md index b2f382cad1..f7707a04e2 100644 --- a/cloud-foundry-uaa/README.md +++ b/cloud-foundry-uaa/README.md @@ -1,3 +1,7 @@ -### Revelant Articles +## Cloud Foundry UAA + +This module contains articles about Cloud Foundry UAA + +### Relevant Articles: - [A Quick Guide To Using Cloud Foundry UAA](https://www.baeldung.com/cloud-foundry-uaa) diff --git a/core-groovy-2/README.md b/core-groovy-2/README.md index 1dbfbd07a5..6359592da6 100644 --- a/core-groovy-2/README.md +++ b/core-groovy-2/README.md @@ -1,4 +1,6 @@ -# Groovy +# Core Groovy 2 + +This module contains articles about core Groovy concepts ## Relevant articles: @@ -9,3 +11,4 @@ - [Integrating Groovy into Java Applications](https://www.baeldung.com/groovy-java-applications) - [Concatenate Strings with Groovy](https://www.baeldung.com/groovy-concatenate-strings) - [Metaprogramming in Groovy](https://www.baeldung.com/groovy-metaprogramming) +- [[<-- Prev]](/core-groovy) \ No newline at end of file diff --git a/core-groovy/README.md b/core-groovy/README.md index 2e62884b1f..0f45eed879 100644 --- a/core-groovy/README.md +++ b/core-groovy/README.md @@ -1,4 +1,6 @@ -# Groovy +# Core Groovy + +This module contains articles about core Groovy concepts ## Relevant articles: @@ -13,3 +15,4 @@ - [Lists in Groovy](https://www.baeldung.com/groovy-lists) - [Converting a String to a Date in Groovy](https://www.baeldung.com/groovy-string-to-date) - [Guide to I/O in Groovy](https://www.baeldung.com/groovy-io) +- [[More -->]](/core-groovy-2) \ No newline at end of file From 0f64304c34e324c70fb6c853de01ac8508eb4fe5 Mon Sep 17 00:00:00 2001 From: Alessio Stalla Date: Fri, 4 Oct 2019 08:52:25 +0200 Subject: [PATCH 43/55] #BAEL-17519 add README descriptions (#7935) --- java-ee-8-security-api/README.md | 4 ++++ java-jdi/README.md | 7 +++++++ java-lite/README.md | 4 ++++ java-math/README.md | 6 +++++- java-numbers-2/README.md | 7 ++++++- java-numbers/README.md | 5 +++-- java-rmi/README.md | 4 ++++ java-spi/README.md | 3 +++ java-streams-2/README.md | 5 +++++ java-streams/README.md | 5 +++-- 10 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 java-jdi/README.md diff --git a/java-ee-8-security-api/README.md b/java-ee-8-security-api/README.md index 5ecce2b4cc..b01a073e35 100644 --- a/java-ee-8-security-api/README.md +++ b/java-ee-8-security-api/README.md @@ -1,3 +1,7 @@ +## Java EE 8 Security API + +This module contains articles about the Security API in Java EE 8. + ### Relevant articles - [Java EE 8 Security API](https://www.baeldung.com/java-ee-8-security) diff --git a/java-jdi/README.md b/java-jdi/README.md new file mode 100644 index 0000000000..c8c2d3e9ab --- /dev/null +++ b/java-jdi/README.md @@ -0,0 +1,7 @@ +## Java JDI + +This module contains articles about JDI, the Java Debug Interface. + +###Relevant articles + +- [An Intro to the Java Debug Interface (JDI)](https://www.baeldung.com/java-debug-interface) diff --git a/java-lite/README.md b/java-lite/README.md index 5221b832f9..96fb6f1a93 100644 --- a/java-lite/README.md +++ b/java-lite/README.md @@ -1,3 +1,7 @@ +## JavaLite + +This module contains articles about JavaLite. + ### Relevant Articles: - [A Guide to JavaLite – Building a RESTful CRUD application](https://www.baeldung.com/javalite-rest) diff --git a/java-math/README.md b/java-math/README.md index b0921e55ae..49ff5afde1 100644 --- a/java-math/README.md +++ b/java-math/README.md @@ -1,4 +1,8 @@ -## Relevant articles: +## Java Math + +This module contains articles about math in Java. + +### Relevant articles: - [Calculate Factorial in Java](https://www.baeldung.com/java-calculate-factorial) - [Generate Combinations in Java](https://www.baeldung.com/java-combinations-algorithm) diff --git a/java-numbers-2/README.md b/java-numbers-2/README.md index 5c6f46b05b..48f9acd32d 100644 --- a/java-numbers-2/README.md +++ b/java-numbers-2/README.md @@ -1,4 +1,8 @@ -## Relevant Articles +## Java Number Cookbooks and Examples + +This module contains articles about numbers in Java. + +### Relevant Articles - [Lossy Conversion in Java](https://www.baeldung.com/java-lossy-conversion) - [A Guide to the Java Math Class](https://www.baeldung.com/java-lang-math) - [Calculate the Area of a Circle in Java](https://www.baeldung.com/java-calculate-circle-area) @@ -9,3 +13,4 @@ - [Binary Numbers in Java](https://www.baeldung.com/java-binary-numbers) - [Finding the Least Common Multiple in Java](https://www.baeldung.com/java-least-common-multiple) - [Binary Numbers in Java](https://www.baeldung.com/java-binary-numbers) +- More articles: [[<-- prev]](/../java-numbers) diff --git a/java-numbers/README.md b/java-numbers/README.md index 7885232c46..eee6fceab1 100644 --- a/java-numbers/README.md +++ b/java-numbers/README.md @@ -1,7 +1,7 @@ -========= - ## Java Number Cookbooks and Examples +This module contains articles about numbers in Java. + ### Relevant Articles: - [Number of Digits in an Integer in Java](http://www.baeldung.com/java-number-of-digits-in-int) - [How to Round a Number to N Decimal Places in Java](http://www.baeldung.com/java-round-decimal-number) @@ -13,3 +13,4 @@ - [Calculating the nth Root in Java](https://www.baeldung.com/java-nth-root) - [Convert Double to String, Removing Decimal Places](https://www.baeldung.com/java-double-to-string) - [Changing the Order in a Sum Operation Can Produce Different Results?](https://www.baeldung.com/java-floating-point-sum-order) +- More articles: [[next -->]](/../java-numbers-2) diff --git a/java-rmi/README.md b/java-rmi/README.md index 201c4c8e66..244f986639 100644 --- a/java-rmi/README.md +++ b/java-rmi/README.md @@ -1,3 +1,7 @@ +## Java RMI + +This module contains articles about RMI (Remote Method Invocation) in Java. + ### Relevant articles - [Getting Started with Java RMI](https://www.baeldung.com/java-rmi) diff --git a/java-spi/README.md b/java-spi/README.md index 25e2d10da4..2ccef98a10 100644 --- a/java-spi/README.md +++ b/java-spi/README.md @@ -1,3 +1,6 @@ +## Java SPI + +This module contains articles about the SPI (Service Provider Interface) in Java. ### Relevant Articles: diff --git a/java-streams-2/README.md b/java-streams-2/README.md index 851d3d71e2..66fbe69ed4 100644 --- a/java-streams-2/README.md +++ b/java-streams-2/README.md @@ -1,4 +1,9 @@ +## Java Streams Cookbooks and Examples + +This module contains articles about the Stream API in Java. + ### Relevant Articles: - [Guide to Stream.reduce()](https://www.baeldung.com/java-stream-reduce) - [How to Break from Java Stream forEach](https://www.baeldung.com/java-break-stream-foreach) - [Java IntStream Conversions](https://www.baeldung.com/java-intstream-convert) +- More articles: [[<-- prev]](/java-streams) diff --git a/java-streams/README.md b/java-streams/README.md index 0d26c182ba..5c231f756f 100644 --- a/java-streams/README.md +++ b/java-streams/README.md @@ -1,7 +1,7 @@ -========= - ## Java Streams Cookbooks and Examples +This module contains articles about the Stream API in Java. + ### Relevant Articles: - [The Java 8 Stream API Tutorial](https://www.baeldung.com/java-8-streams) - [Introduction to Java 8 Streams](https://www.baeldung.com/java-8-streams-introduction) @@ -18,3 +18,4 @@ - [Counting Matches on a Stream Filter](https://www.baeldung.com/java-stream-filter-count) - [Java 8 Streams peek() API](https://www.baeldung.com/java-streams-peek-api) - [Working With Maps Using Streams](https://www.baeldung.com/java-maps-streams) +- More articles: [[next -->]](/../java-streams-2) From f17cb73647432ee67979f28dfb26049bbbbe5262 Mon Sep 17 00:00:00 2001 From: Alessio Stalla Date: Fri, 4 Oct 2019 08:52:53 +0200 Subject: [PATCH 44/55] #BAEL-17521 add README descriptions (#7937) --- jee-7-security/README.md | 4 ++++ jee-7/README.md | 4 ++++ jee-kotlin/README.md | 4 ++++ jersey/README.md | 5 +++++ jgit/README.md | 6 +++++- jgroups/README.md | 7 ++----- jhipster-5/README.md | 3 ++- jib/README.md | 4 ++++ jjwt/README.md | 1 + jmeter/README.md | 6 +++--- 10 files changed, 34 insertions(+), 10 deletions(-) diff --git a/jee-7-security/README.md b/jee-7-security/README.md index 70d451382c..ced2beec46 100644 --- a/jee-7-security/README.md +++ b/jee-7-security/README.md @@ -1,2 +1,6 @@ +## JEE 7 Security + +This module contains articles about security in JEE 7. + ### Relevant Articles: - [Securing Java EE with Spring Security](https://www.baeldung.com/java-ee-spring-security) diff --git a/jee-7/README.md b/jee-7/README.md index 2ae7335ce0..2c45fe2c67 100644 --- a/jee-7/README.md +++ b/jee-7/README.md @@ -1,3 +1,7 @@ +## JEE 7 + +This module contains articles about JEE 7. + ### Relevant Articles: - [Scheduling in Java EE](https://www.baeldung.com/scheduling-in-java-enterprise-edition) - [JSON Processing in Java EE 7](https://www.baeldung.com/jee7-json) diff --git a/jee-kotlin/README.md b/jee-kotlin/README.md index 43dcd992ca..aa3aa58b4e 100644 --- a/jee-kotlin/README.md +++ b/jee-kotlin/README.md @@ -1,2 +1,6 @@ +## JEE in Kotlin + +This module contains articles about Java EE with Kotlin. + ### Relevant Articles: - [Java EE Application with Kotlin](https://www.baeldung.com/java-ee-kotlin-app) diff --git a/jersey/README.md b/jersey/README.md index 1db89ec723..09de7051ca 100644 --- a/jersey/README.md +++ b/jersey/README.md @@ -1,3 +1,8 @@ +## Jersey + +This module contains articles about Jersey. + +### Relevant Articles - [Jersey Filters and Interceptors](https://www.baeldung.com/jersey-filters-interceptors) - [Jersey MVC Support](https://www.baeldung.com/jersey-mvc) - [Bean Validation in Jersey](https://www.baeldung.com/jersey-bean-validation) diff --git a/jgit/README.md b/jgit/README.md index d89104293d..b48f3c7a87 100644 --- a/jgit/README.md +++ b/jgit/README.md @@ -1,3 +1,7 @@ -## Relevant articles: +## JGit + +This module contains articles about JGit. + +### Relevant articles: - [A Guide to JGit](https://www.baeldung.com/jgit) diff --git a/jgroups/README.md b/jgroups/README.md index 128007bb7e..046ac89c1f 100644 --- a/jgroups/README.md +++ b/jgroups/README.md @@ -1,5 +1,7 @@ ## Reliable Messaging with JGroups Tutorial Project +This module contains articles about JGroups. + ### Relevant Article: - [Reliable Messaging with JGroups](https://www.baeldung.com/jgroups) @@ -8,8 +10,3 @@ This Maven project contains the Java code for the article linked above. ### Package Organization Java classes for the intro tutorial are in the org.baeldung.jgroups package. - - -### Running the tests - -``` diff --git a/jhipster-5/README.md b/jhipster-5/README.md index 2731281b3e..ba05641af0 100644 --- a/jhipster-5/README.md +++ b/jhipster-5/README.md @@ -1,2 +1,3 @@ +## JHipster 5 -This is an aggregator module for JHipster 5 modules. +This module contains articles about JHipster 5. This is an aggregator module, articles are in the relevant submodules. diff --git a/jib/README.md b/jib/README.md index 82bd2fed42..e0ff7c4058 100644 --- a/jib/README.md +++ b/jib/README.md @@ -1,3 +1,7 @@ +## Jib + +This module contains articles about Jib. + ### Relevant Articles: - [Dockerizing Java Apps using Jib](https://www.baeldung.com/jib-dockerizing) diff --git a/jjwt/README.md b/jjwt/README.md index 04a85f3ded..25f5a8f6f0 100644 --- a/jjwt/README.md +++ b/jjwt/README.md @@ -1,5 +1,6 @@ ## JWT Fun +This module contains articles about JJWT. This tutorial walks you through the various features supported by the [JJWT](https://github.com/jwtk/jjwt) library - a fluent interface Java JWT building and parsing library. ### Build and Run diff --git a/jmeter/README.md b/jmeter/README.md index 58522067b2..81300afe7c 100644 --- a/jmeter/README.md +++ b/jmeter/README.md @@ -1,7 +1,7 @@ -BASIC CRUD API with Spring Boot -================================ +## JMeter -This is the code of a simple API for some CRUD operations build using Spring Boot. +This module contains articles about JMeter. +It contains the code of a simple API for some CRUD operations built using Spring Boot. ### Requirements From 8efd122412240e6038b3e0e0644c2fb6c1b5d223 Mon Sep 17 00:00:00 2001 From: catalin-burcea Date: Fri, 4 Oct 2019 10:13:23 +0300 Subject: [PATCH 45/55] rename jenkins/hello-world to jenkins/plugins --- jenkins/hello-world/README.md | 7 ------- jenkins/plugins/README.md | 7 +++++++ jenkins/{hello-world => plugins}/pom.xml | 4 ++-- .../java/com/baeldung/jenkins/plugins}/ProjectStats.java | 2 +- .../jenkins/plugins}/ProjectStatsBuildWrapper.java | 2 +- .../src/main/resources/logback.xml | 0 .../{hello-world => plugins}/src/main/resources/stats.html | 0 pom.xml | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) delete mode 100644 jenkins/hello-world/README.md create mode 100644 jenkins/plugins/README.md rename jenkins/{hello-world => plugins}/pom.xml (98%) rename jenkins/{hello-world/src/main/java/com/baeldung/jenkins/helloworld => plugins/src/main/java/com/baeldung/jenkins/plugins}/ProjectStats.java (90%) rename jenkins/{hello-world/src/main/java/com/baeldung/jenkins/helloworld => plugins/src/main/java/com/baeldung/jenkins/plugins}/ProjectStatsBuildWrapper.java (99%) rename jenkins/{hello-world => plugins}/src/main/resources/logback.xml (100%) rename jenkins/{hello-world => plugins}/src/main/resources/stats.html (100%) diff --git a/jenkins/hello-world/README.md b/jenkins/hello-world/README.md deleted file mode 100644 index 5f6b9f364a..0000000000 --- a/jenkins/hello-world/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## Jenkins Plugins - -This module contains articles about Jenkins plugins. - -### Relevant articles: - -- [Writing a Jenkins Plugin](http://www.baeldung.com/jenkins-custom-plugin) diff --git a/jenkins/plugins/README.md b/jenkins/plugins/README.md new file mode 100644 index 0000000000..cf7aa3dba8 --- /dev/null +++ b/jenkins/plugins/README.md @@ -0,0 +1,7 @@ +## Jenkins plugins + +This module contains articles about various Jenkins plugins. + +### Relevant articles: + +- [Writing a Jenkins Plugin](https://www.baeldung.com/jenkins-custom-plugin) diff --git a/jenkins/hello-world/pom.xml b/jenkins/plugins/pom.xml similarity index 98% rename from jenkins/hello-world/pom.xml rename to jenkins/plugins/pom.xml index f00a551173..1db7cec394 100644 --- a/jenkins/hello-world/pom.xml +++ b/jenkins/plugins/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - hello-world + plugins 1.0-SNAPSHOT - hello-world + plugins hpi A sample Jenkins Hello World plugin diff --git a/jenkins/hello-world/src/main/java/com/baeldung/jenkins/helloworld/ProjectStats.java b/jenkins/plugins/src/main/java/com/baeldung/jenkins/plugins/ProjectStats.java similarity index 90% rename from jenkins/hello-world/src/main/java/com/baeldung/jenkins/helloworld/ProjectStats.java rename to jenkins/plugins/src/main/java/com/baeldung/jenkins/plugins/ProjectStats.java index 67af636bb4..46899c49d1 100644 --- a/jenkins/hello-world/src/main/java/com/baeldung/jenkins/helloworld/ProjectStats.java +++ b/jenkins/plugins/src/main/java/com/baeldung/jenkins/plugins/ProjectStats.java @@ -1,4 +1,4 @@ -package com.baeldung.jenkins.helloworld; +package com.baeldung.jenkins.plugins; public class ProjectStats { diff --git a/jenkins/hello-world/src/main/java/com/baeldung/jenkins/helloworld/ProjectStatsBuildWrapper.java b/jenkins/plugins/src/main/java/com/baeldung/jenkins/plugins/ProjectStatsBuildWrapper.java similarity index 99% rename from jenkins/hello-world/src/main/java/com/baeldung/jenkins/helloworld/ProjectStatsBuildWrapper.java rename to jenkins/plugins/src/main/java/com/baeldung/jenkins/plugins/ProjectStatsBuildWrapper.java index 9a7213c76f..39500a42cb 100644 --- a/jenkins/hello-world/src/main/java/com/baeldung/jenkins/helloworld/ProjectStatsBuildWrapper.java +++ b/jenkins/plugins/src/main/java/com/baeldung/jenkins/plugins/ProjectStatsBuildWrapper.java @@ -1,4 +1,4 @@ -package com.baeldung.jenkins.helloworld; +package com.baeldung.jenkins.plugins; import hudson.Extension; import hudson.FilePath; diff --git a/jenkins/hello-world/src/main/resources/logback.xml b/jenkins/plugins/src/main/resources/logback.xml similarity index 100% rename from jenkins/hello-world/src/main/resources/logback.xml rename to jenkins/plugins/src/main/resources/logback.xml diff --git a/jenkins/hello-world/src/main/resources/stats.html b/jenkins/plugins/src/main/resources/stats.html similarity index 100% rename from jenkins/hello-world/src/main/resources/stats.html rename to jenkins/plugins/src/main/resources/stats.html diff --git a/pom.xml b/pom.xml index 733aaad056..539f089e58 100644 --- a/pom.xml +++ b/pom.xml @@ -1039,7 +1039,7 @@ core-kotlin-2 core-kotlin-io - jenkins/hello-world + jenkins/plugins jhipster jws @@ -1589,7 +1589,7 @@ core-kotlin core-kotlin-2 - jenkins/hello-world + jenkins/plugins jhipster jws From 0ba79b88b4fc28b82ddce5cbb58a38b76a1f2d19 Mon Sep 17 00:00:00 2001 From: Martin van Wingerden Date: Wed, 2 Oct 2019 13:26:01 +0200 Subject: [PATCH 46/55] Include the link to https://www.baeldung.com/javax-validation-groups --- javaxval/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/javaxval/README.md b/javaxval/README.md index 46b7deab2a..2b4164671d 100644 --- a/javaxval/README.md +++ b/javaxval/README.md @@ -8,3 +8,4 @@ This module contains articles about Bean Validation. - [Method Constraints with Bean Validation 2.0](https://www.baeldung.com/javax-validation-method-constraints) - [Difference Between @NotNull, @NotEmpty, and @NotBlank Constraints in Bean Validation](https://www.baeldung.com/java-bean-validation-not-null-empty-blank) - [Javax BigDecimal Validation](https://www.baeldung.com/javax-bigdecimal-validation) +- [Grouping Javax Validation Constraints](https://www.baeldung.com/javax-validation-groups) From 76e0fe46428a47a521d15d7b8322cb5e33650bca Mon Sep 17 00:00:00 2001 From: Martin van Wingerden Date: Wed, 2 Oct 2019 13:37:28 +0200 Subject: [PATCH 47/55] Reformatting code of javaxval before starting on [BAEL-3306] --- .../src/main/java/org/baeldung/Customer.java | 10 +- .../main/java/org/baeldung/CustomerMap.java | 4 +- .../appplication/Application.java | 4 +- .../bigdecimal/Invoice.java | 16 +- .../entities/UserNotBlank.java | 6 +- .../entities/UserNotEmpty.java | 8 +- .../entities/UserNotNull.java | 8 +- .../validationgroup/RegistrationForm.java | 162 +++++++++--------- .../javaxval/beanvalidation/User.java | 9 +- .../ValidReservationValidator.java | 6 +- 10 files changed, 116 insertions(+), 117 deletions(-) diff --git a/javaxval/src/main/java/org/baeldung/Customer.java b/javaxval/src/main/java/org/baeldung/Customer.java index a90fb419de..f301fe6c80 100644 --- a/javaxval/src/main/java/org/baeldung/Customer.java +++ b/javaxval/src/main/java/org/baeldung/Customer.java @@ -10,16 +10,16 @@ import javax.validation.constraints.PositiveOrZero; public class Customer { - @NotBlank(message="Name cannot be empty") + @NotBlank(message = "Name cannot be empty") private String name; - private List<@NotBlank(message="Address must not be blank") String> addresses; - + private List<@NotBlank(message = "Address must not be blank") String> addresses; + private Integer age; - + @PositiveOrZero private OptionalInt numberOfOrders; - + //@NotBlank private Profile profile; diff --git a/javaxval/src/main/java/org/baeldung/CustomerMap.java b/javaxval/src/main/java/org/baeldung/CustomerMap.java index 37446cf86e..d8830a7f42 100644 --- a/javaxval/src/main/java/org/baeldung/CustomerMap.java +++ b/javaxval/src/main/java/org/baeldung/CustomerMap.java @@ -6,8 +6,8 @@ import javax.validation.constraints.Email; import javax.validation.constraints.NotNull; public class CustomerMap { - - private Map<@Email(message="Must be a valid email") String, @NotNull Customer> customers; + + private Map<@Email(message = "Must be a valid email") String, @NotNull Customer> customers; public Map getCustomers() { return customers; diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/appplication/Application.java b/javaxval/src/main/java/org/baeldung/javabeanconstraints/appplication/Application.java index c9f2ab6f98..f60eab3e63 100644 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/appplication/Application.java +++ b/javaxval/src/main/java/org/baeldung/javabeanconstraints/appplication/Application.java @@ -6,9 +6,9 @@ import org.baeldung.javabeanconstraints.entities.UserNotBlank; public class Application { - public static void main(String[] args) throws Exception { + public static void main(String[] args) { Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); UserNotBlank user = new UserNotBlank(" "); - validator.validate(user).stream().forEach(violation -> System.out.println(violation.getMessage())); + validator.validate(user).stream().forEach(violation -> System.out.println(violation.getMessage())); } } diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/bigdecimal/Invoice.java b/javaxval/src/main/java/org/baeldung/javabeanconstraints/bigdecimal/Invoice.java index 6df1b79a60..886123dad7 100644 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/bigdecimal/Invoice.java +++ b/javaxval/src/main/java/org/baeldung/javabeanconstraints/bigdecimal/Invoice.java @@ -6,14 +6,14 @@ import javax.validation.constraints.DecimalMin; import javax.validation.constraints.Digits; public class Invoice { - - @DecimalMin(value = "0.0", inclusive = false) - @Digits(integer=3, fraction=2) + + @DecimalMin(value = "0.0", inclusive = false) + @Digits(integer = 3, fraction = 2) private BigDecimal price; private String description; - - public Invoice(BigDecimal price, String description) { - this.price = price; - this.description = description; - } + + public Invoice(BigDecimal price, String description) { + this.price = price; + this.description = description; + } } diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotBlank.java b/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotBlank.java index 2ea6a3af56..b49e587ce5 100644 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotBlank.java +++ b/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotBlank.java @@ -6,15 +6,15 @@ public class UserNotBlank { @NotBlank(message = "Name is mandatory") private final String name; - + public UserNotBlank(String name) { this.name = name; } - + public String getName() { return name; } - + @Override public String toString() { return "User{" + "name=" + name + "}"; diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotEmpty.java b/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotEmpty.java index 39e34b63d3..0da768b103 100644 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotEmpty.java +++ b/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotEmpty.java @@ -3,18 +3,18 @@ package org.baeldung.javabeanconstraints.entities; import javax.validation.constraints.NotEmpty; public class UserNotEmpty { - + @NotEmpty(message = "Name is mandatory") private final String name; - + public UserNotEmpty(String name) { this.name = name; } - + public String getName() { return name; } - + @Override public String toString() { return "User{" + "name=" + name + "}"; diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotNull.java b/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotNull.java index 598c9ba9f9..63a1017b75 100644 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotNull.java +++ b/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotNull.java @@ -3,18 +3,18 @@ package org.baeldung.javabeanconstraints.entities; import javax.validation.constraints.NotNull; public class UserNotNull { - + @NotNull(message = "Name is mandatory") private final String name; - + public UserNotNull(String name) { this.name = name; } - + public String getName() { return name; } - + @Override public String toString() { return "User{" + "name=" + name + "}"; diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationForm.java b/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationForm.java index ac8da5c26b..4cebe0e218 100644 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationForm.java +++ b/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationForm.java @@ -4,107 +4,107 @@ import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; public class RegistrationForm { - @NotBlank(groups = BasicInfo.class) - private String firstName; - @NotBlank(groups = BasicInfo.class) - private String lastName; - @Email(groups = BasicInfo.class) - private String email; - @NotBlank(groups = BasicInfo.class) - private String phone; + @NotBlank(groups = BasicInfo.class) + private String firstName; + @NotBlank(groups = BasicInfo.class) + private String lastName; + @Email(groups = BasicInfo.class) + private String email; + @NotBlank(groups = BasicInfo.class) + private String phone; - @NotBlank(groups = { BasicInfo.class, AdvanceInfo.class }) - private String captcha; + @NotBlank(groups = {BasicInfo.class, AdvanceInfo.class}) + private String captcha; - @NotBlank(groups = AdvanceInfo.class) - private String street; - @NotBlank(groups = AdvanceInfo.class) - private String houseNumber; - @NotBlank(groups = AdvanceInfo.class) - private String zipCode; - @NotBlank(groups = AdvanceInfo.class) - private String city; - @NotBlank(groups = AdvanceInfo.class) - private String contry; + @NotBlank(groups = AdvanceInfo.class) + private String street; + @NotBlank(groups = AdvanceInfo.class) + private String houseNumber; + @NotBlank(groups = AdvanceInfo.class) + private String zipCode; + @NotBlank(groups = AdvanceInfo.class) + private String city; + @NotBlank(groups = AdvanceInfo.class) + private String contry; - public String getStreet() { - return street; - } + public String getStreet() { + return street; + } - public void setStreet(String street) { - this.street = street; - } + public void setStreet(String street) { + this.street = street; + } - public String getHouseNumber() { - return houseNumber; - } + public String getHouseNumber() { + return houseNumber; + } - public void setHouseNumber(String houseNumber) { - this.houseNumber = houseNumber; - } + public void setHouseNumber(String houseNumber) { + this.houseNumber = houseNumber; + } - public String getZipCode() { - return zipCode; - } + public String getZipCode() { + return zipCode; + } - public void setZipCode(String zipCode) { - this.zipCode = zipCode; - } + public void setZipCode(String zipCode) { + this.zipCode = zipCode; + } - public String getCity() { - return city; - } + public String getCity() { + return city; + } - public void setCity(String city) { - this.city = city; - } + public void setCity(String city) { + this.city = city; + } - public String getContry() { - return contry; - } + public String getContry() { + return contry; + } - public void setContry(String contry) { - this.contry = contry; - } + public void setContry(String contry) { + this.contry = contry; + } - public String getFirstName() { - return firstName; - } + public String getFirstName() { + return firstName; + } - public void setFirstName(String firstName) { - this.firstName = firstName; - } + public void setFirstName(String firstName) { + this.firstName = firstName; + } - public String getLastName() { - return lastName; - } + public String getLastName() { + return lastName; + } - public void setLastName(String lastName) { - this.lastName = lastName; - } + public void setLastName(String lastName) { + this.lastName = lastName; + } - public String getEmail() { - return email; - } + public String getEmail() { + return email; + } - public void setEmail(String email) { - this.email = email; - } + public void setEmail(String email) { + this.email = email; + } - public String getPhone() { - return phone; - } + public String getPhone() { + return phone; + } - public void setPhone(String phone) { - this.phone = phone; - } - - public String getCaptcha() { - return captcha; - } + public void setPhone(String phone) { + this.phone = phone; + } - public void setCaptcha(String captcha) { - this.captcha = captcha; - } + public String getCaptcha() { + return captcha; + } + + public void setCaptcha(String captcha) { + this.captcha = captcha; + } } diff --git a/javaxval/src/main/java/org/baeldung/javaxval/beanvalidation/User.java b/javaxval/src/main/java/org/baeldung/javaxval/beanvalidation/User.java index cf80266c9d..8303edd033 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/beanvalidation/User.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/beanvalidation/User.java @@ -8,10 +8,10 @@ import javax.validation.constraints.AssertTrue; import javax.validation.constraints.Email; import javax.validation.constraints.Max; import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Past; import javax.validation.constraints.Size; -import javax.validation.constraints.NotBlank; public class User { @@ -30,9 +30,9 @@ public class User { @Email(message = "Email should be valid") private String email; - - List<@NotBlank String> preferences; - + + private List<@NotBlank String> preferences; + private LocalDate dateOfBirth; public int getAge() { @@ -90,5 +90,4 @@ public class User { public void setPreferences(List preferences) { this.preferences = preferences; } - } diff --git a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservationValidator.java b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservationValidator.java index 7b730480ed..3d3a84ab9f 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservationValidator.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservationValidator.java @@ -24,9 +24,9 @@ public class ValidReservationValidator implements ConstraintValidator 0); + && reservation.getRoom() > 0); } } From 86dd449968afc4ddb44a1f9dbce629ca5ee69b79 Mon Sep 17 00:00:00 2001 From: Martin van Wingerden Date: Wed, 2 Oct 2019 13:52:41 +0200 Subject: [PATCH 48/55] Formatted using the eclipse formatter --- .../src/main/java/org/baeldung/Customer.java | 1 - .../appplication/Application.java | 8 +- .../validationgroup/CompleteInfo.java | 2 +- .../validationgroup/RegistrationForm.java | 12 +- .../MethodValidationConfig.java | 4 +- .../ConsistentDateParameterValidator.java | 3 +- .../constraints/ConsistentDateParameters.java | 10 +- .../constraints/ValidReservation.java | 13 +- .../ValidReservationValidator.java | 11 +- .../methodvalidation/model/Customer.java | 4 +- .../methodvalidation/model/Reservation.java | 9 +- .../model/ReservationManagement.java | 15 +- .../ContainerValidationIntegrationTest.java | 10 +- .../bigdecimal/InvoiceUnitTest.java | 36 ++- .../test/UserNotBlankUnitTest.java | 38 +-- .../test/UserNotEmptyUnitTest.java | 32 +-- .../test/UserNotNullUnitTest.java | 28 ++- .../RegistrationFormUnitTest.java | 225 +++++++++--------- .../ValidationIntegrationTest.java | 22 +- .../ContainerValidationIntegrationTest.java | 9 +- .../ValidationIntegrationTest.java | 24 +- 21 files changed, 275 insertions(+), 241 deletions(-) diff --git a/javaxval/src/main/java/org/baeldung/Customer.java b/javaxval/src/main/java/org/baeldung/Customer.java index f301fe6c80..02a95cc546 100644 --- a/javaxval/src/main/java/org/baeldung/Customer.java +++ b/javaxval/src/main/java/org/baeldung/Customer.java @@ -20,7 +20,6 @@ public class Customer { @PositiveOrZero private OptionalInt numberOfOrders; - //@NotBlank private Profile profile; public String getName() { diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/appplication/Application.java b/javaxval/src/main/java/org/baeldung/javabeanconstraints/appplication/Application.java index f60eab3e63..e5927a093e 100644 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/appplication/Application.java +++ b/javaxval/src/main/java/org/baeldung/javabeanconstraints/appplication/Application.java @@ -2,13 +2,17 @@ package org.baeldung.javabeanconstraints.appplication; import javax.validation.Validation; import javax.validation.Validator; + import org.baeldung.javabeanconstraints.entities.UserNotBlank; public class Application { public static void main(String[] args) { - Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); + Validator validator = Validation.buildDefaultValidatorFactory() + .getValidator(); UserNotBlank user = new UserNotBlank(" "); - validator.validate(user).stream().forEach(violation -> System.out.println(violation.getMessage())); + validator.validate(user) + .stream() + .forEach(violation -> System.out.println(violation.getMessage())); } } diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/CompleteInfo.java b/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/CompleteInfo.java index c989ea3a6f..4d9de8150a 100644 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/CompleteInfo.java +++ b/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/CompleteInfo.java @@ -2,7 +2,7 @@ package org.baeldung.javabeanconstraints.validationgroup; import javax.validation.GroupSequence; -@GroupSequence({BasicInfo.class, AdvanceInfo.class}) +@GroupSequence({ BasicInfo.class, AdvanceInfo.class }) public interface CompleteInfo { } diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationForm.java b/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationForm.java index 4cebe0e218..197b9adad2 100644 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationForm.java +++ b/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationForm.java @@ -13,7 +13,7 @@ public class RegistrationForm { @NotBlank(groups = BasicInfo.class) private String phone; - @NotBlank(groups = {BasicInfo.class, AdvanceInfo.class}) + @NotBlank(groups = { BasicInfo.class, AdvanceInfo.class }) private String captcha; @NotBlank(groups = AdvanceInfo.class) @@ -25,7 +25,7 @@ public class RegistrationForm { @NotBlank(groups = AdvanceInfo.class) private String city; @NotBlank(groups = AdvanceInfo.class) - private String contry; + private String country; public String getStreet() { return street; @@ -59,12 +59,12 @@ public class RegistrationForm { this.city = city; } - public String getContry() { - return contry; + public String getCountry() { + return country; } - public void setContry(String contry) { - this.contry = contry; + public void setCountry(String country) { + this.country = country; } public String getFirstName() { diff --git a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/MethodValidationConfig.java b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/MethodValidationConfig.java index 206a145337..817f2370ef 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/MethodValidationConfig.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/MethodValidationConfig.java @@ -1,5 +1,7 @@ package org.baeldung.javaxval.methodvalidation; +import java.time.LocalDate; + import org.baeldung.javaxval.methodvalidation.model.Customer; import org.baeldung.javaxval.methodvalidation.model.Reservation; import org.springframework.beans.factory.config.BeanDefinition; @@ -9,8 +11,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Scope; import org.springframework.validation.beanvalidation.MethodValidationPostProcessor; -import java.time.LocalDate; - @Configuration @ComponentScan({ "org.baeldung.javaxval.methodvalidation.model" }) public class MethodValidationConfig { diff --git a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameterValidator.java b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameterValidator.java index f1c97760d7..df09cfa906 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameterValidator.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameterValidator.java @@ -1,10 +1,11 @@ package org.baeldung.javaxval.methodvalidation.constraints; +import java.time.LocalDate; + import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; import javax.validation.constraintvalidation.SupportedValidationTarget; import javax.validation.constraintvalidation.ValidationTarget; -import java.time.LocalDate; @SupportedValidationTarget(ValidationTarget.PARAMETERS) public class ConsistentDateParameterValidator implements ConstraintValidator { diff --git a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameters.java b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameters.java index 6b321f545c..bdfabe05ba 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameters.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameters.java @@ -1,13 +1,15 @@ package org.baeldung.javaxval.methodvalidation.constraints; -import javax.validation.Constraint; -import javax.validation.Payload; +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.RUNTIME; +import javax.validation.Constraint; +import javax.validation.Payload; @Constraint(validatedBy = ConsistentDateParameterValidator.class) @Target({ METHOD, CONSTRUCTOR }) diff --git a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservation.java b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservation.java index f9cdea1483..842f9e0621 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservation.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservation.java @@ -1,15 +1,16 @@ package org.baeldung.javaxval.methodvalidation.constraints; -import javax.validation.Constraint; -import javax.validation.Payload; -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - import static java.lang.annotation.ElementType.CONSTRUCTOR; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.validation.Constraint; +import javax.validation.Payload; + @Constraint(validatedBy = ValidReservationValidator.class) @Target({ METHOD, CONSTRUCTOR }) @Retention(RUNTIME) diff --git a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservationValidator.java b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservationValidator.java index 3d3a84ab9f..c139d1affc 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservationValidator.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservationValidator.java @@ -1,10 +1,11 @@ package org.baeldung.javaxval.methodvalidation.constraints; -import org.baeldung.javaxval.methodvalidation.model.Reservation; +import java.time.LocalDate; import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; -import java.time.LocalDate; + +import org.baeldung.javaxval.methodvalidation.model.Reservation; public class ValidReservationValidator implements ConstraintValidator { @@ -24,9 +25,9 @@ public class ValidReservationValidator implements ConstraintValidator 0); + && reservation.getRoom() > 0); } } diff --git a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/Customer.java b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/Customer.java index fe9ad7080e..99a32d6277 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/Customer.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/Customer.java @@ -1,10 +1,10 @@ package org.baeldung.javaxval.methodvalidation.model; -import org.springframework.validation.annotation.Validated; - import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; +import org.springframework.validation.annotation.Validated; + @Validated public class Customer { diff --git a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/Reservation.java b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/Reservation.java index a8c01d2be1..5775bdd66b 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/Reservation.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/Reservation.java @@ -1,13 +1,14 @@ package org.baeldung.javaxval.methodvalidation.model; +import java.time.LocalDate; + +import javax.validation.Valid; +import javax.validation.constraints.Positive; + import org.baeldung.javaxval.methodvalidation.constraints.ConsistentDateParameters; import org.baeldung.javaxval.methodvalidation.constraints.ValidReservation; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.Positive; -import java.time.LocalDate; - @Validated public class Reservation { diff --git a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/ReservationManagement.java b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/ReservationManagement.java index f6fec1a15d..e480e7912d 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/ReservationManagement.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/ReservationManagement.java @@ -1,17 +1,20 @@ package org.baeldung.javaxval.methodvalidation.model; +import java.time.LocalDate; +import java.util.List; + +import javax.validation.Valid; +import javax.validation.constraints.Future; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + import org.baeldung.javaxval.methodvalidation.constraints.ConsistentDateParameters; -import org.baeldung.javaxval.methodvalidation.constraints.ValidReservation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Controller; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.*; -import java.time.LocalDate; -import java.util.List; - @Controller @Validated public class ReservationManagement { diff --git a/javaxval/src/test/java/org/baeldung/ContainerValidationIntegrationTest.java b/javaxval/src/test/java/org/baeldung/ContainerValidationIntegrationTest.java index dff02ff13d..aa2cf577de 100644 --- a/javaxval/src/test/java/org/baeldung/ContainerValidationIntegrationTest.java +++ b/javaxval/src/test/java/org/baeldung/ContainerValidationIntegrationTest.java @@ -10,8 +10,8 @@ import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; import javax.validation.ValidatorFactory; -import org.baeldung.valueextractors.ProfileValueExtractor; +import org.baeldung.valueextractors.ProfileValueExtractor; import org.junit.Before; import org.junit.Test; @@ -20,8 +20,10 @@ public class ContainerValidationIntegrationTest { @Before public void setup() { - ValidatorFactory factory = Validation.byDefaultProvider().configure() - .addValueExtractor(new ProfileValueExtractor()).buildValidatorFactory(); + ValidatorFactory factory = Validation.byDefaultProvider() + .configure() + .addValueExtractor(new ProfileValueExtractor()) + .buildValidatorFactory(); validator = factory.getValidator(); } @@ -74,7 +76,7 @@ public class ContainerValidationIntegrationTest { assertEquals(0, violations.size()); } - //@Test + // @Test public void whenProfileCompanyNameBlank_thenValidationFails() { Customer customer = new Customer(); customer.setName("John"); diff --git a/javaxval/src/test/java/org/baeldung/javabeanconstraints/bigdecimal/InvoiceUnitTest.java b/javaxval/src/test/java/org/baeldung/javabeanconstraints/bigdecimal/InvoiceUnitTest.java index 860177f4c9..a07328e2fb 100644 --- a/javaxval/src/test/java/org/baeldung/javabeanconstraints/bigdecimal/InvoiceUnitTest.java +++ b/javaxval/src/test/java/org/baeldung/javabeanconstraints/bigdecimal/InvoiceUnitTest.java @@ -13,51 +13,49 @@ import org.junit.BeforeClass; import org.junit.Test; public class InvoiceUnitTest { - - private static Validator validator; + + private static Validator validator; @BeforeClass public static void setupValidatorInstance() { - validator = Validation.buildDefaultValidatorFactory().getValidator(); + validator = Validation.buildDefaultValidatorFactory() + .getValidator(); } - + @Test public void whenPriceIntegerDigitLessThanThreeWithDecimalValue_thenShouldGiveConstraintViolations() { - Invoice invoice = new Invoice(new BigDecimal(10.21), "Book purchased"); + Invoice invoice = new Invoice(new BigDecimal(10.21), "Book purchased"); Set> violations = validator.validate(invoice); assertThat(violations.size()).isEqualTo(1); - violations.forEach(action-> assertThat(action.getMessage()) - .isEqualTo("numeric value out of bounds (<3 digits>.<2 digits> expected)")); + violations.forEach(action -> assertThat(action.getMessage()).isEqualTo("numeric value out of bounds (<3 digits>.<2 digits> expected)")); } - + @Test public void whenPriceIntegerDigitLessThanThreeWithIntegerValue_thenShouldNotGiveConstraintViolations() { - Invoice invoice = new Invoice(new BigDecimal(10), "Book purchased"); + Invoice invoice = new Invoice(new BigDecimal(10), "Book purchased"); Set> violations = validator.validate(invoice); assertThat(violations.size()).isEqualTo(0); } - + @Test public void whenPriceIntegerDigitGreaterThanThree_thenShouldGiveConstraintViolations() { - Invoice invoice = new Invoice(new BigDecimal(1021.21), "Book purchased"); + Invoice invoice = new Invoice(new BigDecimal(1021.21), "Book purchased"); Set> violations = validator.validate(invoice); assertThat(violations.size()).isEqualTo(1); - violations.forEach(action-> assertThat(action.getMessage()) - .isEqualTo("numeric value out of bounds (<3 digits>.<2 digits> expected)")); + violations.forEach(action -> assertThat(action.getMessage()).isEqualTo("numeric value out of bounds (<3 digits>.<2 digits> expected)")); } - + @Test public void whenPriceIsZero_thenShouldGiveConstraintViolations() { - Invoice invoice = new Invoice(new BigDecimal(000.00), "Book purchased"); + Invoice invoice = new Invoice(new BigDecimal(000.00), "Book purchased"); Set> violations = validator.validate(invoice); assertThat(violations.size()).isEqualTo(1); - violations.forEach(action-> assertThat(action.getMessage()) - .isEqualTo("must be greater than 0.0")); + violations.forEach(action -> assertThat(action.getMessage()).isEqualTo("must be greater than 0.0")); } - + @Test public void whenPriceIsGreaterThanZero_thenShouldNotGiveConstraintViolations() { - Invoice invoice = new Invoice(new BigDecimal(100.50), "Book purchased"); + Invoice invoice = new Invoice(new BigDecimal(100.50), "Book purchased"); Set> violations = validator.validate(invoice); assertThat(violations.size()).isEqualTo(0); } diff --git a/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotBlankUnitTest.java b/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotBlankUnitTest.java index 954833fef1..48ecb2e649 100644 --- a/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotBlankUnitTest.java +++ b/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotBlankUnitTest.java @@ -1,63 +1,67 @@ package org.baeldung.javabeanconstraints.test; +import static org.assertj.core.api.Assertions.assertThat; + import java.util.Set; + import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; -import static org.assertj.core.api.Assertions.assertThat; + import org.baeldung.javabeanconstraints.entities.UserNotBlank; import org.junit.BeforeClass; import org.junit.Test; public class UserNotBlankUnitTest { - + private static Validator validator; @BeforeClass public static void setupValidatorInstance() { - validator = Validation.buildDefaultValidatorFactory().getValidator(); + validator = Validation.buildDefaultValidatorFactory() + .getValidator(); } - + @Test public void whenNotBlankName_thenNoConstraintViolations() { UserNotBlank user = new UserNotBlank("John"); - + Set> violations = validator.validate(user); - + assertThat(violations.size()).isEqualTo(0); } - + @Test public void whenBlankName_thenOneConstraintViolation() { UserNotBlank user = new UserNotBlank(" "); - + Set> violations = validator.validate(user); - + assertThat(violations.size()).isEqualTo(1); } - + @Test public void whenEmptyName_thenOneConstraintViolation() { UserNotBlank user = new UserNotBlank(""); - + Set> violations = validator.validate(user); - + assertThat(violations.size()).isEqualTo(1); } - + @Test public void whenNullName_thenOneConstraintViolation() { UserNotBlank user = new UserNotBlank(null); - + Set> violations = validator.validate(user); - + assertThat(violations.size()).isEqualTo(1); } - + @Test public void whenToString_thenCorrect() { UserNotBlank user = new UserNotBlank("John"); - + assertThat(user.toString()).isEqualTo("User{name=John}"); } } diff --git a/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotEmptyUnitTest.java b/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotEmptyUnitTest.java index c2675ed8b6..6398d2bb91 100644 --- a/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotEmptyUnitTest.java +++ b/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotEmptyUnitTest.java @@ -1,54 +1,58 @@ package org.baeldung.javabeanconstraints.test; +import static org.assertj.core.api.Assertions.assertThat; + import java.util.Set; + import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; -import static org.assertj.core.api.Assertions.assertThat; + import org.baeldung.javabeanconstraints.entities.UserNotEmpty; import org.junit.BeforeClass; import org.junit.Test; public class UserNotEmptyUnitTest { - + private static Validator validator; @BeforeClass public static void setupValidatorInstance() { - validator = Validation.buildDefaultValidatorFactory().getValidator(); + validator = Validation.buildDefaultValidatorFactory() + .getValidator(); } - + @Test public void whenNotEmptyName_thenNoConstraintViolations() { UserNotEmpty user = new UserNotEmpty("John"); - + Set> violations = validator.validate(user); - + assertThat(violations.size()).isEqualTo(0); } - + @Test public void whenEmptyName_thenOneConstraintViolation() { UserNotEmpty user = new UserNotEmpty(""); - + Set> violations = validator.validate(user); - + assertThat(violations.size()).isEqualTo(1); } - + @Test public void whenNullName_thenOneConstraintViolation() { UserNotEmpty user = new UserNotEmpty(null); - + Set> violations = validator.validate(user); - + assertThat(violations.size()).isEqualTo(1); } - + @Test public void whenToString_thenCorrect() { UserNotEmpty user = new UserNotEmpty("John"); - + assertThat(user.toString()).isEqualTo("User{name=John}"); } } diff --git a/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotNullUnitTest.java b/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotNullUnitTest.java index 3dd1811947..f9387f9199 100644 --- a/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotNullUnitTest.java +++ b/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotNullUnitTest.java @@ -1,10 +1,13 @@ package org.baeldung.javabeanconstraints.test; +import static org.assertj.core.api.Assertions.assertThat; + import java.util.Set; + import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; -import static org.assertj.core.api.Assertions.assertThat; + import org.baeldung.javabeanconstraints.entities.UserNotNull; import org.junit.BeforeClass; import org.junit.Test; @@ -15,40 +18,41 @@ public class UserNotNullUnitTest { @BeforeClass public static void setupValidatorInstance() { - validator = Validation.buildDefaultValidatorFactory().getValidator(); + validator = Validation.buildDefaultValidatorFactory() + .getValidator(); } @Test public void whenNotNullName_thenNoConstraintViolations() { UserNotNull user = new UserNotNull("John"); - + Set> violations = validator.validate(user); - + assertThat(violations.size()).isEqualTo(0); } - + @Test public void whenNullName_thenOneConstraintViolation() { UserNotNull user = new UserNotNull(null); - + Set> violations = validator.validate(user); - + assertThat(violations.size()).isEqualTo(1); } - + @Test public void whenEmptyName_thenNoConstraintViolations() { UserNotNull user = new UserNotNull(""); - + Set> violations = validator.validate(user); - + assertThat(violations.size()).isEqualTo(0); } - + @Test public void whenToString_thenCorrect() { UserNotNull user = new UserNotNull("John"); - + assertThat(user.toString()).isEqualTo("User{name=John}"); } } diff --git a/javaxval/src/test/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationFormUnitTest.java b/javaxval/src/test/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationFormUnitTest.java index bd7034476e..efe61bf926 100644 --- a/javaxval/src/test/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationFormUnitTest.java +++ b/javaxval/src/test/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationFormUnitTest.java @@ -12,126 +12,133 @@ import org.junit.BeforeClass; import org.junit.Test; public class RegistrationFormUnitTest { - private static Validator validator; + private static Validator validator; - @BeforeClass - public static void setupValidatorInstance() { - validator = Validation.buildDefaultValidatorFactory().getValidator(); - } + @BeforeClass + public static void setupValidatorInstance() { + validator = Validation.buildDefaultValidatorFactory() + .getValidator(); + } - @Test - public void whenBasicInfoIsNotComplete_thenShouldGiveConstraintViolationsOnlyForBasicInfo() { - RegistrationForm form = buildRegistrationFormWithBasicInfo(); - form.setFirstName(""); - Set> violations = validator.validate(form, BasicInfo.class); - assertThat(violations.size()).isEqualTo(1); - violations.forEach(action -> { - assertThat(action.getMessage()).isEqualTo("must not be blank"); - assertThat(action.getPropertyPath().toString()).isEqualTo("firstName"); - }); - } + @Test + public void whenBasicInfoIsNotComplete_thenShouldGiveConstraintViolationsOnlyForBasicInfo() { + RegistrationForm form = buildRegistrationFormWithBasicInfo(); + form.setFirstName(""); + Set> violations = validator.validate(form, BasicInfo.class); + assertThat(violations.size()).isEqualTo(1); + violations.forEach(action -> { + assertThat(action.getMessage()).isEqualTo("must not be blank"); + assertThat(action.getPropertyPath() + .toString()).isEqualTo("firstName"); + }); + } - @Test - public void whenAdvanceInfoIsNotComplete_thenShouldGiveConstraintViolationsOnlyForAdvanceInfo() { - RegistrationForm form = buildRegistrationFormWithAdvanceInfo(); - form.setZipCode(""); - Set> violations = validator.validate(form, AdvanceInfo.class); - assertThat(violations.size()).isEqualTo(1); - violations.forEach(action -> { - assertThat(action.getMessage()).isEqualTo("must not be blank"); - assertThat(action.getPropertyPath().toString()).isEqualTo("zipCode"); - }); - } + @Test + public void whenAdvanceInfoIsNotComplete_thenShouldGiveConstraintViolationsOnlyForAdvanceInfo() { + RegistrationForm form = buildRegistrationFormWithAdvanceInfo(); + form.setZipCode(""); + Set> violations = validator.validate(form, AdvanceInfo.class); + assertThat(violations.size()).isEqualTo(1); + violations.forEach(action -> { + assertThat(action.getMessage()).isEqualTo("must not be blank"); + assertThat(action.getPropertyPath() + .toString()).isEqualTo("zipCode"); + }); + } - @Test - public void whenCaptchaIsBlank_thenShouldGiveConstraintViolationsForBasicInfo() { - RegistrationForm form = buildRegistrationFormWithBasicInfo(); - form.setCaptcha(""); - Set> violations = validator.validate(form, BasicInfo.class); - assertThat(violations.size()).isEqualTo(1); - violations.forEach(action -> { - assertThat(action.getMessage()).isEqualTo("must not be blank"); - assertThat(action.getPropertyPath().toString()).isEqualTo("captcha"); - }); - } + @Test + public void whenCaptchaIsBlank_thenShouldGiveConstraintViolationsForBasicInfo() { + RegistrationForm form = buildRegistrationFormWithBasicInfo(); + form.setCaptcha(""); + Set> violations = validator.validate(form, BasicInfo.class); + assertThat(violations.size()).isEqualTo(1); + violations.forEach(action -> { + assertThat(action.getMessage()).isEqualTo("must not be blank"); + assertThat(action.getPropertyPath() + .toString()).isEqualTo("captcha"); + }); + } - @Test - public void whenCaptchaIsBlank_thenShouldGiveConstraintViolationsForAdvanceInfo() { - RegistrationForm form = buildRegistrationFormWithAdvanceInfo(); - form.setCaptcha(""); - Set> violations = validator.validate(form, AdvanceInfo.class); - assertThat(violations.size()).isEqualTo(1); - violations.forEach(action -> { - assertThat(action.getMessage()).isEqualTo("must not be blank"); - assertThat(action.getPropertyPath().toString()).isEqualTo("captcha"); - }); - } + @Test + public void whenCaptchaIsBlank_thenShouldGiveConstraintViolationsForAdvanceInfo() { + RegistrationForm form = buildRegistrationFormWithAdvanceInfo(); + form.setCaptcha(""); + Set> violations = validator.validate(form, AdvanceInfo.class); + assertThat(violations.size()).isEqualTo(1); + violations.forEach(action -> { + assertThat(action.getMessage()).isEqualTo("must not be blank"); + assertThat(action.getPropertyPath() + .toString()).isEqualTo("captcha"); + }); + } - @Test - public void whenBasicInfoIsNotComplete_thenShouldGiveConstraintViolationsForBasicInfoOnly() { - RegistrationForm form = buildRegistrationFormWithBasicInfo(); - form.setFirstName(""); - Set> violations = validator.validate(form, CompleteInfo.class); - assertThat(violations.size()).isEqualTo(1); - violations.forEach(action -> { - assertThat(action.getMessage()).isEqualTo("must not be blank"); - assertThat(action.getPropertyPath().toString()).isEqualTo("firstName"); - }); - } + @Test + public void whenBasicInfoIsNotComplete_thenShouldGiveConstraintViolationsForBasicInfoOnly() { + RegistrationForm form = buildRegistrationFormWithBasicInfo(); + form.setFirstName(""); + Set> violations = validator.validate(form, CompleteInfo.class); + assertThat(violations.size()).isEqualTo(1); + violations.forEach(action -> { + assertThat(action.getMessage()).isEqualTo("must not be blank"); + assertThat(action.getPropertyPath() + .toString()).isEqualTo("firstName"); + }); + } - @Test - public void whenBasicInfoIsCompleteAndAdvanceInfoIsNotComplete_thenShouldGiveConstraintViolationsForAdvanceInfo() { - RegistrationForm form = buildRegistrationFormWithBasicAndAdvanceInfo(); - form.setZipCode(""); - Set> violations = validator.validate(form, CompleteInfo.class); - assertThat(violations.size()).isEqualTo(1); - violations.forEach(action -> { - assertThat(action.getMessage()).isEqualTo("must not be blank"); - assertThat(action.getPropertyPath().toString()).isEqualTo("zipCode"); - }); - } + @Test + public void whenBasicInfoIsCompleteAndAdvanceInfoIsNotComplete_thenShouldGiveConstraintViolationsForAdvanceInfo() { + RegistrationForm form = buildRegistrationFormWithBasicAndAdvanceInfo(); + form.setZipCode(""); + Set> violations = validator.validate(form, CompleteInfo.class); + assertThat(violations.size()).isEqualTo(1); + violations.forEach(action -> { + assertThat(action.getMessage()).isEqualTo("must not be blank"); + assertThat(action.getPropertyPath() + .toString()).isEqualTo("zipCode"); + }); + } - @Test - public void whenBasicAndAdvanceInfoIsComplete_thenShouldNotGiveConstraintViolationsWithCompleteInfoValidationGroup() { - RegistrationForm form = buildRegistrationFormWithBasicAndAdvanceInfo(); - Set> violations = validator.validate(form, CompleteInfo.class); - assertThat(violations.size()).isEqualTo(0); - } + @Test + public void whenBasicAndAdvanceInfoIsComplete_thenShouldNotGiveConstraintViolationsWithCompleteInfoValidationGroup() { + RegistrationForm form = buildRegistrationFormWithBasicAndAdvanceInfo(); + Set> violations = validator.validate(form, CompleteInfo.class); + assertThat(violations.size()).isEqualTo(0); + } - @Test - public void whenBasicAndAdvanceInfoIsComplete_thenShouldNotGiveConstraintViolations() { - RegistrationForm form = buildRegistrationFormWithBasicAndAdvanceInfo(); - Set> violations = validator.validate(form); - assertThat(violations.size()).isEqualTo(0); - } + @Test + public void whenBasicAndAdvanceInfoIsComplete_thenShouldNotGiveConstraintViolations() { + RegistrationForm form = buildRegistrationFormWithBasicAndAdvanceInfo(); + Set> violations = validator.validate(form); + assertThat(violations.size()).isEqualTo(0); + } - private RegistrationForm buildRegistrationFormWithBasicInfo() { - RegistrationForm form = new RegistrationForm(); - form.setFirstName("devender"); - form.setLastName("kumar"); - form.setEmail("anyemail@yopmail.com"); - form.setPhone("12345"); - form.setCaptcha("Y2HAhU5T"); - return form; - } + private RegistrationForm buildRegistrationFormWithBasicInfo() { + RegistrationForm form = new RegistrationForm(); + form.setFirstName("devender"); + form.setLastName("kumar"); + form.setEmail("anyemail@yopmail.com"); + form.setPhone("12345"); + form.setCaptcha("Y2HAhU5T"); + return form; + } - private RegistrationForm buildRegistrationFormWithAdvanceInfo() { - RegistrationForm form = new RegistrationForm(); - return populateAdvanceInfo(form); - } + private RegistrationForm buildRegistrationFormWithAdvanceInfo() { + RegistrationForm form = new RegistrationForm(); + return populateAdvanceInfo(form); + } - private RegistrationForm populateAdvanceInfo(RegistrationForm form) { - form.setCity("Berlin"); - form.setContry("DE"); - form.setStreet("alexa str."); - form.setZipCode("19923"); - form.setHouseNumber("2a"); - form.setCaptcha("Y2HAhU5T"); - return form; - } + private RegistrationForm populateAdvanceInfo(RegistrationForm form) { + form.setCity("Berlin"); + form.setCountry("DE"); + form.setStreet("alexa str."); + form.setZipCode("19923"); + form.setHouseNumber("2a"); + form.setCaptcha("Y2HAhU5T"); + return form; + } - private RegistrationForm buildRegistrationFormWithBasicAndAdvanceInfo() { - RegistrationForm form = buildRegistrationFormWithBasicInfo(); - return populateAdvanceInfo(form); - } + private RegistrationForm buildRegistrationFormWithBasicAndAdvanceInfo() { + RegistrationForm form = buildRegistrationFormWithBasicInfo(); + return populateAdvanceInfo(form); + } } diff --git a/javaxval/src/test/java/org/baeldung/javaxval/beanvalidation/ValidationIntegrationTest.java b/javaxval/src/test/java/org/baeldung/javaxval/beanvalidation/ValidationIntegrationTest.java index 6639d60ac6..3d54955177 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/beanvalidation/ValidationIntegrationTest.java +++ b/javaxval/src/test/java/org/baeldung/javaxval/beanvalidation/ValidationIntegrationTest.java @@ -94,7 +94,7 @@ public class ValidationIntegrationTest { Set> violations = validator.validate(user); assertEquals(1, violations.size()); } - + @Test public void givenBlankPreference_thenValidationFails() { User user = createUser(); @@ -107,18 +107,18 @@ public class ValidationIntegrationTest { @Test public void givenEmptyOptional_thenValidationSucceeds() { User user = createUser(); - - Set> violations = validator.validate(user); - assertEquals(0, violations.size()); - } - - @Test - public void givenPastDateOfBirth_thenValidationSuccess() { - User user = createUser(); - user.setDateOfBirth(LocalDate.of(1980, 5, 20)); Set> violations = validator.validate(user); assertEquals(0, violations.size()); - + } + + @Test + public void givenPastDateOfBirth_thenValidationSuccess() { + User user = createUser(); + user.setDateOfBirth(LocalDate.of(1980, 5, 20)); + + Set> violations = validator.validate(user); + assertEquals(0, violations.size()); + } } diff --git a/javaxval/src/test/java/org/baeldung/javaxval/methodvalidation/ContainerValidationIntegrationTest.java b/javaxval/src/test/java/org/baeldung/javaxval/methodvalidation/ContainerValidationIntegrationTest.java index 2363bf8f5d..8febdca0ee 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/methodvalidation/ContainerValidationIntegrationTest.java +++ b/javaxval/src/test/java/org/baeldung/javaxval/methodvalidation/ContainerValidationIntegrationTest.java @@ -1,5 +1,10 @@ package org.baeldung.javaxval.methodvalidation; +import java.time.LocalDate; +import java.util.List; + +import javax.validation.ConstraintViolationException; + import org.baeldung.javaxval.methodvalidation.model.Customer; import org.baeldung.javaxval.methodvalidation.model.Reservation; import org.baeldung.javaxval.methodvalidation.model.ReservationManagement; @@ -12,10 +17,6 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; -import javax.validation.ConstraintViolationException; -import java.time.LocalDate; -import java.util.List; - @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { MethodValidationConfig.class }, loader = AnnotationConfigContextLoader.class) public class ContainerValidationIntegrationTest { diff --git a/javaxval/src/test/java/org/baeldung/javaxval/methodvalidation/ValidationIntegrationTest.java b/javaxval/src/test/java/org/baeldung/javaxval/methodvalidation/ValidationIntegrationTest.java index 6b53d3a107..9baeba7189 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/methodvalidation/ValidationIntegrationTest.java +++ b/javaxval/src/test/java/org/baeldung/javaxval/methodvalidation/ValidationIntegrationTest.java @@ -1,21 +1,23 @@ package org.baeldung.javaxval.methodvalidation; +import static org.junit.Assert.assertEquals; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.time.LocalDate; +import java.util.Collections; +import java.util.Set; + +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.ValidatorFactory; +import javax.validation.executable.ExecutableValidator; + import org.baeldung.javaxval.methodvalidation.model.Customer; import org.baeldung.javaxval.methodvalidation.model.Reservation; import org.baeldung.javaxval.methodvalidation.model.ReservationManagement; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.*; - -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.ValidatorFactory; -import javax.validation.executable.ExecutableValidator; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.time.LocalDate; -import java.util.Collections; -import java.util.Set; public class ValidationIntegrationTest { From 5aba544fb8ea057478d70c3fc7e15d4866e6223e Mon Sep 17 00:00:00 2001 From: Martin van Wingerden Date: Wed, 2 Oct 2019 13:58:31 +0200 Subject: [PATCH 49/55] Re-enabled a disabled test and made the tests independent of machine locale --- javaxval/src/main/java/org/baeldung/Customer.java | 1 + .../java/org/baeldung/ContainerValidationIntegrationTest.java | 2 +- .../javabeanconstraints/bigdecimal/InvoiceUnitTest.java | 3 +++ .../validationgroup/RegistrationFormUnitTest.java | 3 +++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/javaxval/src/main/java/org/baeldung/Customer.java b/javaxval/src/main/java/org/baeldung/Customer.java index 02a95cc546..f7f4a27b4a 100644 --- a/javaxval/src/main/java/org/baeldung/Customer.java +++ b/javaxval/src/main/java/org/baeldung/Customer.java @@ -20,6 +20,7 @@ public class Customer { @PositiveOrZero private OptionalInt numberOfOrders; + @NotBlank private Profile profile; public String getName() { diff --git a/javaxval/src/test/java/org/baeldung/ContainerValidationIntegrationTest.java b/javaxval/src/test/java/org/baeldung/ContainerValidationIntegrationTest.java index aa2cf577de..afa7c0c16c 100644 --- a/javaxval/src/test/java/org/baeldung/ContainerValidationIntegrationTest.java +++ b/javaxval/src/test/java/org/baeldung/ContainerValidationIntegrationTest.java @@ -76,7 +76,7 @@ public class ContainerValidationIntegrationTest { assertEquals(0, violations.size()); } - // @Test + @Test public void whenProfileCompanyNameBlank_thenValidationFails() { Customer customer = new Customer(); customer.setName("John"); diff --git a/javaxval/src/test/java/org/baeldung/javabeanconstraints/bigdecimal/InvoiceUnitTest.java b/javaxval/src/test/java/org/baeldung/javabeanconstraints/bigdecimal/InvoiceUnitTest.java index a07328e2fb..50206259ae 100644 --- a/javaxval/src/test/java/org/baeldung/javabeanconstraints/bigdecimal/InvoiceUnitTest.java +++ b/javaxval/src/test/java/org/baeldung/javabeanconstraints/bigdecimal/InvoiceUnitTest.java @@ -3,6 +3,7 @@ package org.baeldung.javabeanconstraints.bigdecimal; import static org.assertj.core.api.Assertions.assertThat; import java.math.BigDecimal; +import java.util.Locale; import java.util.Set; import javax.validation.ConstraintViolation; @@ -18,6 +19,8 @@ public class InvoiceUnitTest { @BeforeClass public static void setupValidatorInstance() { + Locale.setDefault(Locale.US); + validator = Validation.buildDefaultValidatorFactory() .getValidator(); } diff --git a/javaxval/src/test/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationFormUnitTest.java b/javaxval/src/test/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationFormUnitTest.java index efe61bf926..e0b1aa7bf8 100644 --- a/javaxval/src/test/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationFormUnitTest.java +++ b/javaxval/src/test/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationFormUnitTest.java @@ -2,6 +2,7 @@ package org.baeldung.javabeanconstraints.validationgroup; import static org.assertj.core.api.Assertions.assertThat; +import java.util.Locale; import java.util.Set; import javax.validation.ConstraintViolation; @@ -16,6 +17,8 @@ public class RegistrationFormUnitTest { @BeforeClass public static void setupValidatorInstance() { + Locale.setDefault(Locale.US); + validator = Validation.buildDefaultValidatorFactory() .getValidator(); } From 3d296c30a548cbb85067c89224647b9297180c8a Mon Sep 17 00:00:00 2001 From: Martin van Wingerden Date: Wed, 2 Oct 2019 19:55:24 +0200 Subject: [PATCH 50/55] Moved classes/package to right package --- .../validationgroup/AdvanceInfo.java | 5 - .../validationgroup/BasicInfo.java | 5 - .../bigdecimal/Invoice.java | 2 +- .../container/validation}/Customer.java | 2 +- .../container/validation}/CustomerMap.java | 2 +- .../container/validation}/Profile.java | 2 +- .../ProfileValueExtractor.java | 4 +- .../application}/Application.java | 36 ++--- .../entities/UserNotBlank.java | 44 +++--- .../entities/UserNotEmpty.java | 44 +++--- .../entities/UserNotNull.java | 44 +++--- .../javaxval/validationgroup/AdvanceInfo.java | 5 + .../javaxval/validationgroup/BasicInfo.java | 5 + .../validationgroup/CompleteInfo.java | 2 +- .../validationgroup/RegistrationForm.java | 2 +- ....validation.valueextraction.ValueExtractor | 2 +- .../bigdecimal/InvoiceUnitTest.java | 2 +- .../ContainerValidationIntegrationTest.java | 7 +- .../test/UserNotBlankUnitTest.java | 134 +++++++++--------- .../test/UserNotEmptyUnitTest.java | 116 +++++++-------- .../test/UserNotNullUnitTest.java | 116 +++++++-------- .../RegistrationFormUnitTest.java | 2 +- 22 files changed, 293 insertions(+), 290 deletions(-) delete mode 100644 javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/AdvanceInfo.java delete mode 100644 javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/BasicInfo.java rename javaxval/src/main/java/org/baeldung/{javabeanconstraints => javaxval}/bigdecimal/Invoice.java (89%) rename javaxval/src/main/java/org/baeldung/{ => javaxval/container/validation}/Customer.java (96%) rename javaxval/src/main/java/org/baeldung/{ => javaxval/container/validation}/CustomerMap.java (89%) rename javaxval/src/main/java/org/baeldung/{ => javaxval/container/validation}/Profile.java (81%) rename javaxval/src/main/java/org/baeldung/{ => javaxval/container/validation}/valueextractors/ProfileValueExtractor.java (79%) rename javaxval/src/main/java/org/baeldung/{javabeanconstraints/appplication => javaxval/javabeanconstraints/application}/Application.java (76%) rename javaxval/src/main/java/org/baeldung/{ => javaxval}/javabeanconstraints/entities/UserNotBlank.java (84%) rename javaxval/src/main/java/org/baeldung/{ => javaxval}/javabeanconstraints/entities/UserNotEmpty.java (84%) rename javaxval/src/main/java/org/baeldung/{ => javaxval}/javabeanconstraints/entities/UserNotNull.java (83%) create mode 100644 javaxval/src/main/java/org/baeldung/javaxval/validationgroup/AdvanceInfo.java create mode 100644 javaxval/src/main/java/org/baeldung/javaxval/validationgroup/BasicInfo.java rename javaxval/src/main/java/org/baeldung/{javabeanconstraints => javaxval}/validationgroup/CompleteInfo.java (69%) rename javaxval/src/main/java/org/baeldung/{javabeanconstraints => javaxval}/validationgroup/RegistrationForm.java (97%) rename javaxval/src/test/java/org/baeldung/{javabeanconstraints => javaxval}/bigdecimal/InvoiceUnitTest.java (98%) rename javaxval/src/test/java/org/baeldung/{ => javaxval/container/validation}/ContainerValidationIntegrationTest.java (90%) rename javaxval/src/test/java/org/baeldung/{ => javaxval}/javabeanconstraints/test/UserNotBlankUnitTest.java (90%) rename javaxval/src/test/java/org/baeldung/{ => javaxval}/javabeanconstraints/test/UserNotEmptyUnitTest.java (89%) rename javaxval/src/test/java/org/baeldung/{ => javaxval}/javabeanconstraints/test/UserNotNullUnitTest.java (89%) rename javaxval/src/test/java/org/baeldung/{javabeanconstraints => javaxval}/validationgroup/RegistrationFormUnitTest.java (99%) diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/AdvanceInfo.java b/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/AdvanceInfo.java deleted file mode 100644 index 4d5df052c2..0000000000 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/AdvanceInfo.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.javabeanconstraints.validationgroup; - -public interface AdvanceInfo { - -} diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/BasicInfo.java b/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/BasicInfo.java deleted file mode 100644 index 4564a7a702..0000000000 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/BasicInfo.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.javabeanconstraints.validationgroup; - -public interface BasicInfo { - -} diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/bigdecimal/Invoice.java b/javaxval/src/main/java/org/baeldung/javaxval/bigdecimal/Invoice.java similarity index 89% rename from javaxval/src/main/java/org/baeldung/javabeanconstraints/bigdecimal/Invoice.java rename to javaxval/src/main/java/org/baeldung/javaxval/bigdecimal/Invoice.java index 886123dad7..087701f166 100644 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/bigdecimal/Invoice.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/bigdecimal/Invoice.java @@ -1,4 +1,4 @@ -package org.baeldung.javabeanconstraints.bigdecimal; +package org.baeldung.javaxval.bigdecimal; import java.math.BigDecimal; diff --git a/javaxval/src/main/java/org/baeldung/Customer.java b/javaxval/src/main/java/org/baeldung/javaxval/container/validation/Customer.java similarity index 96% rename from javaxval/src/main/java/org/baeldung/Customer.java rename to javaxval/src/main/java/org/baeldung/javaxval/container/validation/Customer.java index f7f4a27b4a..6ca5ba3ee1 100644 --- a/javaxval/src/main/java/org/baeldung/Customer.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/container/validation/Customer.java @@ -1,4 +1,4 @@ -package org.baeldung; +package org.baeldung.javaxval.container.validation; import java.util.List; import java.util.Optional; diff --git a/javaxval/src/main/java/org/baeldung/CustomerMap.java b/javaxval/src/main/java/org/baeldung/javaxval/container/validation/CustomerMap.java similarity index 89% rename from javaxval/src/main/java/org/baeldung/CustomerMap.java rename to javaxval/src/main/java/org/baeldung/javaxval/container/validation/CustomerMap.java index d8830a7f42..82cf0f2b0c 100644 --- a/javaxval/src/main/java/org/baeldung/CustomerMap.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/container/validation/CustomerMap.java @@ -1,4 +1,4 @@ -package org.baeldung; +package org.baeldung.javaxval.container.validation; import java.util.Map; diff --git a/javaxval/src/main/java/org/baeldung/Profile.java b/javaxval/src/main/java/org/baeldung/javaxval/container/validation/Profile.java similarity index 81% rename from javaxval/src/main/java/org/baeldung/Profile.java rename to javaxval/src/main/java/org/baeldung/javaxval/container/validation/Profile.java index ec73a5c62f..41260540fc 100644 --- a/javaxval/src/main/java/org/baeldung/Profile.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/container/validation/Profile.java @@ -1,4 +1,4 @@ -package org.baeldung; +package org.baeldung.javaxval.container.validation; public class Profile { private String companyName; diff --git a/javaxval/src/main/java/org/baeldung/valueextractors/ProfileValueExtractor.java b/javaxval/src/main/java/org/baeldung/javaxval/container/validation/valueextractors/ProfileValueExtractor.java similarity index 79% rename from javaxval/src/main/java/org/baeldung/valueextractors/ProfileValueExtractor.java rename to javaxval/src/main/java/org/baeldung/javaxval/container/validation/valueextractors/ProfileValueExtractor.java index f192034261..ebc618e80e 100644 --- a/javaxval/src/main/java/org/baeldung/valueextractors/ProfileValueExtractor.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/container/validation/valueextractors/ProfileValueExtractor.java @@ -1,10 +1,10 @@ -package org.baeldung.valueextractors; +package org.baeldung.javaxval.container.validation.valueextractors; import javax.validation.valueextraction.ExtractedValue; import javax.validation.valueextraction.UnwrapByDefault; import javax.validation.valueextraction.ValueExtractor; -import org.baeldung.Profile; +import org.baeldung.javaxval.container.validation.Profile; @UnwrapByDefault public class ProfileValueExtractor implements ValueExtractor<@ExtractedValue(type = String.class) Profile> { diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/appplication/Application.java b/javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/application/Application.java similarity index 76% rename from javaxval/src/main/java/org/baeldung/javabeanconstraints/appplication/Application.java rename to javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/application/Application.java index e5927a093e..22095084c5 100644 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/appplication/Application.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/application/Application.java @@ -1,18 +1,18 @@ -package org.baeldung.javabeanconstraints.appplication; - -import javax.validation.Validation; -import javax.validation.Validator; - -import org.baeldung.javabeanconstraints.entities.UserNotBlank; - -public class Application { - - public static void main(String[] args) { - Validator validator = Validation.buildDefaultValidatorFactory() - .getValidator(); - UserNotBlank user = new UserNotBlank(" "); - validator.validate(user) - .stream() - .forEach(violation -> System.out.println(violation.getMessage())); - } -} +package org.baeldung.javaxval.javabeanconstraints.application; + +import javax.validation.Validation; +import javax.validation.Validator; + +import org.baeldung.javaxval.javabeanconstraints.entities.UserNotBlank; + +public class Application { + + public static void main(String[] args) { + Validator validator = Validation.buildDefaultValidatorFactory() + .getValidator(); + UserNotBlank user = new UserNotBlank(" "); + validator.validate(user) + .stream() + .forEach(violation -> System.out.println(violation.getMessage())); + } +} diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotBlank.java b/javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotBlank.java similarity index 84% rename from javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotBlank.java rename to javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotBlank.java index b49e587ce5..d86b6a65d2 100644 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotBlank.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotBlank.java @@ -1,22 +1,22 @@ -package org.baeldung.javabeanconstraints.entities; - -import javax.validation.constraints.NotBlank; - -public class UserNotBlank { - - @NotBlank(message = "Name is mandatory") - private final String name; - - public UserNotBlank(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - @Override - public String toString() { - return "User{" + "name=" + name + "}"; - } -} +package org.baeldung.javaxval.javabeanconstraints.entities; + +import javax.validation.constraints.NotBlank; + +public class UserNotBlank { + + @NotBlank(message = "Name is mandatory") + private final String name; + + public UserNotBlank(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + @Override + public String toString() { + return "User{" + "name=" + name + "}"; + } +} diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotEmpty.java b/javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotEmpty.java similarity index 84% rename from javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotEmpty.java rename to javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotEmpty.java index 0da768b103..2082265145 100644 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotEmpty.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotEmpty.java @@ -1,22 +1,22 @@ -package org.baeldung.javabeanconstraints.entities; - -import javax.validation.constraints.NotEmpty; - -public class UserNotEmpty { - - @NotEmpty(message = "Name is mandatory") - private final String name; - - public UserNotEmpty(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - @Override - public String toString() { - return "User{" + "name=" + name + "}"; - } -} +package org.baeldung.javaxval.javabeanconstraints.entities; + +import javax.validation.constraints.NotEmpty; + +public class UserNotEmpty { + + @NotEmpty(message = "Name is mandatory") + private final String name; + + public UserNotEmpty(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + @Override + public String toString() { + return "User{" + "name=" + name + "}"; + } +} diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotNull.java b/javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotNull.java similarity index 83% rename from javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotNull.java rename to javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotNull.java index 63a1017b75..e2f9e7ec57 100644 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/entities/UserNotNull.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotNull.java @@ -1,22 +1,22 @@ -package org.baeldung.javabeanconstraints.entities; - -import javax.validation.constraints.NotNull; - -public class UserNotNull { - - @NotNull(message = "Name is mandatory") - private final String name; - - public UserNotNull(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - @Override - public String toString() { - return "User{" + "name=" + name + "}"; - } -} +package org.baeldung.javaxval.javabeanconstraints.entities; + +import javax.validation.constraints.NotNull; + +public class UserNotNull { + + @NotNull(message = "Name is mandatory") + private final String name; + + public UserNotNull(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + @Override + public String toString() { + return "User{" + "name=" + name + "}"; + } +} diff --git a/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/AdvanceInfo.java b/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/AdvanceInfo.java new file mode 100644 index 0000000000..9a398e9e7e --- /dev/null +++ b/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/AdvanceInfo.java @@ -0,0 +1,5 @@ +package org.baeldung.javaxval.validationgroup; + +public interface AdvanceInfo { + +} diff --git a/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/BasicInfo.java b/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/BasicInfo.java new file mode 100644 index 0000000000..6959f52bfa --- /dev/null +++ b/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/BasicInfo.java @@ -0,0 +1,5 @@ +package org.baeldung.javaxval.validationgroup; + +public interface BasicInfo { + +} diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/CompleteInfo.java b/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/CompleteInfo.java similarity index 69% rename from javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/CompleteInfo.java rename to javaxval/src/main/java/org/baeldung/javaxval/validationgroup/CompleteInfo.java index 4d9de8150a..e34f318b5f 100644 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/CompleteInfo.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/CompleteInfo.java @@ -1,4 +1,4 @@ -package org.baeldung.javabeanconstraints.validationgroup; +package org.baeldung.javaxval.validationgroup; import javax.validation.GroupSequence; diff --git a/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationForm.java b/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/RegistrationForm.java similarity index 97% rename from javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationForm.java rename to javaxval/src/main/java/org/baeldung/javaxval/validationgroup/RegistrationForm.java index 197b9adad2..190a0c1280 100644 --- a/javaxval/src/main/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationForm.java +++ b/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/RegistrationForm.java @@ -1,4 +1,4 @@ -package org.baeldung.javabeanconstraints.validationgroup; +package org.baeldung.javaxval.validationgroup; import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; diff --git a/javaxval/src/main/resources/META-INF/services/javax.validation.valueextraction.ValueExtractor b/javaxval/src/main/resources/META-INF/services/javax.validation.valueextraction.ValueExtractor index e77a30cfe4..16bacf1097 100644 --- a/javaxval/src/main/resources/META-INF/services/javax.validation.valueextraction.ValueExtractor +++ b/javaxval/src/main/resources/META-INF/services/javax.validation.valueextraction.ValueExtractor @@ -1 +1 @@ -org.baeldung.valueextractors.ProfileValueExtractor \ No newline at end of file +org.baeldung.javaxval.container.validation.valueextractors.ProfileValueExtractor \ No newline at end of file diff --git a/javaxval/src/test/java/org/baeldung/javabeanconstraints/bigdecimal/InvoiceUnitTest.java b/javaxval/src/test/java/org/baeldung/javaxval/bigdecimal/InvoiceUnitTest.java similarity index 98% rename from javaxval/src/test/java/org/baeldung/javabeanconstraints/bigdecimal/InvoiceUnitTest.java rename to javaxval/src/test/java/org/baeldung/javaxval/bigdecimal/InvoiceUnitTest.java index 50206259ae..0517642828 100644 --- a/javaxval/src/test/java/org/baeldung/javabeanconstraints/bigdecimal/InvoiceUnitTest.java +++ b/javaxval/src/test/java/org/baeldung/javaxval/bigdecimal/InvoiceUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.javabeanconstraints.bigdecimal; +package org.baeldung.javaxval.bigdecimal; import static org.assertj.core.api.Assertions.assertThat; diff --git a/javaxval/src/test/java/org/baeldung/ContainerValidationIntegrationTest.java b/javaxval/src/test/java/org/baeldung/javaxval/container/validation/ContainerValidationIntegrationTest.java similarity index 90% rename from javaxval/src/test/java/org/baeldung/ContainerValidationIntegrationTest.java rename to javaxval/src/test/java/org/baeldung/javaxval/container/validation/ContainerValidationIntegrationTest.java index afa7c0c16c..fc92c06f9a 100644 --- a/javaxval/src/test/java/org/baeldung/ContainerValidationIntegrationTest.java +++ b/javaxval/src/test/java/org/baeldung/javaxval/container/validation/ContainerValidationIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package org.baeldung.javaxval.container.validation; import static org.junit.Assert.assertEquals; @@ -11,7 +11,10 @@ import javax.validation.Validation; import javax.validation.Validator; import javax.validation.ValidatorFactory; -import org.baeldung.valueextractors.ProfileValueExtractor; +import org.baeldung.javaxval.container.validation.Customer; +import org.baeldung.javaxval.container.validation.CustomerMap; +import org.baeldung.javaxval.container.validation.Profile; +import org.baeldung.javaxval.container.validation.valueextractors.ProfileValueExtractor; import org.junit.Before; import org.junit.Test; diff --git a/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotBlankUnitTest.java b/javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotBlankUnitTest.java similarity index 90% rename from javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotBlankUnitTest.java rename to javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotBlankUnitTest.java index 48ecb2e649..e3a51d4e27 100644 --- a/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotBlankUnitTest.java +++ b/javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotBlankUnitTest.java @@ -1,67 +1,67 @@ -package org.baeldung.javabeanconstraints.test; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Set; - -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; - -import org.baeldung.javabeanconstraints.entities.UserNotBlank; -import org.junit.BeforeClass; -import org.junit.Test; - -public class UserNotBlankUnitTest { - - private static Validator validator; - - @BeforeClass - public static void setupValidatorInstance() { - validator = Validation.buildDefaultValidatorFactory() - .getValidator(); - } - - @Test - public void whenNotBlankName_thenNoConstraintViolations() { - UserNotBlank user = new UserNotBlank("John"); - - Set> violations = validator.validate(user); - - assertThat(violations.size()).isEqualTo(0); - } - - @Test - public void whenBlankName_thenOneConstraintViolation() { - UserNotBlank user = new UserNotBlank(" "); - - Set> violations = validator.validate(user); - - assertThat(violations.size()).isEqualTo(1); - } - - @Test - public void whenEmptyName_thenOneConstraintViolation() { - UserNotBlank user = new UserNotBlank(""); - - Set> violations = validator.validate(user); - - assertThat(violations.size()).isEqualTo(1); - } - - @Test - public void whenNullName_thenOneConstraintViolation() { - UserNotBlank user = new UserNotBlank(null); - - Set> violations = validator.validate(user); - - assertThat(violations.size()).isEqualTo(1); - } - - @Test - public void whenToString_thenCorrect() { - UserNotBlank user = new UserNotBlank("John"); - - assertThat(user.toString()).isEqualTo("User{name=John}"); - } -} +package org.baeldung.javaxval.javabeanconstraints.test; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Set; + +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; + +import org.baeldung.javaxval.javabeanconstraints.entities.UserNotBlank; +import org.junit.BeforeClass; +import org.junit.Test; + +public class UserNotBlankUnitTest { + + private static Validator validator; + + @BeforeClass + public static void setupValidatorInstance() { + validator = Validation.buildDefaultValidatorFactory() + .getValidator(); + } + + @Test + public void whenNotBlankName_thenNoConstraintViolations() { + UserNotBlank user = new UserNotBlank("John"); + + Set> violations = validator.validate(user); + + assertThat(violations.size()).isEqualTo(0); + } + + @Test + public void whenBlankName_thenOneConstraintViolation() { + UserNotBlank user = new UserNotBlank(" "); + + Set> violations = validator.validate(user); + + assertThat(violations.size()).isEqualTo(1); + } + + @Test + public void whenEmptyName_thenOneConstraintViolation() { + UserNotBlank user = new UserNotBlank(""); + + Set> violations = validator.validate(user); + + assertThat(violations.size()).isEqualTo(1); + } + + @Test + public void whenNullName_thenOneConstraintViolation() { + UserNotBlank user = new UserNotBlank(null); + + Set> violations = validator.validate(user); + + assertThat(violations.size()).isEqualTo(1); + } + + @Test + public void whenToString_thenCorrect() { + UserNotBlank user = new UserNotBlank("John"); + + assertThat(user.toString()).isEqualTo("User{name=John}"); + } +} diff --git a/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotEmptyUnitTest.java b/javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotEmptyUnitTest.java similarity index 89% rename from javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotEmptyUnitTest.java rename to javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotEmptyUnitTest.java index 6398d2bb91..22fbab6997 100644 --- a/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotEmptyUnitTest.java +++ b/javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotEmptyUnitTest.java @@ -1,58 +1,58 @@ -package org.baeldung.javabeanconstraints.test; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Set; - -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; - -import org.baeldung.javabeanconstraints.entities.UserNotEmpty; -import org.junit.BeforeClass; -import org.junit.Test; - -public class UserNotEmptyUnitTest { - - private static Validator validator; - - @BeforeClass - public static void setupValidatorInstance() { - validator = Validation.buildDefaultValidatorFactory() - .getValidator(); - } - - @Test - public void whenNotEmptyName_thenNoConstraintViolations() { - UserNotEmpty user = new UserNotEmpty("John"); - - Set> violations = validator.validate(user); - - assertThat(violations.size()).isEqualTo(0); - } - - @Test - public void whenEmptyName_thenOneConstraintViolation() { - UserNotEmpty user = new UserNotEmpty(""); - - Set> violations = validator.validate(user); - - assertThat(violations.size()).isEqualTo(1); - } - - @Test - public void whenNullName_thenOneConstraintViolation() { - UserNotEmpty user = new UserNotEmpty(null); - - Set> violations = validator.validate(user); - - assertThat(violations.size()).isEqualTo(1); - } - - @Test - public void whenToString_thenCorrect() { - UserNotEmpty user = new UserNotEmpty("John"); - - assertThat(user.toString()).isEqualTo("User{name=John}"); - } -} +package org.baeldung.javaxval.javabeanconstraints.test; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Set; + +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; + +import org.baeldung.javaxval.javabeanconstraints.entities.UserNotEmpty; +import org.junit.BeforeClass; +import org.junit.Test; + +public class UserNotEmptyUnitTest { + + private static Validator validator; + + @BeforeClass + public static void setupValidatorInstance() { + validator = Validation.buildDefaultValidatorFactory() + .getValidator(); + } + + @Test + public void whenNotEmptyName_thenNoConstraintViolations() { + UserNotEmpty user = new UserNotEmpty("John"); + + Set> violations = validator.validate(user); + + assertThat(violations.size()).isEqualTo(0); + } + + @Test + public void whenEmptyName_thenOneConstraintViolation() { + UserNotEmpty user = new UserNotEmpty(""); + + Set> violations = validator.validate(user); + + assertThat(violations.size()).isEqualTo(1); + } + + @Test + public void whenNullName_thenOneConstraintViolation() { + UserNotEmpty user = new UserNotEmpty(null); + + Set> violations = validator.validate(user); + + assertThat(violations.size()).isEqualTo(1); + } + + @Test + public void whenToString_thenCorrect() { + UserNotEmpty user = new UserNotEmpty("John"); + + assertThat(user.toString()).isEqualTo("User{name=John}"); + } +} diff --git a/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotNullUnitTest.java b/javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotNullUnitTest.java similarity index 89% rename from javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotNullUnitTest.java rename to javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotNullUnitTest.java index f9387f9199..a684668ae3 100644 --- a/javaxval/src/test/java/org/baeldung/javabeanconstraints/test/UserNotNullUnitTest.java +++ b/javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotNullUnitTest.java @@ -1,58 +1,58 @@ -package org.baeldung.javabeanconstraints.test; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Set; - -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; - -import org.baeldung.javabeanconstraints.entities.UserNotNull; -import org.junit.BeforeClass; -import org.junit.Test; - -public class UserNotNullUnitTest { - - private static Validator validator; - - @BeforeClass - public static void setupValidatorInstance() { - validator = Validation.buildDefaultValidatorFactory() - .getValidator(); - } - - @Test - public void whenNotNullName_thenNoConstraintViolations() { - UserNotNull user = new UserNotNull("John"); - - Set> violations = validator.validate(user); - - assertThat(violations.size()).isEqualTo(0); - } - - @Test - public void whenNullName_thenOneConstraintViolation() { - UserNotNull user = new UserNotNull(null); - - Set> violations = validator.validate(user); - - assertThat(violations.size()).isEqualTo(1); - } - - @Test - public void whenEmptyName_thenNoConstraintViolations() { - UserNotNull user = new UserNotNull(""); - - Set> violations = validator.validate(user); - - assertThat(violations.size()).isEqualTo(0); - } - - @Test - public void whenToString_thenCorrect() { - UserNotNull user = new UserNotNull("John"); - - assertThat(user.toString()).isEqualTo("User{name=John}"); - } -} +package org.baeldung.javaxval.javabeanconstraints.test; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Set; + +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; + +import org.baeldung.javaxval.javabeanconstraints.entities.UserNotNull; +import org.junit.BeforeClass; +import org.junit.Test; + +public class UserNotNullUnitTest { + + private static Validator validator; + + @BeforeClass + public static void setupValidatorInstance() { + validator = Validation.buildDefaultValidatorFactory() + .getValidator(); + } + + @Test + public void whenNotNullName_thenNoConstraintViolations() { + UserNotNull user = new UserNotNull("John"); + + Set> violations = validator.validate(user); + + assertThat(violations.size()).isEqualTo(0); + } + + @Test + public void whenNullName_thenOneConstraintViolation() { + UserNotNull user = new UserNotNull(null); + + Set> violations = validator.validate(user); + + assertThat(violations.size()).isEqualTo(1); + } + + @Test + public void whenEmptyName_thenNoConstraintViolations() { + UserNotNull user = new UserNotNull(""); + + Set> violations = validator.validate(user); + + assertThat(violations.size()).isEqualTo(0); + } + + @Test + public void whenToString_thenCorrect() { + UserNotNull user = new UserNotNull("John"); + + assertThat(user.toString()).isEqualTo("User{name=John}"); + } +} diff --git a/javaxval/src/test/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationFormUnitTest.java b/javaxval/src/test/java/org/baeldung/javaxval/validationgroup/RegistrationFormUnitTest.java similarity index 99% rename from javaxval/src/test/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationFormUnitTest.java rename to javaxval/src/test/java/org/baeldung/javaxval/validationgroup/RegistrationFormUnitTest.java index e0b1aa7bf8..a341c39531 100644 --- a/javaxval/src/test/java/org/baeldung/javabeanconstraints/validationgroup/RegistrationFormUnitTest.java +++ b/javaxval/src/test/java/org/baeldung/javaxval/validationgroup/RegistrationFormUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.javabeanconstraints.validationgroup; +package org.baeldung.javaxval.validationgroup; import static org.assertj.core.api.Assertions.assertThat; From 00d903dc6bec76619d14d201444ad1c75bec6b2e Mon Sep 17 00:00:00 2001 From: Martin van Wingerden Date: Fri, 4 Oct 2019 10:45:58 +0200 Subject: [PATCH 51/55] Add a parent class for locale aware tests --- .../javaxval/LocaleAwareUnitTest.java | 23 +++++++++++++++++++ .../javaxval/bigdecimal/InvoiceUnitTest.java | 6 ++--- .../ContainerValidationIntegrationTest.java | 3 --- .../RegistrationFormUnitTest.java | 6 ++--- 4 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 javaxval/src/test/java/org/baeldung/javaxval/LocaleAwareUnitTest.java diff --git a/javaxval/src/test/java/org/baeldung/javaxval/LocaleAwareUnitTest.java b/javaxval/src/test/java/org/baeldung/javaxval/LocaleAwareUnitTest.java new file mode 100644 index 0000000000..5623b50a72 --- /dev/null +++ b/javaxval/src/test/java/org/baeldung/javaxval/LocaleAwareUnitTest.java @@ -0,0 +1,23 @@ +package org.baeldung.javaxval; + +import java.util.Locale; + +import org.junit.AfterClass; +import org.junit.BeforeClass; + +public abstract class LocaleAwareUnitTest { + private static Locale previousDefault; + + @BeforeClass + public static void setupLocale() { + previousDefault = Locale.getDefault(); + + Locale.setDefault(Locale.US); + } + + @AfterClass + public static void resetLocale() { + Locale.setDefault(previousDefault); + } + +} diff --git a/javaxval/src/test/java/org/baeldung/javaxval/bigdecimal/InvoiceUnitTest.java b/javaxval/src/test/java/org/baeldung/javaxval/bigdecimal/InvoiceUnitTest.java index 0517642828..6a53d67f30 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/bigdecimal/InvoiceUnitTest.java +++ b/javaxval/src/test/java/org/baeldung/javaxval/bigdecimal/InvoiceUnitTest.java @@ -3,24 +3,22 @@ package org.baeldung.javaxval.bigdecimal; import static org.assertj.core.api.Assertions.assertThat; import java.math.BigDecimal; -import java.util.Locale; import java.util.Set; import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; +import org.baeldung.javaxval.LocaleAwareUnitTest; import org.junit.BeforeClass; import org.junit.Test; -public class InvoiceUnitTest { +public class InvoiceUnitTest extends LocaleAwareUnitTest { private static Validator validator; @BeforeClass public static void setupValidatorInstance() { - Locale.setDefault(Locale.US); - validator = Validation.buildDefaultValidatorFactory() .getValidator(); } diff --git a/javaxval/src/test/java/org/baeldung/javaxval/container/validation/ContainerValidationIntegrationTest.java b/javaxval/src/test/java/org/baeldung/javaxval/container/validation/ContainerValidationIntegrationTest.java index fc92c06f9a..25c8111732 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/container/validation/ContainerValidationIntegrationTest.java +++ b/javaxval/src/test/java/org/baeldung/javaxval/container/validation/ContainerValidationIntegrationTest.java @@ -11,9 +11,6 @@ import javax.validation.Validation; import javax.validation.Validator; import javax.validation.ValidatorFactory; -import org.baeldung.javaxval.container.validation.Customer; -import org.baeldung.javaxval.container.validation.CustomerMap; -import org.baeldung.javaxval.container.validation.Profile; import org.baeldung.javaxval.container.validation.valueextractors.ProfileValueExtractor; import org.junit.Before; import org.junit.Test; diff --git a/javaxval/src/test/java/org/baeldung/javaxval/validationgroup/RegistrationFormUnitTest.java b/javaxval/src/test/java/org/baeldung/javaxval/validationgroup/RegistrationFormUnitTest.java index a341c39531..df70ca0bce 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/validationgroup/RegistrationFormUnitTest.java +++ b/javaxval/src/test/java/org/baeldung/javaxval/validationgroup/RegistrationFormUnitTest.java @@ -2,23 +2,21 @@ package org.baeldung.javaxval.validationgroup; import static org.assertj.core.api.Assertions.assertThat; -import java.util.Locale; import java.util.Set; import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; +import org.baeldung.javaxval.LocaleAwareUnitTest; import org.junit.BeforeClass; import org.junit.Test; -public class RegistrationFormUnitTest { +public class RegistrationFormUnitTest extends LocaleAwareUnitTest { private static Validator validator; @BeforeClass public static void setupValidatorInstance() { - Locale.setDefault(Locale.US); - validator = Validation.buildDefaultValidatorFactory() .getValidator(); } From a0cbfa3b061a11832c710c83e13a85a5af48d550 Mon Sep 17 00:00:00 2001 From: wugangca Date: Fri, 4 Oct 2019 06:30:54 -0600 Subject: [PATCH 52/55] =?UTF-8?q?BAEL-2988=20Move=20the=20code=20from=20sp?= =?UTF-8?q?ring-rest-simple=20to=20spring-mvc-simple-=E2=80=A6=20(#7914)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * BAEL-2988 Move the code from spring-rest-simple to spring-mvc-simple-2, based on the review feedback. * BAEL-2988 revert previous changes in the spring-rest-simple --- .../com/baeldung/spring/config/MvcConfig.java | 22 +++++++++++++++++++ .../converter/StringToEnumConverter.java | 4 ++-- .../spring/enums}/EnumController.java | 6 ++--- .../GlobalControllerExceptionHandler.java | 2 +- .../com/baeldung/spring}/model/Modes.java | 2 +- .../java/com/baeldung/config/MvcConfig.java | 7 ------ 6 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 spring-mvc-simple-2/src/main/java/com/baeldung/spring/config/MvcConfig.java rename {spring-rest-simple/src/main/java/com/baeldung => spring-mvc-simple-2/src/main/java/com/baeldung/spring}/config/converter/StringToEnumConverter.java (86%) rename {spring-rest-simple/src/main/java/com/baeldung/cors => spring-mvc-simple-2/src/main/java/com/baeldung/spring/enums}/EnumController.java (81%) rename {spring-rest-simple/src/main/java/com/baeldung => spring-mvc-simple-2/src/main/java/com/baeldung/spring}/exceptions/GlobalControllerExceptionHandler.java (94%) rename {spring-rest-simple/src/main/java/com/baeldung => spring-mvc-simple-2/src/main/java/com/baeldung/spring}/model/Modes.java (53%) diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/spring/config/MvcConfig.java b/spring-mvc-simple-2/src/main/java/com/baeldung/spring/config/MvcConfig.java new file mode 100644 index 0000000000..ad99e8169b --- /dev/null +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/spring/config/MvcConfig.java @@ -0,0 +1,22 @@ +package com.baeldung.spring.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.format.FormatterRegistry; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import com.baeldung.spring.config.converter.StringToEnumConverter; + +@Configuration +@EnableWebMvc +public class MvcConfig implements WebMvcConfigurer { + + public MvcConfig() { + super(); + } + + @Override + public void addFormatters(FormatterRegistry registry) { + registry.addConverter(new StringToEnumConverter()); + } +} diff --git a/spring-rest-simple/src/main/java/com/baeldung/config/converter/StringToEnumConverter.java b/spring-mvc-simple-2/src/main/java/com/baeldung/spring/config/converter/StringToEnumConverter.java similarity index 86% rename from spring-rest-simple/src/main/java/com/baeldung/config/converter/StringToEnumConverter.java rename to spring-mvc-simple-2/src/main/java/com/baeldung/spring/config/converter/StringToEnumConverter.java index 349ee5a796..b481f691bf 100644 --- a/spring-rest-simple/src/main/java/com/baeldung/config/converter/StringToEnumConverter.java +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/spring/config/converter/StringToEnumConverter.java @@ -1,9 +1,9 @@ -package com.baeldung.config.converter; +package com.baeldung.spring.config.converter; import org.springframework.core.convert.converter.Converter; import org.springframework.stereotype.Component; -import com.baeldung.model.Modes; +import com.baeldung.spring.model.Modes; @Component public class StringToEnumConverter implements Converter { diff --git a/spring-rest-simple/src/main/java/com/baeldung/cors/EnumController.java b/spring-mvc-simple-2/src/main/java/com/baeldung/spring/enums/EnumController.java similarity index 81% rename from spring-rest-simple/src/main/java/com/baeldung/cors/EnumController.java rename to spring-mvc-simple-2/src/main/java/com/baeldung/spring/enums/EnumController.java index 34ce4d3927..356e751d5e 100644 --- a/spring-rest-simple/src/main/java/com/baeldung/cors/EnumController.java +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/spring/enums/EnumController.java @@ -1,15 +1,13 @@ -package com.baeldung.cors; +package com.baeldung.spring.enums; -import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.baeldung.model.Modes; +import com.baeldung.spring.model.Modes; -@CrossOrigin(maxAge = 3600) @RestController @RequestMapping("/enums") public class EnumController { diff --git a/spring-rest-simple/src/main/java/com/baeldung/exceptions/GlobalControllerExceptionHandler.java b/spring-mvc-simple-2/src/main/java/com/baeldung/spring/exceptions/GlobalControllerExceptionHandler.java similarity index 94% rename from spring-rest-simple/src/main/java/com/baeldung/exceptions/GlobalControllerExceptionHandler.java rename to spring-mvc-simple-2/src/main/java/com/baeldung/spring/exceptions/GlobalControllerExceptionHandler.java index 78fbcf97dd..2e0f1b6559 100644 --- a/spring-rest-simple/src/main/java/com/baeldung/exceptions/GlobalControllerExceptionHandler.java +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/spring/exceptions/GlobalControllerExceptionHandler.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptions; +package com.baeldung.spring.exceptions; import org.springframework.core.convert.ConversionFailedException; import org.springframework.http.HttpStatus; diff --git a/spring-rest-simple/src/main/java/com/baeldung/model/Modes.java b/spring-mvc-simple-2/src/main/java/com/baeldung/spring/model/Modes.java similarity index 53% rename from spring-rest-simple/src/main/java/com/baeldung/model/Modes.java rename to spring-mvc-simple-2/src/main/java/com/baeldung/spring/model/Modes.java index d3a1ab4a61..dc05448f3f 100644 --- a/spring-rest-simple/src/main/java/com/baeldung/model/Modes.java +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/spring/model/Modes.java @@ -1,4 +1,4 @@ -package com.baeldung.model; +package com.baeldung.spring.model; public enum Modes { ALPHA, BETA; diff --git a/spring-rest-simple/src/main/java/com/baeldung/config/MvcConfig.java b/spring-rest-simple/src/main/java/com/baeldung/config/MvcConfig.java index 246049b722..48b627a344 100644 --- a/spring-rest-simple/src/main/java/com/baeldung/config/MvcConfig.java +++ b/spring-rest-simple/src/main/java/com/baeldung/config/MvcConfig.java @@ -2,7 +2,6 @@ package com.baeldung.config; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.format.FormatterRegistry; import org.springframework.http.MediaType; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.StringHttpMessageConverter; @@ -18,7 +17,6 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import com.baeldung.config.converter.KryoHttpMessageConverter; -import com.baeldung.config.converter.StringToEnumConverter; import java.text.SimpleDateFormat; import java.util.List; @@ -73,9 +71,4 @@ public class MvcConfig implements WebMvcConfigurer { public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**"); } - - @Override - public void addFormatters(FormatterRegistry registry) { - registry.addConverter(new StringToEnumConverter()); - } } From 4ad1a192f829f6c71291747510078972a33fdd80 Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Sat, 5 Oct 2019 19:32:30 +0530 Subject: [PATCH 53/55] BAEL-18132 Fix the integrations tests in spring-boot -Modified tests to used Random Port instead of Defined Port to avoid port conflicts --- ...ationTest.java => ContactAppUnitTest.java} | 27 ++++++++++++++----- ...ppWithObjectMapperCustomizerUnitTest.java} | 23 ++++++++++++---- 2 files changed, 38 insertions(+), 12 deletions(-) rename spring-boot/src/test/java/com/baeldung/jsondateformat/{ContactAppIntegrationTest.java => ContactAppUnitTest.java} (87%) rename spring-boot/src/test/java/com/baeldung/jsondateformat/{ContactAppWithObjectMapperCustomizerIntegrationTest.java => ContactAppWithObjectMapperCustomizerUnitTest.java} (82%) diff --git a/spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppIntegrationTest.java b/spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppUnitTest.java similarity index 87% rename from spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppIntegrationTest.java rename to spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppUnitTest.java index 86af985d8a..7be85b5e4f 100644 --- a/spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppIntegrationTest.java +++ b/spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppUnitTest.java @@ -2,11 +2,14 @@ package com.baeldung.jsondateformat; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; + +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.http.ResponseEntity; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; @@ -22,23 +25,33 @@ import java.util.Map; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT; +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = DEFINED_PORT, classes = ContactApp.class) +@SpringBootTest(webEnvironment = RANDOM_PORT, classes = ContactApp.class) @TestPropertySource(properties = { "spring.jackson.date-format=yyyy-MM-dd HH:mm:ss" }) -public class ContactAppIntegrationTest { +public class ContactAppUnitTest { private final ObjectMapper mapper = new ObjectMapper(); @Autowired TestRestTemplate restTemplate; + + @LocalServerPort + int port; + + String url; + @Before + public void before() { + url=String.format("http://localhost:%s", port); + } + @Test public void givenJsonFormatAnnotationAndJava8DateType_whenGet_thenReturnExpectedDateFormat() throws IOException, ParseException { - ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/contacts", String.class); + ResponseEntity response = restTemplate.getForEntity(url + "/contacts", String.class); assertEquals(200, response.getStatusCodeValue()); @@ -53,7 +66,7 @@ public class ContactAppIntegrationTest { @Test public void givenJsonFormatAnnotationAndLegacyDateType_whenGet_thenReturnExpectedDateFormat() throws IOException { - ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/contacts/javaUtilDate", String.class); + ResponseEntity response = restTemplate.getForEntity(url + "/contacts/javaUtilDate", String.class); assertEquals(200, response.getStatusCodeValue()); @@ -68,7 +81,7 @@ public class ContactAppIntegrationTest { @Test public void givenDefaultDateFormatInAppPropertiesAndLegacyDateType_whenGet_thenReturnExpectedDateFormat() throws IOException { - ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/contacts/plainWithJavaUtilDate", String.class); + ResponseEntity response = restTemplate.getForEntity(url + "/contacts/plainWithJavaUtilDate", String.class); assertEquals(200, response.getStatusCodeValue()); @@ -83,7 +96,7 @@ public class ContactAppIntegrationTest { @Test(expected = DateTimeParseException.class) public void givenDefaultDateFormatInAppPropertiesAndJava8DateType_whenGet_thenNotApplyFormat() throws IOException { - ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/contacts/plain", String.class); + ResponseEntity response = restTemplate.getForEntity(url + "/contacts/plain", String.class); assertEquals(200, response.getStatusCodeValue()); diff --git a/spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppWithObjectMapperCustomizerIntegrationTest.java b/spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppWithObjectMapperCustomizerUnitTest.java similarity index 82% rename from spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppWithObjectMapperCustomizerIntegrationTest.java rename to spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppWithObjectMapperCustomizerUnitTest.java index 554283d758..114f9bfc1a 100644 --- a/spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppWithObjectMapperCustomizerIntegrationTest.java +++ b/spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppWithObjectMapperCustomizerUnitTest.java @@ -2,11 +2,14 @@ package com.baeldung.jsondateformat; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; + +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.http.ResponseEntity; import org.springframework.test.context.junit4.SpringRunner; @@ -19,20 +22,30 @@ import java.util.Map; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT; +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = DEFINED_PORT, classes = ContactApp.class) -public class ContactAppWithObjectMapperCustomizerIntegrationTest { +@SpringBootTest(webEnvironment = RANDOM_PORT, classes = ContactApp.class) +public class ContactAppWithObjectMapperCustomizerUnitTest { private final ObjectMapper mapper = new ObjectMapper(); @Autowired TestRestTemplate restTemplate; + @LocalServerPort + int port; + + String url; + + @Before + public void before() { + url=String.format("http://localhost:%s", port); + } + @Test public void givenDefaultDateFormatInAppPropertiesAndLegacyDateType_whenGet_thenReturnExpectedDateFormat() throws IOException { - ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/contacts/plainWithJavaUtilDate", String.class); + ResponseEntity response = restTemplate.getForEntity(url + "/contacts/plainWithJavaUtilDate", String.class); assertEquals(200, response.getStatusCodeValue()); @@ -47,7 +60,7 @@ public class ContactAppWithObjectMapperCustomizerIntegrationTest { @Test public void givenDefaultDateFormatInAppPropertiesAndJava8DateType_whenGet_thenReturnExpectedDateFormat() throws IOException { - ResponseEntity response = restTemplate.getForEntity("http://localhost:8080/contacts/plain", String.class); + ResponseEntity response = restTemplate.getForEntity(url + "/contacts/plain", String.class); assertEquals(200, response.getStatusCodeValue()); From eeb46ed00ad5c57e57ca5df16a67665a533781ef Mon Sep 17 00:00:00 2001 From: Sjmillington Date: Sat, 5 Oct 2019 15:16:40 +0100 Subject: [PATCH 54/55] Changing AutoValue module to Code-Generation --- {autovalue => code-generation}/README.md | 3 ++- {autovalue => code-generation}/pom.xml | 4 ++-- .../src/main/java/com/baeldung/autofactory/App.java | 0 .../src/main/java/com/baeldung/autofactory/CustomStorage.java | 0 .../java/com/baeldung/autofactory/custom/AbstractFactory.java | 0 .../java/com/baeldung/autofactory/custom/CustomPhone.java | 0 .../main/java/com/baeldung/autofactory/custom/SmartPhone.java | 0 .../src/main/java/com/baeldung/autofactory/model/Camera.java | 0 .../java/com/baeldung/autofactory/model/ClassicPhone.java | 0 .../src/main/java/com/baeldung/autofactory/model/Phone.java | 0 .../com/baeldung/autofactory/modules/SonyCameraModule.java | 0 .../baeldung/autofactory/provided/IntermediateAssembler.java | 0 .../com/baeldung/autofactory/provider/SonyCameraProvider.java | 0 .../baeldung/autoservice/BingTranslationServiceProvider.java | 0 .../autoservice/GoogleTranslationServiceProvider.java | 0 .../java/com/baeldung/autoservice/TranslationService.java | 0 .../src/main/java/com/baeldung/autovalue/AutoValueMoney.java | 0 .../com/baeldung/autovalue/AutoValueMoneyWithBuilder.java | 0 .../src/main/java/com/baeldung/autovalue/Foo.java | 0 .../src/main/java/com/baeldung/autovalue/ImmutableMoney.java | 0 .../src/main/java/com/baeldung/autovalue/MutableMoney.java | 0 {autovalue => code-generation}/src/main/resources/logback.xml | 0 .../com/baeldung/autoservice/TranslationServiceUnitTest.java | 0 .../src/test/java/com/baeldung/autovalue/MoneyUnitTest.java | 0 pom.xml | 4 ++-- 25 files changed, 6 insertions(+), 5 deletions(-) rename {autovalue => code-generation}/README.md (93%) rename {autovalue => code-generation}/pom.xml (95%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autofactory/App.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autofactory/CustomStorage.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autofactory/custom/AbstractFactory.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autofactory/custom/CustomPhone.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autofactory/custom/SmartPhone.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autofactory/model/Camera.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autofactory/model/ClassicPhone.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autofactory/model/Phone.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autofactory/modules/SonyCameraModule.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autofactory/provided/IntermediateAssembler.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autofactory/provider/SonyCameraProvider.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autoservice/BingTranslationServiceProvider.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autoservice/GoogleTranslationServiceProvider.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autoservice/TranslationService.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autovalue/AutoValueMoney.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autovalue/AutoValueMoneyWithBuilder.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autovalue/Foo.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autovalue/ImmutableMoney.java (100%) rename {autovalue => code-generation}/src/main/java/com/baeldung/autovalue/MutableMoney.java (100%) rename {autovalue => code-generation}/src/main/resources/logback.xml (100%) rename {autovalue => code-generation}/src/test/java/com/baeldung/autoservice/TranslationServiceUnitTest.java (100%) rename {autovalue => code-generation}/src/test/java/com/baeldung/autovalue/MoneyUnitTest.java (100%) diff --git a/autovalue/README.md b/code-generation/README.md similarity index 93% rename from autovalue/README.md rename to code-generation/README.md index cdeed98e6d..289a336f99 100644 --- a/autovalue/README.md +++ b/code-generation/README.md @@ -1,8 +1,9 @@ -## AutoValue +## Code Generation This module contains articles about automatic code generation ### Relevant Articles: + - [Introduction to AutoValue](https://www.baeldung.com/introduction-to-autovalue) - [Introduction to AutoFactory](https://www.baeldung.com/autofactory) - [Google AutoService](https://www.baeldung.com/google-autoservice) diff --git a/autovalue/pom.xml b/code-generation/pom.xml similarity index 95% rename from autovalue/pom.xml rename to code-generation/pom.xml index a10e8ef055..7aefc1b5b3 100644 --- a/autovalue/pom.xml +++ b/code-generation/pom.xml @@ -2,9 +2,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 com.baeldung - autovalue + code-generation 1.0 - autovalue + code-generation com.baeldung diff --git a/autovalue/src/main/java/com/baeldung/autofactory/App.java b/code-generation/src/main/java/com/baeldung/autofactory/App.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autofactory/App.java rename to code-generation/src/main/java/com/baeldung/autofactory/App.java diff --git a/autovalue/src/main/java/com/baeldung/autofactory/CustomStorage.java b/code-generation/src/main/java/com/baeldung/autofactory/CustomStorage.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autofactory/CustomStorage.java rename to code-generation/src/main/java/com/baeldung/autofactory/CustomStorage.java diff --git a/autovalue/src/main/java/com/baeldung/autofactory/custom/AbstractFactory.java b/code-generation/src/main/java/com/baeldung/autofactory/custom/AbstractFactory.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autofactory/custom/AbstractFactory.java rename to code-generation/src/main/java/com/baeldung/autofactory/custom/AbstractFactory.java diff --git a/autovalue/src/main/java/com/baeldung/autofactory/custom/CustomPhone.java b/code-generation/src/main/java/com/baeldung/autofactory/custom/CustomPhone.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autofactory/custom/CustomPhone.java rename to code-generation/src/main/java/com/baeldung/autofactory/custom/CustomPhone.java diff --git a/autovalue/src/main/java/com/baeldung/autofactory/custom/SmartPhone.java b/code-generation/src/main/java/com/baeldung/autofactory/custom/SmartPhone.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autofactory/custom/SmartPhone.java rename to code-generation/src/main/java/com/baeldung/autofactory/custom/SmartPhone.java diff --git a/autovalue/src/main/java/com/baeldung/autofactory/model/Camera.java b/code-generation/src/main/java/com/baeldung/autofactory/model/Camera.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autofactory/model/Camera.java rename to code-generation/src/main/java/com/baeldung/autofactory/model/Camera.java diff --git a/autovalue/src/main/java/com/baeldung/autofactory/model/ClassicPhone.java b/code-generation/src/main/java/com/baeldung/autofactory/model/ClassicPhone.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autofactory/model/ClassicPhone.java rename to code-generation/src/main/java/com/baeldung/autofactory/model/ClassicPhone.java diff --git a/autovalue/src/main/java/com/baeldung/autofactory/model/Phone.java b/code-generation/src/main/java/com/baeldung/autofactory/model/Phone.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autofactory/model/Phone.java rename to code-generation/src/main/java/com/baeldung/autofactory/model/Phone.java diff --git a/autovalue/src/main/java/com/baeldung/autofactory/modules/SonyCameraModule.java b/code-generation/src/main/java/com/baeldung/autofactory/modules/SonyCameraModule.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autofactory/modules/SonyCameraModule.java rename to code-generation/src/main/java/com/baeldung/autofactory/modules/SonyCameraModule.java diff --git a/autovalue/src/main/java/com/baeldung/autofactory/provided/IntermediateAssembler.java b/code-generation/src/main/java/com/baeldung/autofactory/provided/IntermediateAssembler.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autofactory/provided/IntermediateAssembler.java rename to code-generation/src/main/java/com/baeldung/autofactory/provided/IntermediateAssembler.java diff --git a/autovalue/src/main/java/com/baeldung/autofactory/provider/SonyCameraProvider.java b/code-generation/src/main/java/com/baeldung/autofactory/provider/SonyCameraProvider.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autofactory/provider/SonyCameraProvider.java rename to code-generation/src/main/java/com/baeldung/autofactory/provider/SonyCameraProvider.java diff --git a/autovalue/src/main/java/com/baeldung/autoservice/BingTranslationServiceProvider.java b/code-generation/src/main/java/com/baeldung/autoservice/BingTranslationServiceProvider.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autoservice/BingTranslationServiceProvider.java rename to code-generation/src/main/java/com/baeldung/autoservice/BingTranslationServiceProvider.java diff --git a/autovalue/src/main/java/com/baeldung/autoservice/GoogleTranslationServiceProvider.java b/code-generation/src/main/java/com/baeldung/autoservice/GoogleTranslationServiceProvider.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autoservice/GoogleTranslationServiceProvider.java rename to code-generation/src/main/java/com/baeldung/autoservice/GoogleTranslationServiceProvider.java diff --git a/autovalue/src/main/java/com/baeldung/autoservice/TranslationService.java b/code-generation/src/main/java/com/baeldung/autoservice/TranslationService.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autoservice/TranslationService.java rename to code-generation/src/main/java/com/baeldung/autoservice/TranslationService.java diff --git a/autovalue/src/main/java/com/baeldung/autovalue/AutoValueMoney.java b/code-generation/src/main/java/com/baeldung/autovalue/AutoValueMoney.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autovalue/AutoValueMoney.java rename to code-generation/src/main/java/com/baeldung/autovalue/AutoValueMoney.java diff --git a/autovalue/src/main/java/com/baeldung/autovalue/AutoValueMoneyWithBuilder.java b/code-generation/src/main/java/com/baeldung/autovalue/AutoValueMoneyWithBuilder.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autovalue/AutoValueMoneyWithBuilder.java rename to code-generation/src/main/java/com/baeldung/autovalue/AutoValueMoneyWithBuilder.java diff --git a/autovalue/src/main/java/com/baeldung/autovalue/Foo.java b/code-generation/src/main/java/com/baeldung/autovalue/Foo.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autovalue/Foo.java rename to code-generation/src/main/java/com/baeldung/autovalue/Foo.java diff --git a/autovalue/src/main/java/com/baeldung/autovalue/ImmutableMoney.java b/code-generation/src/main/java/com/baeldung/autovalue/ImmutableMoney.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autovalue/ImmutableMoney.java rename to code-generation/src/main/java/com/baeldung/autovalue/ImmutableMoney.java diff --git a/autovalue/src/main/java/com/baeldung/autovalue/MutableMoney.java b/code-generation/src/main/java/com/baeldung/autovalue/MutableMoney.java similarity index 100% rename from autovalue/src/main/java/com/baeldung/autovalue/MutableMoney.java rename to code-generation/src/main/java/com/baeldung/autovalue/MutableMoney.java diff --git a/autovalue/src/main/resources/logback.xml b/code-generation/src/main/resources/logback.xml similarity index 100% rename from autovalue/src/main/resources/logback.xml rename to code-generation/src/main/resources/logback.xml diff --git a/autovalue/src/test/java/com/baeldung/autoservice/TranslationServiceUnitTest.java b/code-generation/src/test/java/com/baeldung/autoservice/TranslationServiceUnitTest.java similarity index 100% rename from autovalue/src/test/java/com/baeldung/autoservice/TranslationServiceUnitTest.java rename to code-generation/src/test/java/com/baeldung/autoservice/TranslationServiceUnitTest.java diff --git a/autovalue/src/test/java/com/baeldung/autovalue/MoneyUnitTest.java b/code-generation/src/test/java/com/baeldung/autovalue/MoneyUnitTest.java similarity index 100% rename from autovalue/src/test/java/com/baeldung/autovalue/MoneyUnitTest.java rename to code-generation/src/test/java/com/baeldung/autovalue/MoneyUnitTest.java diff --git a/pom.xml b/pom.xml index 733aaad056..0723c742ae 100644 --- a/pom.xml +++ b/pom.xml @@ -366,7 +366,6 @@ asciidoctor asm atomix - autovalue aws aws-lambda axon @@ -381,6 +380,7 @@ checker-plugin cloud-foundry-uaa/cf-uaa-oauth2-client cloud-foundry-uaa/cf-uaa-oauth2-resource-server + code-generation core-groovy core-groovy-2 core-groovy-collections @@ -1118,7 +1118,6 @@ asciidoctor asm atomix - autovalue aws aws-lambda axon @@ -1131,6 +1130,7 @@ checker-plugin cloud-foundry-uaa/cf-uaa-oauth2-client cloud-foundry-uaa/cf-uaa-oauth2-resource-server + code-generation core-groovy core-groovy-2 core-groovy-collections From 931e71095c79e0fd795cf3adc4c6f787d48295ca Mon Sep 17 00:00:00 2001 From: Sjmillington Date: Sat, 5 Oct 2019 16:58:08 +0100 Subject: [PATCH 55/55] Updated README language --- core-java-modules/core-java-lang-2/README.md | 2 +- core-java-modules/core-java-lang-syntax-2/README.md | 6 ++++-- core-java-modules/core-java-lang-syntax/README.md | 2 +- core-java-modules/core-java-lang/README.md | 2 +- core-java-modules/core-java-networking-2/README.md | 2 +- core-java-modules/core-java-networking/README.md | 2 +- core-java-modules/core-java-perf/README.md | 2 +- core-scala/README.md | 2 +- 8 files changed, 11 insertions(+), 9 deletions(-) diff --git a/core-java-modules/core-java-lang-2/README.md b/core-java-modules/core-java-lang-2/README.md index b03abe38f4..9904e59035 100644 --- a/core-java-modules/core-java-lang-2/README.md +++ b/core-java-modules/core-java-lang-2/README.md @@ -1,6 +1,6 @@ ## Core Java Lang (Part 2) -This module contains articles about core Java language +This module contains articles about core features in the Java language ### Relevant Articles: - [Java Primitives versus Objects](https://www.baeldung.com/java-primitives-vs-objects) diff --git a/core-java-modules/core-java-lang-syntax-2/README.md b/core-java-modules/core-java-lang-syntax-2/README.md index 4cef971f75..d8daadf2aa 100644 --- a/core-java-modules/core-java-lang-syntax-2/README.md +++ b/core-java-modules/core-java-lang-syntax-2/README.md @@ -1,6 +1,8 @@ -========= +## Core Java Lang Syntax -## Core Java Lang Syntax Cookbooks and Examples +This module contains articles about Java syntax ### Relevant Articles: + - [Java ‘private’ Access Modifier](https://www.baeldung.com/java-private-keyword) +- [[<-- Prev]](/core-java-modules/core-java-lang-syntax) diff --git a/core-java-modules/core-java-lang-syntax/README.md b/core-java-modules/core-java-lang-syntax/README.md index 1c95997bd5..6f3120ec2c 100644 --- a/core-java-modules/core-java-lang-syntax/README.md +++ b/core-java-modules/core-java-lang-syntax/README.md @@ -1,6 +1,6 @@ ## Core Java Lang Syntax -This module contains articles about core Java syntax +This module contains articles about Java syntax ### Relevant Articles: - [The Basics of Java Generics](http://www.baeldung.com/java-generics) diff --git a/core-java-modules/core-java-lang/README.md b/core-java-modules/core-java-lang/README.md index 312423ecee..cb460d6295 100644 --- a/core-java-modules/core-java-lang/README.md +++ b/core-java-modules/core-java-lang/README.md @@ -1,6 +1,6 @@ ## Core Java Lang -This module contains articles about core Java language +This module contains articles about core features in the Java language ### Relevant Articles: diff --git a/core-java-modules/core-java-networking-2/README.md b/core-java-modules/core-java-networking-2/README.md index 8fac91a0ae..c384a28b64 100644 --- a/core-java-modules/core-java-networking-2/README.md +++ b/core-java-modules/core-java-networking-2/README.md @@ -1,6 +1,6 @@ ## Core Java Networking (Part 2) -This module contains articles about core Java networking +This module contains articles about networking in Java ### Relevant Articles diff --git a/core-java-modules/core-java-networking/README.md b/core-java-modules/core-java-networking/README.md index c766e5d635..4038e9803a 100644 --- a/core-java-modules/core-java-networking/README.md +++ b/core-java-modules/core-java-networking/README.md @@ -1,6 +1,6 @@ ## Core Java Networking -This module contains articles about core Java networking +This module contains articles about networking in Java ### Relevant Articles diff --git a/core-java-modules/core-java-perf/README.md b/core-java-modules/core-java-perf/README.md index e644c73eea..d1d646ac7f 100644 --- a/core-java-modules/core-java-perf/README.md +++ b/core-java-modules/core-java-perf/README.md @@ -1,6 +1,6 @@ ## Core Java Performance -This module contains articles about core Java performance +This module contains articles about performance of Java applications ### Relevant Articles: - [Verbose Garbage Collection in Java](https://www.baeldung.com/java-verbose-gc) diff --git a/core-scala/README.md b/core-scala/README.md index cfdb0c44ed..e6fc75d59e 100644 --- a/core-scala/README.md +++ b/core-scala/README.md @@ -1,6 +1,6 @@ ## Core Scala -This module contains articles about core Scala +This module contains articles about Scala's core features ### Relevant Articles: