diff --git a/algorithms-miscellaneous-5/README.md b/algorithms-miscellaneous-5/README.md
index 6e0de7d64e..3e6eeb4c93 100644
--- a/algorithms-miscellaneous-5/README.md
+++ b/algorithms-miscellaneous-5/README.md
@@ -15,9 +15,5 @@ This module contains articles about algorithms. Some classes of algorithms, e.g.
- [Maximum Subarray Problem](https://www.baeldung.com/java-maximum-subarray)
- [How to Merge Two Sorted Arrays](https://www.baeldung.com/java-merge-sorted-arrays)
- [Median of Stream of Integers using Heap](https://www.baeldung.com/java-stream-integers-median-using-heap)
-- [Kruskal’s Algorithm for Spanning Trees](https://www.baeldung.com/java-spanning-trees-kruskal)
-- [Balanced Brackets Algorithm in Java](https://www.baeldung.com/java-balanced-brackets-algorithm)
-- [Efficiently Merge Sorted Java Sequences](https://www.baeldung.com/java-merge-sorted-sequences)
-- [Introduction to Greedy Algorithms with Java](https://www.baeldung.com/java-greedy-algorithms)
-- [The Caesar Cipher in Java](https://www.baeldung.com/java-caesar-cipher)
-- More articles: [[<-- prev]](/../algorithms-miscellaneous-4)
+- More articles: [[<-- prev]](/../algorithms-miscellaneous-4) [[next -->]](/../algorithms-miscellaneous-6)
+
diff --git a/algorithms-miscellaneous-5/pom.xml b/algorithms-miscellaneous-5/pom.xml
index 4131e1791d..615cf03467 100644
--- a/algorithms-miscellaneous-5/pom.xml
+++ b/algorithms-miscellaneous-5/pom.xml
@@ -25,12 +25,6 @@
commons-math3
${commons-math3.version}
-
- org.projectlombok
- lombok
- ${lombok.version}
- provided
-
pl.allegro.finance
tradukisto
diff --git a/algorithms-miscellaneous-6/README.md b/algorithms-miscellaneous-6/README.md
index 99be63d7ca..22ee51530f 100644
--- a/algorithms-miscellaneous-6/README.md
+++ b/algorithms-miscellaneous-6/README.md
@@ -2,3 +2,9 @@
- [Boruvka’s Algorithm for Minimum Spanning Trees](https://www.baeldung.com/java-boruvka-algorithm)
- [Gradient Descent in Java](https://www.baeldung.com/java-gradient-descent)
+- [Kruskal’s Algorithm for Spanning Trees](https://www.baeldung.com/java-spanning-trees-kruskal)
+- [Balanced Brackets Algorithm in Java](https://www.baeldung.com/java-balanced-brackets-algorithm)
+- [Efficiently Merge Sorted Java Sequences](https://www.baeldung.com/java-merge-sorted-sequences)
+- [Introduction to Greedy Algorithms with Java](https://www.baeldung.com/java-greedy-algorithms)
+- [The Caesar Cipher in Java](https://www.baeldung.com/java-caesar-cipher)
+- More articles: [[<-- prev]](/../algorithms-miscellaneous-5)
diff --git a/algorithms-miscellaneous-6/pom.xml b/algorithms-miscellaneous-6/pom.xml
index fda9cf10f9..0a0edcbb3f 100644
--- a/algorithms-miscellaneous-6/pom.xml
+++ b/algorithms-miscellaneous-6/pom.xml
@@ -18,10 +18,35 @@
guava
${guava.version}
+
+ org.junit.platform
+ junit-platform-commons
+ ${junit.platform.version}
+
+
+ org.assertj
+ assertj-core
+ ${org.assertj.core.version}
+ test
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+ provided
+
+
+ org.apache.commons
+ commons-math3
+ ${commons-math3.version}
+
28.1-jre
+ 3.9.0
+ 1.6.0
+ 3.6.1
diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDeque.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDeque.java
similarity index 100%
rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDeque.java
rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDeque.java
diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingString.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingString.java
similarity index 100%
rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingString.java
rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingString.java
diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/caesarcipher/CaesarCipher.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/caesarcipher/CaesarCipher.java
similarity index 100%
rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/caesarcipher/CaesarCipher.java
rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/caesarcipher/CaesarCipher.java
diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/Follower.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/Follower.java
similarity index 100%
rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/Follower.java
rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/Follower.java
diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/FollowersPath.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/FollowersPath.java
similarity index 100%
rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/FollowersPath.java
rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/FollowersPath.java
diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/GreedyAlgorithm.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/GreedyAlgorithm.java
similarity index 100%
rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/GreedyAlgorithm.java
rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/GreedyAlgorithm.java
diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/NonGreedyAlgorithm.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/NonGreedyAlgorithm.java
similarity index 100%
rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/NonGreedyAlgorithm.java
rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/NonGreedyAlgorithm.java
diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/SocialConnector.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/SocialConnector.java
similarity index 100%
rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/SocialConnector.java
rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/SocialConnector.java
diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/SocialUser.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/SocialUser.java
similarity index 100%
rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/SocialUser.java
rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/SocialUser.java
diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/CycleDetector.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/kruskal/CycleDetector.java
similarity index 100%
rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/CycleDetector.java
rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/kruskal/CycleDetector.java
diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/DisjointSetInfo.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/kruskal/DisjointSetInfo.java
similarity index 100%
rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/DisjointSetInfo.java
rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/kruskal/DisjointSetInfo.java
diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java
similarity index 100%
rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java
rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java
diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/HeapNode.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/minheapmerge/HeapNode.java
similarity index 95%
rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/HeapNode.java
rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/minheapmerge/HeapNode.java
index 9e8439cb87..e2e41baf4d 100644
--- a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/HeapNode.java
+++ b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/minheapmerge/HeapNode.java
@@ -1,13 +1,13 @@
-package com.baeldung.algorithms.minheapmerge;
-
-public class HeapNode {
-
- int element;
- int arrayIndex;
- int nextElementIndex = 1;
-
- public HeapNode(int element, int arrayIndex) {
- this.element = element;
- this.arrayIndex = arrayIndex;
- }
-}
+package com.baeldung.algorithms.minheapmerge;
+
+public class HeapNode {
+
+ int element;
+ int arrayIndex;
+ int nextElementIndex = 1;
+
+ public HeapNode(int element, int arrayIndex) {
+ this.element = element;
+ this.arrayIndex = arrayIndex;
+ }
+}
diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java
similarity index 96%
rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java
rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java
index b77ce43160..0217480e9e 100644
--- a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java
+++ b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java
@@ -1,88 +1,88 @@
-package com.baeldung.algorithms.minheapmerge;
-
-public class MinHeap {
-
- HeapNode[] heapNodes;
-
- public MinHeap(HeapNode heapNodes[]) {
- this.heapNodes = heapNodes;
- heapifyFromLastLeafsParent();
- }
-
- void heapifyFromLastLeafsParent() {
- int lastLeafsParentIndex = getParentNodeIndex(heapNodes.length);
- while (lastLeafsParentIndex >= 0) {
- heapify(lastLeafsParentIndex);
- lastLeafsParentIndex--;
- }
- }
-
- void heapify(int index) {
- int leftNodeIndex = getLeftNodeIndex(index);
- int rightNodeIndex = getRightNodeIndex(index);
- int smallestElementIndex = index;
- if (leftNodeIndex < heapNodes.length && heapNodes[leftNodeIndex].element < heapNodes[index].element) {
- smallestElementIndex = leftNodeIndex;
- }
- if (rightNodeIndex < heapNodes.length && heapNodes[rightNodeIndex].element < heapNodes[smallestElementIndex].element) {
- smallestElementIndex = rightNodeIndex;
- }
- if (smallestElementIndex != index) {
- swap(index, smallestElementIndex);
- heapify(smallestElementIndex);
- }
- }
-
- int getParentNodeIndex(int index) {
- return (index - 1) / 2;
- }
-
- int getLeftNodeIndex(int index) {
- return (2 * index + 1);
- }
-
- int getRightNodeIndex(int index) {
- return (2 * index + 2);
- }
-
- HeapNode getRootNode() {
- return heapNodes[0];
- }
-
- void heapifyFromRoot() {
- heapify(0);
- }
-
- void swap(int i, int j) {
- HeapNode temp = heapNodes[i];
- heapNodes[i] = heapNodes[j];
- heapNodes[j] = temp;
- }
-
- static int[] merge(int[][] array) {
- HeapNode[] heapNodes = new HeapNode[array.length];
- int resultingArraySize = 0;
-
- for (int i = 0; i < array.length; i++) {
- HeapNode node = new HeapNode(array[i][0], i);
- heapNodes[i] = node;
- resultingArraySize += array[i].length;
- }
-
- MinHeap minHeap = new MinHeap(heapNodes);
- int[] resultingArray = new int[resultingArraySize];
-
- for (int i = 0; i < resultingArraySize; i++) {
- HeapNode root = minHeap.getRootNode();
- resultingArray[i] = root.element;
-
- if (root.nextElementIndex < array[root.arrayIndex].length) {
- root.element = array[root.arrayIndex][root.nextElementIndex++];
- } else {
- root.element = Integer.MAX_VALUE;
- }
- minHeap.heapifyFromRoot();
- }
- return resultingArray;
- }
-}
+package com.baeldung.algorithms.minheapmerge;
+
+public class MinHeap {
+
+ HeapNode[] heapNodes;
+
+ public MinHeap(HeapNode heapNodes[]) {
+ this.heapNodes = heapNodes;
+ heapifyFromLastLeafsParent();
+ }
+
+ void heapifyFromLastLeafsParent() {
+ int lastLeafsParentIndex = getParentNodeIndex(heapNodes.length);
+ while (lastLeafsParentIndex >= 0) {
+ heapify(lastLeafsParentIndex);
+ lastLeafsParentIndex--;
+ }
+ }
+
+ void heapify(int index) {
+ int leftNodeIndex = getLeftNodeIndex(index);
+ int rightNodeIndex = getRightNodeIndex(index);
+ int smallestElementIndex = index;
+ if (leftNodeIndex < heapNodes.length && heapNodes[leftNodeIndex].element < heapNodes[index].element) {
+ smallestElementIndex = leftNodeIndex;
+ }
+ if (rightNodeIndex < heapNodes.length && heapNodes[rightNodeIndex].element < heapNodes[smallestElementIndex].element) {
+ smallestElementIndex = rightNodeIndex;
+ }
+ if (smallestElementIndex != index) {
+ swap(index, smallestElementIndex);
+ heapify(smallestElementIndex);
+ }
+ }
+
+ int getParentNodeIndex(int index) {
+ return (index - 1) / 2;
+ }
+
+ int getLeftNodeIndex(int index) {
+ return (2 * index + 1);
+ }
+
+ int getRightNodeIndex(int index) {
+ return (2 * index + 2);
+ }
+
+ HeapNode getRootNode() {
+ return heapNodes[0];
+ }
+
+ void heapifyFromRoot() {
+ heapify(0);
+ }
+
+ void swap(int i, int j) {
+ HeapNode temp = heapNodes[i];
+ heapNodes[i] = heapNodes[j];
+ heapNodes[j] = temp;
+ }
+
+ static int[] merge(int[][] array) {
+ HeapNode[] heapNodes = new HeapNode[array.length];
+ int resultingArraySize = 0;
+
+ for (int i = 0; i < array.length; i++) {
+ HeapNode node = new HeapNode(array[i][0], i);
+ heapNodes[i] = node;
+ resultingArraySize += array[i].length;
+ }
+
+ MinHeap minHeap = new MinHeap(heapNodes);
+ int[] resultingArray = new int[resultingArraySize];
+
+ for (int i = 0; i < resultingArraySize; i++) {
+ HeapNode root = minHeap.getRootNode();
+ resultingArray[i] = root.element;
+
+ if (root.nextElementIndex < array[root.arrayIndex].length) {
+ root.element = array[root.arrayIndex][root.nextElementIndex++];
+ } else {
+ root.element = Integer.MAX_VALUE;
+ }
+ minHeap.heapifyFromRoot();
+ }
+ return resultingArray;
+ }
+}
diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDequeUnitTest.java b/algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDequeUnitTest.java
similarity index 100%
rename from algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDequeUnitTest.java
rename to algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDequeUnitTest.java
diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingStringUnitTest.java b/algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingStringUnitTest.java
similarity index 100%
rename from algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingStringUnitTest.java
rename to algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingStringUnitTest.java
diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/caesarcipher/CaesarCipherUnitTest.java b/algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/caesarcipher/CaesarCipherUnitTest.java
similarity index 100%
rename from algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/caesarcipher/CaesarCipherUnitTest.java
rename to algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/caesarcipher/CaesarCipherUnitTest.java
diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/greedy/GreedyAlgorithmUnitTest.java b/algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/greedy/GreedyAlgorithmUnitTest.java
similarity index 100%
rename from algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/greedy/GreedyAlgorithmUnitTest.java
rename to algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/greedy/GreedyAlgorithmUnitTest.java
diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java b/algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java
similarity index 100%
rename from algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java
rename to algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java
diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapUnitTest.java b/algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapUnitTest.java
similarity index 96%
rename from algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapUnitTest.java
rename to algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapUnitTest.java
index 80d0d20f05..f84c860dcc 100644
--- a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapUnitTest.java
+++ b/algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapUnitTest.java
@@ -1,22 +1,22 @@
-package com.baeldung.algorithms.minheapmerge;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import org.junit.Test;
-
-public class MinHeapUnitTest {
-
- private final int[][] inputArray = { { 0, 6 }, { 1, 5, 10, 100 }, { 2, 4, 200, 650 } };
- private final int[] expectedArray = { 0, 1, 2, 4, 5, 6, 10, 100, 200, 650 };
-
- @Test
- public void givenSortedArrays_whenMerged_thenShouldReturnASingleSortedarray() {
- int[] resultArray = MinHeap.merge(inputArray);
-
- assertThat(resultArray.length, is(equalTo(10)));
- assertThat(resultArray, is(equalTo(expectedArray)));
- }
-
-}
+package com.baeldung.algorithms.minheapmerge;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+
+public class MinHeapUnitTest {
+
+ private final int[][] inputArray = { { 0, 6 }, { 1, 5, 10, 100 }, { 2, 4, 200, 650 } };
+ private final int[] expectedArray = { 0, 1, 2, 4, 5, 6, 10, 100, 200, 650 };
+
+ @Test
+ public void givenSortedArrays_whenMerged_thenShouldReturnASingleSortedarray() {
+ int[] resultArray = MinHeap.merge(inputArray);
+
+ assertThat(resultArray.length, is(equalTo(10)));
+ assertThat(resultArray, is(equalTo(expectedArray)));
+ }
+
+}
diff --git a/apache-shiro/pom.xml b/apache-shiro/pom.xml
index d519ba42af..3df6283437 100644
--- a/apache-shiro/pom.xml
+++ b/apache-shiro/pom.xml
@@ -10,9 +10,9 @@
com.baeldung
- parent-boot-1
+ parent-boot-2
0.0.1-SNAPSHOT
- ../parent-boot-1
+ ../parent-boot-2
diff --git a/apache-shiro/src/main/java/com/baeldung/Main.java b/apache-shiro/src/main/java/com/baeldung/Main.java
index 5e341f251b..99515bb705 100644
--- a/apache-shiro/src/main/java/com/baeldung/Main.java
+++ b/apache-shiro/src/main/java/com/baeldung/Main.java
@@ -1,11 +1,14 @@
package com.baeldung;
import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.authc.*;
+import org.apache.shiro.authc.AuthenticationException;
+import org.apache.shiro.authc.IncorrectCredentialsException;
+import org.apache.shiro.authc.LockedAccountException;
+import org.apache.shiro.authc.UnknownAccountException;
+import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.mgt.DefaultSecurityManager;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.realm.Realm;
-import org.apache.shiro.realm.text.IniRealm;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
diff --git a/apache-shiro/src/main/java/com/baeldung/MyCustomRealm.java b/apache-shiro/src/main/java/com/baeldung/MyCustomRealm.java
index 8d792c76a5..6d7c01d96e 100644
--- a/apache-shiro/src/main/java/com/baeldung/MyCustomRealm.java
+++ b/apache-shiro/src/main/java/com/baeldung/MyCustomRealm.java
@@ -1,16 +1,24 @@
package com.baeldung;
-import org.apache.shiro.authc.*;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.shiro.authc.AuthenticationException;
+import org.apache.shiro.authc.AuthenticationInfo;
+import org.apache.shiro.authc.AuthenticationToken;
+import org.apache.shiro.authc.SimpleAuthenticationInfo;
+import org.apache.shiro.authc.UnknownAccountException;
+import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.jdbc.JdbcRealm;
import org.apache.shiro.subject.PrincipalCollection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.*;
public class MyCustomRealm extends JdbcRealm {
diff --git a/apache-shiro/src/main/java/com/baeldung/shiro/permissions/custom/Main.java b/apache-shiro/src/main/java/com/baeldung/shiro/permissions/custom/Main.java
index a373122d6c..a902a24388 100644
--- a/apache-shiro/src/main/java/com/baeldung/shiro/permissions/custom/Main.java
+++ b/apache-shiro/src/main/java/com/baeldung/shiro/permissions/custom/Main.java
@@ -1,14 +1,15 @@
package com.baeldung.shiro.permissions.custom;
-import com.baeldung.MyCustomRealm;
import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.authc.*;
+import org.apache.shiro.authc.AuthenticationException;
+import org.apache.shiro.authc.IncorrectCredentialsException;
+import org.apache.shiro.authc.LockedAccountException;
+import org.apache.shiro.authc.UnknownAccountException;
+import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.config.Ini;
import org.apache.shiro.mgt.DefaultSecurityManager;
import org.apache.shiro.mgt.SecurityManager;
-import org.apache.shiro.realm.Realm;
import org.apache.shiro.realm.text.IniRealm;
-import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/atomikos/README.md b/atomikos/README.md
index 19f2e871d4..f9129233ec 100644
--- a/atomikos/README.md
+++ b/atomikos/README.md
@@ -1,7 +1,6 @@
## Atomikos
-
This module contains articles about Atomikos
### Relevant Articles:
-- [Guide Transactions Using Atomikos]()
+- [A Guide to Atomikos](https://www.baeldung.com/java-atomikos)
diff --git a/bazel/bazelapp/README.md b/bazel/bazelapp/README.md
deleted file mode 100644
index 528f797c21..0000000000
--- a/bazel/bazelapp/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-### Relevant Articles:
-
-- [Building Java Applications with Bazel](https://www.baeldung.com/bazel-build-tool)
diff --git a/core-groovy/README.md b/core-groovy/README.md
index 25a0aece3a..f852b3ccf2 100644
--- a/core-groovy/README.md
+++ b/core-groovy/README.md
@@ -12,4 +12,5 @@ This module contains articles about core Groovy concepts
- [Closures in Groovy](https://www.baeldung.com/groovy-closures)
- [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
+- [Convert String to Integer in Groovy](https://www.baeldung.com/groovy-convert-string-to-integer)
+- [[More -->]](/core-groovy-2)
diff --git a/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/helpfulnullpointerexceptions/HelpfulNullPointerException.java b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/npe/HelpfulNullPointerException.java
similarity index 95%
rename from core-java-modules/core-java-14/src/main/java/com/baeldung/java14/helpfulnullpointerexceptions/HelpfulNullPointerException.java
rename to core-java-modules/core-java-14/src/main/java/com/baeldung/java14/npe/HelpfulNullPointerException.java
index ef5dbb754c..913f796cd4 100644
--- a/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/helpfulnullpointerexceptions/HelpfulNullPointerException.java
+++ b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/npe/HelpfulNullPointerException.java
@@ -1,4 +1,4 @@
-package com.baeldung.java14.helpfulnullpointerexceptions;
+package com.baeldung.java14.npe;
public class HelpfulNullPointerException {
diff --git a/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/helpfulnullpointerexceptions/HelpfulNullPointerExceptionUnitTest.java b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/npe/HelpfulNullPointerExceptionUnitTest.java
similarity index 95%
rename from core-java-modules/core-java-14/src/test/java/com/baeldung/java14/helpfulnullpointerexceptions/HelpfulNullPointerExceptionUnitTest.java
rename to core-java-modules/core-java-14/src/test/java/com/baeldung/java14/npe/HelpfulNullPointerExceptionUnitTest.java
index fae331bb92..1b5153c706 100644
--- a/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/helpfulnullpointerexceptions/HelpfulNullPointerExceptionUnitTest.java
+++ b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/npe/HelpfulNullPointerExceptionUnitTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.java14.helpfulnullpointerexceptions;
+package com.baeldung.java14.npe;
import org.junit.Test;
diff --git a/core-java-modules/core-java-arrays-sorting/README.md b/core-java-modules/core-java-arrays-sorting/README.md
index f83dd43526..dedc0340c0 100644
--- a/core-java-modules/core-java-arrays-sorting/README.md
+++ b/core-java-modules/core-java-arrays-sorting/README.md
@@ -5,5 +5,5 @@ This module contains articles about sorting arrays in Java
### Relevant Articles:
- [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)
-- [How to Reverse an Array in Java](http://www.baeldung.com/java-invert-array)
+- [How to Reverse an Array in Java](https://www.baeldung.com/java-invert-array)
- [Arrays.sort vs Arrays.parallelSort](https://www.baeldung.com/java-arrays-sort-vs-parallelsort)
diff --git a/core-java-modules/core-java-collections-maps-3/README.md b/core-java-modules/core-java-collections-maps-3/README.md
index 64a3b75d83..7386f7e9b7 100644
--- a/core-java-modules/core-java-collections-maps-3/README.md
+++ b/core-java-modules/core-java-collections-maps-3/README.md
@@ -5,4 +5,5 @@ This module contains articles about Map data structures in Java.
### Relevant Articles:
- [Java TreeMap vs HashMap](https://www.baeldung.com/java-treemap-vs-hashmap)
- [Comparing Two HashMaps in Java](https://www.baeldung.com/java-compare-hashmaps)
+- [The Map.computeIfAbsent() Method](https://www.baeldung.com/java-map-computeifabsent)
- More articles: [[<-- prev]](/core-java-modules/core-java-collections-maps-2)
diff --git a/core-java-modules/core-java-concurrency-2/README.md b/core-java-modules/core-java-concurrency-2/README.md
index 749d174968..23471a237e 100644
--- a/core-java-modules/core-java-concurrency-2/README.md
+++ b/core-java-modules/core-java-concurrency-2/README.md
@@ -4,4 +4,5 @@
### Relevant Articles:
- [Using a Mutex Object in Java](https://www.baeldung.com/java-mutex)
+- [Testing Multi-Threaded Code in Java](https://www.baeldung.com/java-testing-multithreaded)
diff --git a/core-java-modules/core-java-concurrency-2/pom.xml b/core-java-modules/core-java-concurrency-2/pom.xml
index a9a01b70f3..dfb5674c8e 100644
--- a/core-java-modules/core-java-concurrency-2/pom.xml
+++ b/core-java-modules/core-java-concurrency-2/pom.xml
@@ -15,6 +15,38 @@
0.0.1-SNAPSHOT
../../parent-java
+
+
+
+ junit
+ junit
+ 4.13
+ test
+
+
+ com.googlecode.thread-weaver
+ threadweaver
+ 0.2
+ test
+
+
+ com.google.code.tempus-fugit
+ tempus-fugit
+ 1.1
+ test
+
+
+ com.googlecode.multithreadedtc
+ multithreadedtc
+ 1.01
+ test
+
+
+ org.openjdk.jcstress
+ jcstress-core
+ 0.5
+
+
core-java-concurrency-2
@@ -24,6 +56,51 @@
true
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.1
+
+ ${javac.target}
+ ${javac.target}
+ ${javac.target}
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.2
+
+
+ main
+ package
+
+ shade
+
+
+ jcstress
+
+
+ org.openjdk.jcstress.Main
+
+
+ META-INF/TestList
+
+
+
+
+
+
+
+
+
+ 1.8
+
diff --git a/core-java-modules/core-java-concurrency-testing/src/main/java/com/baeldung/concurrent/MyCounter.java b/core-java-modules/core-java-concurrency-2/src/main/java/com/baeldung/concurrent/MyCounter.java
similarity index 100%
rename from core-java-modules/core-java-concurrency-testing/src/main/java/com/baeldung/concurrent/MyCounter.java
rename to core-java-modules/core-java-concurrency-2/src/main/java/com/baeldung/concurrent/MyCounter.java
diff --git a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterJCStressUnitTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterJCStressUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterJCStressUnitTest.java
rename to core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterJCStressUnitTest.java
diff --git a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCUnitTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCUnitTest.java
similarity index 90%
rename from core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCUnitTest.java
rename to core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCUnitTest.java
index eb4e77cae9..8a0bedf6c2 100644
--- a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCUnitTest.java
+++ b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCUnitTest.java
@@ -1,5 +1,6 @@
package com.baeldung.concurrent;
+import org.junit.Ignore;
import org.junit.Test;
import edu.umd.cs.mtc.MultithreadedTestCase;
@@ -25,9 +26,10 @@ public class MyCounterMultithreadedTCUnitTest extends MultithreadedTestCase {
@SuppressWarnings("deprecation")
@Override
public void finish() {
- assertEquals(2, counter.getCount());
+ assertEquals(2, counter.getCount());
}
+ @Ignore
@Test
public void testCounter() throws Throwable {
TestFramework.runManyTimes(new MyCounterMultithreadedTCUnitTest(), 1000);
diff --git a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterSimpleUnitTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterSimpleUnitTest.java
similarity index 96%
rename from core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterSimpleUnitTest.java
rename to core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterSimpleUnitTest.java
index 4f3409b923..9a405e7e24 100644
--- a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterSimpleUnitTest.java
+++ b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterSimpleUnitTest.java
@@ -6,6 +6,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import org.junit.Ignore;
import org.junit.Test;
public class MyCounterSimpleUnitTest {
@@ -18,7 +19,8 @@ public class MyCounterSimpleUnitTest {
assertEquals(500, counter.getCount());
}
- // @Test
+ @Ignore
+ @Test
public void testCounterWithConcurrency() throws InterruptedException {
int numberOfThreads = 100;
ExecutorService service = Executors.newFixedThreadPool(10);
@@ -34,7 +36,8 @@ public class MyCounterSimpleUnitTest {
assertEquals(numberOfThreads, counter.getCount());
}
- // @Test
+ @Ignore
+ @Test
public void testSummationWithConcurrencyAndWait() throws InterruptedException {
int numberOfThreads = 2;
ExecutorService service = Executors.newFixedThreadPool(10);
diff --git a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitUnitTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitUnitTest.java
similarity index 96%
rename from core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitUnitTest.java
rename to core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitUnitTest.java
index 360c61b4f4..36a2031e78 100644
--- a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitUnitTest.java
+++ b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitUnitTest.java
@@ -3,6 +3,7 @@ package com.baeldung.concurrent;
import static org.junit.Assert.assertEquals;
import org.junit.AfterClass;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -20,6 +21,7 @@ public class MyCounterTempusFugitUnitTest {
private static MyCounter counter = new MyCounter();
+ @Ignore
@Test
@Concurrent(count = 2)
@Repeating(repetition = 10)
diff --git a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverUnitTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverUnitTest.java
similarity index 96%
rename from core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverUnitTest.java
rename to core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverUnitTest.java
index 29b08996cd..e65a963584 100644
--- a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverUnitTest.java
+++ b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverUnitTest.java
@@ -2,6 +2,7 @@ package com.baeldung.concurrent;
import static org.junit.Assert.assertEquals;
+import org.junit.Ignore;
import org.junit.Test;
import com.google.testing.threadtester.AnnotatedTestRunner;
@@ -34,6 +35,7 @@ public class MyCounterThreadWeaverUnitTest {
assertEquals(2, counter.getCount());
}
+ @Ignore
@Test
public void testCounter() {
new AnnotatedTestRunner().runTests(this.getClass(), MyCounter.class);
diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/deadlockAndLivelock/DeadlockExample.java b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/deadlockAndLivelock/DeadlockExample.java
new file mode 100644
index 0000000000..bcdaf302ea
--- /dev/null
+++ b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/deadlockAndLivelock/DeadlockExample.java
@@ -0,0 +1,60 @@
+package com.baeldung.deadlockAndLivelock;
+
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+public class DeadlockExample {
+
+ private Lock lock1 = new ReentrantLock(true);
+ private Lock lock2 = new ReentrantLock(true);
+
+ public static void main(String[] args) {
+ DeadlockExample deadlock = new DeadlockExample();
+ new Thread(deadlock::operation1, "T1").start();
+ new Thread(deadlock::operation2, "T2").start();
+
+ }
+
+ public void operation1() {
+ lock1.lock();
+ print("lock1 acquired, waiting to acquire lock2.");
+ sleep(50);
+
+ lock2.lock();
+ print("lock2 acquired");
+
+ print("executing first operation.");
+
+ lock2.unlock();
+ lock1.unlock();
+
+ }
+
+ public void operation2() {
+ lock2.lock();
+ print("lock2 acquired, waiting to acquire lock1.");
+ sleep(50);
+
+ lock1.lock();
+ print("lock1 acquired");
+
+ print("executing second operation.");
+
+ lock1.unlock();
+ lock2.unlock();
+ }
+
+ public void print(String message) {
+ System.out.println("Thread " + Thread.currentThread()
+ .getName() + ": " + message);
+ }
+
+ public void sleep(long millis) {
+ try {
+ Thread.sleep(millis);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/deadlockAndLivelock/LivelockExample.java b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/deadlockAndLivelock/LivelockExample.java
new file mode 100644
index 0000000000..b0d66a92c2
--- /dev/null
+++ b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/deadlockAndLivelock/LivelockExample.java
@@ -0,0 +1,86 @@
+package com.baeldung.deadlockAndLivelock;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+public class LivelockExample {
+
+ private Lock lock1 = new ReentrantLock(true);
+ private Lock lock2 = new ReentrantLock(true);
+
+ public static void main(String[] args) {
+ LivelockExample livelock = new LivelockExample();
+ new Thread(livelock::operation1, "T1").start();
+ new Thread(livelock::operation2, "T2").start();
+
+ }
+
+ public void operation1() {
+ while (true) {
+ tryLock(lock1, 50);
+ print("lock1 acquired, trying to acquire lock2.");
+ sleep(50);
+
+ if (tryLock(lock2)) {
+ print("lock2 acquired.");
+ } else {
+ print("cannot acquire lock2, releasing lock1.");
+ lock1.unlock();
+ continue;
+ }
+
+ print("executing first operation.");
+ break;
+ }
+ lock2.unlock();
+ lock1.unlock();
+ }
+
+ public void operation2() {
+ while (true) {
+ tryLock(lock2, 50);
+ print("lock2 acquired, trying to acquire lock1.");
+ sleep(50);
+
+ if (tryLock(lock1)) {
+ print("lock1 acquired.");
+ } else {
+ print("cannot acquire lock1, releasing lock2.");
+ lock2.unlock();
+ continue;
+ }
+
+ print("executing second operation.");
+ break;
+ }
+ lock1.unlock();
+ lock2.unlock();
+ }
+
+ public void print(String message) {
+ System.out.println("Thread " + Thread.currentThread()
+ .getName() + ": " + message);
+ }
+
+ public void sleep(long millis) {
+ try {
+ Thread.sleep(millis);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void tryLock(Lock lock, long millis) {
+ try {
+ lock.tryLock(10, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public boolean tryLock(Lock lock) {
+ return lock.tryLock();
+ }
+
+}
diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/lockfree/NonBlockingQueue.java b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/lockfree/NonBlockingQueue.java
new file mode 100644
index 0000000000..9140dc287d
--- /dev/null
+++ b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/lockfree/NonBlockingQueue.java
@@ -0,0 +1,81 @@
+package com.baeldung.lockfree;
+
+import java.util.NoSuchElementException;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class NonBlockingQueue {
+
+ private final AtomicReference> head, tail;
+ private final AtomicInteger size;
+
+ public NonBlockingQueue() {
+ head = new AtomicReference<>(null);
+ tail = new AtomicReference<>(null);
+ size = new AtomicInteger();
+ size.set(0);
+ }
+
+ public void add(T element) {
+ if (element == null) {
+ throw new NullPointerException();
+ }
+
+ Node node = new Node<>(element);
+ Node currentTail;
+ do {
+ currentTail = tail.get();
+ node.setPrevious(currentTail);
+ } while(!tail.compareAndSet(currentTail, node));
+
+ if(node.previous != null) {
+ node.previous.next = node;
+ }
+
+ head.compareAndSet(null, node); //if we are inserting the first element
+ size.incrementAndGet();
+ }
+
+ public T get() {
+ if(head.get() == null) {
+ throw new NoSuchElementException();
+ }
+
+ Node currentHead;
+ Node nextNode;
+ do {
+ currentHead = head.get();
+ nextNode = currentHead.getNext();
+ } while(!head.compareAndSet(currentHead, nextNode));
+
+ size.decrementAndGet();
+ return currentHead.getValue();
+ }
+
+ public int size() {
+ return this.size.get();
+ }
+
+ private class Node {
+ private final T value;
+ private volatile Node next;
+ private volatile Node previous;
+
+ public Node(T value) {
+ this.value = value;
+ this.next = null;
+ }
+
+ public T getValue() {
+ return value;
+ }
+
+ public Node getNext() {
+ return next;
+ }
+
+ public void setPrevious(Node previous) {
+ this.previous = previous;
+ }
+ }
+}
diff --git a/core-java-modules/core-java-concurrency-testing/README.md b/core-java-modules/core-java-concurrency-testing/README.md
deleted file mode 100644
index fef74a6750..0000000000
--- a/core-java-modules/core-java-concurrency-testing/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-=========
-
-## Core Java Concurrency Testing Examples
-
-### Relevant Articles:
-- [Testing Multi-Threaded Code in Java](https://www.baeldung.com/java-testing-multithreaded)
-
diff --git a/core-java-modules/core-java-concurrency-testing/pom.xml b/core-java-modules/core-java-concurrency-testing/pom.xml
deleted file mode 100644
index 51de83f67c..0000000000
--- a/core-java-modules/core-java-concurrency-testing/pom.xml
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
- 4.0.0
- core-java-concurrency-testing
- 0.1.0-SNAPSHOT
- core-java-concurrency-testing
- jar
-
-
- com.baeldung
- parent-java
- 0.0.1-SNAPSHOT
- ../../parent-java
-
-
-
-
- junit
- junit
- 4.13
- test
-
-
- com.googlecode.thread-weaver
- threadweaver
- 0.2
- test
-
-
- com.google.code.tempus-fugit
- tempus-fugit
- 1.1
- test
-
-
- com.googlecode.multithreadedtc
- multithreadedtc
- 1.01
- test
-
-
- org.openjdk.jcstress
- jcstress-core
- 0.5
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.1
-
- ${javac.target}
- ${javac.target}
- ${javac.target}
-
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 2.2
-
-
- main
- package
-
- shade
-
-
- jcstress
-
-
- org.openjdk.jcstress.Main
-
-
- META-INF/TestList
-
-
-
-
-
-
-
-
-
-
diff --git a/core-java-modules/core-java-concurrency-testing/src/main/resources/logback.xml b/core-java-modules/core-java-concurrency-testing/src/main/resources/logback.xml
deleted file mode 100644
index 56af2d397e..0000000000
--- a/core-java-modules/core-java-concurrency-testing/src/main/resources/logback.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/core-java-modules/core-java-concurrency-testing/src/test/resources/.gitignore b/core-java-modules/core-java-concurrency-testing/src/test/resources/.gitignore
deleted file mode 100644
index 83c05e60c8..0000000000
--- a/core-java-modules/core-java-concurrency-testing/src/test/resources/.gitignore
+++ /dev/null
@@ -1,13 +0,0 @@
-*.class
-
-#folders#
-/target
-/neoDb*
-/data
-/src/main/webapp/WEB-INF/classes
-*/META-INF/*
-
-# Packaged files #
-*.jar
-*.war
-*.ear
\ No newline at end of file
diff --git a/core-java-modules/core-java-exceptions/pom.xml b/core-java-modules/core-java-exceptions/pom.xml
index 60c5e2650a..0778b6b5a3 100644
--- a/core-java-modules/core-java-exceptions/pom.xml
+++ b/core-java-modules/core-java-exceptions/pom.xml
@@ -29,6 +29,11 @@
${lombok.version}
provided
+
+ org.apache.commons
+ commons-lang3
+ ${commons.lang3.version}
+
org.assertj
@@ -40,6 +45,7 @@
1.5.0-b01
+ 3.10
3.10.0
diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/Arithmetic.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/Arithmetic.java
new file mode 100644
index 0000000000..db29198b39
--- /dev/null
+++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/Arithmetic.java
@@ -0,0 +1,20 @@
+package com.baeldung.exceptions.globalexceptionhandler;
+
+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/globalexceptionhandler/ArrayIndexOutOfBounds.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/ArrayIndexOutOfBounds.java
new file mode 100644
index 0000000000..54c95f224c
--- /dev/null
+++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/ArrayIndexOutOfBounds.java
@@ -0,0 +1,24 @@
+package com.baeldung.exceptions.globalexceptionhandler;
+
+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/globalexceptionhandler/ClassCast.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/ClassCast.java
new file mode 100644
index 0000000000..8f8a6cf9e6
--- /dev/null
+++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/ClassCast.java
@@ -0,0 +1,36 @@
+package com.baeldung.exceptions.globalexceptionhandler;
+
+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/globalexceptionhandler/FileNotFound.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/FileNotFound.java
new file mode 100644
index 0000000000..a9f2e5ee84
--- /dev/null
+++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/FileNotFound.java
@@ -0,0 +1,25 @@
+package com.baeldung.exceptions.globalexceptionhandler;
+
+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/GlobalExceptionHandler.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/GlobalExceptionHandler.java
new file mode 100644
index 0000000000..f2e89f44e3
--- /dev/null
+++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/GlobalExceptionHandler.java
@@ -0,0 +1,28 @@
+package com.baeldung.exceptions.globalexceptionhandler;
+
+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/globalexceptionhandler/IllegalArgument.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/IllegalArgument.java
new file mode 100644
index 0000000000..d54757dfac
--- /dev/null
+++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/IllegalArgument.java
@@ -0,0 +1,18 @@
+package com.baeldung.exceptions.globalexceptionhandler;
+
+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/globalexceptionhandler/IllegalState.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/IllegalState.java
new file mode 100644
index 0000000000..0a812d2b82
--- /dev/null
+++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/IllegalState.java
@@ -0,0 +1,32 @@
+package com.baeldung.exceptions.globalexceptionhandler;
+
+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/globalexceptionhandler/InterruptedExceptionExample.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/InterruptedExceptionExample.java
new file mode 100644
index 0000000000..d0c8bb2cd0
--- /dev/null
+++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/InterruptedExceptionExample.java
@@ -0,0 +1,28 @@
+package com.baeldung.exceptions.globalexceptionhandler;
+
+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/globalexceptionhandler/MalformedURL.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/MalformedURL.java
new file mode 100644
index 0000000000..9a02f005fd
--- /dev/null
+++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/MalformedURL.java
@@ -0,0 +1,25 @@
+package com.baeldung.exceptions.globalexceptionhandler;
+
+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/globalexceptionhandler/NullPointer.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/NullPointer.java
new file mode 100644
index 0000000000..445cbecdc8
--- /dev/null
+++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/NullPointer.java
@@ -0,0 +1,36 @@
+package com.baeldung.exceptions.globalexceptionhandler;
+
+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/globalexceptionhandler/NumberFormat.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/NumberFormat.java
new file mode 100644
index 0000000000..576fe51f78
--- /dev/null
+++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/NumberFormat.java
@@ -0,0 +1,23 @@
+package com.baeldung.exceptions.globalexceptionhandler;
+
+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/globalexceptionhandler/ParseExceptionExample.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/ParseExceptionExample.java
new file mode 100644
index 0000000000..e3b3e04b10
--- /dev/null
+++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/ParseExceptionExample.java
@@ -0,0 +1,25 @@
+package com.baeldung.exceptions.globalexceptionhandler;
+
+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/globalexceptionhandler/StringIndexOutOfBounds.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/StringIndexOutOfBounds.java
new file mode 100644
index 0000000000..0ee132e568
--- /dev/null
+++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/StringIndexOutOfBounds.java
@@ -0,0 +1,23 @@
+package com.baeldung.exceptions.globalexceptionhandler;
+
+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-exceptions/src/main/java/com/baeldung/exceptions/rootcausefinder/RootCauseFinder.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/rootcausefinder/RootCauseFinder.java
new file mode 100644
index 0000000000..06610f3874
--- /dev/null
+++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/rootcausefinder/RootCauseFinder.java
@@ -0,0 +1,95 @@
+package com.baeldung.exceptions.rootcausefinder;
+
+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 {
+
+ public static Throwable findCauseUsingPlainJava(Throwable throwable) {
+ Objects.requireNonNull(throwable);
+ Throwable rootCause = throwable;
+ while (rootCause.getCause() != null) {
+ 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) throws CalculationException {
+ 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) throws DateParseException {
+
+ 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 Exception {
+
+ CalculationException(DateParseException ex) {
+ super(ex);
+ }
+ }
+
+ static class DateParseException extends Exception {
+
+ 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/test/java/com/baeldung/exceptions/globalexceptionhandler/GlobalExceptionHandlerUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/globalexceptionhandler/GlobalExceptionHandlerUnitTest.java
new file mode 100644
index 0000000000..74ceb3b442
--- /dev/null
+++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/globalexceptionhandler/GlobalExceptionHandlerUnitTest.java
@@ -0,0 +1,64 @@
+package com.baeldung.exceptions.globalexceptionhandler;
+
+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/rootcausefinder/RootCauseFinderUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/rootcausefinder/RootCauseFinderUnitTest.java
new file mode 100644
index 0000000000..f42388857a
--- /dev/null
+++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/rootcausefinder/RootCauseFinderUnitTest.java
@@ -0,0 +1,99 @@
+package com.baeldung.exceptions.rootcausefinder;
+
+import com.baeldung.exceptions.rootcausefinder.RootCauseFinder.CalculationException;
+import com.baeldung.exceptions.rootcausefinder.RootCauseFinder.DateOutOfRangeException;
+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.RootCauseFinder.AgeCalculator;
+import static com.baeldung.exceptions.rootcausefinder.RootCauseFinder.findCauseUsingPlainJava;
+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 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);
+ }
+ }
+
+}
diff --git a/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/exceptions/RootCauseFinder.java b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/exceptions/RootCauseFinder.java
new file mode 100644
index 0000000000..e05dc7a6cd
--- /dev/null
+++ b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/exceptions/RootCauseFinder.java
@@ -0,0 +1,95 @@
+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 {
+
+ public static Throwable findCauseUsingPlainJava(Throwable throwable) {
+ Objects.requireNonNull(throwable);
+ Throwable rootCause = throwable;
+ while (rootCause.getCause() != null) {
+ 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) throws CalculationException {
+ 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) throws DateParseException {
+
+ 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 Exception {
+
+ CalculationException(DateParseException ex) {
+ super(ex);
+ }
+ }
+
+ static class DateParseException extends Exception {
+
+ 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-lang-oop-2/.gitignore b/core-java-modules/core-java-lang-oop-2/.gitignore
deleted file mode 100644
index 36aba1c242..0000000000
--- a/core-java-modules/core-java-lang-oop-2/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-target/
-.idea/
-bin/
-*.iml
\ 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
deleted file mode 100644
index c48a3f5cd9..0000000000
--- a/core-java-modules/core-java-lang-oop-2/README.md
+++ /dev/null
@@ -1,18 +0,0 @@
-## Core Java Lang OOP (Part 2)
-
-This module contains articles about Object-oriented programming (OOP) in Java
-
-### Relevant Articles:
-- [Generic Constructors in Java](https://www.baeldung.com/java-generic-constructors)
-- [Cannot Reference “X” Before Supertype Constructor Has Been Called](https://www.baeldung.com/java-cannot-reference-x-before-supertype-constructor-error)
-- [Anonymous Classes in Java](https://www.baeldung.com/java-anonymous-classes)
-- [Raw Types in Java](https://www.baeldung.com/raw-types-java)
-- [Marker Interfaces in Java](https://www.baeldung.com/java-marker-interfaces)
-- [Java equals() and hashCode() Contracts](https://www.baeldung.com/java-equals-hashcode-contracts)
-- [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)
-- [Java Copy Constructor](https://www.baeldung.com/java-copy-constructor)
-- [Abstract Classes in Java](https://www.baeldung.com/java-abstract-class)
-- [[<-- Prev]](/core-java-modules/core-java-lang-oop)[[More -->]](/core-java-modules/core-java-lang-oop-3)
diff --git a/core-java-modules/core-java-lang-oop-2/pom.xml b/core-java-modules/core-java-lang-oop-2/pom.xml
deleted file mode 100644
index ccacaf7116..0000000000
--- a/core-java-modules/core-java-lang-oop-2/pom.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
- 4.0.0
- core-java-lang-oop-2
- 0.1.0-SNAPSHOT
- core-java-lang-oop-2
- jar
-
-
- com.baeldung
- parent-java
- 0.0.1-SNAPSHOT
- ../../parent-java
-
-
-
-
-
- org.assertj
- assertj-core
- ${assertj-core.version}
- test
-
-
- nl.jqno.equalsverifier
- equalsverifier
- ${equalsverifier.version}
- test
-
-
-
-
- core-java-lang-oop-2
-
-
- src/main/resources
- true
-
-
-
-
-
-
- 3.10.0
- 3.0.3
-
-
-
diff --git a/core-java-modules/core-java-lang-oop-3/README.md b/core-java-modules/core-java-lang-oop-3/README.md
deleted file mode 100644
index 3a0e588ad4..0000000000
--- a/core-java-modules/core-java-lang-oop-3/README.md
+++ /dev/null
@@ -1,16 +0,0 @@
-## Core Java Lang OOP (Part 3)
-
-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)
-- [Access Modifiers in Java](https://www.baeldung.com/java-access-modifiers)
-- [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)
-- [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)
-- [Java Classes and Objects](https://www.baeldung.com/java-classes-objects)
-- [Java Interfaces](https://www.baeldung.com/java-interfaces)
-- [[<-- Prev]](/core-java-modules/core-java-lang-oop-2)[[More -->]](/core-java-modules/core-java-lang-oop-4)
diff --git a/core-java-modules/core-java-lang-oop-3/pom.xml b/core-java-modules/core-java-lang-oop-3/pom.xml
deleted file mode 100644
index cc9b473d03..0000000000
--- a/core-java-modules/core-java-lang-oop-3/pom.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
- 4.0.0
- core-java-lang-oop-3
- 0.1.0-SNAPSHOT
- core-java-lang-oop-3
- jar
-
-
- com.baeldung
- parent-java
- 0.0.1-SNAPSHOT
- ../../parent-java
-
-
-
-
-
- log4j
- log4j
- ${log4j.version}
-
-
- org.slf4j
- log4j-over-slf4j
- ${org.slf4j.version}
-
-
-
- org.assertj
- assertj-core
- ${assertj-core.version}
- test
-
-
- com.h2database
- h2
- ${h2.version}
- test
-
-
-
-
- core-java-lang-oop-3
-
-
- src/main/resources
- true
-
-
-
-
-
- 3.10.0
-
-
-
diff --git a/core-java-modules/core-java-lang-oop-4/README.md b/core-java-modules/core-java-lang-oop-4/README.md
deleted file mode 100644
index 51650dc1f6..0000000000
--- a/core-java-modules/core-java-lang-oop-4/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-## Core Java Lang OOP (Part 4)
-
-This module contains articles about Object-oriented programming (OOP) in Java
-
-### Relevant Articles:
-- [Static and Dynamic Binding in Java](https://www.baeldung.com/java-static-dynamic-binding)
-- [Methods in Java](https://www.baeldung.com/java-methods)
-- [Java ‘private’ Access Modifier](https://www.baeldung.com/java-private-keyword)
-- [[<-- Prev]](/core-java-modules/core-java-lang-oop-3)
\ No newline at end of file
diff --git a/core-java-modules/core-java-lang-oop-4/pom.xml b/core-java-modules/core-java-lang-oop-4/pom.xml
deleted file mode 100644
index 3c7e4f446d..0000000000
--- a/core-java-modules/core-java-lang-oop-4/pom.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
- 4.0.0
- core-java-lang-oop-4
- 0.1.0-SNAPSHOT
- core-java-lang-oop-4
- jar
-
-
- com.baeldung
- parent-java
- 0.0.1-SNAPSHOT
- ../../parent-java
-
-
-
-
-
- log4j
- log4j
- ${log4j.version}
-
-
- org.slf4j
- log4j-over-slf4j
- ${org.slf4j.version}
-
-
-
- org.assertj
- assertj-core
- ${assertj-core.version}
- test
-
-
- com.h2database
- h2
- ${h2.version}
- test
-
-
-
-
- core-java-lang-oop-4
-
-
- src/main/resources
- true
-
-
-
-
-
- 3.10.0
-
-
-
diff --git a/core-java-modules/core-java-lang-oop-constructors/README.md b/core-java-modules/core-java-lang-oop-constructors/README.md
new file mode 100644
index 0000000000..0082969807
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-constructors/README.md
@@ -0,0 +1,8 @@
+## Core Java Lang OOP - Constructors
+
+This module contains article about constructors in Java
+
+### Relevant Articles:
+- [A Guide to Constructors in Java](https://www.baeldung.com/java-constructors)
+- [Java Copy Constructor](https://www.baeldung.com/java-copy-constructor)
+- [Cannot Reference “X” Before Supertype Constructor Has Been Called](https://www.baeldung.com/java-cannot-reference-x-before-supertype-constructor-error)
\ No newline at end of file
diff --git a/core-java-modules/core-java-lang-oop-constructors/pom.xml b/core-java-modules/core-java-lang-oop-constructors/pom.xml
new file mode 100644
index 0000000000..76507103ea
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-constructors/pom.xml
@@ -0,0 +1,28 @@
+
+
+
+ core-java-modules
+ com.baeldung.core-java-modules
+ 1.0.0-SNAPSHOT
+
+ 4.0.0
+
+ core-java-lang-oop-constructors
+ core-java-lang-oop-constructors
+ jar
+
+
+
+ org.assertj
+ assertj-core
+ ${assertj-core.version}
+ test
+
+
+
+
+ 3.10.0
+
+
\ No newline at end of file
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/constructors/BankAccount.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/BankAccount.java
similarity index 99%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/constructors/BankAccount.java
rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/BankAccount.java
index b78b5937e1..b198492129 100644
--- a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/constructors/BankAccount.java
+++ b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/BankAccount.java
@@ -6,7 +6,7 @@ class BankAccount {
String name;
LocalDateTime opened;
double balance;
-
+
@Override
public String toString() {
return String.format("%s, %s, %f", this.name, this.opened.toString(), this.balance);
@@ -47,14 +47,13 @@ class BankAccountCopyConstructor extends BankAccount {
this.opened = opened;
this.balance = balance;
}
-
+
public BankAccountCopyConstructor(BankAccount other) {
this.name = other.name;
this.opened = LocalDateTime.now();
this.balance = 0.0f;
}
}
-
class BankAccountChainedConstructors extends BankAccount {
public BankAccountChainedConstructors(String name, LocalDateTime opened, double balance) {
this.name = name;
@@ -65,4 +64,4 @@ class BankAccountChainedConstructors extends BankAccount {
public BankAccountChainedConstructors(String name) {
this(name, LocalDateTime.now(), 0.0f);
}
-}
+}
\ No newline at end of file
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/constructors/Transaction.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/Transaction.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/constructors/Transaction.java
rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/Transaction.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/copyconstructor/Employee.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Employee.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/copyconstructor/Employee.java
rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Employee.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/copyconstructor/Manager.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Manager.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/copyconstructor/Manager.java
rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Manager.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java
rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java
rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java
rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java
rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyException.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyException.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyException.java
rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyException.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java b/core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java
similarity index 88%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java
rename to core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java
index 274fe77764..e207afec57 100644
--- a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java
+++ b/core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java
@@ -1,20 +1,19 @@
package com.baeldung.constructors;
+import org.assertj.core.api.Assertions;
import org.junit.Test;
import java.time.LocalDateTime;
import java.time.Month;
-import java.util.logging.Logger;
-import static org.assertj.core.api.Assertions.*;
+import static org.assertj.core.api.Assertions.assertThat;
public class ConstructorUnitTest {
- final static Logger LOGGER = Logger.getLogger(ConstructorUnitTest.class.getName());
-
+
@Test
public void givenNoExplicitContructor_whenUsed_thenFails() {
BankAccount account = new BankAccount();
- assertThatThrownBy(() -> {
+ Assertions.assertThatThrownBy(() -> {
account.toString();
}).isInstanceOf(Exception.class);
}
@@ -22,7 +21,7 @@ public class ConstructorUnitTest {
@Test
public void givenNoArgumentConstructor_whenUsed_thenSucceeds() {
BankAccountEmptyConstructor account = new BankAccountEmptyConstructor();
- assertThatCode(() -> {
+ Assertions.assertThatCode(() -> {
account.toString();
}).doesNotThrowAnyException();
}
@@ -33,7 +32,7 @@ public class ConstructorUnitTest {
BankAccountParameterizedConstructor account =
new BankAccountParameterizedConstructor("Tom", opened, 1000.0f);
- assertThatCode(() -> {
+ Assertions.assertThatCode(() -> {
account.toString();
}).doesNotThrowAnyException();
}
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/copyconstructor/EmployeeUnitTest.java b/core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/EmployeeUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/copyconstructor/EmployeeUnitTest.java
rename to core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/EmployeeUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/copyconstructor/ManagerUnitTest.java b/core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/ManagerUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/copyconstructor/ManagerUnitTest.java
rename to core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/ManagerUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-generics/README.md b/core-java-modules/core-java-lang-oop-generics/README.md
new file mode 100644
index 0000000000..f0213c5659
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-generics/README.md
@@ -0,0 +1,8 @@
+## Core Java Lang OOP - Generics
+
+This module contains articles about generics in Java
+
+### Relevant Articles:
+- [Generic Constructors in Java](https://www.baeldung.com/java-generic-constructors)
+- [Type Erasure in Java Explained](https://www.baeldung.com/java-type-erasure)
+- [Raw Types in Java](https://www.baeldung.com/raw-types-java)
diff --git a/core-java-modules/core-java-lang-oop-generics/pom.xml b/core-java-modules/core-java-lang-oop-generics/pom.xml
new file mode 100644
index 0000000000..ae141ecda2
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-generics/pom.xml
@@ -0,0 +1,16 @@
+
+
+
+ core-java-modules
+ com.baeldung.core-java-modules
+ 1.0.0-SNAPSHOT
+
+ 4.0.0
+
+ core-java-lang-oop-generics
+ core-java-lang-oop-generics
+ jar
+
+
\ No newline at end of file
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Entry.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Entry.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Entry.java
rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Entry.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/GenericEntry.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/GenericEntry.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/GenericEntry.java
rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/GenericEntry.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/MapEntry.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/MapEntry.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/MapEntry.java
rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/MapEntry.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Product.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Product.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Product.java
rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Product.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Rankable.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Rankable.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Rankable.java
rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Rankable.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/rawtype/RawTypeDemo.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/rawtype/RawTypeDemo.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/rawtype/RawTypeDemo.java
rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/rawtype/RawTypeDemo.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java
rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/BoundStack.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/BoundStack.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/BoundStack.java
rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/BoundStack.java
diff --git a/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/Example.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/Example.java
new file mode 100644
index 0000000000..f816fd6d16
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/Example.java
@@ -0,0 +1,13 @@
+package com.baeldung.typeerasure;
+
+public class Example {
+
+ public static boolean containsElement(E [] elements, E element){
+ for (E e : elements){
+ if(e.equals(element)){
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/IntegerStack.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/IntegerStack.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/IntegerStack.java
rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/IntegerStack.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/Stack.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/Stack.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/Stack.java
rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/Stack.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java b/core-java-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java
rename to core-java-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java b/core-java-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java
rename to core-java-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-inheritance/README.md b/core-java-modules/core-java-lang-oop-inheritance/README.md
new file mode 100644
index 0000000000..c87bdf13d7
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-inheritance/README.md
@@ -0,0 +1,14 @@
+## Core Java Lang OOP - Inheritance
+
+This module contains articles about inheritance in Java
+
+### Relevant Articles:
+- [Java Interfaces](https://www.baeldung.com/java-interfaces)
+- [Abstract Classes in Java](https://www.baeldung.com/java-abstract-class)
+- [A Guide to Inner Interfaces in Java](https://www.baeldung.com/java-inner-interfaces)
+- [Guide to the super Java Keyword](https://www.baeldung.com/java-super)
+- [Anonymous Classes in Java](https://www.baeldung.com/java-anonymous-classes)
+- [Polymorphism in Java](https://www.baeldung.com/java-polymorphism)
+- [Guide to Inheritance in Java](https://www.baeldung.com/java-inheritance)
+- [Object Type Casting in Java](https://www.baeldung.com/java-type-casting)
+- [Variable and Method Hiding in Java](https://www.baeldung.com/java-variable-method-hiding)
diff --git a/core-java-modules/core-java-lang-oop-inheritance/pom.xml b/core-java-modules/core-java-lang-oop-inheritance/pom.xml
new file mode 100644
index 0000000000..a48b28a289
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-inheritance/pom.xml
@@ -0,0 +1,28 @@
+
+
+
+ core-java-modules
+ com.baeldung.core-java-modules
+ 1.0.0-SNAPSHOT
+
+ 4.0.0
+
+ core-java-lang-oop-inheritance
+ core-java-lang-oop-inheritance
+ jar
+
+
+
+ org.assertj
+ assertj-core
+ ${assertj-core.version}
+ test
+
+
+
+
+ 3.10.0
+
+
\ No newline at end of file
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/abstractclasses/application/Application.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/application/Application.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/abstractclasses/application/Application.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/application/Application.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java
diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/overview/BoardGame.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/overview/BoardGame.java
new file mode 100644
index 0000000000..e0395cec7e
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/overview/BoardGame.java
@@ -0,0 +1,9 @@
+package com.baeldung.abstractclasses.overview;
+
+public abstract class BoardGame {
+ //... field declarations, constructors
+
+ public abstract void play();
+
+ //... concrete methods
+}
diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/overview/Checkers.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/overview/Checkers.java
new file mode 100644
index 0000000000..5c911649c8
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/overview/Checkers.java
@@ -0,0 +1,8 @@
+package com.baeldung.abstractclasses.overview;
+
+public class Checkers extends BoardGame {
+ @Override
+ public void play() {
+ //... implementation
+ }
+}
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Book.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Book.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Book.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Book.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Main.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Main.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Main.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Main.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Animal.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Animal.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Animal.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Animal.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeeder.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeeder.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeeder.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeeder.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Cat.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Cat.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Cat.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Cat.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Dog.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Dog.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Dog.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Dog.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Mew.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Mew.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Mew.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Mew.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/ArmoredCar.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/ArmoredCar.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/ArmoredCar.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/ArmoredCar.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/BMW.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/BMW.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/BMW.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/BMW.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Car.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Car.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Car.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Car.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Employee.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Employee.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Employee.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Employee.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Floatable.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Floatable.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Floatable.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Floatable.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Flyable.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Flyable.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Flyable.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Flyable.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceCar.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceCar.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceCar.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceCar.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceTraveller.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceTraveller.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceTraveller.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceTraveller.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/innerinterfaces/Customer.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/Customer.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/innerinterfaces/Customer.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/Customer.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/Box.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Box.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/Box.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Box.java
diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Computer.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Computer.java
new file mode 100644
index 0000000000..94d39e2448
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Computer.java
@@ -0,0 +1,9 @@
+package com.baeldung.interfaces;
+
+public class Computer implements Electronic {
+
+ @Override
+ public int getElectricityUse() {
+ return 1000;
+ }
+}
diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Electronic.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Electronic.java
new file mode 100644
index 0000000000..fcaf67dc3a
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Electronic.java
@@ -0,0 +1,22 @@
+package com.baeldung.interfaces;
+
+public interface Electronic {
+ // Constant variable
+ String LED = "LED";
+
+ // Abstract method
+ int getElectricityUse();
+
+ // Static method
+ static boolean isEnergyEfficient(String electtronicType) {
+ if (electtronicType.equals(LED)) {
+ return true;
+ }
+ return false;
+ }
+
+ //Default method
+ default void printDescription() {
+ System.out.println("Electronic Description");
+ }
+}
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/Employee.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Employee.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/Employee.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Employee.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/HasColor.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/HasColor.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/HasColor.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/HasColor.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/FileManager.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/FileManager.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/FileManager.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/FileManager.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/GenericFile.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/GenericFile.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/GenericFile.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/GenericFile.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/ImageFile.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/ImageFile.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/ImageFile.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/ImageFile.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/TextFile.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/TextFile.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/TextFile.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/TextFile.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/KeywordDemo.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/KeywordDemo.java
similarity index 50%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/KeywordDemo.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/KeywordDemo.java
index fd608b424c..0e5bd489bb 100644
--- a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/KeywordDemo.java
+++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/KeywordDemo.java
@@ -1,7 +1,4 @@
-package com.baeldung.keyword;
-
-import com.baeldung.keyword.superkeyword.SuperSub;
-import com.baeldung.keyword.thiskeyword.KeywordUnitTest;
+package com.baeldung.superkeyword;
/**
* Created by Gebruiker on 5/14/2018.
@@ -9,8 +6,6 @@ import com.baeldung.keyword.thiskeyword.KeywordUnitTest;
public class KeywordDemo {
public static void main(String[] args) {
- KeywordUnitTest keyword = new KeywordUnitTest();
-
SuperSub child = new SuperSub("message from the child class");
}
}
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/SuperBase.java
similarity index 87%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/SuperBase.java
index a5304fcef9..ec6a90cb06 100644
--- a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java
+++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/SuperBase.java
@@ -1,4 +1,4 @@
-package com.baeldung.keyword.superkeyword;
+package com.baeldung.superkeyword;
/**
* Created by Gebruiker on 5/14/2018.
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/SuperSub.java
similarity index 91%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/SuperSub.java
index 83bc04ad0f..ada52e4ff2 100644
--- a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java
+++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/SuperSub.java
@@ -1,4 +1,4 @@
-package com.baeldung.keyword.superkeyword;
+package com.baeldung.superkeyword;
/**
* Created by Gebruiker on 5/15/2018.
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/BaseMethodClass.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/BaseMethodClass.java
similarity index 71%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/BaseMethodClass.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/BaseMethodClass.java
index 46ed5fd99f..7e6b08c000 100644
--- a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/BaseMethodClass.java
+++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/BaseMethodClass.java
@@ -1,4 +1,4 @@
-package com.baeldung.scope.method;
+package com.baeldung.variableandmethodhiding.method;
public class BaseMethodClass {
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/ChildMethodClass.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/ChildMethodClass.java
similarity index 74%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/ChildMethodClass.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/ChildMethodClass.java
index 1d0cff2d6b..30db54cd84 100644
--- a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/ChildMethodClass.java
+++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/ChildMethodClass.java
@@ -1,4 +1,4 @@
-package com.baeldung.scope.method;
+package com.baeldung.variableandmethodhiding.method;
public class ChildMethodClass extends BaseMethodClass {
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/MethodHidingDemo.java
similarity index 70%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/MethodHidingDemo.java
index 7e0b3ed146..ce1feac665 100644
--- a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java
+++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/MethodHidingDemo.java
@@ -1,4 +1,4 @@
-package com.baeldung.scope.method;
+package com.baeldung.variableandmethodhiding.method;
public class MethodHidingDemo {
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ChildVariable.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/ChildVariable.java
similarity index 81%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ChildVariable.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/ChildVariable.java
index 5730e5e282..83434f7dd3 100644
--- a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ChildVariable.java
+++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/ChildVariable.java
@@ -1,4 +1,4 @@
-package com.baeldung.scope.variable;
+package com.baeldung.variableandmethodhiding.variable;
/**
* Created by Gebruiker on 5/7/2018.
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/HideVariable.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/HideVariable.java
similarity index 89%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/HideVariable.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/HideVariable.java
index 8243fdb249..98a29573b8 100644
--- a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/HideVariable.java
+++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/HideVariable.java
@@ -1,4 +1,4 @@
-package com.baeldung.scope.variable;
+package com.baeldung.variableandmethodhiding.variable;
/**
* Created by Gebruiker on 5/6/2018.
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ParentVariable.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/ParentVariable.java
similarity index 80%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ParentVariable.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/ParentVariable.java
index 7f116b955e..ef17305746 100644
--- a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ParentVariable.java
+++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/ParentVariable.java
@@ -1,4 +1,4 @@
-package com.baeldung.scope.variable;
+package com.baeldung.variableandmethodhiding.variable;
/**
* Created by Gebruiker on 5/7/2018.
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/VariableHidingDemo.java
similarity index 89%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/VariableHidingDemo.java
index 1ad71bd966..0fd83ad55e 100644
--- a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java
+++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/VariableHidingDemo.java
@@ -1,4 +1,4 @@
-package com.baeldung.scope.variable;
+package com.baeldung.variableandmethodhiding.variable;
/**
* Created by Gebruiker on 5/6/2018.
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/resources/files/test.txt b/core-java-modules/core-java-lang-oop-inheritance/src/main/resources/files/test.txt
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/resources/files/test.txt
rename to core-java-modules/core-java-lang-oop-inheritance/src/main/resources/files/test.txt
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/LowercaseFileReaderUnitTest.java
similarity index 94%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/LowercaseFileReaderUnitTest.java
index 45e16f0d25..8e970fc0c7 100644
--- a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java
+++ b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/LowercaseFileReaderUnitTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.abstractclasses.test;
+package com.baeldung.abstractclasses;
import com.baeldung.abstractclasses.filereaders.BaseFileReader;
import com.baeldung.abstractclasses.filereaders.LowercaseFileReader;
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/UppercaseFileReaderUnitTest.java
similarity index 94%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/UppercaseFileReaderUnitTest.java
index dc4df900e4..e7b83a97e6 100644
--- a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java
+++ b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/UppercaseFileReaderUnitTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.abstractclasses.test;
+package com.baeldung.abstractclasses;
import com.baeldung.abstractclasses.filereaders.BaseFileReader;
import com.baeldung.abstractclasses.filereaders.UppercaseFileReader;
diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/casting/CastingUnitTest.java b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/casting/CastingUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/casting/CastingUnitTest.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/casting/CastingUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/inheritance/AppUnitTest.java b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/inheritance/AppUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/inheritance/AppUnitTest.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/inheritance/AppUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java
rename to core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-methods/README.md b/core-java-modules/core-java-lang-oop-methods/README.md
new file mode 100644
index 0000000000..fa474c9795
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-methods/README.md
@@ -0,0 +1,9 @@
+## Core Java Lang OOP - Methods
+
+This module contains articles about methods in Java
+
+### Relevant Articles:
+- [Methods in Java](https://www.baeldung.com/java-methods)
+- [Method Overloading and Overriding in Java](https://www.baeldung.com/java-method-overload-override)
+- [Java equals() and hashCode() Contracts](https://www.baeldung.com/java-equals-hashcode-contracts)
+- [Guide to hashCode() in Java](https://www.baeldung.com/java-hashcode)
diff --git a/core-java-modules/core-java-lang-oop-methods/pom.xml b/core-java-modules/core-java-lang-oop-methods/pom.xml
new file mode 100644
index 0000000000..3590b85454
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-methods/pom.xml
@@ -0,0 +1,49 @@
+
+
+
+ core-java-modules
+ com.baeldung.core-java-modules
+ 1.0.0-SNAPSHOT
+
+ 4.0.0
+
+ core-java-lang-oop-methods
+ core-java-lang-oop-methods
+ jar
+
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+
+
+ commons-lang
+ commons-lang
+ ${commons-lang.version}
+
+
+
+ org.assertj
+ assertj-core
+ ${assertj-core.version}
+ test
+
+
+ nl.jqno.equalsverifier
+ equalsverifier
+ ${equalsverifier.version}
+ test
+
+
+
+
+ 1.18.12
+ 2.6
+
+ 3.10.0
+ 3.0.3
+
+
\ No newline at end of file
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/Money.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Money.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/Money.java
rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Money.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/Team.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Team.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/Team.java
rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Team.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/Voucher.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Voucher.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/Voucher.java
rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Voucher.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/WrongTeam.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongTeam.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/WrongTeam.java
rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongTeam.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java
rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java
diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/apachecommons/User.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/apachecommons/User.java
new file mode 100644
index 0000000000..4be082019a
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/apachecommons/User.java
@@ -0,0 +1,42 @@
+package com.baeldung.hashcode.apachecommons;
+
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class User {
+
+ private final Logger logger = LoggerFactory.getLogger(User.class);
+ private long id;
+ private String name;
+ private String email;
+
+ public User(long id, String name, String email) {
+ this.id = id;
+ this.name = name;
+ this.email = email;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null)
+ return false;
+ if (this.getClass() != o.getClass())
+ return false;
+ User user = (User) o;
+ return id == user.id && (name.equals(user.name) && email.equals(user.email));
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 37).
+ append(id).
+ append(name).
+ append(email).
+ toHashCode();
+ }
+ // getters and setters here
+
+}
diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/eclipse/User.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/eclipse/User.java
new file mode 100644
index 0000000000..e852eef96e
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/eclipse/User.java
@@ -0,0 +1,42 @@
+package com.baeldung.hashcode.eclipse;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class User {
+
+ private final Logger logger = LoggerFactory.getLogger(User.class);
+ private long id;
+ private String name;
+ private String email;
+
+ public User(long id, String name, String email) {
+ this.id = id;
+ this.name = name;
+ this.email = email;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null)
+ return false;
+ if (this.getClass() != o.getClass())
+ return false;
+ User user = (User) o;
+ return id == user.id && (name.equals(user.name) && email.equals(user.email));
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((email == null) ? 0 : email.hashCode());
+ result = prime * result + (int) (id ^ (id >>> 32));
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+ // getters and setters here
+
+}
diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/improved/User.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/improved/User.java
new file mode 100644
index 0000000000..773a2c7e45
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/improved/User.java
@@ -0,0 +1,37 @@
+package com.baeldung.hashcode.improved;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class User {
+
+ private final Logger logger = LoggerFactory.getLogger(User.class);
+ private long id;
+ private String name;
+ private String email;
+
+ public User(long id, String name, String email) {
+ this.id = id;
+ this.name = name;
+ this.email = email;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null)
+ return false;
+ if (this.getClass() != o.getClass())
+ return false;
+ User user = (User) o;
+ return id == user.id && (name.equals(user.name) && email.equals(user.email));
+ }
+
+ @Override
+ public int hashCode() {
+ return (int) id * name.hashCode() * email.hashCode();
+ }
+ // getters and setters here
+
+}
diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/intellij/User.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/intellij/User.java
new file mode 100644
index 0000000000..f7bf1ab735
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/intellij/User.java
@@ -0,0 +1,40 @@
+package com.baeldung.hashcode.intellij;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class User {
+
+ private final Logger logger = LoggerFactory.getLogger(User.class);
+ private long id;
+ private String name;
+ private String email;
+
+ public User(long id, String name, String email) {
+ this.id = id;
+ this.name = name;
+ this.email = email;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null)
+ return false;
+ if (this.getClass() != o.getClass())
+ return false;
+ User user = (User) o;
+ return id == user.id && (name.equals(user.name) && email.equals(user.email));
+ }
+
+ @Override
+ public int hashCode() {
+ int result = (int) (id ^ (id >>> 32));
+ result = 31 * result + name.hashCode();
+ result = 31 * result + email.hashCode();
+ return result;
+ }
+ // getters and setters here
+
+}
diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/lombok/User.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/lombok/User.java
new file mode 100644
index 0000000000..e34246ce24
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/lombok/User.java
@@ -0,0 +1,22 @@
+package com.baeldung.hashcode.lombok;
+
+import lombok.EqualsAndHashCode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@EqualsAndHashCode
+public class User {
+
+ private final Logger logger = LoggerFactory.getLogger(User.class);
+ private long id;
+ private String name;
+ private String email;
+
+ public User(long id, String name, String email) {
+ this.id = id;
+ this.name = name;
+ this.email = email;
+ }
+ // getters and setters here
+
+}
diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/naive/User.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/naive/User.java
new file mode 100644
index 0000000000..b0a33ad3e9
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/naive/User.java
@@ -0,0 +1,37 @@
+package com.baeldung.hashcode.naive;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class User {
+
+ private final Logger logger = LoggerFactory.getLogger(User.class);
+ private long id;
+ private String name;
+ private String email;
+
+ public User(long id, String name, String email) {
+ this.id = id;
+ this.name = name;
+ this.email = email;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null)
+ return false;
+ if (this.getClass() != o.getClass())
+ return false;
+ User user = (User) o;
+ return id == user.id && (name.equals(user.name) && email.equals(user.email));
+ }
+
+ @Override
+ public int hashCode() {
+ return 1;
+ }
+ // getters and setters here
+
+}
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/hashcode/entities/User.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/standard/User.java
similarity index 89%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/hashcode/entities/User.java
rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/standard/User.java
index 524f176e6b..f8fd5cedbd 100644
--- a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/hashcode/entities/User.java
+++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/standard/User.java
@@ -1,4 +1,4 @@
-package com.baeldung.hashcode.entities;
+package com.baeldung.hashcode.standard;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,7 +34,6 @@ public class User {
hash = 31 * hash + (int) id;
hash = 31 * hash + (name == null ? 0 : name.hashCode());
hash = 31 * hash + (email == null ? 0 : email.hashCode());
- logger.info("hashCode() method called - Computed hash: " + hash);
return hash;
}
// getters and setters here
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java
rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java
rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java
rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java
rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java
diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/basicmethods/PersonName.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/PersonName.java
similarity index 96%
rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/basicmethods/PersonName.java
rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/PersonName.java
index 43bbf0dd62..d1f3f58b8c 100644
--- a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/basicmethods/PersonName.java
+++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/PersonName.java
@@ -1,4 +1,4 @@
-package com.baeldung.basicmethods;
+package com.baeldung.methods;
import java.io.FileWriter;
import java.io.IOException;
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java
rename to core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java
similarity index 96%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java
rename to core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java
index 7dfc6d47a3..308004452b 100644
--- a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java
+++ b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java
@@ -38,7 +38,7 @@ public class TeamUnitTest {
}
@Test
- public void equalsContract() {
+ public void equalsHashCodeContracts() {
EqualsVerifier.forClass(Team.class).verify();
}
diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/UserUnitTest.java
similarity index 90%
rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java
rename to core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/UserUnitTest.java
index 44ea7efed1..51475acabf 100644
--- a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java
+++ b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/UserUnitTest.java
@@ -1,5 +1,6 @@
-package com.baeldung.hashcode.entities;
+package com.baeldung.hashcode;
+import com.baeldung.hashcode.standard.User;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java
similarity index 93%
rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java
rename to core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java
index 49857f355a..18b2d4d570 100644
--- a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java
+++ b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java
@@ -1,6 +1,6 @@
package com.baeldung.hashcode.application;
-import com.baeldung.hashcode.entities.User;
+import com.baeldung.hashcode.standard.User;
import org.junit.Test;
import java.util.HashMap;
diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/MethodOverloadingUnitTest.java
similarity index 95%
rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java
rename to core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/MethodOverloadingUnitTest.java
index 081a30c34a..476e70618f 100644
--- a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java
+++ b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/MethodOverloadingUnitTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.methodoverloadingoverriding.test;
+package com.baeldung.methodoverloadingoverriding;
import com.baeldung.methodoverloadingoverriding.util.Multiplier;
import org.junit.BeforeClass;
diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/MethodOverridingUnitTest.java
similarity index 97%
rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java
rename to core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/MethodOverridingUnitTest.java
index 554ac121bc..f4142d7382 100644
--- a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java
+++ b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/MethodOverridingUnitTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.methodoverloadingoverriding.test;
+package com.baeldung.methodoverloadingoverriding;
import com.baeldung.methodoverloadingoverriding.model.Car;
import com.baeldung.methodoverloadingoverriding.model.Vehicle;
diff --git a/core-java-modules/core-java-lang-oop-modifiers/README.md b/core-java-modules/core-java-lang-oop-modifiers/README.md
new file mode 100644
index 0000000000..eef905fa0e
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-modifiers/README.md
@@ -0,0 +1,12 @@
+## Core Java Lang OOP - Modifiers
+
+This module contains articles about modifiers in Java
+
+### Relevant Articles:
+- [Access Modifiers in Java](https://www.baeldung.com/java-access-modifiers)
+- [Java ‘public’ Access Modifier](https://www.baeldung.com/java-public-keyword)
+- [Java ‘private’ Access Modifier](https://www.baeldung.com/java-private-keyword)
+- [The “final” Keyword in Java](https://www.baeldung.com/java-final)
+- [A Guide to the Static Keyword in Java](https://www.baeldung.com/java-static)
+- [Static and Default Methods in Interfaces in Java](https://www.baeldung.com/java-static-default-methods)
+- [The strictfp Keyword in Java](https://www.baeldung.com/java-strictfp)
\ No newline at end of file
diff --git a/core-java-modules/core-java-lang-oop-modifiers/pom.xml b/core-java-modules/core-java-lang-oop-modifiers/pom.xml
new file mode 100644
index 0000000000..615e20690f
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-modifiers/pom.xml
@@ -0,0 +1,34 @@
+
+
+
+ core-java-modules
+ com.baeldung.core-java-modules
+ 1.0.0-SNAPSHOT
+
+ 4.0.0
+
+ core-java-lang-oop-modifiers
+ core-java-lang-oop-modifiers
+ jar
+
+
+
+ org.assertj
+ assertj-core
+ ${assertj-core.version}
+ test
+
+
+ com.h2database
+ h2
+ ${h2.version}
+ test
+
+
+
+
+ 3.10.0
+
+
\ No newline at end of file
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/Public.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/Public.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/Public.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/Public.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/SubClass.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SubClass.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/SubClass.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SubClass.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackCat.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackCat.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackCat.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackCat.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackDog.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackDog.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackDog.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackDog.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Cat.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Cat.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Cat.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Cat.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Dog.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Dog.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Dog.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Dog.java
diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/core/privatemodifier/Employee.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/Employee.java
similarity index 96%
rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/core/privatemodifier/Employee.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/Employee.java
index 4598400e93..a0f7829d51 100644
--- a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/core/privatemodifier/Employee.java
+++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/Employee.java
@@ -1,4 +1,4 @@
-package com.baeldung.core.privatemodifier;
+package com.baeldung.privatemodifier;
public class Employee {
diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/core/privatemodifier/ExampleClass.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/ExampleClass.java
similarity index 84%
rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/core/privatemodifier/ExampleClass.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/ExampleClass.java
index 8659b4ad9c..c87980fbe8 100644
--- a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/core/privatemodifier/ExampleClass.java
+++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/ExampleClass.java
@@ -1,4 +1,4 @@
-package com.baeldung.core.privatemodifier;
+package com.baeldung.privatemodifier;
public class ExampleClass {
diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/core/privatemodifier/PublicOuterClass.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/PublicOuterClass.java
similarity index 90%
rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/core/privatemodifier/PublicOuterClass.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/PublicOuterClass.java
index 8a9e8a8eb3..082d08b034 100644
--- a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/core/privatemodifier/PublicOuterClass.java
+++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/PublicOuterClass.java
@@ -1,4 +1,4 @@
-package com.baeldung.core.privatemodifier;
+package com.baeldung.privatemodifier;
public class PublicOuterClass {
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/publicmodifier/ListOfThree.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/ListOfThree.java
similarity index 92%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/publicmodifier/ListOfThree.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/ListOfThree.java
index 2ded0ba5d3..0e3449f451 100644
--- a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/publicmodifier/ListOfThree.java
+++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/ListOfThree.java
@@ -1,4 +1,4 @@
-package com.baeldung.accessmodifiers.publicmodifier;
+package com.baeldung.publicmodifier;
import java.util.AbstractList;
import java.util.Arrays;
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/publicmodifier/SpecialCharacters.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/SpecialCharacters.java
similarity index 61%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/publicmodifier/SpecialCharacters.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/SpecialCharacters.java
index 5556e9aa57..633308e707 100644
--- a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/publicmodifier/SpecialCharacters.java
+++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/SpecialCharacters.java
@@ -1,4 +1,4 @@
-package com.baeldung.accessmodifiers.publicmodifier;
+package com.baeldung.publicmodifier;
public class SpecialCharacters {
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/publicmodifier/Student.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/Student.java
similarity index 96%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/publicmodifier/Student.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/Student.java
index 83a0dcb30f..5aa80286bf 100644
--- a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/publicmodifier/Student.java
+++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/Student.java
@@ -1,4 +1,4 @@
-package com.baeldung.accessmodifiers.publicmodifier;
+package com.baeldung.publicmodifier;
import java.math.BigDecimal;
import java.sql.Connection;
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Car.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/Car.java
similarity index 96%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Car.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/Car.java
index cdb3806c35..950f008dcd 100644
--- a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Car.java
+++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/Car.java
@@ -1,4 +1,4 @@
-package com.baeldung.staticdemo;
+package com.baeldung.staticmodifier;
/**
* This class demonstrates the use of static fields and static methods
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Singleton.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/Singleton.java
similarity index 88%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Singleton.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/Singleton.java
index de75af9d9d..6e7dcf7c60 100644
--- a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Singleton.java
+++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/Singleton.java
@@ -1,4 +1,4 @@
-package com.baeldung.staticdemo;
+package com.baeldung.staticmodifier;
public class Singleton {
private Singleton() {}
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/StaticBlock.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/StaticBlockDemo.java
similarity index 81%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/StaticBlock.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/StaticBlockDemo.java
index fde7afb090..637bb5e82a 100644
--- a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/StaticBlock.java
+++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/StaticBlockDemo.java
@@ -1,9 +1,9 @@
-package com.baeldung.staticdemo;
+package com.baeldung.staticmodifier;
import java.util.LinkedList;
import java.util.List;
-public class StaticBlock {
+public class StaticBlockDemo {
private static List ranks = new LinkedList<>();
static {
@@ -23,6 +23,6 @@ public class StaticBlock {
}
public static void setRanks(List ranks) {
- StaticBlock.ranks = ranks;
+ StaticBlockDemo.ranks = ranks;
}
}
diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/strictfpUsage/Circle.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/Circle.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/strictfpUsage/Circle.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/Circle.java
diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/strictfpUsage/ScientificCalculator.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/ScientificCalculator.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/strictfpUsage/ScientificCalculator.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/ScientificCalculator.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/defaultistaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/StaticDefaulInterfaceMethodUnitTest.java
similarity index 97%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/defaultistaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/StaticDefaulInterfaceMethodUnitTest.java
index 7d4b06908a..0dffe8f80e 100644
--- a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/defaultistaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java
+++ b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/StaticDefaulInterfaceMethodUnitTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.defaultistaticinterfacemethods.test;
+package com.baeldung.defaultstaticinterfacemethods;
import com.baeldung.defaultstaticinterfacemethods.model.Car;
import com.baeldung.defaultstaticinterfacemethods.model.Motorbike;
diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/accessmodifiers/PublicAccessModifierUnitTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/publicmodifier/PublicAccessModifierUnitTest.java
similarity index 94%
rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/accessmodifiers/PublicAccessModifierUnitTest.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/publicmodifier/PublicAccessModifierUnitTest.java
index ed8fb4f45a..8c014e703b 100644
--- a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/accessmodifiers/PublicAccessModifierUnitTest.java
+++ b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/publicmodifier/PublicAccessModifierUnitTest.java
@@ -1,7 +1,5 @@
-package com.baeldung.accessmodifiers;
+package com.baeldung.publicmodifier;
-import com.baeldung.accessmodifiers.publicmodifier.ListOfThree;
-import com.baeldung.accessmodifiers.publicmodifier.Student;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/CarUnitTest.java
similarity index 80%
rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/CarUnitTest.java
index 3150627269..f55955caa8 100644
--- a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java
+++ b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/CarUnitTest.java
@@ -1,10 +1,10 @@
-package com.baeldung.staticdemo;
+package com.baeldung.staticmodifier;
import static org.junit.Assert.*;
import org.junit.Test;
-public class CarIntegrationTest {
+public class CarUnitTest {
@Test
public void whenNumberOfCarObjectsInitialized_thenStaticCounterIncreases() {
new Car("Jaguar", "V8");
diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/SingletonUnitTest.java
similarity index 81%
rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/SingletonUnitTest.java
index 28d864073a..6371fd4961 100644
--- a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java
+++ b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/SingletonUnitTest.java
@@ -1,9 +1,9 @@
-package com.baeldung.staticdemo;
+package com.baeldung.staticmodifier;
import org.junit.Assert;
import org.junit.Test;
-public class SingletonIntegrationTest {
+public class SingletonUnitTest {
@Test
public void givenStaticInnerClass_whenMultipleTimesInstanceCalled_thenOnlyOneTimeInitialized() {
diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/StaticBlockDemoUnitTest.java
similarity index 72%
rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/StaticBlockDemoUnitTest.java
index f98e3e14db..f31a8e8895 100644
--- a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java
+++ b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/StaticBlockDemoUnitTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.staticdemo;
+package com.baeldung.staticmodifier;
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
import static org.junit.Assert.assertThat;
@@ -7,11 +7,11 @@ import java.util.List;
import org.junit.Test;
-public class StaticBlockIntegrationTest {
+public class StaticBlockDemoUnitTest {
@Test
public void whenAddedListElementsThroughStaticBlock_thenEnsureCorrectOrder() {
- List actualList = StaticBlock.getRanks();
+ List actualList = StaticBlockDemo.getRanks();
assertThat(actualList, contains("Lieutenant", "Captain", "Major", "Colonel", "General"));
}
}
diff --git a/core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/strictfpUsage/ScientificCalculatorUnitTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/strictfpUsage/ScientificCalculatorUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/strictfpUsage/ScientificCalculatorUnitTest.java
rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/strictfpUsage/ScientificCalculatorUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-others/README.md b/core-java-modules/core-java-lang-oop-others/README.md
new file mode 100644
index 0000000000..d3909c0014
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-others/README.md
@@ -0,0 +1,8 @@
+## Core Java Lang OOP - Others
+
+This module contains articles about Object Oriented Programming (OOP) in Java
+
+### Relevant Articles:
+- [Object-Oriented-Programming Concepts in Java](https://www.baeldung.com/java-oop)
+- [Static and Dynamic Binding in Java](https://www.baeldung.com/java-static-dynamic-binding)
+- [Pass-By-Value as a Parameter Passing Mechanism in Java](https://www.baeldung.com/java-pass-by-value-or-pass-by-reference)
diff --git a/core-java-modules/core-java-lang-oop-others/pom.xml b/core-java-modules/core-java-lang-oop-others/pom.xml
new file mode 100644
index 0000000000..8eab301748
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-others/pom.xml
@@ -0,0 +1,16 @@
+
+
+
+ core-java-modules
+ com.baeldung.core-java-modules
+ 1.0.0-SNAPSHOT
+
+ 4.0.0
+
+ core-java-lang-oop-others
+ core-java-lang-oop-others
+ jar
+
+
\ No newline at end of file
diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/binding/Animal.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Animal.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/binding/Animal.java
rename to core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Animal.java
diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/binding/AnimalActivity.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/AnimalActivity.java
similarity index 90%
rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/binding/AnimalActivity.java
rename to core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/AnimalActivity.java
index 1bd36123e3..a30c3acd00 100644
--- a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/binding/AnimalActivity.java
+++ b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/AnimalActivity.java
@@ -15,7 +15,7 @@ public class AnimalActivity {
logger.info("Animal is sleeping");
}
- public static void sleep(Cat cat) {
+ public static void sleep(Dog dog) {
logger.info("Cat is sleeping");
}
@@ -30,7 +30,7 @@ public class AnimalActivity {
//assigning a dog object to reference of type Animal
- Animal catAnimal = new Cat();
+ Animal catAnimal = new Dog();
catAnimal.makeNoise();
diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/binding/Cat.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Dog.java
similarity index 68%
rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/binding/Cat.java
rename to core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Dog.java
index bbe740e412..b6924569d0 100644
--- a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/binding/Cat.java
+++ b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Dog.java
@@ -6,9 +6,9 @@ import org.slf4j.LoggerFactory;
/**
* Created by madhumita.g on 25-07-2018.
*/
-public class Cat extends Animal {
+public class Dog extends Animal {
- final static Logger logger = LoggerFactory.getLogger(Cat.class);
+ final static Logger logger = LoggerFactory.getLogger(Dog.class);
public void makeNoise() {
diff --git a/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ArmoredCar.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ArmoredCar.java
new file mode 100644
index 0000000000..29cba3702a
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ArmoredCar.java
@@ -0,0 +1,13 @@
+package com.baeldung.oop;
+
+public class ArmoredCar extends Car {
+ private int bulletProofWindows;
+
+ public ArmoredCar(String type, String model, String color) {
+ super(type, model, color);
+ }
+
+ public void remoteStartCar() {
+ // this vehicle can be started by using a remote control
+ }
+}
diff --git a/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Car.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Car.java
new file mode 100644
index 0000000000..8ea4d779b6
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Car.java
@@ -0,0 +1,58 @@
+package com.baeldung.oop;
+
+public class Car extends Vehicle {
+
+ private String type;
+ private String color;
+ private int speed;
+ private int numberOfGears;
+
+ public Car(String type, String model, String color) {
+ super(4, model);
+ this.type = type;
+ this.color = color;
+ }
+
+ public String getColor() {
+ return color;
+ }
+
+ public void setColor(String color) {
+ this.color = color;
+ }
+
+ public int getSpeed() {
+ return speed;
+ }
+
+ public void setSpeed(int speed) {
+ this.speed = speed;
+ }
+
+ public int increaseSpeed(int increment) {
+ if (increment > 0) {
+ this.speed += increment;
+ } else {
+ System.out.println("Increment can't be negative.");
+ }
+ return this.speed;
+ }
+
+ public int decreaseSpeed(int decrement) {
+ if (decrement > 0 && decrement <= this.speed) {
+ this.speed -= decrement;
+ } else {
+ System.out.println("Decrement can't be negative or greater than current speed.");
+ }
+ return this.speed;
+ }
+
+ public void openDoors() {
+ // process to open the doors
+ }
+
+ @Override
+ public void honk() {
+ // produces car-specific honk
+ }
+}
diff --git a/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/GenericFile.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/GenericFile.java
new file mode 100644
index 0000000000..812a3f1d63
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/GenericFile.java
@@ -0,0 +1,63 @@
+package com.baeldung.oop;
+
+import java.util.Date;
+
+public class GenericFile {
+ private String name;
+ private String extension;
+ private Date dateCreated;
+ private String version;
+ private byte[] content;
+
+ public GenericFile() {
+ this.setDateCreated(new Date());
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getExtension() {
+ return extension;
+ }
+
+ public void setExtension(String extension) {
+ this.extension = extension;
+ }
+
+ public Date getDateCreated() {
+ return dateCreated;
+ }
+
+ public void setDateCreated(Date dateCreated) {
+ this.dateCreated = dateCreated;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public byte[] getContent() {
+ return content;
+ }
+
+ public void setContent(byte[] content) {
+ this.content = content;
+ }
+
+ public String getFileInfo() {
+ return "Generic File Impl";
+ }
+
+ public Object read() {
+ return content;
+ }
+}
diff --git a/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ImageFile.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ImageFile.java
new file mode 100644
index 0000000000..2e2b9b4129
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ImageFile.java
@@ -0,0 +1,41 @@
+package com.baeldung.oop;
+
+public class ImageFile extends GenericFile {
+ private int height;
+ private int width;
+
+ public ImageFile(String name, int height, int width, byte[] content, String version) {
+ this.setHeight(height);
+ this.setWidth(width);
+ this.setContent(content);
+ this.setName(name);
+ this.setVersion(version);
+ this.setExtension(".jpg");
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public void setHeight(int height) {
+ this.height = height;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public void setWidth(int width) {
+ this.width = width;
+ }
+
+ public String getFileInfo() {
+ return "Image File Impl";
+ }
+
+ public String read() {
+ return this.getContent()
+ .toString();
+ }
+
+}
diff --git a/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/TextFile.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/TextFile.java
new file mode 100644
index 0000000000..0d7b8e4192
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/TextFile.java
@@ -0,0 +1,44 @@
+package com.baeldung.oop;
+
+public class TextFile extends GenericFile {
+ private int wordCount;
+
+ public TextFile(String name, String content, String version) {
+ String[] words = content.split(" ");
+ this.setWordCount(words.length > 0 ? words.length : 1);
+ this.setContent(content.getBytes());
+ this.setName(name);
+ this.setVersion(version);
+ this.setExtension(".txt");
+ }
+
+ public int getWordCount() {
+ return wordCount;
+ }
+
+ public void setWordCount(int wordCount) {
+ this.wordCount = wordCount;
+ }
+
+ public String getFileInfo() {
+ return "Text File Impl";
+ }
+
+ public String read() {
+ return this.getContent()
+ .toString();
+ }
+
+ public String read(int limit) {
+ return this.getContent()
+ .toString()
+ .substring(0, limit);
+ }
+
+ public String read(int start, int stop) {
+ return this.getContent()
+ .toString()
+ .substring(start, stop);
+ }
+
+}
diff --git a/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Vehicle.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Vehicle.java
new file mode 100644
index 0000000000..d5ef05bc31
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Vehicle.java
@@ -0,0 +1,23 @@
+package com.baeldung.oop;
+
+public class Vehicle {
+ private int wheels;
+ private String model;
+
+ public Vehicle(int wheels, String model) {
+ this.wheels = wheels;
+ this.model = model;
+ }
+
+ public void start() {
+ // the process of starting the vehicle
+ }
+
+ public void stop() {
+ // process to stop the vehicle
+ }
+
+ public void honk() {
+ // produces a default honk
+ }
+}
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java
rename to core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/parameterpassing/Primitives.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/Primitives.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/parameterpassing/Primitives.java
rename to core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/Primitives.java
diff --git a/core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java b/core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java
similarity index 96%
rename from core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java
rename to core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java
index 41c67ff389..6ef9b51818 100644
--- a/core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java
+++ b/core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java
@@ -62,9 +62,9 @@ public class AnimalActivityUnitTest {
@Test
public void givenDogReference__whenRefersCatObject_shouldCallFunctionWithAnimalParam() {
- Cat cat = new Cat();
+ Dog dog = new Dog();
- AnimalActivity.sleep(cat);
+ AnimalActivity.sleep(dog);
verify(mockAppender).doAppend(captorLoggingEvent.capture());
@@ -79,7 +79,7 @@ public class AnimalActivityUnitTest {
@Test
public void givenAnimaReference__whenRefersDogObject_shouldCallFunctionWithAnimalParam() {
- Animal cat = new Cat();
+ Animal cat = new Dog();
AnimalActivity.sleep(cat);
diff --git a/core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/binding/AnimalUnitTest.java b/core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/binding/AnimalUnitTest.java
rename to core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/binding/CatUnitTest.java b/core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/DogUnitTest.java
similarity index 94%
rename from core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/binding/CatUnitTest.java
rename to core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/DogUnitTest.java
index 76ccfb7719..977c5d65e6 100644
--- a/core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/binding/CatUnitTest.java
+++ b/core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/DogUnitTest.java
@@ -22,7 +22,7 @@ import static org.mockito.Mockito.verify;
* Created by madhumita.g on 01-08-2018.
*/
@RunWith(MockitoJUnitRunner.class)
-public class CatUnitTest {
+public class DogUnitTest {
@Mock
private Appender mockAppender;
@@ -45,9 +45,9 @@ public class CatUnitTest {
@Test
public void makeNoiseTest() {
- Cat cat = new Cat();
+ Dog dog = new Dog();
- cat.makeNoise();
+ dog.makeNoise();
verify(mockAppender).doAppend(captorLoggingEvent.capture());
diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java b/core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java
rename to core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java b/core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java
rename to core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-patterns/README.md b/core-java-modules/core-java-lang-oop-patterns/README.md
new file mode 100644
index 0000000000..178a556a96
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-patterns/README.md
@@ -0,0 +1,9 @@
+## Core Java Lang OOP - Patterns
+
+This module contains articles about Object-oriented programming (OOP) patterns in Java
+
+### Relevant Articles:
+- [Composition, Aggregation, and Association in Java](https://www.baeldung.com/java-composition-aggregation-association)
+- [Inheritance and Composition (Is-a vs Has-a relationship) in Java](https://www.baeldung.com/java-inheritance-composition)
+- [Immutable Objects in Java](https://www.baeldung.com/java-immutable-object)
+- [How to Make a Deep Copy of an Object in Java](https://www.baeldung.com/java-deep-copy)
diff --git a/core-java-modules/core-java-lang-oop/pom.xml b/core-java-modules/core-java-lang-oop-patterns/pom.xml
similarity index 55%
rename from core-java-modules/core-java-lang-oop/pom.xml
rename to core-java-modules/core-java-lang-oop-patterns/pom.xml
index 4415784f85..0102ef2653 100644
--- a/core-java-modules/core-java-lang-oop/pom.xml
+++ b/core-java-modules/core-java-lang-oop-patterns/pom.xml
@@ -1,20 +1,17 @@
-
- 4.0.0
- core-java-lang-oop
- 0.1.0-SNAPSHOT
- core-java-lang-oop
- jar
-
+
- com.baeldung
- parent-java
- 0.0.1-SNAPSHOT
- ../../parent-java
+ core-java-modules
+ com.baeldung.core-java-modules
+ 1.0.0-SNAPSHOT
+ 4.0.0
+
+ core-java-lang-oop-patterns
+ core-java-lang-oop-patterns
+ jar
@@ -22,8 +19,6 @@
commons-lang3
${commons-lang3.version}
-
-
com.fasterxml.jackson.core
jackson-databind
@@ -34,7 +29,7 @@
gson
${gson.version}
-
+
org.assertj
assertj-core
@@ -43,20 +38,8 @@
-
- core-java-lang-oop
-
-
- src/main/resources
- true
-
-
-
-
2.8.2
-
3.10.0
-
-
+
\ No newline at end of file
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/deepcopy/Address.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/Address.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/deepcopy/Address.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/Address.java
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/deepcopy/User.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/User.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/deepcopy/User.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/User.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/immutableobjects/Currency.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Currency.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/immutableobjects/Currency.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Currency.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/immutableobjects/Money.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Money.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/immutableobjects/Money.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Money.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/application/Application.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/application/Application.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/application/Application.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/application/Application.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java
diff --git a/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/ComputerBuilder.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/ComputerBuilder.java
new file mode 100644
index 0000000000..4d8574e93f
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/ComputerBuilder.java
@@ -0,0 +1,13 @@
+package com.baeldung.inheritancecomposition.model;
+
+public abstract class ComputerBuilder {
+
+ public final void buildComputer() {
+ addProcessor();
+ addMemory();
+ }
+
+ public abstract void addProcessor();
+
+ public abstract void addMemory();
+}
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Person.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Person.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Person.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Person.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java
diff --git a/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardComputerBuilder.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardComputerBuilder.java
new file mode 100644
index 0000000000..76c4732ace
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardComputerBuilder.java
@@ -0,0 +1,13 @@
+package com.baeldung.inheritancecomposition.model;
+
+public class StandardComputerBuilder extends ComputerBuilder {
+ @Override
+ public void addProcessor() {
+ // method implementation
+ }
+
+ @Override
+ public void addMemory() {
+ // method implementation
+ }
+}
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/aggregation/Car.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Car.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/aggregation/Car.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Car.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/aggregation/CarWithStaticInnerWheel.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/CarWithStaticInnerWheel.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/aggregation/CarWithStaticInnerWheel.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/CarWithStaticInnerWheel.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/aggregation/Wheel.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Wheel.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/aggregation/Wheel.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Wheel.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/association/Child.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Child.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/association/Child.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Child.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/association/Mother.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Mother.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/association/Mother.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Mother.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/composition/Building.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/Building.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/composition/Building.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/Building.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/composition/BuildingWithDefinitionRoomInMethod.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/BuildingWithDefinitionRoomInMethod.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/composition/BuildingWithDefinitionRoomInMethod.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/BuildingWithDefinitionRoomInMethod.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/university/Department.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Department.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/university/Department.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Department.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/university/Professor.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Professor.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/university/Professor.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Professor.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/university/University.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/University.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/university/University.java
rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/University.java
diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java b/core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java
rename to core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java b/core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java
rename to core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java b/core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java
rename to core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/ActressUnitTest.java b/core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/ActressUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/ActressUnitTest.java
rename to core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/ActressUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/CompositionUnitTest.java b/core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/CompositionUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/CompositionUnitTest.java
rename to core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/CompositionUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/InheritanceUnitTest.java b/core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/InheritanceUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/InheritanceUnitTest.java
rename to core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/InheritanceUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/PersonUnitTest.java b/core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/PersonUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/PersonUnitTest.java
rename to core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/PersonUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/WaitressUnitTest.java b/core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/WaitressUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/WaitressUnitTest.java
rename to core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/WaitressUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-types/README.md b/core-java-modules/core-java-lang-oop-types/README.md
new file mode 100644
index 0000000000..80344c70fa
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-types/README.md
@@ -0,0 +1,9 @@
+## Core Java Lang OOP - Types
+
+This module contains articles about types in Java
+
+### Relevant Articles:
+- [Java Classes and Objects](https://www.baeldung.com/java-classes-objects)
+- [Guide to the this Java Keyword](https://www.baeldung.com/java-this)
+- [Nested Classes in Java](https://www.baeldung.com/java-nested-classes)
+- [Marker Interfaces in Java](https://www.baeldung.com/java-marker-interfaces)
diff --git a/core-java-modules/core-java-lang-oop-types/pom.xml b/core-java-modules/core-java-lang-oop-types/pom.xml
new file mode 100644
index 0000000000..f73434a9ff
--- /dev/null
+++ b/core-java-modules/core-java-lang-oop-types/pom.xml
@@ -0,0 +1,15 @@
+
+
+
+ core-java-modules
+ com.baeldung.core-java-modules
+ 1.0.0-SNAPSHOT
+
+ 4.0.0
+
+ core-java-lang-oop-types
+ core-java-lang-oop-types
+ jar
+
\ No newline at end of file
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/markerinterface/DeletableShape.java b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/DeletableShape.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/markerinterface/DeletableShape.java
rename to core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/DeletableShape.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/markerinterface/Rectangle.java b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Rectangle.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/markerinterface/Rectangle.java
rename to core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Rectangle.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/markerinterface/Shape.java b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Shape.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/markerinterface/Shape.java
rename to core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Shape.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/markerinterface/ShapeDao.java b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/ShapeDao.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/markerinterface/ShapeDao.java
rename to core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/ShapeDao.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/objects/Car.java b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/objects/Car.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/objects/Car.java
rename to core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/objects/Car.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/thiskeyword/Keyword.java
similarity index 64%
rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java
rename to core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/thiskeyword/Keyword.java
index 35fd7358af..a09a1ac8e1 100644
--- a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java
+++ b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/thiskeyword/Keyword.java
@@ -1,17 +1,17 @@
-package com.baeldung.keyword.thiskeyword;
+package com.baeldung.thiskeyword;
-public class KeywordUnitTest {
+public class Keyword {
private String name;
private int age;
- public KeywordUnitTest() {
+ public Keyword() {
this("John", 27);
this.printMessage();
printInstance(this);
}
- public KeywordUnitTest(String name, int age) {
+ public Keyword(String name, int age) {
this.name = name;
this.age = age;
}
@@ -20,11 +20,11 @@ public class KeywordUnitTest {
System.out.println("invoked by this");
}
- public void printInstance(KeywordUnitTest thisKeyword) {
+ public void printInstance(Keyword thisKeyword) {
System.out.println(thisKeyword);
}
- public KeywordUnitTest getCurrentInstance() {
+ public Keyword getCurrentInstance() {
return this;
}
@@ -33,8 +33,8 @@ public class KeywordUnitTest {
boolean isInnerClass = true;
public ThisInnerClass() {
- KeywordUnitTest thisKeyword = KeywordUnitTest.this;
- String outerString = KeywordUnitTest.this.name;
+ Keyword thisKeyword = Keyword.this;
+ String outerString = Keyword.this.name;
System.out.println(this.isInnerClass);
}
}
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java
rename to core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/AnonymousInner.java b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInnerUnitTest.java
similarity index 91%
rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/AnonymousInner.java
rename to core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInnerUnitTest.java
index 9fa8ee9cd5..98917b9e05 100644
--- a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/AnonymousInner.java
+++ b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInnerUnitTest.java
@@ -6,7 +6,7 @@ abstract class SimpleAbstractClass {
abstract void run();
}
-public class AnonymousInner {
+public class AnonymousInnerUnitTest {
@Test
public void run() {
diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/Enclosing.java b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Enclosing.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/Enclosing.java
rename to core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Enclosing.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/NewEnclosing.java b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewEnclosing.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/NewEnclosing.java
rename to core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewEnclosing.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/NewOuter.java b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewOuter.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/NewOuter.java
rename to core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewOuter.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/Outer.java b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Outer.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/Outer.java
rename to core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Outer.java
diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/objects/ObjectsUnitTest.java b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/objects/ObjectsUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/objects/ObjectsUnitTest.java
rename to core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/objects/ObjectsUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop/.gitignore b/core-java-modules/core-java-lang-oop/.gitignore
deleted file mode 100644
index 3de4cc647e..0000000000
--- a/core-java-modules/core-java-lang-oop/.gitignore
+++ /dev/null
@@ -1,26 +0,0 @@
-*.class
-
-0.*
-
-#folders#
-/target
-/neoDb*
-/data
-/src/main/webapp/WEB-INF/classes
-*/META-INF/*
-.resourceCache
-
-# Packaged files #
-*.jar
-*.war
-*.ear
-
-# Files generated by integration tests
-*.txt
-backup-pom.xml
-/bin/
-/temp
-
-#IntelliJ specific
-.idea/
-*.iml
\ 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
deleted file mode 100644
index 2be3d0cab1..0000000000
--- a/core-java-modules/core-java-lang-oop/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
-## Core Java Lang OOP
-
-This module contains articles about Object-oriented programming (OOP) in Java
-
-### Relevant Articles:
-- [Guide to hashCode() in Java](https://www.baeldung.com/java-hashcode)
-- [A Guide to the Static Keyword in Java](https://www.baeldung.com/java-static)
-- [Polymorphism in Java](https://www.baeldung.com/java-polymorphism)
-- [Method Overloading and Overriding in Java](https://www.baeldung.com/java-method-overload-override)
-- [How to Make a Deep Copy of an Object in Java](https://www.baeldung.com/java-deep-copy)
-- [Guide to Inheritance in Java](https://www.baeldung.com/java-inheritance)
-- [Object Type Casting in Java](https://www.baeldung.com/java-type-casting)
-- [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)
-- [Object-Oriented-Programming Concepts in Java](https://www.baeldung.com/java-oop)
-- [[More -->]](/core-java-modules/core-java-lang-oop-2)
diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/initializationguide/User.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/initializationguide/User.java
deleted file mode 100644
index 1d9a872d69..0000000000
--- a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/initializationguide/User.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.baeldung.initializationguide;
-
-import java.io.Serializable;
-
-public class User implements Serializable, Cloneable {
- private static final long serialVersionUID = 1L;
- static String forum;
- private String name;
- private int id;
-
- {
- id = 0;
- System.out.println("Instance Initializer");
- }
-
- static {
- forum = "Java";
- System.out.println("Static Initializer");
- }
-
- public User(String name, int id) {
- super();
- this.name = name;
- this.id = id;
- }
-
- public User() {
- System.out.println("Constructor");
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- @Override
- protected Object clone() throws CloneNotSupportedException {
- return this;
- }
-
-}
-
diff --git a/core-java-modules/core-java-lang-oop/src/main/resources/logback.xml b/core-java-modules/core-java-lang-oop/src/main/resources/logback.xml
deleted file mode 100644
index 56af2d397e..0000000000
--- a/core-java-modules/core-java-lang-oop/src/main/resources/logback.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/initializationguide/UserUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/initializationguide/UserUnitTest.java
deleted file mode 100644
index a26b602609..0000000000
--- a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/initializationguide/UserUnitTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.baeldung.initializationguide;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.*;
-
-import java.lang.reflect.InvocationTargetException;
-
-public class UserUnitTest {
-
- @Test
- public void givenUserInstance_whenIntializedWithNew_thenInstanceIsNotNull() {
- User user = new User("Alice", 1);
- assertThat(user).isNotNull();
- }
-
- @Test
- public void givenUserInstance_whenInitializedWithReflection_thenInstanceIsNotNull() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
- User user = User.class.getConstructor(String.class, int.class)
- .newInstance("Alice", 2);
- assertThat(user).isNotNull();
- }
-
- @Test
- public void givenUserInstance_whenCopiedWithClone_thenExactMatchIsCreated() throws CloneNotSupportedException {
- User user = new User("Alice", 3);
- User clonedUser = (User) user.clone();
- assertThat(clonedUser).isEqualTo(user);
- }
-
- @Test
- public void givenUserInstance_whenValuesAreNotInitialized_thenUserNameAndIdReturnDefault() {
- User user = new User();
- assertThat(user.getName()).isNull();
- assertThat(user.getId() == 0);
- }
-}
diff --git a/core-java-modules/core-java-lang-oop/src/test/resources/.gitignore b/core-java-modules/core-java-lang-oop/src/test/resources/.gitignore
deleted file mode 100644
index 83c05e60c8..0000000000
--- a/core-java-modules/core-java-lang-oop/src/test/resources/.gitignore
+++ /dev/null
@@ -1,13 +0,0 @@
-*.class
-
-#folders#
-/target
-/neoDb*
-/data
-/src/main/webapp/WEB-INF/classes
-*/META-INF/*
-
-# Packaged files #
-*.jar
-*.war
-*.ear
\ No newline at end of file
diff --git a/core-java-modules/core-java-lang-operators/pom.xml b/core-java-modules/core-java-lang-operators/pom.xml
index b95caa81b8..09fbce4b3c 100644
--- a/core-java-modules/core-java-lang-operators/pom.xml
+++ b/core-java-modules/core-java-lang-operators/pom.xml
@@ -17,6 +17,12 @@
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+ provided
+
org.assertj
diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/objectclass/Borrower.java b/core-java-modules/core-java-lang-operators/src/main/java/com/baeldung/objectclass/Borrower.java
similarity index 100%
rename from core-java-modules/core-java/src/main/java/com/baeldung/objectclass/Borrower.java
rename to core-java-modules/core-java-lang-operators/src/main/java/com/baeldung/objectclass/Borrower.java
diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/objectclass/Lender.java b/core-java-modules/core-java-lang-operators/src/main/java/com/baeldung/objectclass/Lender.java
similarity index 100%
rename from core-java-modules/core-java/src/main/java/com/baeldung/objectclass/Lender.java
rename to core-java-modules/core-java-lang-operators/src/main/java/com/baeldung/objectclass/Lender.java
diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/objectclass/User.java b/core-java-modules/core-java-lang-operators/src/main/java/com/baeldung/objectclass/User.java
similarity index 100%
rename from core-java-modules/core-java/src/main/java/com/baeldung/objectclass/User.java
rename to core-java-modules/core-java-lang-operators/src/main/java/com/baeldung/objectclass/User.java
diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/objectclass/CreditAppUnitTest.java b/core-java-modules/core-java-lang-operators/src/test/java/com/baeldung/objectclass/CreditAppUnitTest.java
similarity index 74%
rename from core-java-modules/core-java/src/test/java/com/baeldung/objectclass/CreditAppUnitTest.java
rename to core-java-modules/core-java-lang-operators/src/test/java/com/baeldung/objectclass/CreditAppUnitTest.java
index 8330ddbac5..bba30adcdb 100644
--- a/core-java-modules/core-java/src/test/java/com/baeldung/objectclass/CreditAppUnitTest.java
+++ b/core-java-modules/core-java-lang-operators/src/test/java/com/baeldung/objectclass/CreditAppUnitTest.java
@@ -5,6 +5,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import org.junit.Ignore;
import org.junit.Test;
public class CreditAppUnitTest {
@@ -40,13 +41,28 @@ public class CreditAppUnitTest {
assertNotNull(lender);
}
+ @Ignore
+ @Test
+ public void givenBorrower_whenDoubleOrNotString_thenRequestLoan() {
+ Borrower borrower = new Borrower();
+ double amount = 100.0;
+
+ /*if(amount instanceof Double) { // Compilation error, no autoboxing
+ borrower.requestLoan(amount);
+ }
+
+ if(!(amount instanceof String)) { // Compilation error, incompatible operands
+ borrower.requestLoan(amount);
+ }*/
+
+ }
+
@Test
public void givenBorrower_whenLoanAmountIsDouble_thenRequestLoan() {
Borrower borrower = new Borrower();
double amount = 100.0;
- //if(amount instanceof Double) // Compilation error, no autoboxing
- if(Double.class.isInstance(amount)) {
+ if(Double.class.isInstance(amount)) { // No compilation error
borrower.requestLoan(amount);
}
assertEquals(100, borrower.getTotalLoanAmount());
@@ -57,8 +73,7 @@ public class CreditAppUnitTest {
Borrower borrower = new Borrower();
Double amount = 100.0;
- //if(amount instanceof String) // Compilation error, incompatible operands
- if(!String.class.isInstance(amount)) {
+ if(!String.class.isInstance(amount)) { // No compilation error
borrower.requestLoan(amount);
}
assertEquals(100, borrower.getTotalLoanAmount());
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/ComplexClass.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/ComplexClass.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/ComplexClass.java
rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/ComplexClass.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/PrimitiveClass.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/PrimitiveClass.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/PrimitiveClass.java
rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/PrimitiveClass.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/Rectangle.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Rectangle.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/Rectangle.java
rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Rectangle.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/Shape.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Shape.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/Shape.java
rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Shape.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/Square.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Square.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/Square.java
rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Square.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/entities/ComplexClassUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/ComplexClassUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/entities/ComplexClassUnitTest.java
rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/ComplexClassUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/entities/PrimitiveClassUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/PrimitiveClassUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/entities/PrimitiveClassUnitTest.java
rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/PrimitiveClassUnitTest.java
diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/entities/SquareClassUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/SquareClassUnitTest.java
similarity index 100%
rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/entities/SquareClassUnitTest.java
rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/SquareClassUnitTest.java
diff --git a/core-java-modules/core-java-networking-2/README.md b/core-java-modules/core-java-networking-2/README.md
index 120b111ff5..662d97252e 100644
--- a/core-java-modules/core-java-networking-2/README.md
+++ b/core-java-modules/core-java-networking-2/README.md
@@ -11,4 +11,5 @@ This module contains articles about networking in Java
- [Sending Emails with Java](https://www.baeldung.com/java-email)
- [Authentication with HttpUrlConnection](https://www.baeldung.com/java-http-url-connection)
- [Download a File from an URL in Java](https://www.baeldung.com/java-download-file)
+- [Handling java.net.ConnectException](https://www.baeldung.com/java-net-connectexception)
- [[<-- Prev]](/core-java-modules/core-java-networking)
diff --git a/core-java-modules/core-java-streams-3/README.md b/core-java-modules/core-java-streams-3/README.md
index 05c4b99900..65713aa04f 100644
--- a/core-java-modules/core-java-streams-3/README.md
+++ b/core-java-modules/core-java-streams-3/README.md
@@ -10,4 +10,5 @@ This module contains articles about the Stream API in Java.
- [Primitive Type Streams in Java 8](https://www.baeldung.com/java-8-primitive-streams)
- [Debugging Java 8 Streams with IntelliJ](https://www.baeldung.com/intellij-debugging-java-streams)
- [Add BigDecimals using the Stream API](https://www.baeldung.com/java-stream-add-bigdecimals)
+- [Should We Close a Java Stream?](https://www.baeldung.com/java-stream-close)
- More articles: [[<-- prev>]](/../core-java-streams-2)
diff --git a/core-java-modules/core-java-time-measurements/pom.xml b/core-java-modules/core-java-time-measurements/pom.xml
index 71a012ca2b..b751cc0d74 100644
--- a/core-java-modules/core-java-time-measurements/pom.xml
+++ b/core-java-modules/core-java-time-measurements/pom.xml
@@ -96,7 +96,7 @@
3.6.1
1.8.9
- 2.0.0-RC.4
+ 2.0.0
1.44
2.22.1
diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml
index b7454cc737..c6cc3726e1 100644
--- a/core-java-modules/pom.xml
+++ b/core-java-modules/pom.xml
@@ -85,10 +85,14 @@
core-java-lang-2
core-java-lang-math
core-java-lang-math-2
- core-java-lang-oop
- core-java-lang-oop-2
- core-java-lang-oop-3
- core-java-lang-oop-4
+ core-java-lang-oop-constructors
+ core-java-lang-oop-patterns
+ core-java-lang-oop-generics
+ core-java-lang-oop-modifiers
+ core-java-lang-oop-types
+ core-java-lang-oop-inheritance
+ core-java-lang-oop-methods
+ core-java-lang-oop-others
core-java-lang-operators
core-java-lang-syntax
core-java-lang-syntax-2
diff --git a/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/foldvsreduce/FoldAndReduceTest.kt b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/foldvsreduce/FoldAndReduceTest.kt
new file mode 100644
index 0000000000..7b263914c6
--- /dev/null
+++ b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/foldvsreduce/FoldAndReduceTest.kt
@@ -0,0 +1,59 @@
+package com.baeldung.foldvsreduce
+
+import org.junit.Test
+import org.junit.jupiter.api.assertThrows
+import java.lang.RuntimeException
+import kotlin.test.assertEquals
+
+class FoldAndReduceTest {
+
+ @Test
+ fun testReduceLimitations() {
+ val numbers: List = listOf(1, 2, 3)
+ val sum: Number = numbers.reduce { acc, next -> acc + next }
+ assertEquals(6, sum)
+
+ val emptyList = listOf()
+ assertThrows { emptyList.reduce { acc, next -> acc + next } }
+
+ // doesn't compile
+ // val sum = numbers.reduce { acc, next -> acc.toLong() + next.toLong()}
+ }
+
+ @Test
+ fun testFold() {
+
+ val numbers: List = listOf(1, 2, 3)
+ val sum: Int = numbers.fold(0, { acc, next -> acc + next })
+ assertEquals(6, sum)
+
+ //change result type
+ val sumLong: Long = numbers.fold(0L, { acc, next -> acc + next.toLong() })
+ assertEquals(6L, sumLong)
+
+ val emptyList = listOf()
+ val emptySum = emptyList.fold(0, { acc, next -> acc + next })
+ assertEquals(0, emptySum)
+
+ //power of changing result type
+ val (even, odd) = numbers.fold(Pair(listOf(), listOf()), { acc, next ->
+ if (next % 2 == 0) Pair(acc.first + next, acc.second)
+ else Pair(acc.first, acc.second + next)
+ })
+
+ assertEquals(listOf(2), even)
+ assertEquals(listOf(1, 3), odd)
+ }
+
+ @Test
+ fun testVariationsOfFold() {
+ val numbers = listOf(1, 2, 3)
+ val reversed = numbers.foldRight(listOf(), { next, acc -> acc + next})
+ assertEquals(listOf(3,2,1), reversed)
+
+ val reversedIndexes = numbers.foldRightIndexed(listOf(), { i, _, acc -> acc + i })
+ assertEquals(listOf(2,1,0), reversedIndexes)
+ }
+
+
+}
\ No newline at end of file
diff --git a/java-collections-conversions-2/pom.xml b/java-collections-conversions-2/pom.xml
index b04d764719..0f7cdadeb2 100644
--- a/java-collections-conversions-2/pom.xml
+++ b/java-collections-conversions-2/pom.xml
@@ -20,6 +20,23 @@
commons-lang3
${commons-lang3.version}
+
+ org.modelmapper
+ modelmapper
+ ${modelmapper.version}
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+ org.hamcrest
+ hamcrest
+ ${hamcrest.version}
+ test
+
diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java
new file mode 100644
index 0000000000..23a549e652
--- /dev/null
+++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java
@@ -0,0 +1,32 @@
+package com.baeldung.modelmapper;
+
+import org.modelmapper.ModelMapper;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * This is a helper class that contains method for custom mapping of the users list.
+ * Initially, an instance of ModelMapper was created.
+ *
+ * @author Sasa Milenkovic
+ */
+public class MapperUtil {
+
+ private static ModelMapper modelMapper = new ModelMapper();
+
+
+ private MapperUtil() {
+
+
+ }
+
+ public static List mapList(List source, Class targetClass) {
+
+ return source
+ .stream()
+ .map(element -> modelMapper.map(element, targetClass))
+ .collect(Collectors.toList());
+ }
+
+}
diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java
new file mode 100644
index 0000000000..8ed674d86a
--- /dev/null
+++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java
@@ -0,0 +1,70 @@
+package com.baeldung.modelmapper;
+
+/**
+ * User model entity class
+ *
+ * @author Sasa Milenkovic
+ */
+public class User {
+
+ private String userId;
+ private String username;
+ private String email;
+ private String contactNumber;
+ private String userType;
+
+ // Standard constructors, getters and setters
+
+ public User() {
+ }
+
+ public User(String userId, String username, String email, String contactNumber, String userType) {
+ this.userId = userId;
+ this.username = username;
+ this.email = email;
+ this.contactNumber = contactNumber;
+ this.userType = userType;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String userName) {
+ this.username = userName;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getContactNumber() {
+ return contactNumber;
+ }
+
+ public void setContactNumber(String contactNumber) {
+ this.contactNumber = contactNumber;
+ }
+
+ public String getUserType() {
+ return userType;
+ }
+
+ public void setUserType(String userType) {
+ this.userType = userType;
+ }
+
+
+}
diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java
new file mode 100644
index 0000000000..b67bb58ef4
--- /dev/null
+++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java
@@ -0,0 +1,41 @@
+package com.baeldung.modelmapper;
+
+/**
+ * UserDTO model class
+ *
+ * @author Sasa Milenkovic
+ */
+public class UserDTO {
+
+ private String userId;
+ private String username;
+ private String email;
+
+ // getters and setters
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+
+}
diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserList.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserList.java
new file mode 100644
index 0000000000..7b6bed807b
--- /dev/null
+++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserList.java
@@ -0,0 +1,21 @@
+package com.baeldung.modelmapper;
+
+import java.util.Collection;
+
+/**
+ * UserList class that contain collection of users
+ *
+ * @author Sasa Milenkovic
+ */
+public class UserList {
+
+ private Collection users;
+
+ public Collection getUsers() {
+ return users;
+ }
+
+ public void setUsers(Collection users) {
+ this.users = users;
+ }
+}
diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserListDTO.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserListDTO.java
new file mode 100644
index 0000000000..c001cbbc3c
--- /dev/null
+++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserListDTO.java
@@ -0,0 +1,21 @@
+package com.baeldung.modelmapper;
+
+import java.util.List;
+
+/**
+ * UserListDTO class that contain list of username properties
+ *
+ * @author Sasa Milenkovic
+ */
+public class UserListDTO {
+
+ private List usernames;
+
+ public List getUsernames() {
+ return usernames;
+ }
+
+ public void setUsernames(List usernames) {
+ this.usernames = usernames;
+ }
+}
diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UsersListConverter.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UsersListConverter.java
new file mode 100644
index 0000000000..19423713e2
--- /dev/null
+++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UsersListConverter.java
@@ -0,0 +1,23 @@
+package com.baeldung.modelmapper;
+
+import org.modelmapper.AbstractConverter;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * UsersListConverter class map the property data from the list of users into the list of user names.
+ *
+ * @author Sasa Milenkovic
+ */
+public class UsersListConverter extends AbstractConverter, List> {
+
+ @Override
+ protected List convert(List users) {
+
+ return users
+ .stream()
+ .map(User::getUsername)
+ .collect(Collectors.toList());
+ }
+}
diff --git a/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java b/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java
new file mode 100644
index 0000000000..a8a72b12f7
--- /dev/null
+++ b/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java
@@ -0,0 +1,92 @@
+package com.baeldung.modelmapper;
+
+import org.hamcrest.Matchers;
+import org.junit.Before;
+import org.junit.Test;
+import org.modelmapper.ModelMapper;
+import org.modelmapper.TypeMap;
+import org.modelmapper.TypeToken;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.Matchers.hasProperty;
+import static org.junit.Assert.assertThat;
+
+
+/**
+ * This class has test methods of mapping Integer to Character list,
+ * mapping users list to DTO list using MapperUtil custom type method and property mapping using converter class
+ *
+ * @author Sasa Milenkovic
+ */
+public class UsersListMappingUnitTest {
+
+ private ModelMapper modelMapper;
+ private List users;
+
+ @Before
+ public void init() {
+
+ modelMapper = new ModelMapper();
+
+ TypeMap typeMap = modelMapper.createTypeMap(UserList.class, UserListDTO.class);
+
+ typeMap.addMappings(mapper -> mapper.using(new UsersListConverter())
+ .map(UserList::getUsers, UserListDTO::setUsernames));
+
+ users = new ArrayList();
+ users.add(new User("b100", "user1", "user1@baeldung.com", "111-222", "USER"));
+ users.add(new User("b101", "user2", "user2@baeldung.com", "111-333", "USER"));
+ users.add(new User("b102", "user3", "user3@baeldung.com", "111-444", "ADMIN"));
+
+ }
+
+ @Test
+ public void whenInteger_thenMapToCharacter() {
+
+ List integers = new ArrayList();
+
+ integers.add(1);
+ integers.add(2);
+ integers.add(3);
+
+ List characters = modelMapper.map(integers, new TypeToken>() {
+ }.getType());
+
+ assertThat(characters, hasItems('1', '2', '3'));
+
+ }
+
+ @Test
+ public void givenUsersList_whenUseGenericType_thenMapToUserDTO() {
+
+ // Mapping lists using custom (generic) type mapping
+
+ List userDtoList = MapperUtil.mapList(users, UserDTO.class);
+
+ assertThat(userDtoList, Matchers.hasItem(
+ Matchers.both(hasProperty("userId", equalTo("b100")))
+ .and(hasProperty("email", equalTo("user1@baeldung.com")))
+ .and(hasProperty("username", equalTo("user1")))));
+
+
+ }
+
+ @Test
+ public void givenUsersList_whenUseConverter_thenMapToUsernames() {
+
+ // Mapping lists using property mapping and converter
+
+ UserList userList = new UserList();
+ userList.setUsers(users);
+ UserListDTO dtos = new UserListDTO();
+ modelMapper.map(userList, dtos);
+
+ assertThat(dtos.getUsernames(), hasItems("user1", "user2", "user3"));
+
+ }
+
+}
\ No newline at end of file
diff --git a/java-collections-maps-3/README.md b/java-collections-maps-3/README.md
new file mode 100644
index 0000000000..4da8547824
--- /dev/null
+++ b/java-collections-maps-3/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles:
+
+- [Java Map With Case-Insensitive Keys](https://www.baeldung.com/java-map-with-case-insensitive-keys)
diff --git a/jee-7/pom.xml b/jee-7/pom.xml
index 7352c6550a..9077aae1a6 100644
--- a/jee-7/pom.xml
+++ b/jee-7/pom.xml
@@ -256,10 +256,9 @@
- src/main/resources
-
- country.wsdl
-
+
+ http://localhost:8888/ws/country?wsdl
+
true
com.baeldung.soap.ws.client.generated
src/main/java
diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java b/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java
index 09f4c29202..a6983938f5 100644
--- a/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java
+++ b/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java
@@ -12,11 +12,11 @@ import javax.xml.ws.WebServiceFeature;
/**
* This class was generated by the JAX-WS RI.
- * JAX-WS RI 2.3.2
+ * JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*
*/
-@WebServiceClient(name = "CountryServiceImplService", targetNamespace = "http://server.ws.soap.baeldung.com/", wsdlLocation = "file:src/main/resources/country.wsdl")
+@WebServiceClient(name = "CountryServiceImplService", targetNamespace = "http://server.ws.soap.baeldung.com/", wsdlLocation = "http://localhost:8888/ws/country?wsdl")
public class CountryServiceImplService extends Service {
private final static URL COUNTRYSERVICEIMPLSERVICE_WSDL_LOCATION;
@@ -27,7 +27,7 @@ public class CountryServiceImplService extends Service {
URL url = null;
WebServiceException e = null;
try {
- url = new URL("file:src/main/resources/country.wsdl");
+ url = new URL("http://localhost:8888/ws/country?wsdl");
} catch (MalformedURLException ex) {
e = new WebServiceException(ex);
}
diff --git a/jee-7/src/main/resources/country.wsdl b/jee-7/src/main/resources/country.wsdl
deleted file mode 100644
index 4d41fce322..0000000000
--- a/jee-7/src/main/resources/country.wsdl
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/CustomCheckPointUnitTest.java b/jee-7/src/test/java/com/baeldung/batch/understanding/CustomCheckPointUnitTest.java
index 744bdfc8f5..c607efeb24 100644
--- a/jee-7/src/test/java/com/baeldung/batch/understanding/CustomCheckPointUnitTest.java
+++ b/jee-7/src/test/java/com/baeldung/batch/understanding/CustomCheckPointUnitTest.java
@@ -1,20 +1,17 @@
package com.baeldung.batch.understanding;
-import static org.junit.jupiter.api.Assertions.*;
-import java.util.Map;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.util.Properties;
+
import javax.batch.operations.JobOperator;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
-import javax.batch.runtime.Metric;
import javax.batch.runtime.StepExecution;
-import com.baeldung.batch.understanding.BatchTestHelper;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Disabled;
-@Disabled("Should be fixed in BAEL-3812")
class CustomCheckPointUnitTest {
@Test
public void givenChunk_whenCustomCheckPoint_thenCommitCountIsThree() throws Exception {
diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/JobSequenceUnitTest.java b/jee-7/src/test/java/com/baeldung/batch/understanding/JobSequenceUnitTest.java
index 88b981df92..4b27e5f5ec 100644
--- a/jee-7/src/test/java/com/baeldung/batch/understanding/JobSequenceUnitTest.java
+++ b/jee-7/src/test/java/com/baeldung/batch/understanding/JobSequenceUnitTest.java
@@ -1,6 +1,8 @@
package com.baeldung.batch.understanding;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.List;
@@ -13,9 +15,7 @@ import javax.batch.runtime.JobExecution;
import javax.batch.runtime.StepExecution;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Disabled;
-@Disabled("Should be fixed in BAEL-3812")
class JobSequenceUnitTest {
@Test
public void givenTwoSteps_thenBatch_CompleteWithSuccess() throws Exception {
diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetUnitTest.java b/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetUnitTest.java
index 3babf9b5aa..788b75eb3e 100644
--- a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetUnitTest.java
+++ b/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetUnitTest.java
@@ -1,17 +1,16 @@
package com.baeldung.batch.understanding;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.Properties;
import javax.batch.operations.JobOperator;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
-import java.util.Properties;
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import org.junit.jupiter.api.Test;
-@Disabled("Should be fixed in BAEL-3812")
class SimpleBatchLetUnitTest {
@Test
public void givenBatchLet_thenBatch_CompleteWithSuccess() throws Exception {
diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleChunkUnitTest.java b/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleChunkUnitTest.java
index 5871143fa3..9010c365a2 100644
--- a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleChunkUnitTest.java
+++ b/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleChunkUnitTest.java
@@ -1,6 +1,7 @@
package com.baeldung.batch.understanding;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import java.util.Map;
@@ -14,9 +15,7 @@ import javax.batch.runtime.Metric;
import javax.batch.runtime.StepExecution;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Disabled;
-@Disabled("Should be fixed in BAEL-3812")
class SimpleChunkUnitTest {
@Test
public void givenChunk_thenBatch_CompletesWithSucess() throws Exception {
diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkUnitTest.java b/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkUnitTest.java
index c53561a0c0..bc410aec8d 100644
--- a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkUnitTest.java
+++ b/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkUnitTest.java
@@ -1,19 +1,18 @@
package com.baeldung.batch.understanding;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+import java.util.Properties;
import javax.batch.operations.JobOperator;
import javax.batch.runtime.BatchRuntime;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
import javax.batch.runtime.StepExecution;
-import java.util.List;
-import java.util.Properties;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
-@Disabled("Should be fixed in BAEL-3812")
class SimpleErrorChunkUnitTest {
@Test
diff --git a/jee-7/src/test/resources/jberet.properties b/jee-7/src/test/resources/jberet.properties
new file mode 100644
index 0000000000..e8b9907de5
--- /dev/null
+++ b/jee-7/src/test/resources/jberet.properties
@@ -0,0 +1 @@
+db-url=jdbc:h2:mem:jberet-repo;DB_CLOSE_DELAY=-1
\ No newline at end of file
diff --git a/jhipster/jhipster-uaa/gateway/pom.xml b/jhipster/jhipster-uaa/gateway/pom.xml
index 1b85877a9b..b417bd7b57 100644
--- a/jhipster/jhipster-uaa/gateway/pom.xml
+++ b/jhipster/jhipster-uaa/gateway/pom.xml
@@ -1013,7 +1013,7 @@
1.0.0
- 0.24.0-RC.0
+ 0.24.0
3.0.0
1.8
diff --git a/jhipster/jhipster-uaa/quotes/pom.xml b/jhipster/jhipster-uaa/quotes/pom.xml
index aacc6f8e36..f088ad2fd1 100644
--- a/jhipster/jhipster-uaa/quotes/pom.xml
+++ b/jhipster/jhipster-uaa/quotes/pom.xml
@@ -910,6 +910,6 @@
${project.basedir}/src/test/
- 0.24.0-RC.0
+ 0.24.0
diff --git a/jhipster/jhipster-uaa/uaa/pom.xml b/jhipster/jhipster-uaa/uaa/pom.xml
index 27a056820d..f9c1f226bb 100644
--- a/jhipster/jhipster-uaa/uaa/pom.xml
+++ b/jhipster/jhipster-uaa/uaa/pom.xml
@@ -835,7 +835,7 @@
1.0.0
- 0.24.0-RC.0
+ 0.24.0
3.0.0
1.8
diff --git a/jsoup/src/test/java/com/baeldung/jsonproxy/JsoupProxyIntegrationTest.java b/jsoup/src/test/java/com/baeldung/jsonproxy/JsoupProxyIntegrationTest.java
new file mode 100644
index 0000000000..8e854ead6a
--- /dev/null
+++ b/jsoup/src/test/java/com/baeldung/jsonproxy/JsoupProxyIntegrationTest.java
@@ -0,0 +1,27 @@
+package com.baeldung.jsonproxy;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+
+import org.jsoup.Jsoup;
+import org.junit.Test;
+
+public class JsoupProxyIntegrationTest {
+
+ @Test
+ public void whenUsingHostAndPort_thenConnect() throws IOException {
+ Jsoup.connect("https://spring.io/blog")
+ .proxy("200.216.227.141", 53281)
+ .get();
+ }
+
+ @Test
+ public void whenUsingProxyClass_thenConnect() throws IOException {
+ Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("200.216.227.141", 53281));
+
+ Jsoup.connect("https://spring.io/blog")
+ .proxy(proxy)
+ .get();
+ }
+}
diff --git a/libraries-2/README.md b/libraries-2/README.md
index edf513c6ee..8dae12a1cf 100644
--- a/libraries-2/README.md
+++ b/libraries-2/README.md
@@ -18,5 +18,5 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m
- [Guide to MapDB](https://www.baeldung.com/mapdb)
- [A Guide to Apache Mesos](https://www.baeldung.com/apache-mesos)
- [JasperReports with Spring](https://www.baeldung.com/spring-jasper)
-- More articles [[<-- prev]](/libraries)
+- More articles [[<-- prev]](/libraries) [[next -->]](/libraries-3)
diff --git a/libraries-3/README.md b/libraries-3/README.md
index ec433960ef..6279dcf5ad 100644
--- a/libraries-3/README.md
+++ b/libraries-3/README.md
@@ -17,3 +17,4 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m
- [Using NullAway to Avoid NullPointerExceptions](https://www.baeldung.com/java-nullaway)
- [Introduction to Alibaba Arthas](https://www.baeldung.com/java-alibaba-arthas-intro)
- [Quick Guide to Spring Cloud Circuit Breaker](https://www.baeldung.com/spring-cloud-circuit-breaker)
+- More articles [[<-- prev]](/libraries-2) [[next -->]](/libraries-4)
diff --git a/libraries-4/README.md b/libraries-4/README.md
new file mode 100644
index 0000000000..0dee9f1c1e
--- /dev/null
+++ b/libraries-4/README.md
@@ -0,0 +1,21 @@
+## Libraries-4
+
+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
+- [Quick Guide to RSS with Rome](https://www.baeldung.com/rome-rss)
+- [Introduction to PCollections](https://www.baeldung.com/java-pcollections)
+- [Introduction to Eclipse Collections](https://www.baeldung.com/eclipse-collections)
+- [DistinctBy in the Java Stream API](https://www.baeldung.com/java-streams-distinct-by)
+- [Introduction to NoException](https://www.baeldung.com/no-exception)
+- [Spring Yarg Integration](https://www.baeldung.com/spring-yarg)
+- [Delete a Directory Recursively in Java](https://www.baeldung.com/java-delete-directory)
+- [Guide to JDeferred](https://www.baeldung.com/jdeferred)
+- [Introduction to MBassador](https://www.baeldung.com/mbassador)
+- [Using Pairs in Java](https://www.baeldung.com/java-pairs)
+- More articles [[<-- prev]](/libraries-3) [[next -->]](/libraries-5)
diff --git a/libraries-4/pom.xml b/libraries-4/pom.xml
new file mode 100644
index 0000000000..f26e7fc055
--- /dev/null
+++ b/libraries-4/pom.xml
@@ -0,0 +1,116 @@
+
+
+
+ parent-modules
+ com.baeldung
+ 1.0.0-SNAPSHOT
+
+ 4.0.0
+
+ libraries-4
+
+
+
+ org.jdeferred
+ jdeferred-core
+ ${jdeferred.version}
+
+
+ org.eclipse.collections
+ eclipse-collections
+ ${eclipse-collections.version}
+
+
+ com.haulmont.yarg
+ yarg
+ ${yarg.version}
+
+
+ net.engio
+ mbassador
+ ${mbassador.version}
+
+
+ com.machinezoo.noexception
+ noexception
+ ${noexception.version}
+
+
+ rome
+ rome
+ ${rome.version}
+
+
+ org.springframework
+ spring-web
+ ${spring.version}
+
+
+ org.datanucleus
+ javax.jdo
+ ${javax.jdo.version}
+
+
+ javax.servlet
+ servlet-api
+ ${javax.servlet.version}
+
+
+ io.vavr
+ vavr
+ ${vavr.version}
+
+
+ org.assertj
+ assertj-core
+ ${assertj.version}
+
+
+ org.pcollections
+ pcollections
+ ${pcollections.version}
+
+
+ org.awaitility
+ awaitility
+ ${awaitility.version}
+ test
+
+
+ one.util
+ streamex
+ ${streamex.version}
+
+
+ javax.el
+ javax.el-api
+ ${javax.el.version}
+
+
+ org.glassfish.web
+ javax.el
+ 2.2.4
+
+
+
+
+ 1.2.6
+ 8.2.0
+ 1.1.0
+ 2.0.12
+ 1.3.1
+ 1.0
+ 4.3.8.RELEASE
+ 2.5
+ 3.2.0-m7
+ 0.9.0
+ 3.6.2
+ 2.1.2
+ 3.0.0
+ 0.6.5
+ 3.0.0
+
+
+
\ No newline at end of file
diff --git a/libraries/src/main/java/com/baeldung/distinct/DistinctWithJavaFunction.java b/libraries-4/src/main/java/com/baeldung/distinct/DistinctWithJavaFunction.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/distinct/DistinctWithJavaFunction.java
rename to libraries-4/src/main/java/com/baeldung/distinct/DistinctWithJavaFunction.java
diff --git a/libraries/src/main/java/com/baeldung/distinct/Person.java b/libraries-4/src/main/java/com/baeldung/distinct/Person.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/distinct/Person.java
rename to libraries-4/src/main/java/com/baeldung/distinct/Person.java
diff --git a/libraries/src/main/java/com/baeldung/eclipsecollections/ConvertContainerToAnother.java b/libraries-4/src/main/java/com/baeldung/eclipsecollections/ConvertContainerToAnother.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/eclipsecollections/ConvertContainerToAnother.java
rename to libraries-4/src/main/java/com/baeldung/eclipsecollections/ConvertContainerToAnother.java
diff --git a/libraries/src/main/java/com/baeldung/eclipsecollections/Student.java b/libraries-4/src/main/java/com/baeldung/eclipsecollections/Student.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/eclipsecollections/Student.java
rename to libraries-4/src/main/java/com/baeldung/eclipsecollections/Student.java
diff --git a/libraries/src/main/java/com/baeldung/jdeffered/FilterDemo.java b/libraries-4/src/main/java/com/baeldung/jdeffered/FilterDemo.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/jdeffered/FilterDemo.java
rename to libraries-4/src/main/java/com/baeldung/jdeffered/FilterDemo.java
diff --git a/libraries/src/main/java/com/baeldung/jdeffered/PipeDemo.java b/libraries-4/src/main/java/com/baeldung/jdeffered/PipeDemo.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/jdeffered/PipeDemo.java
rename to libraries-4/src/main/java/com/baeldung/jdeffered/PipeDemo.java
diff --git a/libraries/src/main/java/com/baeldung/jdeffered/PromiseDemo.java b/libraries-4/src/main/java/com/baeldung/jdeffered/PromiseDemo.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/jdeffered/PromiseDemo.java
rename to libraries-4/src/main/java/com/baeldung/jdeffered/PromiseDemo.java
diff --git a/libraries/src/main/java/com/baeldung/jdeffered/ThreadSafeDemo.java b/libraries-4/src/main/java/com/baeldung/jdeffered/ThreadSafeDemo.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/jdeffered/ThreadSafeDemo.java
rename to libraries-4/src/main/java/com/baeldung/jdeffered/ThreadSafeDemo.java
diff --git a/libraries/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerDemo.java b/libraries-4/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerDemo.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerDemo.java
rename to libraries-4/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerDemo.java
diff --git a/libraries/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerWithExecutorDemo.java b/libraries-4/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerWithExecutorDemo.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerWithExecutorDemo.java
rename to libraries-4/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerWithExecutorDemo.java
diff --git a/libraries/src/main/java/com/baeldung/jdeffered/manager/SimpleDeferredManagerDemo.java b/libraries-4/src/main/java/com/baeldung/jdeffered/manager/SimpleDeferredManagerDemo.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/jdeffered/manager/SimpleDeferredManagerDemo.java
rename to libraries-4/src/main/java/com/baeldung/jdeffered/manager/SimpleDeferredManagerDemo.java
diff --git a/libraries/src/main/java/com/baeldung/mbassador/AckMessage.java b/libraries-4/src/main/java/com/baeldung/mbassador/AckMessage.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/mbassador/AckMessage.java
rename to libraries-4/src/main/java/com/baeldung/mbassador/AckMessage.java
diff --git a/libraries/src/main/java/com/baeldung/mbassador/Message.java b/libraries-4/src/main/java/com/baeldung/mbassador/Message.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/mbassador/Message.java
rename to libraries-4/src/main/java/com/baeldung/mbassador/Message.java
diff --git a/libraries/src/main/java/com/baeldung/mbassador/RejectMessage.java b/libraries-4/src/main/java/com/baeldung/mbassador/RejectMessage.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/mbassador/RejectMessage.java
rename to libraries-4/src/main/java/com/baeldung/mbassador/RejectMessage.java
diff --git a/libraries/src/main/java/com/baeldung/noexception/CustomExceptionHandler.java b/libraries-4/src/main/java/com/baeldung/noexception/CustomExceptionHandler.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/noexception/CustomExceptionHandler.java
rename to libraries-4/src/main/java/com/baeldung/noexception/CustomExceptionHandler.java
diff --git a/libraries/src/main/java/com/baeldung/pairs/CustomPair.java b/libraries-4/src/main/java/com/baeldung/pairs/CustomPair.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/pairs/CustomPair.java
rename to libraries-4/src/main/java/com/baeldung/pairs/CustomPair.java
diff --git a/libraries/src/main/java/com/baeldung/rome/RSSRomeExample.java b/libraries-4/src/main/java/com/baeldung/rome/RSSRomeExample.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/rome/RSSRomeExample.java
rename to libraries-4/src/main/java/com/baeldung/rome/RSSRomeExample.java
diff --git a/libraries/src/main/java/com/baeldung/yarg/DocumentController.java b/libraries-4/src/main/java/com/baeldung/yarg/DocumentController.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/yarg/DocumentController.java
rename to libraries-4/src/main/java/com/baeldung/yarg/DocumentController.java
diff --git a/libraries/src/test/java/com/baeldung/distinct/DistinctWithEclipseCollectionsUnitTest.java b/libraries-4/src/test/java/com/baeldung/distinct/DistinctWithEclipseCollectionsUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/distinct/DistinctWithEclipseCollectionsUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/distinct/DistinctWithEclipseCollectionsUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/distinct/DistinctWithJavaFunctionUnitTest.java b/libraries-4/src/test/java/com/baeldung/distinct/DistinctWithJavaFunctionUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/distinct/DistinctWithJavaFunctionUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/distinct/DistinctWithJavaFunctionUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/distinct/DistinctWithStreamexUnitTest.java b/libraries-4/src/test/java/com/baeldung/distinct/DistinctWithStreamexUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/distinct/DistinctWithStreamexUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/distinct/DistinctWithStreamexUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/distinct/DistinctWithVavrUnitTest.java b/libraries-4/src/test/java/com/baeldung/distinct/DistinctWithVavrUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/distinct/DistinctWithVavrUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/distinct/DistinctWithVavrUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/distinct/PersonDataGenerator.java b/libraries-4/src/test/java/com/baeldung/distinct/PersonDataGenerator.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/distinct/PersonDataGenerator.java
rename to libraries-4/src/test/java/com/baeldung/distinct/PersonDataGenerator.java
diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/AllSatisfyPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/AllSatisfyPatternUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/eclipsecollections/AllSatisfyPatternUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/AllSatisfyPatternUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/AnySatisfyPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/AnySatisfyPatternUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/eclipsecollections/AnySatisfyPatternUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/AnySatisfyPatternUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/CollectPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/CollectPatternUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/eclipsecollections/CollectPatternUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/CollectPatternUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/ConvertContainerToAnotherUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/ConvertContainerToAnotherUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/eclipsecollections/ConvertContainerToAnotherUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/ConvertContainerToAnotherUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/DetectPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/DetectPatternUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/eclipsecollections/DetectPatternUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/DetectPatternUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/FlatCollectUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/FlatCollectUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/eclipsecollections/FlatCollectUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/FlatCollectUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/ForEachPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/ForEachPatternUnitTest.java
similarity index 90%
rename from libraries/src/test/java/com/baeldung/eclipsecollections/ForEachPatternUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/ForEachPatternUnitTest.java
index 38d95047ed..a1bd280658 100644
--- a/libraries/src/test/java/com/baeldung/eclipsecollections/ForEachPatternUnitTest.java
+++ b/libraries-4/src/test/java/com/baeldung/eclipsecollections/ForEachPatternUnitTest.java
@@ -5,6 +5,7 @@ import static org.junit.Assert.assertEquals;
import org.eclipse.collections.api.tuple.Pair;
import org.eclipse.collections.impl.map.mutable.UnifiedMap;
import org.eclipse.collections.impl.tuple.Tuples;
+import org.junit.Assert;
import org.junit.Test;
public class ForEachPatternUnitTest {
@@ -23,7 +24,7 @@ public class ForEachPatternUnitTest {
}
for (int i = 0; i < map.size(); i++) {
- assertEquals("New Value", map.get(i + 1));
+ Assert.assertEquals("New Value", map.get(i + 1));
}
}
}
diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/InjectIntoPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/InjectIntoPatternUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/eclipsecollections/InjectIntoPatternUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/InjectIntoPatternUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/LazyIterationUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/LazyIterationUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/eclipsecollections/LazyIterationUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/LazyIterationUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/PartitionPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/PartitionPatternUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/eclipsecollections/PartitionPatternUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/PartitionPatternUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/RejectPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/RejectPatternUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/eclipsecollections/RejectPatternUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/RejectPatternUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/SelectPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/SelectPatternUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/eclipsecollections/SelectPatternUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/SelectPatternUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/ZipUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/ZipUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/eclipsecollections/ZipUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/ZipUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/ZipWithIndexUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/ZipWithIndexUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/eclipsecollections/ZipWithIndexUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/ZipWithIndexUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/java/io/JavaDirectoryDeleteUnitTest.java b/libraries-4/src/test/java/com/baeldung/io/JavaDirectoryDeleteUnitTest.java
similarity index 96%
rename from libraries/src/test/java/com/baeldung/java/io/JavaDirectoryDeleteUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/io/JavaDirectoryDeleteUnitTest.java
index 53d9d11bbb..c9c8242cd5 100644
--- a/libraries/src/test/java/com/baeldung/java/io/JavaDirectoryDeleteUnitTest.java
+++ b/libraries-4/src/test/java/com/baeldung/io/JavaDirectoryDeleteUnitTest.java
@@ -1,138 +1,138 @@
-package com.baeldung.java.io;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-
-import org.apache.commons.io.FileUtils;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.springframework.util.FileSystemUtils;
-
-public class JavaDirectoryDeleteUnitTest {
- private static Path TEMP_DIRECTORY;
- private static final String DIRECTORY_NAME = "toBeDeleted";
-
- private static final List ALL_LINES = Arrays.asList("This is line 1", "This is line 2", "This is line 3", "This is line 4", "This is line 5", "This is line 6");
-
- @BeforeClass
- public static void initializeTempDirectory() throws IOException {
- TEMP_DIRECTORY = Files.createTempDirectory("tmpForJUnit");
- }
-
- @AfterClass
- public static void cleanTempDirectory() throws IOException {
- FileUtils.deleteDirectory(TEMP_DIRECTORY.toFile());
- }
-
- @Before
- public void setupDirectory() throws IOException {
- Path tempPathForEachTest = Files.createDirectory(TEMP_DIRECTORY.resolve(DIRECTORY_NAME));
-
- // Create a directory structure
- Files.write(tempPathForEachTest.resolve("file1.txt"), ALL_LINES.subList(0, 2));
- Files.write(tempPathForEachTest.resolve("file2.txt"), ALL_LINES.subList(2, 4));
-
- Files.createDirectories(tempPathForEachTest.resolve("Empty"));
-
- Path aSubDir = Files.createDirectories(tempPathForEachTest.resolve("notEmpty"));
- Files.write(aSubDir.resolve("file3.txt"), ALL_LINES.subList(3, 5));
- Files.write(aSubDir.resolve("file4.txt"), ALL_LINES.subList(0, 3));
-
- aSubDir = Files.createDirectories(aSubDir.resolve("anotherSubDirectory"));
- Files.write(aSubDir.resolve("file5.txt"), ALL_LINES.subList(4, 5));
- Files.write(aSubDir.resolve("file6.txt"), ALL_LINES.subList(0, 2));
- }
-
- @After
- public void checkAndCleanupIfRequired() throws IOException {
- Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME);
- if (Files.exists(pathToBeDeleted)) {
- FileUtils.deleteDirectory(pathToBeDeleted.toFile());
- }
- }
-
- private boolean deleteDirectory(File directoryToBeDeleted) {
- File[] allContents = directoryToBeDeleted.listFiles();
-
- if (allContents != null) {
- for (File file : allContents) {
- deleteDirectory(file);
- }
- }
-
- return directoryToBeDeleted.delete();
- }
-
- @Test
- public void givenDirectory_whenDeletedWithRecursion_thenIsGone() throws IOException {
- Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME);
-
- boolean result = deleteDirectory(pathToBeDeleted.toFile());
-
- assertTrue("Could not delete directory", result);
- assertFalse("Directory still exists", Files.exists(pathToBeDeleted));
- }
-
- @Test
- public void givenDirectory_whenDeletedWithCommonsIOFileUtils_thenIsGone() throws IOException {
- Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME);
-
- FileUtils.deleteDirectory(pathToBeDeleted.toFile());
-
- assertFalse("Directory still exists", Files.exists(pathToBeDeleted));
- }
-
- @Test
- public void givenDirectory_whenDeletedWithSpringFileSystemUtils_thenIsGone() throws IOException {
- Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME);
-
- boolean result = FileSystemUtils.deleteRecursively(pathToBeDeleted.toFile());
-
- assertTrue("Could not delete directory", result);
- assertFalse("Directory still exists", Files.exists(pathToBeDeleted));
- }
-
- @Test
- public void givenDirectory_whenDeletedWithFilesWalk_thenIsGone() throws IOException {
- Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME);
-
- Files.walk(pathToBeDeleted).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
-
- assertFalse("Directory still exists", Files.exists(pathToBeDeleted));
- }
-
- @Test
- public void givenDirectory_whenDeletedWithNIO2WalkFileTree_thenIsGone() throws IOException {
- Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME);
-
- Files.walkFileTree(pathToBeDeleted, new SimpleFileVisitor() {
- @Override
- public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
- Files.delete(dir);
- return FileVisitResult.CONTINUE;
- }
-
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
- Files.delete(file);
- return FileVisitResult.CONTINUE;
- }
- });
-
- assertFalse("Directory still exists", Files.exists(pathToBeDeleted));
- }
-}
+package com.baeldung.io;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.util.FileSystemUtils;
+
+public class JavaDirectoryDeleteUnitTest {
+ private static Path TEMP_DIRECTORY;
+ private static final String DIRECTORY_NAME = "toBeDeleted";
+
+ private static final List ALL_LINES = Arrays.asList("This is line 1", "This is line 2", "This is line 3", "This is line 4", "This is line 5", "This is line 6");
+
+ @BeforeClass
+ public static void initializeTempDirectory() throws IOException {
+ TEMP_DIRECTORY = Files.createTempDirectory("tmpForJUnit");
+ }
+
+ @AfterClass
+ public static void cleanTempDirectory() throws IOException {
+ FileUtils.deleteDirectory(TEMP_DIRECTORY.toFile());
+ }
+
+ @Before
+ public void setupDirectory() throws IOException {
+ Path tempPathForEachTest = Files.createDirectory(TEMP_DIRECTORY.resolve(DIRECTORY_NAME));
+
+ // Create a directory structure
+ Files.write(tempPathForEachTest.resolve("file1.txt"), ALL_LINES.subList(0, 2));
+ Files.write(tempPathForEachTest.resolve("file2.txt"), ALL_LINES.subList(2, 4));
+
+ Files.createDirectories(tempPathForEachTest.resolve("Empty"));
+
+ Path aSubDir = Files.createDirectories(tempPathForEachTest.resolve("notEmpty"));
+ Files.write(aSubDir.resolve("file3.txt"), ALL_LINES.subList(3, 5));
+ Files.write(aSubDir.resolve("file4.txt"), ALL_LINES.subList(0, 3));
+
+ aSubDir = Files.createDirectories(aSubDir.resolve("anotherSubDirectory"));
+ Files.write(aSubDir.resolve("file5.txt"), ALL_LINES.subList(4, 5));
+ Files.write(aSubDir.resolve("file6.txt"), ALL_LINES.subList(0, 2));
+ }
+
+ @After
+ public void checkAndCleanupIfRequired() throws IOException {
+ Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME);
+ if (Files.exists(pathToBeDeleted)) {
+ FileUtils.deleteDirectory(pathToBeDeleted.toFile());
+ }
+ }
+
+ private boolean deleteDirectory(File directoryToBeDeleted) {
+ File[] allContents = directoryToBeDeleted.listFiles();
+
+ if (allContents != null) {
+ for (File file : allContents) {
+ deleteDirectory(file);
+ }
+ }
+
+ return directoryToBeDeleted.delete();
+ }
+
+ @Test
+ public void givenDirectory_whenDeletedWithRecursion_thenIsGone() throws IOException {
+ Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME);
+
+ boolean result = deleteDirectory(pathToBeDeleted.toFile());
+
+ assertTrue("Could not delete directory", result);
+ assertFalse("Directory still exists", Files.exists(pathToBeDeleted));
+ }
+
+ @Test
+ public void givenDirectory_whenDeletedWithCommonsIOFileUtils_thenIsGone() throws IOException {
+ Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME);
+
+ FileUtils.deleteDirectory(pathToBeDeleted.toFile());
+
+ assertFalse("Directory still exists", Files.exists(pathToBeDeleted));
+ }
+
+ @Test
+ public void givenDirectory_whenDeletedWithSpringFileSystemUtils_thenIsGone() throws IOException {
+ Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME);
+
+ boolean result = FileSystemUtils.deleteRecursively(pathToBeDeleted.toFile());
+
+ assertTrue("Could not delete directory", result);
+ assertFalse("Directory still exists", Files.exists(pathToBeDeleted));
+ }
+
+ @Test
+ public void givenDirectory_whenDeletedWithFilesWalk_thenIsGone() throws IOException {
+ Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME);
+
+ Files.walk(pathToBeDeleted).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
+
+ assertFalse("Directory still exists", Files.exists(pathToBeDeleted));
+ }
+
+ @Test
+ public void givenDirectory_whenDeletedWithNIO2WalkFileTree_thenIsGone() throws IOException {
+ Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME);
+
+ Files.walkFileTree(pathToBeDeleted, new SimpleFileVisitor() {
+ @Override
+ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
+ Files.delete(dir);
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
+ Files.delete(file);
+ return FileVisitResult.CONTINUE;
+ }
+ });
+
+ assertFalse("Directory still exists", Files.exists(pathToBeDeleted));
+ }
+}
diff --git a/libraries/src/test/java/com/baeldung/jdeffered/JDeferredUnitTest.java b/libraries-4/src/test/java/com/baeldung/jdeffered/JDeferredUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/jdeffered/JDeferredUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/jdeffered/JDeferredUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/mbassador/MBassadorAsyncDispatchUnitTest.java b/libraries-4/src/test/java/com/baeldung/mbassador/MBassadorAsyncDispatchUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/mbassador/MBassadorAsyncDispatchUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/mbassador/MBassadorAsyncDispatchUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/mbassador/MBassadorAsyncInvocationUnitTest.java b/libraries-4/src/test/java/com/baeldung/mbassador/MBassadorAsyncInvocationUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/mbassador/MBassadorAsyncInvocationUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/mbassador/MBassadorAsyncInvocationUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/mbassador/MBassadorBasicUnitTest.java b/libraries-4/src/test/java/com/baeldung/mbassador/MBassadorBasicUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/mbassador/MBassadorBasicUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/mbassador/MBassadorBasicUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/mbassador/MBassadorConfigurationUnitTest.java b/libraries-4/src/test/java/com/baeldung/mbassador/MBassadorConfigurationUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/mbassador/MBassadorConfigurationUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/mbassador/MBassadorConfigurationUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/mbassador/MBassadorFilterUnitTest.java b/libraries-4/src/test/java/com/baeldung/mbassador/MBassadorFilterUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/mbassador/MBassadorFilterUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/mbassador/MBassadorFilterUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/mbassador/MBassadorHierarchyUnitTest.java b/libraries-4/src/test/java/com/baeldung/mbassador/MBassadorHierarchyUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/mbassador/MBassadorHierarchyUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/mbassador/MBassadorHierarchyUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/noexception/NoExceptionUnitTest.java b/libraries-4/src/test/java/com/baeldung/noexception/NoExceptionUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/noexception/NoExceptionUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/noexception/NoExceptionUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/pairs/ApacheCommonsPairUnitTest.java b/libraries-4/src/test/java/com/baeldung/pairs/ApacheCommonsPairUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/pairs/ApacheCommonsPairUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/pairs/ApacheCommonsPairUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/pairs/CoreJavaPairUnitTest.java b/libraries-4/src/test/java/com/baeldung/pairs/CoreJavaPairUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/pairs/CoreJavaPairUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/pairs/CoreJavaPairUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/pairs/CoreJavaSimpleEntryUnitTest.java b/libraries-4/src/test/java/com/baeldung/pairs/CoreJavaSimpleEntryUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/pairs/CoreJavaSimpleEntryUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/pairs/CoreJavaSimpleEntryUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/pairs/VavrPairsUnitTest.java b/libraries-4/src/test/java/com/baeldung/pairs/VavrPairsUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/pairs/VavrPairsUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/pairs/VavrPairsUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java b/libraries-4/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java
rename to libraries-4/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java
diff --git a/libraries-5/README.md b/libraries-5/README.md
new file mode 100644
index 0000000000..f1e749b293
--- /dev/null
+++ b/libraries-5/README.md
@@ -0,0 +1,21 @@
+## Libraries-5
+
+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
+- [Introduction to Caffeine](https://www.baeldung.com/java-caching-caffeine)
+- [Introduction to StreamEx](https://www.baeldung.com/streamex)
+- [A Docker Guide for Java](https://www.baeldung.com/docker-java-api)
+- [Introduction to Akka Actors in Java](https://www.baeldung.com/akka-actors-java)
+- [A Guide to Byte Buddy](https://www.baeldung.com/byte-buddy)
+- [Introduction to jOOL](https://www.baeldung.com/jool)
+- [Consumer Driven Contracts with Pact](https://www.baeldung.com/pact-junit-consumer-driven-contracts)
+- [Introduction to Atlassian Fugue](https://www.baeldung.com/java-fugue)
+- [Publish and Receive Messages with Nats Java Client](https://www.baeldung.com/nats-java-client)
+- [Java Concurrency Utility with JCTools](https://www.baeldung.com/java-concurrency-jc-tools)
+- More articles [[<-- prev]](/libraries-4) [[next -->]](/libraries-6)
diff --git a/libraries-5/pom.xml b/libraries-5/pom.xml
new file mode 100644
index 0000000000..63296d4a89
--- /dev/null
+++ b/libraries-5/pom.xml
@@ -0,0 +1,146 @@
+
+
+
+ parent-modules
+ com.baeldung
+ 1.0.0-SNAPSHOT
+
+
+ libraries-5
+ 4.0.0
+
+
+
+ org.springframework
+ spring-web
+ ${spring.version}
+
+
+ org.assertj
+ assertj-core
+ ${assertj.version}
+
+
+ org.jooq
+ jool
+ ${jool.version}
+
+
+ au.com.dius
+ pact-jvm-consumer-junit_2.11
+ ${pact.version}
+ test
+
+
+ org.codehaus.groovy
+ groovy-all
+
+
+
+
+
+
+ com.typesafe.akka
+ akka-actor_${scala.version}
+ ${typesafe-akka.version}
+
+
+ com.typesafe.akka
+ akka-testkit_${scala.version}
+ ${typesafe-akka.version}
+ test
+
+
+
+ one.util
+ streamex
+ ${streamex.version}
+
+
+ net.bytebuddy
+ byte-buddy
+ ${bytebuddy.version}
+
+
+ net.bytebuddy
+ byte-buddy-agent
+ ${bytebuddy.version}
+
+
+
+
+ com.github.docker-java
+ docker-java
+ ${docker.version}
+
+
+ org.slf4j
+ slf4j-log4j12
+
+
+ org.slf4j
+ jcl-over-slf4j
+
+
+ ch.qos.logback
+ logback-classic
+
+
+
+
+
+
+ com.github.ben-manes.caffeine
+ caffeine
+ ${caffeine.version}
+
+
+ com.google.code.findbugs
+ jsr305
+ ${findbugs.version}
+ test
+
+
+
+ io.atlassian.fugue
+ fugue
+ ${fugue.version}
+
+
+ io.nats
+ jnats
+ ${jnats.version}
+
+
+ org.jctools
+ jctools-core
+ ${jctools.version}
+
+
+ org.openjdk.jmh
+ jmh-core
+ ${jmh.version}
+
+
+
+
+ 3.5.0
+ 0.9.12
+ 4.3.8.RELEASE
+ 3.6.2
+ 2.11
+ 2.5.11
+ 0.6.5
+ 1.7.1
+ 3.0.14
+ 2.5.5
+ 3.0.2
+ 4.5.1
+ 1.0
+ 2.1.2
+ 1.19
+
+
+
\ No newline at end of file
diff --git a/libraries/src/main/java/com/baeldung/akka/FirstActor.java b/libraries-5/src/main/java/com/baeldung/akka/FirstActor.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/akka/FirstActor.java
rename to libraries-5/src/main/java/com/baeldung/akka/FirstActor.java
diff --git a/libraries/src/main/java/com/baeldung/akka/MyActor.java b/libraries-5/src/main/java/com/baeldung/akka/MyActor.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/akka/MyActor.java
rename to libraries-5/src/main/java/com/baeldung/akka/MyActor.java
diff --git a/libraries/src/main/java/com/baeldung/akka/PrinterActor.java b/libraries-5/src/main/java/com/baeldung/akka/PrinterActor.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/akka/PrinterActor.java
rename to libraries-5/src/main/java/com/baeldung/akka/PrinterActor.java
diff --git a/libraries/src/main/java/com/baeldung/akka/ReadingActor.java b/libraries-5/src/main/java/com/baeldung/akka/ReadingActor.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/akka/ReadingActor.java
rename to libraries-5/src/main/java/com/baeldung/akka/ReadingActor.java
diff --git a/libraries/src/main/java/com/baeldung/akka/WordCounterActor.java b/libraries-5/src/main/java/com/baeldung/akka/WordCounterActor.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/akka/WordCounterActor.java
rename to libraries-5/src/main/java/com/baeldung/akka/WordCounterActor.java
diff --git a/libraries/src/main/java/com/baeldung/bytebuddy/Bar.java b/libraries-5/src/main/java/com/baeldung/bytebuddy/Bar.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/bytebuddy/Bar.java
rename to libraries-5/src/main/java/com/baeldung/bytebuddy/Bar.java
diff --git a/libraries/src/main/java/com/baeldung/bytebuddy/Foo.java b/libraries-5/src/main/java/com/baeldung/bytebuddy/Foo.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/bytebuddy/Foo.java
rename to libraries-5/src/main/java/com/baeldung/bytebuddy/Foo.java
diff --git a/libraries/src/main/java/com/baeldung/caffeine/DataObject.java b/libraries-5/src/main/java/com/baeldung/caffeine/DataObject.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/caffeine/DataObject.java
rename to libraries-5/src/main/java/com/baeldung/caffeine/DataObject.java
diff --git a/libraries/src/main/java/com/baeldung/jctools/MpmcBenchmark.java b/libraries-5/src/main/java/com/baeldung/jctools/MpmcBenchmark.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/jctools/MpmcBenchmark.java
rename to libraries-5/src/main/java/com/baeldung/jctools/MpmcBenchmark.java
diff --git a/libraries/src/main/java/com/baeldung/jctools/README.md b/libraries-5/src/main/java/com/baeldung/jctools/README.md
similarity index 100%
rename from libraries/src/main/java/com/baeldung/jctools/README.md
rename to libraries-5/src/main/java/com/baeldung/jctools/README.md
diff --git a/libraries/src/main/java/com/baeldung/jnats/NatsClient.java b/libraries-5/src/main/java/com/baeldung/jnats/NatsClient.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/jnats/NatsClient.java
rename to libraries-5/src/main/java/com/baeldung/jnats/NatsClient.java
diff --git a/libraries/src/main/java/com/baeldung/streamex/Role.java b/libraries-5/src/main/java/com/baeldung/streamex/Role.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/streamex/Role.java
rename to libraries-5/src/main/java/com/baeldung/streamex/Role.java
diff --git a/libraries/src/main/java/com/baeldung/streamex/StreamEX.java b/libraries-5/src/main/java/com/baeldung/streamex/StreamEX.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/streamex/StreamEX.java
rename to libraries-5/src/main/java/com/baeldung/streamex/StreamEX.java
diff --git a/libraries/src/main/java/com/baeldung/streamex/User.java b/libraries-5/src/main/java/com/baeldung/streamex/User.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/streamex/User.java
rename to libraries-5/src/main/java/com/baeldung/streamex/User.java
diff --git a/libraries/src/test/java/com/baeldung/akka/AkkaActorsUnitTest.java b/libraries-5/src/test/java/com/baeldung/akka/AkkaActorsUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/akka/AkkaActorsUnitTest.java
rename to libraries-5/src/test/java/com/baeldung/akka/AkkaActorsUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/bytebuddy/ByteBuddyUnitTest.java b/libraries-5/src/test/java/com/baeldung/bytebuddy/ByteBuddyUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/bytebuddy/ByteBuddyUnitTest.java
rename to libraries-5/src/test/java/com/baeldung/bytebuddy/ByteBuddyUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/caffeine/CaffeineUnitTest.java b/libraries-5/src/test/java/com/baeldung/caffeine/CaffeineUnitTest.java
similarity index 88%
rename from libraries/src/test/java/com/baeldung/caffeine/CaffeineUnitTest.java
rename to libraries-5/src/test/java/com/baeldung/caffeine/CaffeineUnitTest.java
index d523d0ff8b..65c441c50d 100644
--- a/libraries/src/test/java/com/baeldung/caffeine/CaffeineUnitTest.java
+++ b/libraries-5/src/test/java/com/baeldung/caffeine/CaffeineUnitTest.java
@@ -8,6 +8,7 @@ import java.util.concurrent.TimeUnit;
import javax.annotation.Nonnull;
+import org.junit.Assert;
import org.junit.Test;
import com.github.benmanes.caffeine.cache.*;
@@ -65,43 +66,43 @@ public class CaffeineUnitTest {
assertEquals("Data for " + key, dataObject.getData());
});
- cache.getAll(Arrays.asList("A", "B", "C")).thenAccept(dataObjectMap -> assertEquals(3, dataObjectMap.size()));
+ cache.getAll(Arrays.asList("A", "B", "C")).thenAccept(dataObjectMap -> Assert.assertEquals(3, dataObjectMap.size()));
}
@Test
public void givenLoadingCacheWithSmallSize_whenPut_thenSizeIsConstant() {
LoadingCache cache = Caffeine.newBuilder().maximumSize(1).refreshAfterWrite(10, TimeUnit.MINUTES).build(k -> DataObject.get("Data for " + k));
- assertEquals(0, cache.estimatedSize());
+ Assert.assertEquals(0, cache.estimatedSize());
cache.get("A");
- assertEquals(1, cache.estimatedSize());
+ Assert.assertEquals(1, cache.estimatedSize());
cache.get("B");
cache.cleanUp();
- assertEquals(1, cache.estimatedSize());
+ Assert.assertEquals(1, cache.estimatedSize());
}
@Test
public void givenLoadingCacheWithWeigher_whenPut_thenSizeIsConstant() {
LoadingCache cache = Caffeine.newBuilder().maximumWeight(10).weigher((k, v) -> 5).build(k -> DataObject.get("Data for " + k));
- assertEquals(0, cache.estimatedSize());
+ Assert.assertEquals(0, cache.estimatedSize());
cache.get("A");
- assertEquals(1, cache.estimatedSize());
+ Assert.assertEquals(1, cache.estimatedSize());
cache.get("B");
- assertEquals(2, cache.estimatedSize());
+ Assert.assertEquals(2, cache.estimatedSize());
cache.get("C");
cache.cleanUp();
- assertEquals(2, cache.estimatedSize());
+ Assert.assertEquals(2, cache.estimatedSize());
}
@Test
@@ -138,7 +139,7 @@ public class CaffeineUnitTest {
cache.get("A");
cache.get("A");
- assertEquals(1, cache.stats().hitCount());
- assertEquals(1, cache.stats().missCount());
+ Assert.assertEquals(1, cache.stats().hitCount());
+ Assert.assertEquals(1, cache.stats().missCount());
}
}
\ No newline at end of file
diff --git a/libraries/src/test/java/com/baeldung/dockerapi/ContainerLiveTest.java b/libraries-5/src/test/java/com/baeldung/dockerapi/ContainerLiveTest.java
similarity index 94%
rename from libraries/src/test/java/com/baeldung/dockerapi/ContainerLiveTest.java
rename to libraries-5/src/test/java/com/baeldung/dockerapi/ContainerLiveTest.java
index e6f0fd1c31..007c70355a 100644
--- a/libraries/src/test/java/com/baeldung/dockerapi/ContainerLiveTest.java
+++ b/libraries-5/src/test/java/com/baeldung/dockerapi/ContainerLiveTest.java
@@ -6,6 +6,8 @@ import com.github.dockerjava.api.command.InspectContainerResponse;
import com.github.dockerjava.api.model.Container;
import com.github.dockerjava.api.model.PortBinding;
import com.github.dockerjava.core.DockerClientBuilder;
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.core.Is;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -51,7 +53,7 @@ public class ContainerLiveTest {
CreateContainerResponse container = dockerClient.createContainerCmd("mongo:3.6").withCmd("--bind_ip_all").withName("mongo").withHostName("baeldung").withEnv("MONGO_LATEST_VERSION=3.6").withPortBindings(PortBinding.parse("9999:27017")).exec();
// then
- assertThat(container.getId(), is(not(null)));
+ MatcherAssert.assertThat(container.getId(), is(not(null)));
}
@Test
@@ -104,7 +106,7 @@ public class ContainerLiveTest {
// then
InspectContainerResponse containerResponse = dockerClient.inspectContainerCmd(container.getId()).exec();
- assertThat(containerResponse.getId(), is(container.getId()));
+ MatcherAssert.assertThat(containerResponse.getId(), Is.is(container.getId()));
}
@Test
diff --git a/libraries/src/test/java/com/baeldung/dockerapi/DockerClientLiveTest.java b/libraries-5/src/test/java/com/baeldung/dockerapi/DockerClientLiveTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/dockerapi/DockerClientLiveTest.java
rename to libraries-5/src/test/java/com/baeldung/dockerapi/DockerClientLiveTest.java
diff --git a/libraries/src/test/java/com/baeldung/dockerapi/ImageLiveTest.java b/libraries-5/src/test/java/com/baeldung/dockerapi/ImageLiveTest.java
similarity index 96%
rename from libraries/src/test/java/com/baeldung/dockerapi/ImageLiveTest.java
rename to libraries-5/src/test/java/com/baeldung/dockerapi/ImageLiveTest.java
index 7e8cd6a354..96e7922f2a 100644
--- a/libraries/src/test/java/com/baeldung/dockerapi/ImageLiveTest.java
+++ b/libraries-5/src/test/java/com/baeldung/dockerapi/ImageLiveTest.java
@@ -8,6 +8,8 @@ import com.github.dockerjava.core.DockerClientBuilder;
import com.github.dockerjava.core.command.BuildImageResultCallback;
import com.github.dockerjava.core.command.PullImageResultCallback;
import com.github.dockerjava.core.command.PushImageResultCallback;
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.core.Is;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -81,7 +83,7 @@ public class ImageLiveTest {
InspectImageResponse imageResponse = dockerClient.inspectImageCmd(image.getId()).exec();
// then
- assertThat(imageResponse.getId(), is(image.getId()));
+ MatcherAssert.assertThat(imageResponse.getId(), Is.is(image.getId()));
}
@Test
diff --git a/libraries/src/test/java/com/baeldung/dockerapi/NetworkLiveTest.java b/libraries-5/src/test/java/com/baeldung/dockerapi/NetworkLiveTest.java
similarity index 95%
rename from libraries/src/test/java/com/baeldung/dockerapi/NetworkLiveTest.java
rename to libraries-5/src/test/java/com/baeldung/dockerapi/NetworkLiveTest.java
index d3abbe2e7e..31ad32c7b5 100644
--- a/libraries/src/test/java/com/baeldung/dockerapi/NetworkLiveTest.java
+++ b/libraries-5/src/test/java/com/baeldung/dockerapi/NetworkLiveTest.java
@@ -5,6 +5,7 @@ import com.github.dockerjava.api.command.CreateNetworkResponse;
import com.github.dockerjava.api.model.Network;
import com.github.dockerjava.api.model.Network.Ipam;
import com.github.dockerjava.core.DockerClientBuilder;
+import org.hamcrest.MatcherAssert;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
@@ -64,7 +65,7 @@ public class NetworkLiveTest {
Network network = dockerClient.inspectNetworkCmd().withNetworkId(networkName).exec();
// then
- assertThat(network.getName(), is(networkName));
+ MatcherAssert.assertThat(network.getName(), is(networkName));
}
@Test
diff --git a/libraries/src/test/java/com/baeldung/dockerapi/VolumeLiveTest.java b/libraries-5/src/test/java/com/baeldung/dockerapi/VolumeLiveTest.java
similarity index 92%
rename from libraries/src/test/java/com/baeldung/dockerapi/VolumeLiveTest.java
rename to libraries-5/src/test/java/com/baeldung/dockerapi/VolumeLiveTest.java
index 9e60a76b33..f2a078b2c6 100644
--- a/libraries/src/test/java/com/baeldung/dockerapi/VolumeLiveTest.java
+++ b/libraries-5/src/test/java/com/baeldung/dockerapi/VolumeLiveTest.java
@@ -5,6 +5,7 @@ import com.github.dockerjava.api.command.CreateVolumeResponse;
import com.github.dockerjava.api.command.InspectVolumeResponse;
import com.github.dockerjava.api.command.ListVolumesResponse;
import com.github.dockerjava.core.DockerClientBuilder;
+import org.hamcrest.MatcherAssert;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -57,7 +58,7 @@ public class VolumeLiveTest {
CreateVolumeResponse unnamedVolume = dockerClient.createVolumeCmd().exec();
// then
- assertThat(unnamedVolume.getName(), is(not(null)));
+ MatcherAssert.assertThat(unnamedVolume.getName(), is(not(null)));
}
@Test
@@ -67,7 +68,7 @@ public class VolumeLiveTest {
CreateVolumeResponse namedVolume = dockerClient.createVolumeCmd().withName("myNamedVolume").exec();
// then
- assertThat(namedVolume.getName(), is(not(null)));
+ MatcherAssert.assertThat(namedVolume.getName(), is(not(null)));
}
@Test
diff --git a/libraries/src/test/java/com/baeldung/atlassian/fugue/FugueUnitTest.java b/libraries-5/src/test/java/com/baeldung/fugue/FugueUnitTest.java
similarity index 99%
rename from libraries/src/test/java/com/baeldung/atlassian/fugue/FugueUnitTest.java
rename to libraries-5/src/test/java/com/baeldung/fugue/FugueUnitTest.java
index 773e39b76a..c3a89a1355 100644
--- a/libraries/src/test/java/com/baeldung/atlassian/fugue/FugueUnitTest.java
+++ b/libraries-5/src/test/java/com/baeldung/fugue/FugueUnitTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.atlassian.fugue;
+package com.baeldung.fugue;
import io.atlassian.fugue.*;
import org.junit.Assert;
diff --git a/libraries/src/test/java/com/baeldung/jctools/JCToolsUnitTest.java b/libraries-5/src/test/java/com/baeldung/jctools/JCToolsUnitTest.java
similarity index 88%
rename from libraries/src/test/java/com/baeldung/jctools/JCToolsUnitTest.java
rename to libraries-5/src/test/java/com/baeldung/jctools/JCToolsUnitTest.java
index 4a9d0fadb2..a5dacdbdac 100644
--- a/libraries/src/test/java/com/baeldung/jctools/JCToolsUnitTest.java
+++ b/libraries-5/src/test/java/com/baeldung/jctools/JCToolsUnitTest.java
@@ -1,5 +1,6 @@
package com.baeldung.jctools;
+import org.assertj.core.api.Assertions;
import org.jctools.queues.SpscArrayQueue;
import org.jctools.queues.SpscChunkedArrayQueue;
import org.junit.Test;
@@ -44,16 +45,16 @@ public class JCToolsUnitTest {
@Test
public void whenQueueIsFull_thenNoMoreElementsCanBeAdded() throws InterruptedException {
SpscChunkedArrayQueue queue = new SpscChunkedArrayQueue<>(8, 16);
- assertThat(queue.capacity()).isEqualTo(16);
+ Assertions.assertThat(queue.capacity()).isEqualTo(16);
CountDownLatch startConsuming = new CountDownLatch(1);
CountDownLatch awakeProducer = new CountDownLatch(1);
AtomicReference error = new AtomicReference<>();
Thread producer = new Thread(() -> {
IntStream.range(0, queue.capacity()).forEach(i -> {
- assertThat(queue.offer(i)).isTrue();
+ Assertions.assertThat(queue.offer(i)).isTrue();
});
- assertThat(queue.offer(queue.capacity())).isFalse();
+ Assertions.assertThat(queue.offer(queue.capacity())).isFalse();
startConsuming.countDown();
try {
awakeProducer.await();
@@ -61,7 +62,7 @@ public class JCToolsUnitTest {
throw new RuntimeException(e);
}
- assertThat(queue.offer(queue.capacity())).isTrue();
+ Assertions.assertThat(queue.offer(queue.capacity())).isTrue();
});
producer.setUncaughtExceptionHandler((t, e) -> {
error.set(e);
diff --git a/libraries/src/test/java/com/baeldung/jnats/NatsClientLiveTest.java b/libraries-5/src/test/java/com/baeldung/jnats/NatsClientLiveTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/jnats/NatsClientLiveTest.java
rename to libraries-5/src/test/java/com/baeldung/jnats/NatsClientLiveTest.java
diff --git a/libraries/src/test/java/com/baeldung/jool/JOOLUnitTest.java b/libraries-5/src/test/java/com/baeldung/jool/JOOLUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/jool/JOOLUnitTest.java
rename to libraries-5/src/test/java/com/baeldung/jool/JOOLUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/pact/PactConsumerDrivenContractUnitTest.java b/libraries-5/src/test/java/com/baeldung/pact/PactConsumerDrivenContractUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/pact/PactConsumerDrivenContractUnitTest.java
rename to libraries-5/src/test/java/com/baeldung/pact/PactConsumerDrivenContractUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/stream/StreamExMergeStreamsUnitTest.java b/libraries-5/src/test/java/com/baeldung/streamex/StreamExMergeStreamsUnitTest.java
similarity index 98%
rename from libraries/src/test/java/com/baeldung/stream/StreamExMergeStreamsUnitTest.java
rename to libraries-5/src/test/java/com/baeldung/streamex/StreamExMergeStreamsUnitTest.java
index 220348bf36..b267eaea9b 100644
--- a/libraries/src/test/java/com/baeldung/stream/StreamExMergeStreamsUnitTest.java
+++ b/libraries-5/src/test/java/com/baeldung/streamex/StreamExMergeStreamsUnitTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.stream;
+package com.baeldung.streamex;
import one.util.streamex.StreamEx;
import org.junit.Test;
diff --git a/libraries/src/test/resources/dockerapi/Dockerfile b/libraries-5/src/test/resources/dockerapi/Dockerfile
similarity index 100%
rename from libraries/src/test/resources/dockerapi/Dockerfile
rename to libraries-5/src/test/resources/dockerapi/Dockerfile
diff --git a/libraries-6/README.md b/libraries-6/README.md
new file mode 100644
index 0000000000..79bb83113e
--- /dev/null
+++ b/libraries-6/README.md
@@ -0,0 +1,17 @@
+## Libraries-6
+
+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
+- [Introduction to JavaPoet](https://www.baeldung.com/java-poet)
+- [Guide to Resilience4j](https://www.baeldung.com/resilience4j)
+- [Implementing a FTP-Client in Java](https://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)
+- [Exactly Once Processing in Kafka](https://www.baeldung.com/kafka-exactly-once)
+- More articles [[<-- prev]](/libraries-5)
diff --git a/libraries-6/pom.xml b/libraries-6/pom.xml
new file mode 100644
index 0000000000..030e5aa77b
--- /dev/null
+++ b/libraries-6/pom.xml
@@ -0,0 +1,111 @@
+
+
+
+ parent-modules
+ com.baeldung
+ 1.0.0-SNAPSHOT
+
+ 4.0.0
+
+ libraries-6
+
+
+
+ org.functionaljava
+ functionaljava-java8
+ ${functionaljava.version}
+
+
+ com.codepoetics
+ protonpack
+ ${protonpack.version}
+
+
+ org.apache.kafka
+ kafka-streams
+ ${kafka.version}
+
+
+ org.apache.kafka
+ kafka-clients
+ ${kafka.version}
+ test
+ test
+
+
+ io.github.resilience4j
+ resilience4j-circuitbreaker
+ ${resilience4j.version}
+
+
+ io.github.resilience4j
+ resilience4j-bulkhead
+ ${resilience4j.version}
+
+
+ io.github.resilience4j
+ resilience4j-retry
+ ${resilience4j.version}
+
+
+ io.github.resilience4j
+ resilience4j-timelimiter
+ ${resilience4j.version}
+
+
+ com.squareup
+ javapoet
+ ${javapoet.version}
+
+
+ org.mockftpserver
+ MockFtpServer
+ ${mockftpserver.version}
+ test
+
+
+
+ org.reflections
+ reflections
+ ${reflections.version}
+
+
+ org.apache.commons
+ commons-lang3
+ ${commons-lang3.version}
+
+
+ commons-net
+ commons-net
+ ${commons-net.version}
+
+
+ org.assertj
+ assertj-core
+ ${assertj.version}
+
+
+ commons-io
+ commons-io
+ ${commonsio.version}
+ test
+
+
+
+
+ 2.0.0
+ 1.10.0
+ 0.9.11
+ 2.7.1
+ 4.8.1
+ 0.12.1
+ 1.15
+ 3.6
+ 3.6.2
+ 2.6
+
+
+
+
\ No newline at end of file
diff --git a/libraries/src/main/java/com/baeldung/fj/FunctionalJavaIOMain.java b/libraries-6/src/main/java/com/baeldung/fj/FunctionalJavaIOMain.java
similarity index 96%
rename from libraries/src/main/java/com/baeldung/fj/FunctionalJavaIOMain.java
rename to libraries-6/src/main/java/com/baeldung/fj/FunctionalJavaIOMain.java
index eaa201d1ba..e97f128b30 100644
--- a/libraries/src/main/java/com/baeldung/fj/FunctionalJavaIOMain.java
+++ b/libraries-6/src/main/java/com/baeldung/fj/FunctionalJavaIOMain.java
@@ -1,43 +1,43 @@
-package com.baeldung.fj;
-
-import fj.F;
-import fj.F1Functions;
-import fj.Unit;
-import fj.data.IO;
-import fj.data.IOFunctions;
-
-public class FunctionalJavaIOMain {
-
- public static IO printLetters(final String s) {
- return () -> {
- for (int i = 0; i < s.length(); i++) {
- System.out.println(s.charAt(i));
- }
- return Unit.unit();
- };
- }
-
- public static void main(String[] args) {
-
- F> printLetters = i -> printLetters(i);
-
- IO lowerCase = IOFunctions.stdoutPrintln("What's your first Name ?");
-
- IO input = IOFunctions.stdoutPrint("First Name: ");
-
- IO userInput = IOFunctions.append(lowerCase, input);
-
- IO readInput = IOFunctions.stdinReadLine();
-
- F toUpperCase = i -> i.toUpperCase();
-
- F> transformInput = F1Functions., String> o(printLetters).f(toUpperCase);
-
- IO readAndPrintResult = IOFunctions.bind(readInput, transformInput);
-
- IO program = IOFunctions.bind(userInput, nothing -> readAndPrintResult);
-
- IOFunctions.toSafe(program).run();
-
- }
-}
+package com.baeldung.fj;
+
+import fj.F;
+import fj.F1Functions;
+import fj.Unit;
+import fj.data.IO;
+import fj.data.IOFunctions;
+
+public class FunctionalJavaIOMain {
+
+ public static IO printLetters(final String s) {
+ return () -> {
+ for (int i = 0; i < s.length(); i++) {
+ System.out.println(s.charAt(i));
+ }
+ return Unit.unit();
+ };
+ }
+
+ public static void main(String[] args) {
+
+ F> printLetters = i -> printLetters(i);
+
+ IO lowerCase = IOFunctions.stdoutPrintln("What's your first Name ?");
+
+ IO input = IOFunctions.stdoutPrint("First Name: ");
+
+ IO userInput = IOFunctions.append(lowerCase, input);
+
+ IO readInput = IOFunctions.stdinReadLine();
+
+ F toUpperCase = i -> i.toUpperCase();
+
+ F> transformInput = F1Functions., String> o(printLetters).f(toUpperCase);
+
+ IO readAndPrintResult = IOFunctions.bind(readInput, transformInput);
+
+ IO program = IOFunctions.bind(userInput, nothing -> readAndPrintResult);
+
+ IOFunctions.toSafe(program).run();
+
+ }
+}
diff --git a/libraries/src/main/java/com/baeldung/fj/FunctionalJavaMain.java b/libraries-6/src/main/java/com/baeldung/fj/FunctionalJavaMain.java
similarity index 96%
rename from libraries/src/main/java/com/baeldung/fj/FunctionalJavaMain.java
rename to libraries-6/src/main/java/com/baeldung/fj/FunctionalJavaMain.java
index c6412f2923..1a59e6c22a 100644
--- a/libraries/src/main/java/com/baeldung/fj/FunctionalJavaMain.java
+++ b/libraries-6/src/main/java/com/baeldung/fj/FunctionalJavaMain.java
@@ -1,48 +1,48 @@
-package com.baeldung.fj;
-
-import fj.F;
-import fj.Show;
-import fj.data.Array;
-import fj.data.List;
-import fj.data.Option;
-import fj.function.Characters;
-import fj.function.Integers;
-
-public class FunctionalJavaMain {
-
- public static final F isEven = i -> i % 2 == 0;
-
- public static void main(String[] args) {
-
- List fList = List.list(3, 4, 5, 6);
- List evenList = fList.map(isEven);
- Show.listShow(Show.booleanShow).println(evenList);
-
- fList = fList.map(i -> i + 1);
- Show.listShow(Show.intShow).println(fList);
-
- Array a = Array.array(17, 44, 67, 2, 22, 80, 1, 27);
- Array b = a.filter(Integers.even);
- Show.arrayShow(Show.intShow).println(b);
-
- Array array = Array.array("Welcome", "To", "baeldung");
- Boolean isExist = array.exists(s -> List.fromString(s).forall(Characters.isLowerCase));
- System.out.println(isExist);
-
- Array intArray = Array.array(17, 44, 67, 2, 22, 80, 1, 27);
- int sum = intArray.foldLeft(Integers.add, 0);
- System.out.println(sum);
-
- Option n1 = Option.some(1);
- Option n2 = Option.some(2);
-
- F> f1 = i -> i % 2 == 0 ? Option.some(i + 100) : Option.none();
-
- Option result1 = n1.bind(f1);
- Option result2 = n2.bind(f1);
-
- Show.optionShow(Show.intShow).println(result1);
- Show.optionShow(Show.intShow).println(result2);
- }
-
-}
+package com.baeldung.fj;
+
+import fj.F;
+import fj.Show;
+import fj.data.Array;
+import fj.data.List;
+import fj.data.Option;
+import fj.function.Characters;
+import fj.function.Integers;
+
+public class FunctionalJavaMain {
+
+ public static final F isEven = i -> i % 2 == 0;
+
+ public static void main(String[] args) {
+
+ List fList = List.list(3, 4, 5, 6);
+ List evenList = fList.map(isEven);
+ Show.listShow(Show.booleanShow).println(evenList);
+
+ fList = fList.map(i -> i + 1);
+ Show.listShow(Show.intShow).println(fList);
+
+ Array a = Array.array(17, 44, 67, 2, 22, 80, 1, 27);
+ Array b = a.filter(Integers.even);
+ Show.arrayShow(Show.intShow).println(b);
+
+ Array array = Array.array("Welcome", "To", "baeldung");
+ Boolean isExist = array.exists(s -> List.fromString(s).forall(Characters.isLowerCase));
+ System.out.println(isExist);
+
+ Array intArray = Array.array(17, 44, 67, 2, 22, 80, 1, 27);
+ int sum = intArray.foldLeft(Integers.add, 0);
+ System.out.println(sum);
+
+ Option n1 = Option.some(1);
+ Option n2 = Option.some(2);
+
+ F> f1 = i -> i % 2 == 0 ? Option.some(i + 100) : Option.none();
+
+ Option result1 = n1.bind(f1);
+ Option result2 = n2.bind(f1);
+
+ Show.optionShow(Show.intShow).println(result1);
+ Show.optionShow(Show.intShow).println(result2);
+ }
+
+}
diff --git a/libraries/src/main/java/com/baeldung/ftp/FtpClient.java b/libraries-6/src/main/java/com/baeldung/ftp/FtpClient.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/ftp/FtpClient.java
rename to libraries-6/src/main/java/com/baeldung/ftp/FtpClient.java
diff --git a/libraries/src/main/java/com/baeldung/javapoet/PersonGenerator.java b/libraries-6/src/main/java/com/baeldung/javapoet/PersonGenerator.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/javapoet/PersonGenerator.java
rename to libraries-6/src/main/java/com/baeldung/javapoet/PersonGenerator.java
diff --git a/libraries/src/main/java/com/baeldung/kafka/TransactionalMessageProducer.java b/libraries-6/src/main/java/com/baeldung/kafka/TransactionalMessageProducer.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/kafka/TransactionalMessageProducer.java
rename to libraries-6/src/main/java/com/baeldung/kafka/TransactionalMessageProducer.java
diff --git a/libraries/src/main/java/com/baeldung/kafka/TransactionalWordCount.java b/libraries-6/src/main/java/com/baeldung/kafka/TransactionalWordCount.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/kafka/TransactionalWordCount.java
rename to libraries-6/src/main/java/com/baeldung/kafka/TransactionalWordCount.java
diff --git a/libraries/src/main/java/com/baeldung/kafka/Tuple.java b/libraries-6/src/main/java/com/baeldung/kafka/Tuple.java
similarity index 100%
rename from libraries/src/main/java/com/baeldung/kafka/Tuple.java
rename to libraries-6/src/main/java/com/baeldung/kafka/Tuple.java
diff --git a/libraries/src/main/java/com/baeldung/reflections/ReflectionsApp.java b/libraries-6/src/main/java/com/baeldung/reflections/ReflectionsApp.java
similarity index 97%
rename from libraries/src/main/java/com/baeldung/reflections/ReflectionsApp.java
rename to libraries-6/src/main/java/com/baeldung/reflections/ReflectionsApp.java
index 30da8ea837..4f5b6dd183 100644
--- a/libraries/src/main/java/com/baeldung/reflections/ReflectionsApp.java
+++ b/libraries-6/src/main/java/com/baeldung/reflections/ReflectionsApp.java
@@ -1,71 +1,71 @@
-package com.baeldung.reflections;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.Date;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-import org.reflections.Reflections;
-import org.reflections.scanners.MethodAnnotationsScanner;
-import org.reflections.scanners.MethodParameterScanner;
-import org.reflections.scanners.ResourcesScanner;
-import org.reflections.scanners.Scanner;
-import org.reflections.scanners.SubTypesScanner;
-import org.reflections.util.ClasspathHelper;
-import org.reflections.util.ConfigurationBuilder;
-
-public class ReflectionsApp {
-
- public Set> getReflectionsSubTypes() {
- Reflections reflections = new Reflections("org.reflections");
- Set> scannersSet = reflections.getSubTypesOf(Scanner.class);
- return scannersSet;
- }
-
- public Set> getJDKFunctinalInterfaces() {
- Reflections reflections = new Reflections("java.util.function");
- Set> typesSet = reflections.getTypesAnnotatedWith(FunctionalInterface.class);
- return typesSet;
- }
-
- public Set getDateDeprecatedMethods() {
- Reflections reflections = new Reflections(java.util.Date.class, new MethodAnnotationsScanner());
- Set deprecatedMethodsSet = reflections.getMethodsAnnotatedWith(Deprecated.class);
- return deprecatedMethodsSet;
- }
-
- @SuppressWarnings("rawtypes")
- public Set getDateDeprecatedConstructors() {
- Reflections reflections = new Reflections(java.util.Date.class, new MethodAnnotationsScanner());
- Set constructorsSet = reflections.getConstructorsAnnotatedWith(Deprecated.class);
- return constructorsSet;
- }
-
- public Set getMethodsWithDateParam() {
- Reflections reflections = new Reflections(java.text.SimpleDateFormat.class, new MethodParameterScanner());
- Set methodsSet = reflections.getMethodsMatchParams(Date.class);
- return methodsSet;
- }
-
- public Set getMethodsWithVoidReturn() {
- Reflections reflections = new Reflections(java.text.SimpleDateFormat.class, new MethodParameterScanner());
- Set methodsSet = reflections.getMethodsReturn(void.class);
- return methodsSet;
- }
-
- public Set getPomXmlPaths() {
- Reflections reflections = new Reflections(new ResourcesScanner());
- Set resourcesSet = reflections.getResources(Pattern.compile(".*pom\\.xml"));
- return resourcesSet;
- }
-
- public Set> getReflectionsSubTypesUsingBuilder() {
- Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("org.reflections"))
- .setScanners(new SubTypesScanner()));
-
- Set> scannersSet = reflections.getSubTypesOf(Scanner.class);
- return scannersSet;
- }
-
-}
+package com.baeldung.reflections;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.Date;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import org.reflections.Reflections;
+import org.reflections.scanners.MethodAnnotationsScanner;
+import org.reflections.scanners.MethodParameterScanner;
+import org.reflections.scanners.ResourcesScanner;
+import org.reflections.scanners.Scanner;
+import org.reflections.scanners.SubTypesScanner;
+import org.reflections.util.ClasspathHelper;
+import org.reflections.util.ConfigurationBuilder;
+
+public class ReflectionsApp {
+
+ public Set> getReflectionsSubTypes() {
+ Reflections reflections = new Reflections("org.reflections");
+ Set> scannersSet = reflections.getSubTypesOf(Scanner.class);
+ return scannersSet;
+ }
+
+ public Set> getJDKFunctinalInterfaces() {
+ Reflections reflections = new Reflections("java.util.function");
+ Set> typesSet = reflections.getTypesAnnotatedWith(FunctionalInterface.class);
+ return typesSet;
+ }
+
+ public Set getDateDeprecatedMethods() {
+ Reflections reflections = new Reflections(java.util.Date.class, new MethodAnnotationsScanner());
+ Set deprecatedMethodsSet = reflections.getMethodsAnnotatedWith(Deprecated.class);
+ return deprecatedMethodsSet;
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Set getDateDeprecatedConstructors() {
+ Reflections reflections = new Reflections(java.util.Date.class, new MethodAnnotationsScanner());
+ Set constructorsSet = reflections.getConstructorsAnnotatedWith(Deprecated.class);
+ return constructorsSet;
+ }
+
+ public Set getMethodsWithDateParam() {
+ Reflections reflections = new Reflections(java.text.SimpleDateFormat.class, new MethodParameterScanner());
+ Set methodsSet = reflections.getMethodsMatchParams(Date.class);
+ return methodsSet;
+ }
+
+ public Set getMethodsWithVoidReturn() {
+ Reflections reflections = new Reflections(java.text.SimpleDateFormat.class, new MethodParameterScanner());
+ Set methodsSet = reflections.getMethodsReturn(void.class);
+ return methodsSet;
+ }
+
+ public Set getPomXmlPaths() {
+ Reflections reflections = new Reflections(new ResourcesScanner());
+ Set resourcesSet = reflections.getResources(Pattern.compile(".*pom\\.xml"));
+ return resourcesSet;
+ }
+
+ public Set> getReflectionsSubTypesUsingBuilder() {
+ Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("org.reflections"))
+ .setScanners(new SubTypesScanner()));
+
+ Set> scannersSet = reflections.getSubTypesOf(Scanner.class);
+ return scannersSet;
+ }
+
+}
diff --git a/libraries/src/test/java/com/baeldung/fj/FunctionalJavaUnitTest.java b/libraries-6/src/test/java/com/baeldung/fj/FunctionalJavaUnitTest.java
similarity index 95%
rename from libraries/src/test/java/com/baeldung/fj/FunctionalJavaUnitTest.java
rename to libraries-6/src/test/java/com/baeldung/fj/FunctionalJavaUnitTest.java
index 97ead07470..f79d334b23 100644
--- a/libraries/src/test/java/com/baeldung/fj/FunctionalJavaUnitTest.java
+++ b/libraries-6/src/test/java/com/baeldung/fj/FunctionalJavaUnitTest.java
@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import org.junit.Assert;
import org.junit.Test;
import fj.F;
@@ -96,9 +97,9 @@ public class FunctionalJavaUnitTest {
Option result2 = n2.bind(function);
Option result3 = n3.bind(function);
- assertEquals(Option.none(), result1);
- assertEquals(Option.some(102), result2);
- assertEquals(Option.none(), result3);
+ Assert.assertEquals(Option.none(), result1);
+ Assert.assertEquals(Option.some(102), result2);
+ Assert.assertEquals(Option.none(), result3);
}
@Test
diff --git a/libraries/src/test/java/com/baeldung/ftp/FtpClientIntegrationTest.java b/libraries-6/src/test/java/com/baeldung/ftp/FtpClientIntegrationTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/ftp/FtpClientIntegrationTest.java
rename to libraries-6/src/test/java/com/baeldung/ftp/FtpClientIntegrationTest.java
diff --git a/libraries/src/test/java/com/baeldung/ftp/JdkFtpClientIntegrationTest.java b/libraries-6/src/test/java/com/baeldung/ftp/JdkFtpClientIntegrationTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/ftp/JdkFtpClientIntegrationTest.java
rename to libraries-6/src/test/java/com/baeldung/ftp/JdkFtpClientIntegrationTest.java
diff --git a/libraries/src/test/java/com/baeldung/javapoet/test/PersonGeneratorUnitTest.java b/libraries-6/src/test/java/com/baeldung/javapoet/test/PersonGeneratorUnitTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/javapoet/test/PersonGeneratorUnitTest.java
rename to libraries-6/src/test/java/com/baeldung/javapoet/test/PersonGeneratorUnitTest.java
diff --git a/libraries/src/test/java/com/baeldung/javapoet/test/person/Gender.java b/libraries-6/src/test/java/com/baeldung/javapoet/test/person/Gender.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/javapoet/test/person/Gender.java
rename to libraries-6/src/test/java/com/baeldung/javapoet/test/person/Gender.java
diff --git a/libraries/src/test/java/com/baeldung/javapoet/test/person/Person.java b/libraries-6/src/test/java/com/baeldung/javapoet/test/person/Person.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/javapoet/test/person/Person.java
rename to libraries-6/src/test/java/com/baeldung/javapoet/test/person/Person.java
diff --git a/libraries/src/test/java/com/baeldung/javapoet/test/person/Student.java b/libraries-6/src/test/java/com/baeldung/javapoet/test/person/Student.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/javapoet/test/person/Student.java
rename to libraries-6/src/test/java/com/baeldung/javapoet/test/person/Student.java
diff --git a/libraries/src/test/java/com/baeldung/kafkastreams/KafkaStreamsLiveTest.java b/libraries-6/src/test/java/com/baeldung/kafkastreams/KafkaStreamsLiveTest.java
similarity index 100%
rename from libraries/src/test/java/com/baeldung/kafkastreams/KafkaStreamsLiveTest.java
rename to libraries-6/src/test/java/com/baeldung/kafkastreams/KafkaStreamsLiveTest.java
diff --git a/libraries/src/test/java/com/baeldung/reflections/ReflectionsUnitTest.java b/libraries-6/src/test/java/com/baeldung/reflections/ReflectionsUnitTest.java
similarity index 96%
rename from libraries/src/test/java/com/baeldung/reflections/ReflectionsUnitTest.java
rename to libraries-6/src/test/java/com/baeldung/reflections/ReflectionsUnitTest.java
index 9a3ef0747b..b86094b6f4 100644
--- a/libraries/src/test/java/com/baeldung/reflections/ReflectionsUnitTest.java
+++ b/libraries-6/src/test/java/com/baeldung/reflections/ReflectionsUnitTest.java
@@ -1,50 +1,50 @@
-package com.baeldung.reflections;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-
-import org.junit.jupiter.api.Test;
-
-public class ReflectionsUnitTest {
-
- @Test
- public void givenTypeThenGetAllSubTypes() {
- ReflectionsApp reflectionsApp = new ReflectionsApp();
- assertFalse(reflectionsApp.getReflectionsSubTypes()
- .isEmpty());
- }
-
- @Test
- public void givenTypeAndUsingBuilderThenGetAllSubTypes() {
- ReflectionsApp reflectionsApp = new ReflectionsApp();
- assertFalse(reflectionsApp.getReflectionsSubTypesUsingBuilder()
- .isEmpty());
- }
-
- @Test
- public void givenAnnotationThenGetAllAnnotatedMethods() {
- ReflectionsApp reflectionsApp = new ReflectionsApp();
- assertFalse(reflectionsApp.getDateDeprecatedMethods()
- .isEmpty());
- }
-
- @Test
- public void givenAnnotationThenGetAllAnnotatedConstructors() {
- ReflectionsApp reflectionsApp = new ReflectionsApp();
- assertFalse(reflectionsApp.getDateDeprecatedConstructors()
- .isEmpty());
- }
-
- @Test
- public void givenParamTypeThenGetAllMethods() {
- ReflectionsApp reflectionsApp = new ReflectionsApp();
- assertFalse(reflectionsApp.getMethodsWithDateParam()
- .isEmpty());
- }
-
- @Test
- public void givenReturnTypeThenGetAllMethods() {
- ReflectionsApp reflectionsApp = new ReflectionsApp();
- assertFalse(reflectionsApp.getMethodsWithVoidReturn()
- .isEmpty());
- }
-}
+package com.baeldung.reflections;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+
+import org.junit.jupiter.api.Test;
+
+public class ReflectionsUnitTest {
+
+ @Test
+ public void givenTypeThenGetAllSubTypes() {
+ ReflectionsApp reflectionsApp = new ReflectionsApp();
+ assertFalse(reflectionsApp.getReflectionsSubTypes()
+ .isEmpty());
+ }
+
+ @Test
+ public void givenTypeAndUsingBuilderThenGetAllSubTypes() {
+ ReflectionsApp reflectionsApp = new ReflectionsApp();
+ assertFalse(reflectionsApp.getReflectionsSubTypesUsingBuilder()
+ .isEmpty());
+ }
+
+ @Test
+ public void givenAnnotationThenGetAllAnnotatedMethods() {
+ ReflectionsApp reflectionsApp = new ReflectionsApp();
+ assertFalse(reflectionsApp.getDateDeprecatedMethods()
+ .isEmpty());
+ }
+
+ @Test
+ public void givenAnnotationThenGetAllAnnotatedConstructors() {
+ ReflectionsApp reflectionsApp = new ReflectionsApp();
+ assertFalse(reflectionsApp.getDateDeprecatedConstructors()
+ .isEmpty());
+ }
+
+ @Test
+ public void givenParamTypeThenGetAllMethods() {
+ ReflectionsApp reflectionsApp = new ReflectionsApp();
+ assertFalse(reflectionsApp.getMethodsWithDateParam()
+ .isEmpty());
+ }
+
+ @Test
+ public void givenReturnTypeThenGetAllMethods() {
+ ReflectionsApp reflectionsApp = new ReflectionsApp();
+ assertFalse(reflectionsApp.getMethodsWithVoidReturn()
+ .isEmpty());
+ }
+}
diff --git a/libraries/src/test/java/com/baeldung/resilience4j/Resilience4jUnitTest.java b/libraries-6/src/test/java/com/baeldung/resilence4j/Resilience4jUnitTest.java
similarity index 99%
rename from libraries/src/test/java/com/baeldung/resilience4j/Resilience4jUnitTest.java
rename to libraries-6/src/test/java/com/baeldung/resilence4j/Resilience4jUnitTest.java
index ced95c99cb..1d69d20bc2 100644
--- a/libraries/src/test/java/com/baeldung/resilience4j/Resilience4jUnitTest.java
+++ b/libraries-6/src/test/java/com/baeldung/resilence4j/Resilience4jUnitTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.resilience4j;
+package com.baeldung.resilence4j;
import io.github.resilience4j.bulkhead.Bulkhead;
import io.github.resilience4j.bulkhead.BulkheadConfig;
diff --git a/libraries/src/test/resources/ftp/baz.txt b/libraries-6/src/test/resources/ftp/baz.txt
similarity index 100%
rename from libraries/src/test/resources/ftp/baz.txt
rename to libraries-6/src/test/resources/ftp/baz.txt
diff --git a/libraries-data-2/pom.xml b/libraries-data-2/pom.xml
index e6106c0fe3..73c5452f77 100644
--- a/libraries-data-2/pom.xml
+++ b/libraries-data-2/pom.xml
@@ -128,6 +128,21 @@
${awaitility.version}
test
+
+ org.rosuda.REngine
+ Rserve
+ ${rserve.version}
+
+
+ com.github.jbytecode
+ RCaller
+ ${rcaller.version}
+
+
+ org.renjin
+ renjin-script-engine
+ ${renjin.version}
+
@@ -137,6 +152,13 @@
http://repo.numericalmethod.com/maven/
default
+
+
+
+ bedatadriven
+ bedatadriven public repo
+ https://nexus.bedatadriven.com/content/groups/public/
+
@@ -153,6 +175,27 @@
3.6.2
1.7.25
3.0.0
+ RELEASE
+ 3.0
+ 1.8.1
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+
+ com/baeldung/r/FastRMean.java
+
+
+ com/baeldung/r/FastRMeanUnitTest.java
+
+
+
+
+
+
\ No newline at end of file
diff --git a/libraries-data-2/src/main/java/com/baeldung/r/FastRMean.java b/libraries-data-2/src/main/java/com/baeldung/r/FastRMean.java
new file mode 100644
index 0000000000..8348bfa403
--- /dev/null
+++ b/libraries-data-2/src/main/java/com/baeldung/r/FastRMean.java
@@ -0,0 +1,33 @@
+package com.baeldung.r;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+/**
+ * FastR showcase.
+ *
+ * @author Donato Rimenti
+ */
+public class FastRMean {
+
+ /**
+ * Invokes the customMean R function passing the given values as arguments.
+ *
+ * @param values the input to the mean script
+ * @return the result of the R script
+ */
+ public double mean(int[] values) {
+ Context polyglot = Context.newBuilder()
+ .allowAllAccess(true)
+ .build();
+ String meanScriptContent = RUtils.getMeanScriptContent();
+ polyglot.eval("R", meanScriptContent);
+ Value rBindings = polyglot.getBindings("R");
+ Value rInput = rBindings.getMember("c")
+ .execute(values);
+ return rBindings.getMember("customMean")
+ .execute(rInput)
+ .asDouble();
+ }
+
+}
\ No newline at end of file
diff --git a/libraries-data-2/src/main/java/com/baeldung/r/RCallerMean.java b/libraries-data-2/src/main/java/com/baeldung/r/RCallerMean.java
new file mode 100644
index 0000000000..99edb8c043
--- /dev/null
+++ b/libraries-data-2/src/main/java/com/baeldung/r/RCallerMean.java
@@ -0,0 +1,37 @@
+package com.baeldung.r;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import com.github.rcaller.rstuff.RCaller;
+import com.github.rcaller.rstuff.RCallerOptions;
+import com.github.rcaller.rstuff.RCode;
+
+/**
+ * RCaller showcase.
+ *
+ * @author Donato Rimenti
+ */
+public class RCallerMean {
+
+ /**
+ * Invokes the customMean R function passing the given values as arguments.
+ *
+ * @param values the input to the mean script
+ * @return the result of the R script
+ * @throws IOException if any error occurs
+ * @throws URISyntaxException if any error occurs
+ */
+ public double mean(int[] values) throws IOException, URISyntaxException {
+ String fileContent = RUtils.getMeanScriptContent();
+ RCode code = RCode.create();
+ code.addRCode(fileContent);
+ code.addIntArray("input", values);
+ code.addRCode("result <- customMean(input)");
+ RCaller caller = RCaller.create(code, RCallerOptions.create());
+ caller.runAndReturnResult("result");
+ return caller.getParser()
+ .getAsDoubleArray("result")[0];
+ }
+
+}
\ No newline at end of file
diff --git a/libraries-data-2/src/main/java/com/baeldung/r/RUtils.java b/libraries-data-2/src/main/java/com/baeldung/r/RUtils.java
new file mode 100644
index 0000000000..a9393cdcc2
--- /dev/null
+++ b/libraries-data-2/src/main/java/com/baeldung/r/RUtils.java
@@ -0,0 +1,33 @@
+package com.baeldung.r;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.stream.Collectors;
+
+/**
+ * Utility class for loading the script.R content.
+ *
+ * @author Donato Rimenti
+ */
+public class RUtils {
+
+ /**
+ * Loads the script.R and returns its content as a string.
+ *
+ * @return the script.R content as a string
+ * @throws IOException if any error occurs
+ * @throws URISyntaxException if any error occurs
+ */
+ static String getMeanScriptContent() throws IOException, URISyntaxException {
+ URI rScriptUri = RUtils.class.getClassLoader()
+ .getResource("script.R")
+ .toURI();
+ Path inputScript = Paths.get(rScriptUri);
+ return Files.lines(inputScript)
+ .collect(Collectors.joining());
+ }
+}
\ No newline at end of file
diff --git a/libraries-data-2/src/main/java/com/baeldung/r/RenjinMean.java b/libraries-data-2/src/main/java/com/baeldung/r/RenjinMean.java
new file mode 100644
index 0000000000..4576ec5fb4
--- /dev/null
+++ b/libraries-data-2/src/main/java/com/baeldung/r/RenjinMean.java
@@ -0,0 +1,36 @@
+package com.baeldung.r;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import javax.script.ScriptException;
+
+import org.renjin.script.RenjinScriptEngine;
+import org.renjin.sexp.DoubleArrayVector;
+
+/**
+ * Renjin showcase.
+ *
+ * @author Donato Rimenti
+ */
+public class RenjinMean {
+
+ /**
+ * Invokes the customMean R function passing the given values as arguments.
+ *
+ * @param values the input to the mean script
+ * @return the result of the R script
+ * @throws IOException if any error occurs
+ * @throws URISyntaxException if any error occurs
+ * @throws ScriptException if any error occurs
+ */
+ public double mean(int[] values) throws IOException, URISyntaxException, ScriptException {
+ RenjinScriptEngine engine = new RenjinScriptEngine();
+ String meanScriptContent = RUtils.getMeanScriptContent();
+ engine.put("input", values);
+ engine.eval(meanScriptContent);
+ DoubleArrayVector result = (DoubleArrayVector) engine.eval("customMean(input)");
+ return result.asReal();
+ }
+
+}
\ No newline at end of file
diff --git a/libraries-data-2/src/main/java/com/baeldung/r/RserveMean.java b/libraries-data-2/src/main/java/com/baeldung/r/RserveMean.java
new file mode 100644
index 0000000000..1aaa7fa847
--- /dev/null
+++ b/libraries-data-2/src/main/java/com/baeldung/r/RserveMean.java
@@ -0,0 +1,30 @@
+package com.baeldung.r;
+
+import org.rosuda.REngine.REXPMismatchException;
+import org.rosuda.REngine.REngineException;
+import org.rosuda.REngine.Rserve.RConnection;
+
+/**
+ * Rserve showcase.
+ *
+ * @author Donato Rimenti
+ */
+public class RserveMean {
+
+ /**
+ * Connects to the Rserve istance listening on 127.0.0.1:6311 and invokes the
+ * customMean R function passing the given values as arguments.
+ *
+ * @param values the input to the mean script
+ * @return the result of the R script
+ * @throws REngineException if any error occurs
+ * @throws REXPMismatchException if any error occurs
+ */
+ public double mean(int[] values) throws REngineException, REXPMismatchException {
+ RConnection c = new RConnection();
+ c.assign("input", values);
+ return c.eval("customMean(input)")
+ .asDouble();
+ }
+
+}
\ No newline at end of file
diff --git a/libraries-data-2/src/test/java/com/baeldung/r/FastRMeanUnitTest.java b/libraries-data-2/src/test/java/com/baeldung/r/FastRMeanUnitTest.java
new file mode 100644
index 0000000000..4e7426b75a
--- /dev/null
+++ b/libraries-data-2/src/test/java/com/baeldung/r/FastRMeanUnitTest.java
@@ -0,0 +1,29 @@
+package com.baeldung.r;
+
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Test for {@link FastRMean}.
+ *
+ * @author Donato Rimenti
+ */
+@Ignore
+public class FastRMeanUnitTest {
+
+ /**
+ * Object to test.
+ */
+ private FastRMean fastrMean = new FastRMean();
+
+ /**
+ * Test for {@link FastRMeanUnitTest#mean(int[])}.
+ */
+ @Test
+ public void givenValues_whenMean_thenCorrect() {
+ int[] input = { 1, 2, 3, 4, 5 };
+ double result = fastrMean.mean(input);
+ Assert.assertEquals(3.0, result, 0.000001);
+ }
+}
\ No newline at end of file
diff --git a/libraries-data-2/src/test/java/com/baeldung/r/RCallerMeanIntegrationTest.java b/libraries-data-2/src/test/java/com/baeldung/r/RCallerMeanIntegrationTest.java
new file mode 100644
index 0000000000..ce6b3a4332
--- /dev/null
+++ b/libraries-data-2/src/test/java/com/baeldung/r/RCallerMeanIntegrationTest.java
@@ -0,0 +1,37 @@
+package com.baeldung.r;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import javax.script.ScriptException;
+
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Test for {@link RCallerMean}.
+ *
+ * @author Donato Rimenti
+ */
+@Ignore
+public class RCallerMeanIntegrationTest {
+
+ /**
+ * Object to test.
+ */
+ private RCallerMean rcallerMean = new RCallerMean();
+
+ /**
+ * Test for {@link RCallerMeanIntegrationTest#mean(int[])}.
+ *
+ * @throws ScriptException if an error occurs
+ * @throws URISyntaxException if an error occurs
+ */
+ @Test
+ public void givenValues_whenMean_thenCorrect() throws IOException, URISyntaxException {
+ int[] input = { 1, 2, 3, 4, 5 };
+ double result = rcallerMean.mean(input);
+ Assert.assertEquals(3.0, result, 0.000001);
+ }
+}
\ No newline at end of file
diff --git a/libraries-data-2/src/test/java/com/baeldung/r/RenjinMeanUnitTest.java b/libraries-data-2/src/test/java/com/baeldung/r/RenjinMeanUnitTest.java
new file mode 100644
index 0000000000..f52d37d614
--- /dev/null
+++ b/libraries-data-2/src/test/java/com/baeldung/r/RenjinMeanUnitTest.java
@@ -0,0 +1,37 @@
+package com.baeldung.r;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import javax.script.ScriptException;
+
+import org.junit.Test;
+
+import org.junit.Assert;
+
+/**
+ * Test for {@link RenjinMean}.
+ *
+ * @author Donato Rimenti
+ */
+public class RenjinMeanUnitTest {
+
+ /**
+ * Object to test.
+ */
+ private RenjinMean renjinMean = new RenjinMean();
+
+ /**
+ * Test for {@link RenjinMeanUnitTest#mean(int[])}.
+ *
+ * @throws ScriptException if an error occurs
+ * @throws URISyntaxException if an error occurs
+ * @throws IOException if an error occurs
+ */
+ @Test
+ public void givenValues_whenMean_thenCorrect() throws IOException, URISyntaxException, ScriptException {
+ int[] input = { 1, 2, 3, 4, 5 };
+ double result = renjinMean.mean(input);
+ Assert.assertEquals(3.0, result, 0.000001);
+ }
+}
\ No newline at end of file
diff --git a/libraries-data-2/src/test/java/com/baeldung/r/RserveMeanIntegrationTest.java b/libraries-data-2/src/test/java/com/baeldung/r/RserveMeanIntegrationTest.java
new file mode 100644
index 0000000000..23d42bd8e9
--- /dev/null
+++ b/libraries-data-2/src/test/java/com/baeldung/r/RserveMeanIntegrationTest.java
@@ -0,0 +1,34 @@
+package com.baeldung.r;
+
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.rosuda.REngine.REXPMismatchException;
+import org.rosuda.REngine.REngineException;
+
+/**
+ * Test for {@link RserveMean}.
+ *
+ * @author Donato Rimenti
+ */
+@Ignore
+public class RserveMeanIntegrationTest {
+
+ /**
+ * Object to test.
+ */
+ private RserveMean rserveMean = new RserveMean();
+
+ /**
+ * Test for {@link RserveMeanIntegrationTest#mean(int[])}.
+ *
+ * @throws REXPMismatchException if an error occurs
+ * @throws REngineException if an error occurs
+ */
+ @Test
+ public void givenValues_whenMean_thenCorrect() throws REngineException, REXPMismatchException {
+ int[] input = { 1, 2, 3, 4, 5 };
+ double result = rserveMean.mean(input);
+ Assert.assertEquals(3.0, result, 0.000001);
+ }
+}
\ No newline at end of file
diff --git a/libraries-data-2/src/test/resources/script.R b/libraries-data-2/src/test/resources/script.R
new file mode 100644
index 0000000000..08f859cc3d
--- /dev/null
+++ b/libraries-data-2/src/test/resources/script.R
@@ -0,0 +1,3 @@
+customMean <- function(vector) {
+ mean(vector)
+}
\ No newline at end of file
diff --git a/libraries-testing/README.md b/libraries-testing/README.md
index 7098c10d28..ffdefe4b19 100644
--- a/libraries-testing/README.md
+++ b/libraries-testing/README.md
@@ -11,4 +11,4 @@ This module contains articles about test libraries.
- [Introduction to Awaitlity](https://www.baeldung.com/awaitlity-testing)
- [Introduction to Hoverfly in Java](https://www.baeldung.com/hoverfly)
- [Testing with Hamcrest](https://www.baeldung.com/java-junit-hamcrest-guide)
-- [Introduction To DBUnit](https://www.baeldung.com/dbunit)
+- [Introduction To DBUnit](https://www.baeldung.com/java-dbunit)
diff --git a/libraries/README.md b/libraries/README.md
index 79ba8fe55d..b61289504c 100644
--- a/libraries/README.md
+++ b/libraries/README.md
@@ -19,30 +19,4 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m
- [Software Transactional Memory in Java Using Multiverse](https://www.baeldung.com/java-multiverse-stm)
- [Locality-Sensitive Hashing in Java Using Java-LSH](https://www.baeldung.com/locality-sensitive-hashing)
- [Introduction to Neuroph](https://www.baeldung.com/neuroph)
-- [Quick Guide to RSS with Rome](https://www.baeldung.com/rome-rss)
-- [Introduction to PCollections](https://www.baeldung.com/java-pcollections)
-- [Introduction to Eclipse Collections](https://www.baeldung.com/eclipse-collections)
-- [DistinctBy in the Java Stream API](https://www.baeldung.com/java-streams-distinct-by)
-- [Introduction to NoException](https://www.baeldung.com/no-exception)
-- [Spring Yarg Integration](https://www.baeldung.com/spring-yarg)
-- [Delete a Directory Recursively in Java](https://www.baeldung.com/java-delete-directory)
-- [Guide to JDeferred](https://www.baeldung.com/jdeferred)
-- [Introduction to MBassador](https://www.baeldung.com/mbassador)
-- [Using Pairs in Java](https://www.baeldung.com/java-pairs)
-- [Introduction to Caffeine](https://www.baeldung.com/java-caching-caffeine)
-- [Introduction to StreamEx](https://www.baeldung.com/streamex)
-- [A Docker Guide for Java](https://www.baeldung.com/docker-java-api)
-- [Introduction to Akka Actors in Java](https://www.baeldung.com/akka-actors-java)
-- [A Guide to Byte Buddy](https://www.baeldung.com/byte-buddy)
-- [Introduction to jOOL](https://www.baeldung.com/jool)
-- [Consumer Driven Contracts with Pact](https://www.baeldung.com/pact-junit-consumer-driven-contracts)
-- [Introduction to Atlassian Fugue](https://www.baeldung.com/java-fugue)
-- [Publish and Receive Messages with Nats Java Client](https://www.baeldung.com/nats-java-client)
-- [Java Concurrency Utility with JCTools](https://www.baeldung.com/java-concurrency-jc-tools)
-- [Introduction to JavaPoet](https://www.baeldung.com/java-poet)
-- [Guide to Resilience4j](https://www.baeldung.com/resilience4j)
-- [Exactly Once Processing in Kafka](https://www.baeldung.com/kafka-exactly-once)
-- [Implementing a FTP-Client in Java](https://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/libraries/pom.xml b/libraries/pom.xml
index 41bc2b9311..fee66f928d 100644
--- a/libraries/pom.xml
+++ b/libraries/pom.xml
@@ -12,18 +12,6 @@
-
-
- com.typesafe.akka
- akka-actor_2.12
- ${typesafe-akka.version}
-
-
- com.typesafe.akka
- akka-testkit_2.12
- ${typesafe-akka.version}
- test
-
org.beykery
@@ -63,18 +51,6 @@
javers-core
${javers.version}
-
-
- io.nats
- jnats
- ${jnats.version}
-
-
-
- rome
- rome
- ${rome.version}
-
net.serenity-bdd
serenity-core
@@ -218,11 +194,6 @@
quartz
${quartz.version}
-
- one.util
- streamex
- ${streamex.version}
-
org.jooq
jool
@@ -245,28 +216,9 @@
${java-lsh.version}
- au.com.dius
- pact-jvm-consumer-junit_2.11
- ${pact.version}
- test
-
-
- org.codehaus.groovy
- groovy-all
-
-
-
-
- org.awaitility
- awaitility
- ${awaitility.version}
- test
-
-
- org.awaitility
- awaitility-proxy
- ${awaitility.version}
- test
+ commons-io
+ commons-io
+ ${commonsio.version}
org.hamcrest
@@ -274,89 +226,12 @@
${org.hamcrest.java-hamcrest.version}
test
-
- net.bytebuddy
- byte-buddy
- ${bytebuddy.version}
-
-
- net.bytebuddy
- byte-buddy-agent
- ${bytebuddy.version}
-
-
- org.pcollections
- pcollections
- ${pcollections.version}
-
-
- com.machinezoo.noexception
- noexception
- ${noexception.version}
-
-
- org.eclipse.collections
- eclipse-collections
- ${eclipse-collections.version}
-
-
- io.vavr
- vavr
- ${vavr.version}
-
-
- com.haulmont.yarg
- yarg
- ${yarg.version}
-
-
- net.engio
- mbassador
- ${mbassador.version}
-
-
- org.jdeferred
- jdeferred-core
- ${jdeferred.version}
-
com.codepoetics
protonpack
${protonpack.version}
-
- org.functionaljava
- functionaljava-java8
- ${functionaljava.version}
-
-
- com.github.ben-manes.caffeine
- caffeine
- ${caffeine.version}
-
-
-
-
- com.github.docker-java
- docker-java
- ${docker.version}
-
-
- org.slf4j
- slf4j-log4j12
-
-
- org.slf4j
- jcl-over-slf4j
-
-
- ch.qos.logback
- logback-classic
-
-
-
-
@@ -364,77 +239,12 @@
google-oauth-client-jetty
${google-api.version}
-
- org.apache.kafka
- kafka-streams
- ${kafka.version}
-
-
- org.apache.kafka
- kafka-clients
- ${kafka.version}
- test
- test
-
-
-
-
- io.atlassian.fugue
- fugue
- ${fugue.version}
-
-
-
- org.jctools
- jctools-core
- ${jctools.version}
-
-
-
-
- io.github.resilience4j
- resilience4j-circuitbreaker
- ${resilience4j.version}
-
-
- io.github.resilience4j
- resilience4j-bulkhead
- ${resilience4j.version}
-
-
- io.github.resilience4j
- resilience4j-retry
- ${resilience4j.version}
-
-
- io.github.resilience4j
- resilience4j-timelimiter
- ${resilience4j.version}
-
-
- com.squareup
- javapoet
- ${javapoet.version}
-
org.hamcrest
hamcrest-all
${hamcrest-all.version}
test
-
-
- org.mockftpserver
- MockFtpServer
- ${mockftpserver.version}
- test
-
-
-
- org.reflections
- reflections
- ${reflections.version}
-
@@ -562,8 +372,6 @@
1.2
3.6.2
3.1.0
- 1.0
-
2.92
1.9.26
1.41.0
@@ -572,26 +380,10 @@
1.1.0
0.10
3.5.0
- 3.0.0
2.0.0.0
- 1.7.1
- 2.1.2
- 1.0
- 8.2.0
- 0.6.5
- 0.9.0
-
1.15
- 2.5.5
1.23.0
- 2.0.0
- 3.0.14
-
0.9.4.0006L
- 2.1.2
- 2.5.11
- 0.12.1
- 1.10.0
1.3
3.2.0-m7
5.1.1
@@ -604,16 +396,9 @@
2.3.0
0.9.12
1.19
- 1.1.0
- 2.0.4
- 1.3.1
- 1.2.6
- 4.8.1
- 4.5.1
3.0.2
- 2.7.1
3.6
- 0.9.11
+ 2.6
diff --git a/maven-all/maven-unused-dependencies/pom.xml b/maven-all/maven-unused-dependencies/pom.xml
new file mode 100644
index 0000000000..825858e481
--- /dev/null
+++ b/maven-all/maven-unused-dependencies/pom.xml
@@ -0,0 +1,47 @@
+
+ 4.0.0
+ com.baeldung
+ maven-unused-dependencies
+ 0.0.1-SNAPSHOT
+
+
+ 3.2.2
+ 1.7.25
+ 3.1.2
+ 3.1
+
+
+
+
+ commons-collections
+ commons-collections
+ ${commons-collections.version}
+
+
+ org.slf4j
+ slf4j-api
+ ${slf4j-api.version}
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+ 1.8
+ 1.8
+
+
+
+ maven-dependency-plugin
+ ${maven-dependency-plugin.version}
+
+
+
+
+
\ No newline at end of file
diff --git a/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java b/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java
new file mode 100644
index 0000000000..c9390880ed
--- /dev/null
+++ b/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java
@@ -0,0 +1,17 @@
+package com.baeldung.mavendependencyplugin;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class UnusedDependenciesExample {
+
+ /**
+ * When the Maven dependency analyzer analyzes the code, it will see that the slf4j dependency is being used in this method.
+ *
+ * @return the slf4j {@link Logger}.
+ */
+ public Logger getLogger() {
+ return LoggerFactory.getLogger(UnusedDependenciesExample.class);
+ }
+
+}
diff --git a/maven-java-11/README.md b/maven-java-11/README.md
deleted file mode 100644
index b923518825..0000000000
--- a/maven-java-11/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-## Maven and Java 11
-
-This module contains articles about Maven with Java 11+.
-
-### Relevant Articles:
-
diff --git a/maven-java-11/multimodule-maven-project/daomodule/pom.xml b/maven-java-11/multimodule-maven-project/daomodule/pom.xml
deleted file mode 100644
index cbe0b4cb95..0000000000
--- a/maven-java-11/multimodule-maven-project/daomodule/pom.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- 4.0.0
- com.baeldung.daomodule
- daomodule
- 1.0
- daomodule
- jar
-
-
- com.baeldung.multimodule-maven-project
- multimodule-maven-project
- 1.0
-
-
-
diff --git a/maven-java-11/multimodule-maven-project/daomodule/src/main/java/com/baeldung/dao/Dao.java b/maven-java-11/multimodule-maven-project/daomodule/src/main/java/com/baeldung/dao/Dao.java
deleted file mode 100644
index f86ae8abb3..0000000000
--- a/maven-java-11/multimodule-maven-project/daomodule/src/main/java/com/baeldung/dao/Dao.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.baeldung.dao;
-
-import java.util.List;
-import java.util.Optional;
-
-public interface Dao {
-
- Optional findById(int id);
-
- List findAll();
-
-}
diff --git a/maven-java-11/multimodule-maven-project/daomodule/src/main/java/module-info.java b/maven-java-11/multimodule-maven-project/daomodule/src/main/java/module-info.java
deleted file mode 100644
index 072d7ad007..0000000000
--- a/maven-java-11/multimodule-maven-project/daomodule/src/main/java/module-info.java
+++ /dev/null
@@ -1,3 +0,0 @@
-module com.baeldung.dao {
- exports com.baeldung.dao;
-}
diff --git a/maven-java-11/multimodule-maven-project/entitiymodule/pom.xml b/maven-java-11/multimodule-maven-project/entitiymodule/pom.xml
deleted file mode 100644
index 228619ed74..0000000000
--- a/maven-java-11/multimodule-maven-project/entitiymodule/pom.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
- 4.0.0
- com.baeldung.entitymodule
- entitymodule
- 1.0
- entitymodule
- jar
-
-
- com.baeldung.multimodule-maven-project
- multimodule-maven-project
- 1.0
-
-
-
- 11
- 11
-
-
-
diff --git a/maven-java-11/multimodule-maven-project/entitiymodule/src/main/java/com/baeldung/entity/User.java b/maven-java-11/multimodule-maven-project/entitiymodule/src/main/java/com/baeldung/entity/User.java
deleted file mode 100644
index 22022a2e6d..0000000000
--- a/maven-java-11/multimodule-maven-project/entitiymodule/src/main/java/com/baeldung/entity/User.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.baeldung.entity;
-
-public class User {
-
- private final String name;
-
- public User(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public String toString() {
- return "User{" + "name=" + name + '}';
- }
-}
diff --git a/maven-java-11/multimodule-maven-project/entitiymodule/src/main/java/module-info.java b/maven-java-11/multimodule-maven-project/entitiymodule/src/main/java/module-info.java
deleted file mode 100644
index 67a3097352..0000000000
--- a/maven-java-11/multimodule-maven-project/entitiymodule/src/main/java/module-info.java
+++ /dev/null
@@ -1,3 +0,0 @@
-module com.baeldung.entity {
- exports com.baeldung.entity;
-}
diff --git a/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml b/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml
deleted file mode 100644
index a4a6575906..0000000000
--- a/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
- 4.0.0
- com.baeldung.mainappmodule
- mainappmodule
- 1.0
- mainappmodule
- jar
-
-
- com.baeldung.multimodule-maven-project
- multimodule-maven-project
- 1.0
- 1.0
- 1.0
- 1.0
-
-
-
-
- com.baeldung.entitymodule
- entitymodule
- ${entitymodule.version}
-
-
- com.baeldung.daomodule
- daomodule
- ${daomodule.version}
-
-
- com.baeldung.userdaomodule
- userdaomodule
- ${userdaomodule.version}
-
-
-
-
diff --git a/maven-java-11/multimodule-maven-project/mainppmodule/src/main/java/com/baeldung/mainapp/Application.java b/maven-java-11/multimodule-maven-project/mainppmodule/src/main/java/com/baeldung/mainapp/Application.java
deleted file mode 100644
index 0c0df7461b..0000000000
--- a/maven-java-11/multimodule-maven-project/mainppmodule/src/main/java/com/baeldung/mainapp/Application.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.baeldung.mainapp;
-
-import com.baeldung.dao.Dao;
-import com.baeldung.entity.User;
-import com.baeldung.userdao.UserDao;
-import java.util.HashMap;
-import java.util.Map;
-
-public class Application {
-
- public static void main(String[] args) {
- Map users = new HashMap<>();
- users.put(1, new User("Julie"));
- users.put(2, new User("David"));
- Dao userDao = new UserDao(users);
- userDao.findAll().forEach(System.out::println);
- }
-
-}
diff --git a/maven-java-11/multimodule-maven-project/mainppmodule/src/main/java/module-info.java b/maven-java-11/multimodule-maven-project/mainppmodule/src/main/java/module-info.java
deleted file mode 100644
index c688fcf7de..0000000000
--- a/maven-java-11/multimodule-maven-project/mainppmodule/src/main/java/module-info.java
+++ /dev/null
@@ -1,6 +0,0 @@
-module com.baeldung.mainapp {
- requires com.baeldung.entity;
- requires com.baeldung.userdao;
- requires com.baeldung.dao;
- uses com.baeldung.dao.Dao;
-}
diff --git a/maven-java-11/multimodule-maven-project/pom.xml b/maven-java-11/multimodule-maven-project/pom.xml
deleted file mode 100644
index 65f5b7a814..0000000000
--- a/maven-java-11/multimodule-maven-project/pom.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
- 4.0.0
- com.baeldung.multimodule-maven-project
- multimodule-maven-project
- 1.0
- multimodule-maven-project
- pom
-
-
- com.baeldung.maven-java-11
- maven-java-11
- 1.0
-
-
-
- entitymodule
- daomodule
- userdaomodule
- mainappmodule
-
-
-
-
-
- junit
- junit
- ${junit.version}
- test
-
-
- org.assertj
- assertj-core
- ${assertj.version}
- test
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- ${compiler.plugin.version}
-
- ${source.version}
- ${target.version}
-
-
-
-
-
-
-
- UTF-8
- 4.12
- 3.12.2
- 3.8.0
- 11
- 11
-
-
-
diff --git a/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml b/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml
deleted file mode 100644
index cf6ea85cb5..0000000000
--- a/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
- 4.0.0
- com.baeldung.userdaomodule
- userdaomodule
- 1.0
- userdaomodule
- jar
-
-
- com.baeldung.multimodule-maven-project
- multimodule-maven-project
- 1.0
-
-
-
-
- com.baeldung.entitymodule
- entitymodule
- ${entitymodule.version}1.0
-
-
- com.baeldung.daomodule
- daomodule
- ${daomodule.version}
-
-
- junit
- junit
- test
-
-
-
-
- 1.0
- 1.0
-
-
-
diff --git a/maven-java-11/multimodule-maven-project/userdaomodule/src/main/java/com/baeldung/userdao/UserDao.java b/maven-java-11/multimodule-maven-project/userdaomodule/src/main/java/com/baeldung/userdao/UserDao.java
deleted file mode 100644
index 1f1ea38a60..0000000000
--- a/maven-java-11/multimodule-maven-project/userdaomodule/src/main/java/com/baeldung/userdao/UserDao.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.baeldung.userdao;
-
-import com.baeldung.dao.Dao;
-import com.baeldung.entity.User;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-public class UserDao implements Dao {
-
- private final Map users;
-
- public UserDao() {
- users = new HashMap<>();
- }
-
- public UserDao(Map users) {
- this.users = users;
- }
-
- @Override
- public List findAll() {
- return new ArrayList<>(users.values());
- }
-
- @Override
- public Optional findById(int id) {
- return Optional.ofNullable(users.get(id));
- }
-}
\ No newline at end of file
diff --git a/maven-java-11/multimodule-maven-project/userdaomodule/src/main/java/module-info.java b/maven-java-11/multimodule-maven-project/userdaomodule/src/main/java/module-info.java
deleted file mode 100644
index f1cb217e23..0000000000
--- a/maven-java-11/multimodule-maven-project/userdaomodule/src/main/java/module-info.java
+++ /dev/null
@@ -1,6 +0,0 @@
-module com.baeldung.userdao {
- requires com.baeldung.entity;
- requires com.baeldung.dao;
- provides com.baeldung.dao.Dao with com.baeldung.userdao.UserDao;
- exports com.baeldung.userdao;
-}
diff --git a/maven-java-11/multimodule-maven-project/userdaomodule/src/test/java/com/baeldung/userdao/test/UserDaoUnitTest.java b/maven-java-11/multimodule-maven-project/userdaomodule/src/test/java/com/baeldung/userdao/test/UserDaoUnitTest.java
deleted file mode 100644
index 191d17ff32..0000000000
--- a/maven-java-11/multimodule-maven-project/userdaomodule/src/test/java/com/baeldung/userdao/test/UserDaoUnitTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.baeldung.userdao.test;
-
-import com.baeldung.dao.Dao;
-import com.baeldung.entity.User;
-import com.baeldung.userdao.UserDao;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import static org.junit.Assert.*;
-import static org.hamcrest.CoreMatchers.*;
-import org.junit.Before;
-import org.junit.Test;
-
-public class UserDaoUnitTest {
-
- private Dao userDao;
-
- @Before
- public void setUpUserDaoInstance() {
- Map users = new HashMap<>();
- users.put(1, new User("Julie"));
- users.put(2, new User("David"));
- userDao = new UserDao(users);
- }
-
- @Test
- public void givenUserDaoIntance_whenCalledFindById_thenCorrect() {
- assertThat(userDao.findById(1), isA(Optional.class));
- }
-
- @Test
- public void givenUserDaoIntance_whenCalledFindAll_thenCorrect() {
- assertThat(userDao.findAll(), isA(List.class));
- }
-}
diff --git a/maven-java-11/pom.xml b/maven-java-11/pom.xml
deleted file mode 100644
index 10e80365c8..0000000000
--- a/maven-java-11/pom.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
- 4.0.0
- com.baeldung.maven-java-11
- maven-java-11
- 1.0
- maven-java-11
- pom
-
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
-
-
- multimodule-maven-project
-
-
-
- UTF-8
- 11
- 11
-
-
-
diff --git a/mybatis/src/main/java/com/baeldung/mybatis/mapper/AddressMapper.java b/mybatis/src/main/java/com/baeldung/mybatis/mapper/AddressMapper.java
index e96a4837db..c79ef667bd 100644
--- a/mybatis/src/main/java/com/baeldung/mybatis/mapper/AddressMapper.java
+++ b/mybatis/src/main/java/com/baeldung/mybatis/mapper/AddressMapper.java
@@ -14,8 +14,8 @@ public interface AddressMapper {
@Results(value = { @Result(property = "addressId", column = "addressId"),
@Result(property = "streetAddress", column = "streetAddress"),
@Result(property = "person", column = "personId", javaType = Person.class, one = @One(select = "getPerson")) })
- Address getAddresses(Integer addressID);
+ Address getAddresses(Integer addressId);
@Select("SELECT personId FROM address WHERE addressId = #{addressId})")
- Person getPerson(Integer personId);
+ Person getPerson(Integer addressId);
}
diff --git a/netty/README.md b/netty/README.md
new file mode 100644
index 0000000000..30c63cd5a8
--- /dev/null
+++ b/netty/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles:
+
+- [HTTP/2 in Netty](https://www.baeldung.com/netty-http2)
diff --git a/oauth2-framework-impl/oauth2-authorization-server/README.md b/oauth2-framework-impl/oauth2-authorization-server/README.md
deleted file mode 100644
index 4bcb9790b1..0000000000
--- a/oauth2-framework-impl/oauth2-authorization-server/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-### Relevant Articles:
-
-- [Implementing The OAuth 2.0 Authorization Framework Using Jakarta EE](https://www.baeldung.com/java-ee-oauth2-implementation)
diff --git a/oauth2-framework-impl/oauth2-resource-server/README.md b/oauth2-framework-impl/oauth2-resource-server/README.md
deleted file mode 100644
index 4bcb9790b1..0000000000
--- a/oauth2-framework-impl/oauth2-resource-server/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-### Relevant Articles:
-
-- [Implementing The OAuth 2.0 Authorization Framework Using Jakarta EE](https://www.baeldung.com/java-ee-oauth2-implementation)
diff --git a/parent-java/pom.xml b/parent-java/pom.xml
index 4828bc2abb..baad9fecf4 100644
--- a/parent-java/pom.xml
+++ b/parent-java/pom.xml
@@ -1,8 +1,8 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
parent-java
0.0.1-SNAPSHOT
@@ -45,6 +45,9 @@
23.0
2.6
1.19
+ 2.3.7
+ 4.12
+ 2.2
diff --git a/patterns/solid/src/main/java/com/baeldung/s/TextManipulator.java b/patterns/solid/src/main/java/com/baeldung/s/TextManipulator.java
new file mode 100644
index 0000000000..d084a78815
--- /dev/null
+++ b/patterns/solid/src/main/java/com/baeldung/s/TextManipulator.java
@@ -0,0 +1,37 @@
+package com.baeldung.s;
+
+public class TextManipulator {
+ private String text;
+
+ public TextManipulator(String text) {
+ this.text = text;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void appendText(String newText) {
+ text = text.concat(newText);
+ }
+
+ public String findWordAndReplace(String word, String replacementWord) {
+ if (text.contains(word)) {
+ text = text.replace(word, replacementWord);
+ }
+ return text;
+ }
+
+ public String findWordAndDelete(String word) {
+ if (text.contains(word)) {
+ text = text.replace(word, "");
+ }
+ return text;
+ }
+
+ /*
+ * Bad practice when implementing SRP principle, not in the scope of this class
+ public void printText() {
+ System.out.println(textManipulator.getText());
+ }*/
+}
diff --git a/patterns/solid/src/main/java/com/baeldung/s/TextPrinter.java b/patterns/solid/src/main/java/com/baeldung/s/TextPrinter.java
new file mode 100644
index 0000000000..d6a413e7ac
--- /dev/null
+++ b/patterns/solid/src/main/java/com/baeldung/s/TextPrinter.java
@@ -0,0 +1,23 @@
+package com.baeldung.s;
+
+import java.util.Arrays;
+
+public class TextPrinter {
+ TextManipulator textManipulator;
+
+ public TextPrinter(TextManipulator textManipulator) {
+ this.textManipulator = textManipulator;
+ }
+
+ public void printText() {
+ System.out.println(textManipulator.getText());
+ }
+
+ public void printOutEachWordOfText() {
+ System.out.println(Arrays.toString(textManipulator.getText().split(" ")));
+ }
+
+ public void printRangeOfCharacters(int startingIndex, int endIndex) {
+ System.out.println(textManipulator.getText().substring(startingIndex, endIndex));
+ }
+}
diff --git a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/connectionpool/BasicConnectionPool.java b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/connectionpool/BasicConnectionPool.java
index 289db18c53..22ef0e5411 100644
--- a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/connectionpool/BasicConnectionPool.java
+++ b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/connectionpool/BasicConnectionPool.java
@@ -14,7 +14,8 @@ public class BasicConnectionPool implements ConnectionPool {
private final List connectionPool;
private final List usedConnections = new ArrayList<>();
private static final int INITIAL_POOL_SIZE = 10;
- private final int MAX_POOL_SIZE = 20;
+ private static final int MAX_POOL_SIZE = 20;
+ private static final int MAX_TIMEOUT = 5;
public static BasicConnectionPool create(String url, String user, String password) throws SQLException {
List pool = new ArrayList<>(INITIAL_POOL_SIZE);
@@ -42,6 +43,11 @@ public class BasicConnectionPool implements ConnectionPool {
}
Connection connection = connectionPool.remove(connectionPool.size() - 1);
+
+ if(!connection.isValid(MAX_TIMEOUT)){
+ connection = createConnection(url, user, password);
+ }
+
usedConnections.add(connection);
return connection;
}
diff --git a/persistence-modules/hibernate-jpa/README.md b/persistence-modules/hibernate-jpa/README.md
index fb48f975bc..514fcedb8a 100644
--- a/persistence-modules/hibernate-jpa/README.md
+++ b/persistence-modules/hibernate-jpa/README.md
@@ -14,3 +14,4 @@ This module contains articles specific to use of Hibernate as a JPA implementati
- [TransactionRequiredException Error](https://www.baeldung.com/jpa-transaction-required-exception)
- [JPA/Hibernate Persistence Context](https://www.baeldung.com/jpa-hibernate-persistence-context)
- [Quick Guide to EntityManager#getReference()](https://www.baeldung.com/jpa-entity-manager-get-reference)
+- [Hibernate Error “No Persistence Provider for EntityManager”](https://www.baeldung.com/hibernate-no-persistence-provider)
diff --git a/persistence-modules/java-jpa-2/pom.xml b/persistence-modules/java-jpa-2/pom.xml
index f79f6f1633..ab5bb39dfc 100644
--- a/persistence-modules/java-jpa-2/pom.xml
+++ b/persistence-modules/java-jpa-2/pom.xml
@@ -48,6 +48,17 @@
${postgres.version}
runtime
+
+ com.querydsl
+ querydsl-apt
+ ${querydsl.version}
+ provided
+
+
+ com.querydsl
+ querydsl-jpa
+ ${querydsl.version}
+
org.assertj
@@ -101,23 +112,41 @@
target/metamodel
+ ${project.build.directory}/generated-sources/java/
+
+ com.mysema.maven
+ apt-maven-plugin
+ 1.1.3
+
+
+
+ process
+
+
+ target/generated-sources/java
+ com.querydsl.apt.jpa.JPAAnnotationProcessor
+
+
+
+
- 5.4.0.Final
- 2.7.4-RC1
+ 5.4.14.Final
+ 2.7.4
42.2.5
2.2
3.11.1
3.5.1
3.3.3
3.0.0
+ 4.3.1
-
\ No newline at end of file
+
diff --git a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java
new file mode 100644
index 0000000000..96310c1cc5
--- /dev/null
+++ b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java
@@ -0,0 +1,90 @@
+package com.baeldung.jpa.unrelated.entities;
+
+import org.hibernate.annotations.Fetch;
+import org.hibernate.annotations.FetchMode;
+import org.hibernate.annotations.NotFound;
+import org.hibernate.annotations.NotFoundAction;
+
+import javax.persistence.*;
+import java.util.List;
+import java.util.Objects;
+
+@Entity
+@Table(name = "menu")
+public class Cocktail {
+ @Id
+ @Column(name = "cocktail_name")
+ private String name;
+
+ @Column
+ private double price;
+
+ @Column(name = "category")
+ private String category;
+
+ @OneToOne
+ @NotFound(action = NotFoundAction.IGNORE)
+ @JoinColumn(name = "cocktail_name",
+ referencedColumnName = "cocktail",
+ insertable = false, updatable = false,
+ foreignKey = @javax.persistence
+ .ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
+ private Recipe recipe;
+
+ @OneToMany(fetch = FetchType.LAZY)
+ @NotFound(action = NotFoundAction.IGNORE)
+ @JoinColumn(
+ name = "cocktail",
+ referencedColumnName = "cocktail_name",
+ insertable = false,
+ updatable = false,
+ foreignKey = @javax.persistence
+ .ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
+ private List recipeList;
+
+ public Cocktail() {
+ }
+
+ public Cocktail(String name, double price, String baseIngredient) {
+ this.name = name;
+ this.price = price;
+ this.category = baseIngredient;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public double getPrice() {
+ return price;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public Recipe getRecipe() {
+ return recipe;
+ }
+
+ public List getRecipeList() {
+ return recipeList;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ Cocktail cocktail = (Cocktail) o;
+ return Double.compare(cocktail.price, price) == 0 &&
+ Objects.equals(name, cocktail.name) &&
+ Objects.equals(category, cocktail.category);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, price, category);
+ }
+}
diff --git a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/MultipleRecipe.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/MultipleRecipe.java
new file mode 100644
index 0000000000..8664d6fd7f
--- /dev/null
+++ b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/MultipleRecipe.java
@@ -0,0 +1,71 @@
+package com.baeldung.jpa.unrelated.entities;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.util.Objects;
+
+@Entity
+@Table(name = "multiple_recipes")
+public class MultipleRecipe {
+ @Id
+ @Column(name = "id")
+ private Long id;
+
+ @Column(name = "cocktail")
+ private String cocktail;
+
+ @Column(name = "instructions")
+ private String instructions;
+
+ @Column(name = "base_ingredient")
+ private String baseIngredient;
+
+ public MultipleRecipe() {
+ }
+
+ public MultipleRecipe(Long id, String cocktail,
+ String instructions, String baseIngredient) {
+ this.id = id;
+ this.cocktail = cocktail;
+ this.instructions = instructions;
+ this.baseIngredient = baseIngredient;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getCocktail() {
+ return cocktail;
+ }
+
+ public String getInstructions() {
+ return instructions;
+ }
+
+ public String getBaseIngredient() {
+ return baseIngredient;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ MultipleRecipe that = (MultipleRecipe) o;
+
+ return Objects.equals(id, that.id) &&
+ Objects.equals(cocktail, that.cocktail) &&
+ Objects.equals(instructions, that.instructions) &&
+ Objects.equals(baseIngredient, that.baseIngredient);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, cocktail,
+ instructions, baseIngredient);
+ }
+}
diff --git a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Recipe.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Recipe.java
new file mode 100644
index 0000000000..4b3d200b60
--- /dev/null
+++ b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Recipe.java
@@ -0,0 +1,50 @@
+package com.baeldung.jpa.unrelated.entities;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.util.Objects;
+
+@Entity
+@Table(name="recipes")
+public class Recipe {
+ @Id
+ @Column(name = "cocktail")
+ private String cocktail;
+
+ @Column
+ private String instructions;
+
+ public Recipe() {
+ }
+
+ public Recipe(String cocktail, String instructions) {
+ this.cocktail = cocktail;
+ this.instructions = instructions;
+ }
+
+ public String getCocktail() {
+ return cocktail;
+ }
+
+ public String getInstructions() {
+ return instructions;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ Recipe recipe = (Recipe) o;
+ return Objects.equals(cocktail, recipe.cocktail)
+ && Objects.equals(instructions, recipe.instructions);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(cocktail, instructions);
+ }
+}
diff --git a/persistence-modules/java-jpa-2/src/main/resources/META-INF/persistence.xml b/persistence-modules/java-jpa-2/src/main/resources/META-INF/persistence.xml
index 11e007973f..eec7f7cf6e 100644
--- a/persistence-modules/java-jpa-2/src/main/resources/META-INF/persistence.xml
+++ b/persistence-modules/java-jpa-2/src/main/resources/META-INF/persistence.xml
@@ -162,5 +162,26 @@
value="false" />
-
-
\ No newline at end of file
+
+
+ org.hibernate.jpa.HibernatePersistenceProvider
+ com.baeldung.jpa.unrelated.entities.Cocktail
+ com.baeldung.jpa.unrelated.entities.Recipe
+ com.baeldung.jpa.unrelated.entities.MultipleRecipe
+ true
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java
new file mode 100644
index 0000000000..044e59b16e
--- /dev/null
+++ b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java
@@ -0,0 +1,189 @@
+package com.baeldung.jpa.unrelated.entities;
+
+import javax.persistence.*;
+
+import com.querydsl.jpa.impl.JPAQuery;
+import org.junit.jupiter.api.*;
+
+import java.util.List;
+import java.util.function.Consumer;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+public class UnrelatedEntitiesUnitTest {
+ private static EntityManagerFactory entityManagerFactory;
+ private static EntityManager entityManager;
+ private static Cocktail mojito;
+ private static Cocktail ginTonic;
+
+ @BeforeAll
+ public static void setup() {
+ entityManagerFactory = Persistence.createEntityManagerFactory("jpa-h2-unrelated-entities");
+ entityManager = entityManagerFactory.createEntityManager();
+ mojito = new Cocktail("Mojito", 11, "Rum");
+ ginTonic = new Cocktail("Gin tonic", 8.50, "Gin");
+ entityManager.getTransaction().begin();
+ entityManager.persist(mojito);
+ entityManager.persist(ginTonic);
+ entityManager.persist(new Recipe(mojito.getName(), "Some instructions"));
+ entityManager.persist(new MultipleRecipe(1L, mojito.getName(),
+ "some instructions", mojito.getCategory()));
+ entityManager.persist(new MultipleRecipe(2L, mojito.getName(),
+ "some other instructions", mojito.getCategory()));
+ entityManager.getTransaction().commit();
+ }
+
+ @AfterAll
+ public static void closeSession() {
+ entityManager.close();
+ }
+
+
+ @Test
+ public void givenCocktailsWithRecipe_whenQuerying_thenTheExpectedCocktailsReturned() {
+ // JPA
+ Cocktail cocktail = entityManager.createQuery("select c "
+ + "from Cocktail c join c.recipe", Cocktail.class)
+ .getSingleResult();
+ verifyResult(mojito, cocktail);
+
+ cocktail = entityManager.createQuery("select c "
+ + "from Cocktail c join Recipe r "
+ + "on c.name = r.cocktail", Cocktail.class)
+ .getSingleResult();
+ verifyResult(mojito, cocktail);
+
+ // QueryDSL
+ cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail)
+ .join(QCocktail.cocktail.recipe)
+ .fetchOne();
+ verifyResult(mojito, cocktail);
+
+ cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail)
+ .join(QRecipe.recipe)
+ .on(QCocktail.cocktail.name.eq(QRecipe.recipe.cocktail))
+ .fetchOne();
+ verifyResult(mojito, cocktail);
+ }
+
+ @Test
+ public void givenCocktailsWithoutRecipe_whenQuerying_thenTheExpectedCocktailsReturned() {
+ Cocktail cocktail = entityManager.createQuery("select c "
+ + "from Cocktail c left join c.recipe r "
+ + "where r is null", Cocktail.class)
+ .getSingleResult();
+ verifyResult(ginTonic, cocktail);
+
+ cocktail = entityManager.createQuery("select c "
+ + "from Cocktail c left join Recipe r "
+ + "on c.name = r.cocktail "
+ + "where r is null", Cocktail.class)
+ .getSingleResult();
+ verifyResult(ginTonic, cocktail);
+
+ QRecipe recipe = new QRecipe("alias");
+ cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail)
+ .leftJoin(QCocktail.cocktail.recipe, recipe)
+ .where(recipe.isNull())
+ .fetchOne();
+ verifyResult(ginTonic, cocktail);
+
+ cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail)
+ .leftJoin(QRecipe.recipe)
+ .on(QCocktail.cocktail.name.eq(QRecipe.recipe.cocktail))
+ .where(QRecipe.recipe.isNull())
+ .fetchOne();
+ verifyResult(ginTonic, cocktail);
+ }
+
+ @Test
+ public void givenCocktailsWithMultipleRecipes_whenQuerying_thenTheExpectedCocktailsReturned() {
+ // JPQL
+ Cocktail cocktail = entityManager.createQuery("select c "
+ + "from Cocktail c join c.recipeList", Cocktail.class)
+ .getSingleResult();
+ verifyResult(mojito, cocktail);
+
+ cocktail = entityManager.createQuery("select c "
+ + "from Cocktail c join MultipleRecipe mr "
+ + "on mr.cocktail = c.name", Cocktail.class)
+ .getSingleResult();
+ verifyResult(mojito, cocktail);
+
+ // QueryDSL
+ cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail)
+ .join(QCocktail.cocktail.recipeList)
+ .fetchOne();
+ verifyResult(mojito, cocktail);
+
+ cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail)
+ .join(QMultipleRecipe.multipleRecipe)
+ .on(QCocktail.cocktail.name.eq(QMultipleRecipe.multipleRecipe.cocktail))
+ .fetchOne();
+ verifyResult(mojito, cocktail);
+ }
+
+ @Test
+ public void givenCocktailsWithoutMultipleRecipes_whenQuerying_thenTheExpectedCocktailsReturned() {
+ // JPQL
+ Cocktail cocktail = entityManager.createQuery("select c "
+ + "from Cocktail c left join c.recipeList r "
+ + "where r is null", Cocktail.class)
+ .getSingleResult();
+ verifyResult(ginTonic, cocktail);
+
+ cocktail = entityManager.createQuery("select c "
+ + "from Cocktail c left join MultipleRecipe r "
+ + "on c.name = r.cocktail "
+ + "where r is null", Cocktail.class)
+ .getSingleResult();
+ verifyResult(ginTonic, cocktail);
+
+ // QueryDSL
+ QMultipleRecipe multipleRecipe = new QMultipleRecipe("alias");
+ cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail)
+ .leftJoin(QCocktail.cocktail.recipeList, multipleRecipe)
+ .where(multipleRecipe.isNull())
+ .fetchOne();
+ verifyResult(ginTonic, cocktail);
+
+ cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail)
+ .leftJoin(QMultipleRecipe.multipleRecipe)
+ .on(QCocktail.cocktail.name.eq(QMultipleRecipe.multipleRecipe.cocktail))
+ .where(QMultipleRecipe.multipleRecipe.isNull())
+ .fetchOne();
+ verifyResult(ginTonic, cocktail);
+ }
+
+ @Test
+ public void givenMultipleRecipesWithCocktails_whenQuerying_thenTheExpectedMultipleRecipesReturned() {
+ Consumer> verifyResult = recipes -> {
+ assertEquals(2, recipes.size());
+ recipes.forEach(r -> assertEquals(mojito.getName(), r.getCocktail()));
+ };
+
+ // JPQL
+ List recipes = entityManager.createQuery("select distinct r "
+ + "from MultipleRecipe r "
+ + "join Cocktail c "
+ + "on r.baseIngredient = c.category",
+ MultipleRecipe.class).getResultList();
+
+ verifyResult.accept(recipes);
+
+ // QueryDSL
+ QCocktail cocktail = QCocktail.cocktail;
+ QMultipleRecipe multipleRecipe = QMultipleRecipe.multipleRecipe;
+ recipes = new JPAQuery(entityManager).from(multipleRecipe)
+ .join(cocktail)
+ .on(multipleRecipe.baseIngredient.eq(cocktail.category))
+ .fetch();
+
+ verifyResult.accept(recipes);
+ }
+
+ private void verifyResult(Cocktail expectedCocktail, Cocktail queryResult) {
+ assertNotNull(queryResult);
+ assertEquals(expectedCocktail, queryResult);
+ }
+}
diff --git a/persistence-modules/java-jpa/pom.xml b/persistence-modules/java-jpa/pom.xml
index 762c541d96..3601721dac 100644
--- a/persistence-modules/java-jpa/pom.xml
+++ b/persistence-modules/java-jpa/pom.xml
@@ -106,7 +106,7 @@
5.4.0.Final
- 2.7.4-RC1
+ 2.7.4
42.2.5
2.2
3.3.3
diff --git a/persistence-modules/java-mongodb/README.md b/persistence-modules/java-mongodb/README.md
index 5c3c448b03..b79cea6781 100644
--- a/persistence-modules/java-mongodb/README.md
+++ b/persistence-modules/java-mongodb/README.md
@@ -11,3 +11,4 @@ This module contains articles about MongoDB in Java.
- [Introduction to Morphia – Java ODM for MongoDB](https://www.baeldung.com/mongodb-morphia)
- [MongoDB Aggregations Using Java](https://www.baeldung.com/java-mongodb-aggregations)
- [MongoDB BSON to JSON](https://www.baeldung.com/bson-to-json)
+- [BSON to JSON Document Conversion in Java](https://www.baeldung.com/java-convert-bson-to-json)
diff --git a/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonIntegrationTest.java b/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonLiveTest.java
similarity index 96%
rename from persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonIntegrationTest.java
rename to persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonLiveTest.java
index e382ea4ab2..4e70394069 100644
--- a/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonIntegrationTest.java
+++ b/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonLiveTest.java
@@ -1,142 +1,142 @@
-package com.baeldung.bsontojson;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.bson.Document;
-import org.bson.json.Converter;
-import org.bson.json.JsonMode;
-import org.bson.json.JsonWriterSettings;
-import org.bson.json.StrictJsonWriter;
-import org.bson.types.ObjectId;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.jupiter.api.AfterEach;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.baeldung.morphia.domain.Book;
-import com.baeldung.morphia.domain.Publisher;
-import com.mongodb.MongoClient;
-import com.mongodb.client.MongoDatabase;
-
-import dev.morphia.Datastore;
-import dev.morphia.Morphia;
-
-public class BsonToJsonIntegrationTest {
-
- private static final String DB_NAME = "library";
- private static Datastore datastore;
-
- @BeforeClass
- public static void setUp() {
- Morphia morphia = new Morphia();
- morphia.mapPackage("com.baeldung.morphia");
- datastore = morphia.createDatastore(new MongoClient(), DB_NAME);
- datastore.ensureIndexes();
-
- datastore.save(new Book()
- .setIsbn("isbn")
- .setTitle("title")
- .setAuthor("author")
- .setCost(3.95)
- .setPublisher(new Publisher(new ObjectId("fffffffffffffffffffffffa"),"publisher"))
- .setPublishDate(LocalDateTime.parse("2020-01-01T18:13:32Z", DateTimeFormatter.ISO_DATE_TIME))
- .addCompanionBooks(new Book().setIsbn("isbn2")));
- }
-
- @AfterClass
- public static void tearDown() {
- datastore.delete(datastore.createQuery(Book.class));
- }
-
- @Test
- public void givenBsonDocument_whenUsingStandardJsonTransformation_thenJsonDateIsObjectEpochTime() {
-
- String json = null;
- try (MongoClient mongoClient = new MongoClient()) {
- MongoDatabase mongoDatabase = mongoClient.getDatabase(DB_NAME);
- Document bson = mongoDatabase.getCollection("Books").find().first();
- json = bson.toJson();
- }
-
- String expectedJson = "{\"_id\": \"isbn\", " +
- "\"className\": \"com.baeldung.morphia.domain.Book\", " +
- "\"title\": \"title\", " +
- "\"author\": \"author\", " +
- "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " +
- "\"name\": \"publisher\"}, " +
- "\"price\": 3.95, " +
- "\"publishDate\": {\"$date\": 1577898812000}}";
-
- assertNotNull(json);
-
- assertEquals(expectedJson, json);
- }
-
-
- @Test
- public void givenBsonDocument_whenUsingRelaxedJsonTransformation_thenJsonDateIsObjectIsoDate() {
-
- String json = null;
- try (MongoClient mongoClient = new MongoClient()) {
- MongoDatabase mongoDatabase = mongoClient.getDatabase(DB_NAME);
- Document bson = mongoDatabase.getCollection("Books").find().first();
- json = bson.toJson(JsonWriterSettings
- .builder()
- .outputMode(JsonMode.RELAXED)
- .build());
- }
-
- String expectedJson = "{\"_id\": \"isbn\", " +
- "\"className\": \"com.baeldung.morphia.domain.Book\", " +
- "\"title\": \"title\", " +
- "\"author\": \"author\", " +
- "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " +
- "\"name\": \"publisher\"}, " +
- "\"price\": 3.95, " +
- "\"publishDate\": {\"$date\": \"2020-01-01T17:13:32Z\"}}";
-
- assertNotNull(json);
-
- assertEquals(expectedJson, json);
- }
-
- @Test
- public void givenBsonDocument_whenUsingCustomJsonTransformation_thenJsonDateIsStringField() {
-
- String json = null;
- try (MongoClient mongoClient = new MongoClient()) {
- MongoDatabase mongoDatabase = mongoClient.getDatabase(DB_NAME);
- Document bson = mongoDatabase.getCollection("Books").find().first();
- json = bson.toJson(JsonWriterSettings
- .builder()
- .dateTimeConverter(new JsonDateTimeConverter())
- .build());
- }
-
- String expectedJson = "{\"_id\": \"isbn\", " +
- "\"className\": \"com.baeldung.morphia.domain.Book\", " +
- "\"title\": \"title\", " +
- "\"author\": \"author\", " +
- "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " +
- "\"name\": \"publisher\"}, " +
- "\"price\": 3.95, " +
- "\"publishDate\": \"2020-01-01T17:13:32Z\"}";
-
- assertEquals(expectedJson, json);
-
- }
-
-}
+package com.baeldung.bsontojson;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.sql.Timestamp;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.bson.Document;
+import org.bson.json.Converter;
+import org.bson.json.JsonMode;
+import org.bson.json.JsonWriterSettings;
+import org.bson.json.StrictJsonWriter;
+import org.bson.types.ObjectId;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.baeldung.morphia.domain.Book;
+import com.baeldung.morphia.domain.Publisher;
+import com.mongodb.MongoClient;
+import com.mongodb.client.MongoDatabase;
+
+import dev.morphia.Datastore;
+import dev.morphia.Morphia;
+
+public class BsonToJsonLiveTest {
+
+ private static final String DB_NAME = "library";
+ private static Datastore datastore;
+
+ @BeforeClass
+ public static void setUp() {
+ Morphia morphia = new Morphia();
+ morphia.mapPackage("com.baeldung.morphia");
+ datastore = morphia.createDatastore(new MongoClient(), DB_NAME);
+ datastore.ensureIndexes();
+
+ datastore.save(new Book()
+ .setIsbn("isbn")
+ .setTitle("title")
+ .setAuthor("author")
+ .setCost(3.95)
+ .setPublisher(new Publisher(new ObjectId("fffffffffffffffffffffffa"),"publisher"))
+ .setPublishDate(LocalDateTime.parse("2020-01-01T18:13:32Z", DateTimeFormatter.ISO_DATE_TIME))
+ .addCompanionBooks(new Book().setIsbn("isbn2")));
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ datastore.delete(datastore.createQuery(Book.class));
+ }
+
+ @Test
+ public void givenBsonDocument_whenUsingStandardJsonTransformation_thenJsonDateIsObjectEpochTime() {
+
+ String json = null;
+ try (MongoClient mongoClient = new MongoClient()) {
+ MongoDatabase mongoDatabase = mongoClient.getDatabase(DB_NAME);
+ Document bson = mongoDatabase.getCollection("Books").find().first();
+ json = bson.toJson();
+ }
+
+ String expectedJson = "{\"_id\": \"isbn\", " +
+ "\"className\": \"com.baeldung.morphia.domain.Book\", " +
+ "\"title\": \"title\", " +
+ "\"author\": \"author\", " +
+ "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " +
+ "\"name\": \"publisher\"}, " +
+ "\"price\": 3.95, " +
+ "\"publishDate\": {\"$date\": 1577898812000}}";
+
+ assertNotNull(json);
+
+ assertEquals(expectedJson, json);
+ }
+
+
+ @Test
+ public void givenBsonDocument_whenUsingRelaxedJsonTransformation_thenJsonDateIsObjectIsoDate() {
+
+ String json = null;
+ try (MongoClient mongoClient = new MongoClient()) {
+ MongoDatabase mongoDatabase = mongoClient.getDatabase(DB_NAME);
+ Document bson = mongoDatabase.getCollection("Books").find().first();
+ json = bson.toJson(JsonWriterSettings
+ .builder()
+ .outputMode(JsonMode.RELAXED)
+ .build());
+ }
+
+ String expectedJson = "{\"_id\": \"isbn\", " +
+ "\"className\": \"com.baeldung.morphia.domain.Book\", " +
+ "\"title\": \"title\", " +
+ "\"author\": \"author\", " +
+ "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " +
+ "\"name\": \"publisher\"}, " +
+ "\"price\": 3.95, " +
+ "\"publishDate\": {\"$date\": \"2020-01-01T17:13:32Z\"}}";
+
+ assertNotNull(json);
+
+ assertEquals(expectedJson, json);
+ }
+
+ @Test
+ public void givenBsonDocument_whenUsingCustomJsonTransformation_thenJsonDateIsStringField() {
+
+ String json = null;
+ try (MongoClient mongoClient = new MongoClient()) {
+ MongoDatabase mongoDatabase = mongoClient.getDatabase(DB_NAME);
+ Document bson = mongoDatabase.getCollection("Books").find().first();
+ json = bson.toJson(JsonWriterSettings
+ .builder()
+ .dateTimeConverter(new JsonDateTimeConverter())
+ .build());
+ }
+
+ String expectedJson = "{\"_id\": \"isbn\", " +
+ "\"className\": \"com.baeldung.morphia.domain.Book\", " +
+ "\"title\": \"title\", " +
+ "\"author\": \"author\", " +
+ "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " +
+ "\"name\": \"publisher\"}, " +
+ "\"price\": 3.95, " +
+ "\"publishDate\": \"2020-01-01T17:13:32Z\"}";
+
+ assertEquals(expectedJson, json);
+
+ }
+
+}
diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml
index ec7f0bcec2..78da896861 100644
--- a/persistence-modules/pom.xml
+++ b/persistence-modules/pom.xml
@@ -61,6 +61,7 @@
spring-data-jpa-2
spring-data-jpa-3
spring-data-jpa-4
+ spring-data-jpa-5
spring-data-keyvalue
spring-data-mongodb
spring-data-neo4j
diff --git a/persistence-modules/redis/pom.xml b/persistence-modules/redis/pom.xml
index fffcfbb96b..c9206e5f92 100644
--- a/persistence-modules/redis/pom.xml
+++ b/persistence-modules/redis/pom.xml
@@ -9,16 +9,31 @@
com.baeldung
- persistence-modules
- 1.0.0-SNAPSHOT
+ parent-boot-2
+ 0.0.1-SNAPSHOT
+ ../../parent-boot-2
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
redis.clients
jedis
- ${jedis.version}
-
+
com.github.kstyrc
embedded-redis
@@ -32,15 +47,12 @@
io.lettuce
lettuce-core
- ${lettuce-core.version}
-
+
-
- 3.2.0
+
0.6
- 3.3.0
- 5.0.1.RELEASE
+ 3.3.0
diff --git a/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/RedisConfig.java b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/RedisConfig.java
new file mode 100644
index 0000000000..ad43ad8159
--- /dev/null
+++ b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/RedisConfig.java
@@ -0,0 +1,24 @@
+package com.baeldung.spring.redis.configuration;
+
+import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+
+import com.baeldung.spring.redis.configuration.entity.Book;
+
+@Configuration
+@EnableConfigurationProperties(RedisProperties.class)
+public class RedisConfig {
+
+ @Bean
+ public RedisTemplate redisTemplate(RedisConnectionFactory connectionFactory) {
+ RedisTemplate template = new RedisTemplate<>();
+ template.setConnectionFactory(connectionFactory);
+ // Add some specific configuration here. Key serializers, etc.
+ return template;
+ }
+
+}
diff --git a/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/SpringRedisConfigurationApplication.java b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/SpringRedisConfigurationApplication.java
new file mode 100644
index 0000000000..932a6b7478
--- /dev/null
+++ b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/SpringRedisConfigurationApplication.java
@@ -0,0 +1,19 @@
+package com.baeldung.spring.redis.configuration;
+
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SpringRedisConfigurationApplication implements CommandLineRunner {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringRedisConfigurationApplication.class, args);
+ }
+
+ @Override
+ public void run(String... args) throws Exception {
+
+ }
+
+}
diff --git a/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/controller/BooksController.java b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/controller/BooksController.java
new file mode 100644
index 0000000000..b3faf030c9
--- /dev/null
+++ b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/controller/BooksController.java
@@ -0,0 +1,32 @@
+package com.baeldung.spring.redis.configuration.controller;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.baeldung.spring.redis.configuration.entity.Book;
+import com.baeldung.spring.redis.configuration.repository.BooksRepository;
+
+@RestController
+@RequestMapping("/books")
+public class BooksController {
+
+ @Autowired
+ private BooksRepository repository;
+
+ @PostMapping("/create")
+ public String newBook(@RequestBody Book newBook) {
+ repository.save(newBook);
+ return "Added";
+ }
+
+ @GetMapping("/get/{id}")
+ public Book findOne(@PathVariable Long id) {
+ return repository.findById(id);
+ }
+
+}
diff --git a/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/entity/Book.java b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/entity/Book.java
new file mode 100644
index 0000000000..52d579d4fb
--- /dev/null
+++ b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/entity/Book.java
@@ -0,0 +1,46 @@
+package com.baeldung.spring.redis.configuration.entity;
+
+import java.io.Serializable;
+
+public class Book implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private Long id;
+
+ private String name;
+
+ public Book() {
+ }
+
+ public Book(String name) {
+ this.name = name;
+ }
+
+ public Book(Long id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return "Book [id=" + id + ", name=" + name + "]";
+ }
+
+}
diff --git a/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/repository/BooksRepository.java b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/repository/BooksRepository.java
new file mode 100644
index 0000000000..a6eba0e742
--- /dev/null
+++ b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/repository/BooksRepository.java
@@ -0,0 +1,25 @@
+package com.baeldung.spring.redis.configuration.repository;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+
+import com.baeldung.spring.redis.configuration.entity.Book;
+
+@Component
+public class BooksRepository {
+
+ @Autowired
+ private RedisTemplate redisTemplate;
+
+ public void save(Book book) {
+ redisTemplate.opsForValue()
+ .set(book.getId(), book);
+ }
+
+ public Book findById(Long id) {
+ return redisTemplate.opsForValue()
+ .get(id);
+ }
+
+}
diff --git a/persistence-modules/redis/src/main/resources/application.properties b/persistence-modules/redis/src/main/resources/application.properties
new file mode 100644
index 0000000000..e3140c4e29
--- /dev/null
+++ b/persistence-modules/redis/src/main/resources/application.properties
@@ -0,0 +1,9 @@
+spring.redis.database=0
+spring.redis.host=localhost
+spring.redis.port=16379
+spring.redis.password=mypass
+spring.redis.timeout=60000
+spring.redis.lettuce.pool.max-active=8
+spring.redis.lettuce.pool.max-idle=8
+spring.redis.lettuce.pool.max-wait=-1
+spring.redis.lettuce.pool.min-idle=0
\ No newline at end of file
diff --git a/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/controller/BooksControllerUnitTest.java b/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/controller/BooksControllerUnitTest.java
new file mode 100644
index 0000000000..a5c3340065
--- /dev/null
+++ b/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/controller/BooksControllerUnitTest.java
@@ -0,0 +1,52 @@
+package com.baeldung.spring.redis.configuration.controller;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.mockito.Mockito.when;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.baeldung.spring.redis.configuration.entity.Book;
+import com.baeldung.spring.redis.configuration.repository.BooksRepository;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+public class BooksControllerUnitTest {
+
+ @Spy
+ @InjectMocks
+ private BooksController booksController;
+
+ @Mock
+ private BooksRepository booksRepository;
+
+ private static final Long BOOK_ID = 1l;
+ private static final Long OTHER_BOOK_ID = 2l;
+ private static final String BOOK_NAME = "Ulysses";
+ private static final String ADDED = "Added";
+
+ @Test
+ public void whenNewBook_thenCorrect() {
+ assertEquals(ADDED, booksController.newBook(new Book(BOOK_ID, BOOK_NAME)));
+ }
+
+ @Test
+ public void whenFindOneFinds_thenCorrect() {
+ Book book = new Book(BOOK_ID, BOOK_NAME);
+ when(booksRepository.findById(BOOK_ID)).thenReturn(book);
+ assertSame(book, booksController.findOne(BOOK_ID));
+ }
+
+ @Test
+ public void whenFindOneNotFound_thenReturnsNull() {
+ Book book = new Book(BOOK_ID, BOOK_NAME);
+ when(booksRepository.findById(BOOK_ID)).thenReturn(book);
+ assertNull(booksController.findOne(OTHER_BOOK_ID));
+ }
+
+}
diff --git a/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/repository/BooksRepositoryUnitTest.java b/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/repository/BooksRepositoryUnitTest.java
new file mode 100644
index 0000000000..1edf9c7e89
--- /dev/null
+++ b/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/repository/BooksRepositoryUnitTest.java
@@ -0,0 +1,66 @@
+package com.baeldung.spring.redis.configuration.repository;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.ValueOperations;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.baeldung.spring.redis.configuration.entity.Book;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+public class BooksRepositoryUnitTest {
+
+ @Spy
+ @InjectMocks
+ private BooksRepository booksRepository;
+
+ @Mock
+ private RedisTemplate redisTemplate;
+
+ @Mock
+ private ValueOperations valueOperations;
+
+ private static final Long BOOK_ID = 1l;
+ private static final Long OTHER_BOOK_ID = 2l;
+ private static final String BOOK_NAME = "Ulysses";
+
+ @Test
+ public void whenSave_thenCorrect() {
+ Book book = new Book(BOOK_ID, BOOK_NAME);
+ when(redisTemplate.opsForValue()).thenReturn(valueOperations);
+ booksRepository.save(book);
+ verify(redisTemplate, times(1)).opsForValue();
+ verify(valueOperations, times(1)).set(BOOK_ID, book);
+ }
+
+ @Test
+ public void whenFindByIdFound_thenReturnsBook() {
+ Book book = new Book(BOOK_ID, BOOK_NAME);
+ when(redisTemplate.opsForValue()).thenReturn(valueOperations);
+ when(valueOperations.get(BOOK_ID)).thenReturn(book);
+ assertSame(book, booksRepository.findById(BOOK_ID));
+ verify(redisTemplate, times(1)).opsForValue();
+ verify(valueOperations, times(1)).get(BOOK_ID);
+ }
+
+ @Test
+ public void whenFindByIdNotFound_thenReturnsNull() {
+ Book book = new Book(BOOK_ID, BOOK_NAME);
+ when(redisTemplate.opsForValue()).thenReturn(valueOperations);
+ when(valueOperations.get(BOOK_ID)).thenReturn(book);
+ assertNull(booksRepository.findById(OTHER_BOOK_ID));
+ verify(redisTemplate, times(1)).opsForValue();
+ verify(valueOperations, times(1)).get(OTHER_BOOK_ID);
+ }
+
+}
diff --git a/persistence-modules/spring-boot-persistence-2/README.md b/persistence-modules/spring-boot-persistence-2/README.md
index 5d171fb2ca..3ea93db4fe 100644
--- a/persistence-modules/spring-boot-persistence-2/README.md
+++ b/persistence-modules/spring-boot-persistence-2/README.md
@@ -1,3 +1,4 @@
### Relevant Articles:
- [Using JDBI with Spring Boot](https://www.baeldung.com/spring-boot-jdbi)
+- [Oracle Connection Pooling With Spring](https://www.baeldung.com/spring-oracle-connection-pooling)
diff --git a/persistence-modules/spring-data-dynamodb/pom.xml b/persistence-modules/spring-data-dynamodb/pom.xml
index fceceb40ba..377e35b635 100644
--- a/persistence-modules/spring-data-dynamodb/pom.xml
+++ b/persistence-modules/spring-data-dynamodb/pom.xml
@@ -9,9 +9,9 @@
com.baeldung
- parent-boot-1
+ parent-boot-2
0.0.1-SNAPSHOT
- ../../parent-boot-1
+ ../../parent-boot-2
@@ -19,7 +19,7 @@
org.springframework.data
spring-data-releasetrain
- Hopper-SR10
+ Lovelace-SR16
pom
import
@@ -174,7 +174,7 @@
com.baeldung.Application
4.3.4.RELEASE
4.5.2
- 4.4.1
+ 5.1.0
1.11.64
3.3.7-1
1.0.392
diff --git a/persistence-modules/spring-data-dynamodb/src/main/java/com/baeldung/spring/data/dynamodb/config/DynamoDBConfig.java b/persistence-modules/spring-data-dynamodb/src/main/java/com/baeldung/spring/data/dynamodb/config/DynamoDBConfig.java
index 9278c0a12e..7e97e6b383 100644
--- a/persistence-modules/spring-data-dynamodb/src/main/java/com/baeldung/spring/data/dynamodb/config/DynamoDBConfig.java
+++ b/persistence-modules/spring-data-dynamodb/src/main/java/com/baeldung/spring/data/dynamodb/config/DynamoDBConfig.java
@@ -44,8 +44,8 @@ public class DynamoDBConfig {
return new BasicAWSCredentials(amazonAWSAccessKey, amazonAWSSecretKey);
}
- @Bean(name = "mvcHandlerMappingIntrospector")
- public HandlerMappingIntrospector mvcHandlerMappingIntrospector() {
+ @Bean(name = "mvcHandlerMappingIntrospectorCustom")
+ public HandlerMappingIntrospector mvcHandlerMappingIntrospectorCustom() {
return new HandlerMappingIntrospector(context);
}
}
diff --git a/persistence-modules/spring-data-dynamodb/src/main/java/com/baeldung/spring/data/dynamodb/repositories/ProductInfoRepository.java b/persistence-modules/spring-data-dynamodb/src/main/java/com/baeldung/spring/data/dynamodb/repositories/ProductInfoRepository.java
index da47f033b6..6e8b493c3b 100644
--- a/persistence-modules/spring-data-dynamodb/src/main/java/com/baeldung/spring/data/dynamodb/repositories/ProductInfoRepository.java
+++ b/persistence-modules/spring-data-dynamodb/src/main/java/com/baeldung/spring/data/dynamodb/repositories/ProductInfoRepository.java
@@ -1,12 +1,13 @@
package com.baeldung.spring.data.dynamodb.repositories;
-import com.baeldung.spring.data.dynamodb.model.ProductInfo;
+import java.util.Optional;
+
import org.socialsignin.spring.data.dynamodb.repository.EnableScan;
import org.springframework.data.repository.CrudRepository;
-import java.util.List;
+import com.baeldung.spring.data.dynamodb.model.ProductInfo;
@EnableScan
public interface ProductInfoRepository extends CrudRepository {
- List findById(String id);
+ Optional findById(String id);
}
diff --git a/persistence-modules/spring-data-jpa-4/README.md b/persistence-modules/spring-data-jpa-4/README.md
index 3884435f75..085dfcb366 100644
--- a/persistence-modules/spring-data-jpa-4/README.md
+++ b/persistence-modules/spring-data-jpa-4/README.md
@@ -6,6 +6,7 @@
- [JPA Entity Lifecycle Events](https://www.baeldung.com/jpa-entity-lifecycle-events)
- [Working with Lazy Element Collections in JPA](https://www.baeldung.com/java-jpa-lazy-collections)
- [Calling Stored Procedures from Spring Data JPA Repositories](https://www.baeldung.com/spring-data-jpa-stored-procedures)
+- [Custom Naming Convention with Spring Data JPA](https://www.baeldung.com/spring-data-jpa-custom-naming)
### Eclipse Config
After importing the project into Eclipse, you may see the following error:
diff --git a/persistence-modules/spring-data-jpa-5/README.md b/persistence-modules/spring-data-jpa-5/README.md
new file mode 100644
index 0000000000..e8f83654df
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-5/README.md
@@ -0,0 +1,13 @@
+### Relevant Articles:
+
+- [Spring JPA @Embedded and @EmbeddedId](TBD)
+
+### Eclipse Config
+After importing the project into Eclipse, you may see the following error:
+"No persistence xml file found in project"
+
+This can be ignored:
+- Project -> Properties -> Java Persistance -> JPA -> Error/Warnings -> Select Ignore on "No persistence xml file found in project"
+Or:
+- Eclipse -> Preferences - Validation - disable the "Build" execution of the JPA Validator
+
diff --git a/persistence-modules/spring-data-jpa-5/pom.xml b/persistence-modules/spring-data-jpa-5/pom.xml
new file mode 100644
index 0000000000..3053384559
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-5/pom.xml
@@ -0,0 +1,37 @@
+
+
+ 4.0.0
+ spring-data-jpa-5
+ spring-data-jpa-5
+
+
+ com.baeldung
+ parent-boot-2
+ 0.0.1-SNAPSHOT
+ ../../parent-boot-2
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jdbc
+
+
+
+ com.h2database
+ h2
+
+
+
+
diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/BookApplication.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/BookApplication.java
new file mode 100644
index 0000000000..52f06058aa
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/BookApplication.java
@@ -0,0 +1,12 @@
+package com.baeldung.composite;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class BookApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(BookApplication.class);
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/entity/Book.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/entity/Book.java
new file mode 100644
index 0000000000..e4f1727654
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/entity/Book.java
@@ -0,0 +1,47 @@
+package com.baeldung.composite.entity;
+
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+
+@Entity
+public class Book {
+
+ @EmbeddedId
+ private BookId id;
+ private String genre;
+ private Integer price;
+
+ public Book() {
+ }
+
+ public Book(String author, String name, String genre, Integer price) {
+ BookId id = new BookId(author, name);
+ this.id = id;
+ this.genre = genre;
+ this.price = price;
+ }
+
+ public BookId getId() {
+ return id;
+ }
+
+ public void setId(BookId id) {
+ this.id = id;
+ }
+
+ public String getGenre() {
+ return genre;
+ }
+
+ public void setGenre(String genre) {
+ this.genre = genre;
+ }
+
+ public Integer getPrice() {
+ return price;
+ }
+
+ public void setPrice(Integer price) {
+ this.price = price;
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/entity/BookId.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/entity/BookId.java
new file mode 100644
index 0000000000..1524452412
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/entity/BookId.java
@@ -0,0 +1,51 @@
+package com.baeldung.composite.entity;
+
+import javax.persistence.Embeddable;
+import java.io.Serializable;
+import java.util.Objects;
+
+@Embeddable
+public class BookId implements Serializable {
+
+ private String author;
+ private String name;
+
+ public BookId() {
+ }
+
+ public BookId(String author, String name) {
+ this.author = author;
+ this.name = name;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ BookId bookId = (BookId) o;
+ return Objects.equals(author, bookId.author) && Objects.equals(name, bookId.name);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(author, name);
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/repository/BookRepository.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/repository/BookRepository.java
new file mode 100644
index 0000000000..d5993eaf79
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/repository/BookRepository.java
@@ -0,0 +1,18 @@
+package com.baeldung.composite.repository;
+
+import com.baeldung.composite.entity.Book;
+import com.baeldung.composite.entity.BookId;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface BookRepository extends JpaRepository {
+
+ List findByIdName(String name);
+
+ List findByIdAuthor(String author);
+
+ List findByGenre(String genre);
+}
diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/AccountApplication.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/AccountApplication.java
new file mode 100644
index 0000000000..547992a6c1
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/AccountApplication.java
@@ -0,0 +1,12 @@
+package com.baeldung.schemageneration;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class AccountApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(AccountApplication.class, args);
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/HibernateUtil.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/HibernateUtil.java
new file mode 100644
index 0000000000..7d69d65705
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/HibernateUtil.java
@@ -0,0 +1,39 @@
+package com.baeldung.schemageneration;
+
+import com.baeldung.schemageneration.model.Account;
+import com.baeldung.schemageneration.model.AccountSetting;
+import org.hibernate.boot.Metadata;
+import org.hibernate.boot.MetadataSources;
+import org.hibernate.boot.registry.StandardServiceRegistry;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.cfg.Environment;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
+import org.hibernate.tool.schema.TargetType;
+
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
+
+public class HibernateUtil {
+
+ /**
+ * Generates database create commands for the specified entities using Hibernate native API, SchemaExport.
+ * Creation commands are exported into the create.sql file.
+ */
+ public static void generateSchema() {
+ Map settings = new HashMap<>();
+ settings.put(Environment.URL, "jdbc:h2:mem:schema");
+
+ StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(settings).build();
+
+ MetadataSources metadataSources = new MetadataSources(serviceRegistry);
+ metadataSources.addAnnotatedClass(Account.class);
+ metadataSources.addAnnotatedClass(AccountSetting.class);
+ Metadata metadata = metadataSources.buildMetadata();
+
+ SchemaExport schemaExport = new SchemaExport();
+ schemaExport.setFormat(true);
+ schemaExport.setOutputFile("create.sql");
+ schemaExport.createOnly(EnumSet.of(TargetType.SCRIPT), metadata);
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/model/Account.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/model/Account.java
new file mode 100644
index 0000000000..785e275e26
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/model/Account.java
@@ -0,0 +1,74 @@
+package com.baeldung.schemageneration.model;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import java.util.ArrayList;
+import java.util.List;
+
+@Entity
+@Table(name = "accounts")
+public class Account {
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ @Column(nullable = false, length = 100)
+ private String name;
+
+ @Column(name = "email_address")
+ private String emailAddress;
+
+ @OneToMany(mappedBy = "account", cascade = CascadeType.ALL)
+ private List accountSettings = new ArrayList<>();
+
+ public Account() {
+ }
+
+ public Account(String name, String emailAddress) {
+ this.name = name;
+ this.emailAddress = emailAddress;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getEmailAddress() {
+ return emailAddress;
+ }
+
+ public void setEmailAddress(String emailAddress) {
+ this.emailAddress = emailAddress;
+ }
+
+ public List getAccountSettings() {
+ return accountSettings;
+ }
+
+ public void setAccountSettings(List accountSettings) {
+ this.accountSettings = accountSettings;
+ }
+
+ public void addAccountSetting(AccountSetting setting) {
+ this.accountSettings.add(setting);
+ setting.setAccount(this);
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/model/AccountSetting.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/model/AccountSetting.java
new file mode 100644
index 0000000000..61e43894a8
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/model/AccountSetting.java
@@ -0,0 +1,68 @@
+package com.baeldung.schemageneration.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "account_settings")
+public class AccountSetting {
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ @Column(name = "name", nullable = false)
+ private String settingName;
+
+ @Column(name = "value", nullable = false)
+ private String settingValue;
+
+ @ManyToOne()
+ @JoinColumn(name ="account_id", nullable = false)
+ private Account account;
+
+ public AccountSetting() {
+ }
+
+ public AccountSetting(String settingName, String settingValue) {
+ this.settingName = settingName;
+ this.settingValue = settingValue;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getSettingName() {
+ return settingName;
+ }
+
+ public void setSettingName(String settingName) {
+ this.settingName = settingName;
+ }
+
+ public String getSettingValue() {
+ return settingValue;
+ }
+
+ public void setSettingValue(String settingValue) {
+ this.settingValue = settingValue;
+ }
+
+ public Account getAccount() {
+ return account;
+ }
+
+ public void setAccount(Account account) {
+ this.account = account;
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/repository/AccountRepository.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/repository/AccountRepository.java
new file mode 100644
index 0000000000..dc57ffe6d3
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/repository/AccountRepository.java
@@ -0,0 +1,8 @@
+package com.baeldung.schemageneration.repository;
+
+import com.baeldung.schemageneration.model.Account;
+import org.springframework.data.repository.CrudRepository;
+
+public interface AccountRepository extends CrudRepository {
+ Account findByName(String name);
+}
diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/repository/AccountSettingRepository.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/repository/AccountSettingRepository.java
new file mode 100644
index 0000000000..c2b8ff7398
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/repository/AccountSettingRepository.java
@@ -0,0 +1,8 @@
+package com.baeldung.schemageneration.repository;
+
+import com.baeldung.schemageneration.model.AccountSetting;
+import org.springframework.data.repository.CrudRepository;
+
+public interface AccountSettingRepository extends CrudRepository {
+ AccountSetting findByAccountId(Long accountId);
+}
diff --git a/persistence-modules/spring-data-jpa-5/src/main/resources/application.properties b/persistence-modules/spring-data-jpa-5/src/main/resources/application.properties
new file mode 100644
index 0000000000..f55ad438ff
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-5/src/main/resources/application.properties
@@ -0,0 +1,13 @@
+
+spring.datasource.url=jdbc:h2:mem:baeldung
+
+# JPA-Schema-Generation
+# Use below configuration to generate database schema create commands based on the entity models
+# and export them into the create.sql file
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=create.sql
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-source=metadata
+#spring.jpa.properties.hibernate.format_sql=true
+
+spring.jpa.show-sql=true
+
diff --git a/persistence-modules/spring-data-jpa-5/src/test/java/com/baeldung/composite/repository/BookRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-5/src/test/java/com/baeldung/composite/repository/BookRepositoryIntegrationTest.java
new file mode 100644
index 0000000000..9d25acbd96
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-5/src/test/java/com/baeldung/composite/repository/BookRepositoryIntegrationTest.java
@@ -0,0 +1,64 @@
+package com.baeldung.composite.repository;
+
+import com.baeldung.composite.BookApplication;
+import com.baeldung.composite.entity.Book;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = BookApplication.class)
+public class BookRepositoryIntegrationTest {
+
+ public static final String JAVA_101 = "Java101";
+ public static final String JANE = "Jane";
+ public static final String TECH = "Tech";
+ @Autowired
+ BookRepository repository;
+
+ @Before
+ public void setUp() {
+ Book book1 = new Book("John", JAVA_101, TECH, 20);
+ Book book2 = new Book(JANE, JAVA_101, "Arch", 25);
+ Book book3 = new Book(JANE, "Scala101", TECH, 23);
+
+ repository.saveAll(Arrays.asList(book1, book2, book3));
+ }
+
+ @After
+ public void tearDown() {
+ repository.deleteAll();
+ }
+
+ @Test
+ public void testFindByName() {
+ List books = repository.findByIdName(JAVA_101);
+
+ assertEquals(2, books.size());
+ }
+
+ @Test
+ public void testFindByAuthor() {
+ List books = repository.findByIdAuthor(JANE);
+
+ assertEquals(2, books.size());
+ }
+
+ @Test
+ public void testFindByGenre() {
+ List books = repository.findByGenre(TECH);
+
+ assertEquals(2, books.size());
+ }
+}
\ No newline at end of file
diff --git a/persistence-modules/spring-data-jpa-5/src/test/java/com/baeldung/schemageneration/AccountRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-5/src/test/java/com/baeldung/schemageneration/AccountRepositoryIntegrationTest.java
new file mode 100644
index 0000000000..86a7671fe4
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-5/src/test/java/com/baeldung/schemageneration/AccountRepositoryIntegrationTest.java
@@ -0,0 +1,72 @@
+package com.baeldung.schemageneration;
+
+import com.baeldung.schemageneration.model.Account;
+import com.baeldung.schemageneration.model.AccountSetting;
+import com.baeldung.schemageneration.repository.AccountRepository;
+import com.baeldung.schemageneration.repository.AccountSettingRepository;
+import org.junit.After;
+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.test.context.junit4.SpringRunner;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = AccountApplication.class)
+public class AccountRepositoryIntegrationTest {
+
+ private static final String USER_NAME = "Eduard";
+ private static final String USER_EMAIL_ADDRESS = "eduard@gmx.com";
+ private static final String ACCOUNT_SETTING_NAME = "Timezone";
+ private static final String ACCOUNT_SETTING_VALUE = "UTC+02";
+
+ @Autowired
+ private AccountRepository accountRepository;
+
+ @Autowired
+ private AccountSettingRepository accountSettingRepository;
+
+ @After
+ public void tearDown() {
+ accountRepository.deleteAll();
+ }
+
+ @Test
+ public void givenNewAccount_whenSave_thenSuccess() {
+ Account account = new Account(USER_NAME, USER_EMAIL_ADDRESS);
+ accountRepository.save(account);
+
+ assertEquals(1, accountRepository.count());
+ }
+
+ @Test
+ public void givenSavedAccount_whenFindByName_thenFound() {
+ Account account = new Account(USER_NAME, USER_EMAIL_ADDRESS);
+ accountRepository.save(account);
+
+ Account accountFound = accountRepository.findByName(USER_NAME);
+
+ assertNotNull(accountFound);
+ assertEquals(USER_NAME, accountFound.getName());
+ assertEquals(USER_EMAIL_ADDRESS, accountFound.getEmailAddress());
+ }
+
+ @Test
+ public void givenSavedAccount_whenAccountSettingIsAdded_thenPersisted() {
+ Account account = new Account(USER_NAME, USER_EMAIL_ADDRESS);
+ account.addAccountSetting(new AccountSetting(ACCOUNT_SETTING_NAME, ACCOUNT_SETTING_VALUE));
+ accountRepository.save(account);
+
+ Account accountFound = accountRepository.findByName(USER_NAME);
+ assertNotNull(accountFound);
+ AccountSetting accountSetting = accountSettingRepository.findByAccountId(accountFound.getId());
+
+ assertNotNull(accountSetting);
+ assertEquals(ACCOUNT_SETTING_NAME, accountSetting.getSettingName());
+ assertEquals(ACCOUNT_SETTING_VALUE, accountSetting.getSettingValue());
+ }
+
+}
diff --git a/persistence-modules/spring-data-jpa-5/src/test/resources/application-test.properties b/persistence-modules/spring-data-jpa-5/src/test/resources/application-test.properties
new file mode 100644
index 0000000000..e3d39fe1e2
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-5/src/test/resources/application-test.properties
@@ -0,0 +1,3 @@
+spring.jpa.hibernate.ddl-auto=update
+spring.datasource.url=jdbc:h2:mem:baeldung
+
diff --git a/persistence-modules/spring-data-mongodb/README.md b/persistence-modules/spring-data-mongodb/README.md
index c4f21dffc0..381bf83fa8 100644
--- a/persistence-modules/spring-data-mongodb/README.md
+++ b/persistence-modules/spring-data-mongodb/README.md
@@ -13,3 +13,12 @@
- [Spring Data Annotations](http://www.baeldung.com/spring-data-annotations)
- [Spring Data MongoDB Transactions](https://www.baeldung.com/spring-data-mongodb-transactions )
- [ZonedDateTime with Spring Data MongoDB](https://www.baeldung.com/spring-data-mongodb-zoneddatetime)
+
+
+## Spring Data MongoDB Live Testing
+
+
+There are 3 scripts to simplify running live tests:
+1. [`live-test-setup.sh`](src/live-test/resources/live-test-setup.sh) builds a docker image with the necessary setup and runs it. The environment is ready, when the log stops - it takes approximately 30 seconds.
+2. [`live-test.sh`](src/live-test/resources/live-test.sh) runs the live tests (but no other tests).
+3. [`live-test-teardown.sh`](src/live-test/resources/live-test-teardown.sh) stops and removes the docker image.
diff --git a/persistence-modules/spring-data-mongodb/src/live-test/resources/Dockerfile b/persistence-modules/spring-data-mongodb/src/live-test/resources/Dockerfile
new file mode 100644
index 0000000000..9e3634feb0
--- /dev/null
+++ b/persistence-modules/spring-data-mongodb/src/live-test/resources/Dockerfile
@@ -0,0 +1,8 @@
+FROM mongo:4.2.1
+
+COPY init-session.js /docker-entrypoint-initdb.d/
+
+EXPOSE 27017
+
+HEALTHCHECK --interval=5s --timeout=3s --start-period=10s CMD mongo db.stats()
+CMD ["mongod", "--replSet", "rs0"]
diff --git a/persistence-modules/spring-data-mongodb/src/live-test/resources/init-session.js b/persistence-modules/spring-data-mongodb/src/live-test/resources/init-session.js
new file mode 100644
index 0000000000..2e968884cc
--- /dev/null
+++ b/persistence-modules/spring-data-mongodb/src/live-test/resources/init-session.js
@@ -0,0 +1 @@
+rs.initiate();
diff --git a/persistence-modules/spring-data-mongodb/src/live-test/resources/live-test-setup.sh b/persistence-modules/spring-data-mongodb/src/live-test/resources/live-test-setup.sh
new file mode 100644
index 0000000000..78968d51aa
--- /dev/null
+++ b/persistence-modules/spring-data-mongodb/src/live-test/resources/live-test-setup.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+docker image build -t spring-data-mongodb:live-test .
+
+docker run -p 27017:27017 --name spring-data-mongodb-live-test spring-data-mongodb:live-test
diff --git a/persistence-modules/spring-data-mongodb/src/live-test/resources/live-test-teardown.sh b/persistence-modules/spring-data-mongodb/src/live-test/resources/live-test-teardown.sh
new file mode 100644
index 0000000000..a29163bc7a
--- /dev/null
+++ b/persistence-modules/spring-data-mongodb/src/live-test/resources/live-test-teardown.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+docker stop spring-data-mongodb-live-test
+docker rm spring-data-mongodb-live-test
diff --git a/persistence-modules/spring-data-mongodb/src/live-test/resources/live-test.sh b/persistence-modules/spring-data-mongodb/src/live-test/resources/live-test.sh
new file mode 100644
index 0000000000..307a68a3bd
--- /dev/null
+++ b/persistence-modules/spring-data-mongodb/src/live-test/resources/live-test.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+mvn clean compile test -P live-all -f ../../../pom.xml
diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java
index bafcd770ec..6cd9657006 100644
--- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java
+++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java
@@ -62,24 +62,6 @@ public class MongoTransactionalLiveTest {
}
}
- @Test(expected = MongoCommandException.class)
- @Transactional
- public void whenCountDuringMongoTransaction_thenException() {
- userRepository.save(new User("John", 30));
- userRepository.save(new User("Ringo", 35));
- userRepository.count();
- }
-
- @Test
- @Transactional
- public void whenQueryDuringMongoTransaction_thenSuccess() {
- userRepository.save(new User("Jane", 20));
- userRepository.save(new User("Nick", 33));
- List users = mongoTemplate.find(new Query(), User.class);
-
- assertTrue(users.size() > 1);
- }
-
// ==== Using test instead of before and after due to @transactional doesn't allow list collection
@Test
diff --git a/persistence-modules/spring-persistence-simple/pom.xml b/persistence-modules/spring-persistence-simple/pom.xml
index 878c4592f9..7318ec55bd 100644
--- a/persistence-modules/spring-persistence-simple/pom.xml
+++ b/persistence-modules/spring-persistence-simple/pom.xml
@@ -132,13 +132,13 @@
- 5.2.5.RELEASE
+ 5.2.6.RELEASE
5.4.13.Final
8.0.19
1.4.200
- 2.2.6.RELEASE
+ 2.2.7.RELEASE
9.0.0.M26
1.1
4.2.1
diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceConfig.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceConfig.java
index 80f3ff14c5..cdddbaa787 100644
--- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceConfig.java
+++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceConfig.java
@@ -11,7 +11,6 @@ import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
-import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.hibernate5.HibernateTransactionManager;
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
import org.springframework.orm.jpa.JpaTransactionManager;
@@ -26,7 +25,6 @@ import java.util.Properties;
@Configuration
@EnableTransactionManagement
-@EnableJpaRepositories(basePackages = { "com.baeldung.hibernate.dao" }, transactionManagerRef = "jpaTransactionManager")
@EnableJpaAuditing
@PropertySource({ "classpath:persistence-mysql.properties" })
@ComponentScan(basePackages = { "com.baeldung.persistence.dao", "com.baeldung.jpa.dao" })
@@ -97,7 +95,7 @@ public class PersistenceConfig {
return new FooService();
}
- private final Properties hibernateProperties() {
+ private Properties hibernateProperties() {
final Properties hibernateProperties = new Properties();
hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto"));
hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect"));
diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java
index 06cae493c9..e8a2aefd6b 100644
--- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java
+++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java
@@ -8,7 +8,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
-import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
@@ -24,7 +23,6 @@ import java.util.Properties;
@EnableTransactionManagement
@PropertySource({ "classpath:persistence-h2.properties" })
@ComponentScan({ "com.baeldung.persistence","com.baeldung.jpa.dao" })
-@EnableJpaRepositories(basePackages = "com.baeldung.jpa.dao")
public class PersistenceJPAConfig {
@Autowired
diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/config/PersistenceConfig.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/config/PersistenceConfig.java
index 66b540a692..604923d615 100644
--- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/config/PersistenceConfig.java
+++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/config/PersistenceConfig.java
@@ -1,9 +1,6 @@
package com.baeldung.spring.data.persistence.config;
-import java.util.Properties;
-
-import javax.sql.DataSource;
-
+import com.google.common.base.Preconditions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
@@ -19,14 +16,15 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
-import com.google.common.base.Preconditions;
+import javax.sql.DataSource;
+import java.util.Properties;
@Configuration
@EnableTransactionManagement
@PropertySource({ "classpath:persistence-${envTarget:h2}.properties" })
@ComponentScan({ "com.baeldung.spring.data.persistence" })
-// @ImportResource("classpath*:springDataPersistenceConfig.xml")
-@EnableJpaRepositories(basePackages = { "com.baeldung.spring.data.persistence.dao", "com.baeldung.spring.data.persistence.jpaquery" })
+//@ImportResource("classpath*:*springDataJpaRepositoriesConfig.xml")
+@EnableJpaRepositories("com.baeldung.spring.data.persistence.repository")
public class PersistenceConfig {
@Autowired
@@ -40,10 +38,9 @@ public class PersistenceConfig {
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
- em.setPackagesToScan(new String[] { "com.baeldung.spring.data.persistence.model" });
+ em.setPackagesToScan("com.baeldung.spring.data.persistence.model");
final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
- // vendorAdapter.set
em.setJpaVendorAdapter(vendorAdapter);
em.setJpaProperties(additionalProperties());
@@ -78,7 +75,7 @@ public class PersistenceConfig {
final Properties hibernateProperties = new Properties();
hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto"));
hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect"));
- // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true");
+
return hibernateProperties;
}
diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/User.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/User.java
index 09f1092644..1475eccbf0 100644
--- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/User.java
+++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/User.java
@@ -1,7 +1,6 @@
package com.baeldung.spring.data.persistence.model;
import javax.persistence.*;
-
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
@@ -13,14 +12,22 @@ public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
+
private String name;
+
private LocalDate creationDate;
+
private LocalDate lastLoginDate;
+
private boolean active;
+
private int age;
+
@Column(unique = true, nullable = false)
private String email;
+
private Integer status;
+
@OneToMany
List possessionList;
@@ -28,7 +35,7 @@ public class User {
super();
}
- public User(String name, LocalDate creationDate,String email, Integer status) {
+ public User(String name, LocalDate creationDate, String email, Integer status) {
this.name = name;
this.creationDate = creationDate;
this.email = email;
@@ -75,7 +82,7 @@ public class User {
public void setAge(final int age) {
this.age = age;
}
-
+
public LocalDate getCreationDate() {
return creationDate;
}
@@ -94,18 +101,18 @@ public class User {
builder.append("User [name=").append(name).append(", id=").append(id).append("]");
return builder.toString();
}
-
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
return id == user.id &&
- age == user.age &&
- Objects.equals(name, user.name) &&
- Objects.equals(creationDate, user.creationDate) &&
- Objects.equals(email, user.email) &&
- Objects.equals(status, user.status);
+ age == user.age &&
+ Objects.equals(name, user.name) &&
+ Objects.equals(creationDate, user.creationDate) &&
+ Objects.equals(email, user.email) &&
+ Objects.equals(status, user.status);
}
@Override
diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/dao/IFooDao.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/IFooDao.java
similarity index 87%
rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/dao/IFooDao.java
rename to persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/IFooDao.java
index d2b746dc8b..0b750e37e1 100644
--- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/dao/IFooDao.java
+++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/IFooDao.java
@@ -1,11 +1,13 @@
-package com.baeldung.spring.data.persistence.dao;
+package com.baeldung.spring.data.persistence.repository;
import com.baeldung.spring.data.persistence.model.Foo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
+
public interface IFooDao extends JpaRepository {
@Query("SELECT f FROM Foo f WHERE LOWER(f.name) = LOWER(:name)")
Foo retrieveByName(@Param("name") String name);
+
}
diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepository.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepository.java
similarity index 96%
rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepository.java
rename to persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepository.java
index f22970c401..a8e3a536c3 100644
--- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepository.java
+++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepository.java
@@ -1,9 +1,4 @@
-package com.baeldung.spring.data.persistence.jpaquery;
-
-import java.time.LocalDate;
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Stream;
+package com.baeldung.spring.data.persistence.repository;
import com.baeldung.spring.data.persistence.model.User;
import org.springframework.data.domain.Page;
@@ -14,13 +9,18 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
+import java.time.LocalDate;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Stream;
+
public interface UserRepository extends JpaRepository, UserRepositoryCustom {
Stream findAllByName(String name);
@Query("SELECT u FROM User u WHERE u.status = 1")
Collection findAllActiveUsers();
-
+
@Query("select u from User u where u.email like '%@gmail.com'")
List findUsersWithGmailAddress();
@@ -74,14 +74,14 @@ public interface UserRepository extends JpaRepository, UserReposi
@Query(value = "INSERT INTO Users (name, age, email, status, active) VALUES (:name, :age, :email, :status, :active)", nativeQuery = true)
@Modifying
void insertUser(@Param("name") String name, @Param("age") Integer age, @Param("email") String email, @Param("status") Integer status, @Param("active") boolean active);
-
+
@Modifying
@Query(value = "UPDATE Users u SET status = ? WHERE u.name = ?", nativeQuery = true)
int updateUserSetStatusForNameNativePostgres(Integer status, String name);
-
+
@Query(value = "SELECT u FROM User u WHERE u.name IN :names")
- List findUserByNameList(@Param("names") Collection names);
-
+ List findUserByNameList(@Param("names") Collection names);
+
void deleteAllByCreationDateAfter(LocalDate date);
@Modifying(clearAutomatically = true, flushAutomatically = true)
diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCustom.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustom.java
similarity index 85%
rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCustom.java
rename to persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustom.java
index 8bfcb93158..77e661bbbe 100644
--- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCustom.java
+++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustom.java
@@ -1,14 +1,16 @@
-package com.baeldung.spring.data.persistence.jpaquery;
+package com.baeldung.spring.data.persistence.repository;
+
+import com.baeldung.spring.data.persistence.model.User;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
-import com.baeldung.spring.data.persistence.model.User;
-
public interface UserRepositoryCustom {
+
List findUserByEmails(Set emails);
List findAllUsersByPredicates(Collection> predicates);
+
}
diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCustomImpl.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustomImpl.java
similarity index 85%
rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCustomImpl.java
rename to persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustomImpl.java
index f264ca0b44..366b2c54d0 100644
--- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCustomImpl.java
+++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustomImpl.java
@@ -1,5 +1,10 @@
-package com.baeldung.spring.data.persistence.jpaquery;
+package com.baeldung.spring.data.persistence.repository;
+import com.baeldung.spring.data.persistence.model.User;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.criteria.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -7,16 +12,6 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Path;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
-
-import com.baeldung.spring.data.persistence.model.User;
-
public class UserRepositoryCustomImpl implements UserRepositoryCustom {
@PersistenceContext
diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/impl/FooService.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/impl/FooService.java
index cd566ba9f6..c1406b8602 100644
--- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/impl/FooService.java
+++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/impl/FooService.java
@@ -2,7 +2,7 @@ package com.baeldung.spring.data.persistence.service.impl;
import com.baeldung.spring.data.persistence.model.Foo;
-import com.baeldung.spring.data.persistence.dao.IFooDao;
+import com.baeldung.spring.data.persistence.repository.IFooDao;
import com.baeldung.spring.data.persistence.service.IFooService;
import com.baeldung.spring.data.persistence.service.common.AbstractService;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/springDataPersistenceConfig.xml b/persistence-modules/spring-persistence-simple/src/main/resources/springDataJpaRepositoriesConfig.xml
similarity index 60%
rename from persistence-modules/spring-persistence-simple/src/main/resources/springDataPersistenceConfig.xml
rename to persistence-modules/spring-persistence-simple/src/main/resources/springDataJpaRepositoriesConfig.xml
index 5ea2d9c05b..91778a17af 100644
--- a/persistence-modules/spring-persistence-simple/src/main/resources/springDataPersistenceConfig.xml
+++ b/persistence-modules/spring-persistence-simple/src/main/resources/springDataJpaRepositoriesConfig.xml
@@ -1,12 +1,13 @@
-
-
+
\ No newline at end of file
diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCommon.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCommon.java
similarity index 99%
rename from persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCommon.java
rename to persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCommon.java
index 5874b3c643..13b5b4357d 100644
--- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCommon.java
+++ b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCommon.java
@@ -1,4 +1,4 @@
-package com.baeldung.spring.data.persistence.jpaquery;
+package com.baeldung.spring.data.persistence.repository;
import com.baeldung.spring.data.persistence.config.PersistenceConfig;
import com.baeldung.spring.data.persistence.model.User;
diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryIntegrationTest.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryIntegrationTest.java
similarity index 94%
rename from persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryIntegrationTest.java
rename to persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryIntegrationTest.java
index 3bffb51917..c76e345fdd 100644
--- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryIntegrationTest.java
+++ b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryIntegrationTest.java
@@ -1,8 +1,4 @@
-package com.baeldung.spring.data.persistence.jpaquery;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.time.LocalDate;
+package com.baeldung.spring.data.persistence.repository;
import com.baeldung.spring.data.persistence.config.PersistenceConfig;
import com.baeldung.spring.data.persistence.model.User;
@@ -14,9 +10,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
import org.springframework.transaction.annotation.Transactional;
-/**
- * Created by adam.
- */
+import java.time.LocalDate;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class)
@DirtiesContext
diff --git a/pom.xml b/pom.xml
index 02d1ab6cd2..c6addfa6aa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -652,6 +652,7 @@
spring-core
spring-core-2
spring-core-3
+ spring-core-4
spring-cucumber
spring-data-rest
@@ -810,9 +811,13 @@
jws
libraries
+ libraries-4
+ libraries-5
+ libraries-6
vaadin
vavr
+ vavr-2
@@ -1010,6 +1015,7 @@
libraries-2
libraries-3
+
libraries-apache-commons
libraries-apache-commons-collections
libraries-apache-commons-io
@@ -1157,6 +1163,7 @@
spring-core
spring-core-2
spring-core-3
+ spring-core-4
spring-cucumber
spring-data-rest
@@ -1308,13 +1315,47 @@
jws
libraries
+ libraries-4
+ libraries-5
+ libraries-6
vaadin
vavr
+ vavr-2
+
+ live-all
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ **/SpringContextTest.java
+ **/*UnitTest.java
+ **/*IntegrationTest.java
+ **/*IntTest.java
+ **/*LongRunningUnitTest.java
+ **/*ManualTest.java
+ **/*JdbcTest.java
+
+
+ **/*LiveTest.java
+
+
+
+
+
+
+
+
+
+
diff --git a/reactor-core/README.md b/reactor-core/README.md
index e3cca35f86..0214aa26fd 100644
--- a/reactor-core/README.md
+++ b/reactor-core/README.md
@@ -7,3 +7,4 @@ This module contains articles about Reactor Core.
- [Intro To Reactor Core](https://www.baeldung.com/reactor-core)
- [Combining Publishers in Project Reactor](https://www.baeldung.com/reactor-combine-streams)
- [Programmatically Creating Sequences with Project Reactor](https://www.baeldung.com/flux-sequences-reactor)
+- [How to Extract a Mono’s Content in Java](https://www.baeldung.com/java-string-from-mono)
diff --git a/spring-5-security/src/main/java/com/baeldung/manuallogout/BasicAuthController.java b/spring-5-security/src/main/java/com/baeldung/manuallogout/BasicAuthController.java
deleted file mode 100644
index 8f01940dce..0000000000
--- a/spring-5-security/src/main/java/com/baeldung/manuallogout/BasicAuthController.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.baeldung.manuallogout;
-
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-@Controller
-public class BasicAuthController {
-
- @RequestMapping(value = {"/basiclogout"}, method = RequestMethod.POST)
- public String logout(HttpServletRequest request, HttpServletResponse response) {
- HttpSession session;
- SecurityContextHolder.clearContext();
- session = request.getSession(false);
- if (session != null) {
- session.invalidate();
- }
- for (Cookie cookie : request.getCookies()) {
- String cookieName = cookie.getName();
- Cookie cookieToDelete = new Cookie(cookieName, null);
- cookieToDelete.setMaxAge(0);
- response.addCookie(cookieToDelete);
- }
- return "redirect:/login?logout";
- }
-}
diff --git a/spring-5-security/src/main/java/com/baeldung/manuallogout/ClearSiteDataController.java b/spring-5-security/src/main/java/com/baeldung/manuallogout/ClearSiteDataController.java
deleted file mode 100644
index 7eef397da3..0000000000
--- a/spring-5-security/src/main/java/com/baeldung/manuallogout/ClearSiteDataController.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.baeldung.manuallogout;
-
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.web.authentication.logout.HeaderWriterLogoutHandler;
-import org.springframework.security.web.header.writers.ClearSiteDataHeaderWriter;
-import org.springframework.security.web.header.writers.ClearSiteDataHeaderWriter.Directive;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-@Controller
-public class ClearSiteDataController {
-
- Directive[] SOURCE = {Directive.COOKIES, Directive.STORAGE, Directive.EXECUTION_CONTEXTS, Directive.CACHE};
-
- @RequestMapping(value = {"/csdlogout"}, method = RequestMethod.POST)
- public String logout(HttpServletRequest request, HttpServletResponse response) {
- Authentication auth = SecurityContextHolder.getContext().getAuthentication();
- if (auth != null) {
- ClearSiteDataHeaderWriter csdHeaderWriter = new ClearSiteDataHeaderWriter(SOURCE);
- new HeaderWriterLogoutHandler(csdHeaderWriter).logout(request, response, auth);
- }
- return "redirect:/login?logout";
- }
-}
diff --git a/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java b/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java
index 6f14f6fca2..08c2d83b99 100644
--- a/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java
+++ b/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java
@@ -1,39 +1,76 @@
package com.baeldung.manuallogout;
import org.springframework.context.annotation.Configuration;
-import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.core.annotation.Order;
+
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.web.authentication.logout.HeaderWriterLogoutHandler;
+import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;
+import org.springframework.security.web.header.writers.ClearSiteDataHeaderWriter;
+
+import javax.servlet.http.Cookie;
+
+import static org.springframework.security.web.header.writers.ClearSiteDataHeaderWriter.Directive.*;
@Configuration
@EnableWebSecurity
-public class SimpleSecurityConfiguration extends WebSecurityConfigurerAdapter {
+public class SimpleSecurityConfiguration {
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http.formLogin()
- .loginProcessingUrl("/login")
- .loginPage("/login")
- .usernameParameter("username")
- .passwordParameter("password")
- .defaultSuccessUrl("/")
- .failureUrl("/login?error");
+ @Order(3)
+ @Configuration
+ public static class DefaultLogoutConfiguration extends WebSecurityConfigurerAdapter {
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http
+ .antMatcher("/basic/**")
+ .authorizeRequests(authz -> authz.anyRequest().permitAll())
+ .logout(logout -> logout
+ .logoutUrl("/basic/basiclogout")
+ );
+ }
}
- @Override
- protected void configure(AuthenticationManagerBuilder auth) throws Exception {
- auth.inMemoryAuthentication()
- .withUser("user")
- .password("password")
- .roles("USER")
- .and()
- .withUser("manager")
- .password("password")
- .credentialsExpired(true)
- .accountExpired(true)
- .accountLocked(true)
- .authorities("WRITE_PRIVILEGES", "READ_PRIVILEGES")
- .roles("MANAGER");
+ @Order(2)
+ @Configuration
+ public static class AllCookieClearingLogoutConfiguration extends WebSecurityConfigurerAdapter {
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http
+ .antMatcher("/cookies/**")
+ .authorizeRequests(authz -> authz.anyRequest().permitAll())
+ .logout(logout -> logout
+ .logoutUrl("/cookies/cookielogout")
+ .addLogoutHandler(new SecurityContextLogoutHandler())
+ .addLogoutHandler((request, response, auth) -> {
+ for (Cookie cookie : request.getCookies()) {
+ String cookieName = cookie.getName();
+ Cookie cookieToDelete = new Cookie(cookieName, null);
+ cookieToDelete.setMaxAge(0);
+ response.addCookie(cookieToDelete);
+ }
+ })
+ );
+ }
+ }
+
+ @Order(1)
+ @Configuration
+ public static class ClearSiteDataHeaderLogoutConfiguration extends WebSecurityConfigurerAdapter {
+
+ private static final ClearSiteDataHeaderWriter.Directive[] SOURCE =
+ {CACHE, COOKIES, STORAGE, EXECUTION_CONTEXTS};
+
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http
+ .antMatcher("/csd/**")
+ .authorizeRequests(authz -> authz.anyRequest().permitAll())
+ .logout(logout -> logout
+ .logoutUrl("/csd/csdlogout")
+ .addLogoutHandler(new HeaderWriterLogoutHandler(new ClearSiteDataHeaderWriter(SOURCE)))
+ );
+ }
}
}
diff --git a/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java b/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java
index a64cb82910..8909dc2620 100644
--- a/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java
+++ b/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java
@@ -7,6 +7,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.security.test.context.support.WithMockUser;
+import org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
@@ -36,7 +37,17 @@ public class ManualLogoutIntegrationTest {
@WithMockUser(value = "spring")
@Test
- public void givenLoggedUserWhenUserLogoutThenSessionCleared() throws Exception {
+ public void givenLoggedUserWhenUserLogoutThenSessionClearedAndNecessaryCookieCleared() throws Exception {
+
+ this.mockMvc.perform(post("/basic/basiclogout").secure(true).with(csrf()))
+ .andExpect(status().is3xxRedirection())
+ .andExpect(unauthenticated())
+ .andReturn();
+ }
+
+ @WithMockUser(value = "spring")
+ @Test
+ public void givenLoggedUserWhenUserLogoutThenSessionClearedAndAllCookiesCleared() throws Exception {
MockHttpSession session = new MockHttpSession();
session.setAttribute(ATTRIBUTE_NAME, ATTRIBUTE_VALUE);
@@ -44,7 +55,7 @@ public class ManualLogoutIntegrationTest {
Cookie randomCookie = new Cookie(COOKIE_NAME, COOKIE_VALUE);
randomCookie.setMaxAge(EXPIRY); // 10 minutes
- MockHttpServletRequest requestStateAfterLogout = this.mockMvc.perform(post("/basiclogout").secure(true).with(csrf()).session(session).cookie(randomCookie))
+ MockHttpServletRequest requestStateAfterLogout = this.mockMvc.perform(post("/cookies/cookielogout").secure(true).with(csrf()).session(session).cookie(randomCookie))
.andExpect(status().is3xxRedirection())
.andExpect(unauthenticated())
.andExpect(cookie().maxAge(COOKIE_NAME, 0))
@@ -53,15 +64,13 @@ public class ManualLogoutIntegrationTest {
HttpSession sessionStateAfterLogout = requestStateAfterLogout.getSession();
assertNull(sessionStateAfterLogout.getAttribute(ATTRIBUTE_NAME));
-
-
}
@WithMockUser(value = "spring")
@Test
public void givenLoggedUserWhenUserLogoutThenClearDataSiteHeaderPresent() throws Exception {
- this.mockMvc.perform(post("/csdlogout").secure(true).with(csrf()))
+ this.mockMvc.perform(post("/csd/csdlogout").secure(true).with(csrf()))
.andDo(print())
.andExpect(status().is3xxRedirection())
.andExpect(header().exists(CLEAR_SITE_DATA_HEADER))
diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/SpringBootGroovyApplication.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/SpringBootGroovyApplication.groovy
similarity index 73%
rename from spring-boot-groovy/src/main/groovy/com/baeldung/app/SpringBootGroovyApplication.groovy
rename to spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/SpringBootGroovyApplication.groovy
index 226a2ff53d..4912b75a66 100644
--- a/spring-boot-groovy/src/main/groovy/com/baeldung/app/SpringBootGroovyApplication.groovy
+++ b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/SpringBootGroovyApplication.groovy
@@ -1,9 +1,9 @@
-package com.baeldung.app
+package com.baeldung.springwithgroovy
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
-import com.baeldung.app.SpringBootGroovyApplication
+import com.baeldung.springwithgroovy.SpringBootGroovyApplication
@SpringBootApplication
class SpringBootGroovyApplication {
diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/controller/TodoController.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/controller/TodoController.groovy
similarity index 89%
rename from spring-boot-groovy/src/main/groovy/com/baeldung/app/controller/TodoController.groovy
rename to spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/controller/TodoController.groovy
index 02f6d0223b..9c6aee20d3 100644
--- a/spring-boot-groovy/src/main/groovy/com/baeldung/app/controller/TodoController.groovy
+++ b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/controller/TodoController.groovy
@@ -1,4 +1,4 @@
-package com.baeldung.app.controller
+package com.baeldung.springwithgroovy.controller
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.DeleteMapping
@@ -11,8 +11,8 @@ import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RestController
-import com.baeldung.app.entity.Todo
-import com.baeldung.app.service.TodoService
+import com.baeldung.springwithgroovy.entity.Todo
+import com.baeldung.springwithgroovy.service.TodoService
@RestController
@RequestMapping('todo')
diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/entity/Todo.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/entity/Todo.groovy
similarity index 89%
rename from spring-boot-groovy/src/main/groovy/com/baeldung/app/entity/Todo.groovy
rename to spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/entity/Todo.groovy
index 9f1253c5b3..000d981701 100644
--- a/spring-boot-groovy/src/main/groovy/com/baeldung/app/entity/Todo.groovy
+++ b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/entity/Todo.groovy
@@ -1,4 +1,4 @@
-package com.baeldung.app.entity
+package com.baeldung.springwithgroovy.entity
import javax.persistence.Column
import javax.persistence.Entity
diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/repository/TodoRepository.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/repository/TodoRepository.groovy
similarity index 65%
rename from spring-boot-groovy/src/main/groovy/com/baeldung/app/repository/TodoRepository.groovy
rename to spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/repository/TodoRepository.groovy
index c0b35cc37d..eb58cc0791 100644
--- a/spring-boot-groovy/src/main/groovy/com/baeldung/app/repository/TodoRepository.groovy
+++ b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/repository/TodoRepository.groovy
@@ -1,9 +1,9 @@
-package com.baeldung.app.repository
+package com.baeldung.springwithgroovy.repository
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository
-import com.baeldung.app.entity.Todo
+import com.baeldung.springwithgroovy.entity.Todo
@Repository
interface TodoRepository extends JpaRepository {}
\ No newline at end of file
diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/service/TodoService.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/TodoService.groovy
similarity index 66%
rename from spring-boot-groovy/src/main/groovy/com/baeldung/app/service/TodoService.groovy
rename to spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/TodoService.groovy
index 0a59d93330..c57af34cde 100644
--- a/spring-boot-groovy/src/main/groovy/com/baeldung/app/service/TodoService.groovy
+++ b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/TodoService.groovy
@@ -1,6 +1,6 @@
-package com.baeldung.app.service
+package com.baeldung.springwithgroovy.service
-import com.baeldung.app.entity.Todo
+import com.baeldung.springwithgroovy.entity.Todo
interface TodoService {
diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/service/impl/TodoServiceImpl.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/impl/TodoServiceImpl.groovy
similarity index 75%
rename from spring-boot-groovy/src/main/groovy/com/baeldung/app/service/impl/TodoServiceImpl.groovy
rename to spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/impl/TodoServiceImpl.groovy
index 6d0ee03a9f..943c1c6944 100644
--- a/spring-boot-groovy/src/main/groovy/com/baeldung/app/service/impl/TodoServiceImpl.groovy
+++ b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/impl/TodoServiceImpl.groovy
@@ -1,11 +1,11 @@
-package com.baeldung.app.service.impl
+package com.baeldung.springwithgroovy.service.impl
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
-import com.baeldung.app.entity.Todo
-import com.baeldung.app.repository.TodoRepository
-import com.baeldung.app.service.TodoService
+import com.baeldung.springwithgroovy.entity.Todo
+import com.baeldung.springwithgroovy.repository.TodoRepository
+import com.baeldung.springwithgroovy.service.TodoService
@Service
class TodoServiceImpl implements TodoService {
diff --git a/spring-boot-groovy/src/test/groovy/com/baeldung/app/TodoAppUnitTest.groovy b/spring-boot-groovy/src/test/groovy/com/baeldung/springwithgroovy/TodoAppUnitTest.groovy
similarity index 97%
rename from spring-boot-groovy/src/test/groovy/com/baeldung/app/TodoAppUnitTest.groovy
rename to spring-boot-groovy/src/test/groovy/com/baeldung/springwithgroovy/TodoAppUnitTest.groovy
index faf2d64ba7..bf8b0ff27f 100644
--- a/spring-boot-groovy/src/test/groovy/com/baeldung/app/TodoAppUnitTest.groovy
+++ b/spring-boot-groovy/src/test/groovy/com/baeldung/springwithgroovy/TodoAppUnitTest.groovy
@@ -1,4 +1,4 @@
-package com.baeldung.app
+package com.baeldung.springwithgroovy
import static org.junit.jupiter.api.Assertions.assertEquals
import static org.junit.jupiter.api.Assertions.assertTrue
@@ -12,7 +12,7 @@ import org.springframework.http.MediaType
import org.springframework.test.context.event.annotation.BeforeTestClass
import org.springframework.test.context.junit4.SpringRunner
-import com.baeldung.app.entity.Todo
+import com.baeldung.springwithgroovy.entity.Todo
import io.restassured.RestAssured
import io.restassured.response.Response
diff --git a/spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/favicon/config/FaviconConfiguration.java b/spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/favicon/config/FaviconConfiguration.java
index d1809199d6..f2a173caf3 100644
--- a/spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/favicon/config/FaviconConfiguration.java
+++ b/spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/favicon/config/FaviconConfiguration.java
@@ -28,7 +28,7 @@ public class FaviconConfiguration {
@Bean
protected ResourceHttpRequestHandler faviconRequestHandler() {
ResourceHttpRequestHandler requestHandler = new ResourceHttpRequestHandler();
- ClassPathResource classPathResource = new ClassPathResource("com/baeldung/images");
+ ClassPathResource classPathResource = new ClassPathResource("com/baeldung/images/");
List locations = Arrays.asList(classPathResource);
requestHandler.setLocations(locations);
return requestHandler;
diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml
index 0bba2936a7..532f45cf3e 100644
--- a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml
+++ b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml
@@ -63,7 +63,7 @@
UTF-8
- 1.5.2.RELEASE
+ 2.2.6.RELEASE
0.0.1-SNAPSHOT
diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/com/baeldung/SpringContextTest.java
similarity index 100%
rename from spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java
rename to spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/com/baeldung/SpringContextTest.java
diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml
index 818ce5c107..8d328b88be 100644
--- a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml
+++ b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml
@@ -8,9 +8,9 @@
com.baeldung
- parent-boot-1
+ parent-boot-2
0.0.1-SNAPSHOT
- ../../../parent-boot-1
+ ../../../parent-boot-2
diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/com/baeldung/SpringContextTest.java
similarity index 100%
rename from spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java
rename to spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/com/baeldung/SpringContextTest.java
diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml
index ba2b4101e8..0e8fb4cbc9 100644
--- a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml
+++ b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml
@@ -51,7 +51,7 @@
UTF-8
0.0.1-SNAPSHOT
- 1.5.2.RELEASE
+ 2.2.6.RELEASE
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter/pom.xml
index 89119e2e99..47296990aa 100644
--- a/spring-boot-modules/spring-boot-custom-starter/greeter/pom.xml
+++ b/spring-boot-modules/spring-boot-custom-starter/greeter/pom.xml
@@ -8,9 +8,9 @@
com.baeldung
- parent-boot-1
+ parent-boot-2
0.0.1-SNAPSHOT
- ../../../parent-boot-1
+ ../../../parent-boot-2
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-properties/pom.xml b/spring-boot-modules/spring-boot-properties/pom.xml
index ec05ec1bdc..ef9c084f4c 100644
--- a/spring-boot-modules/spring-boot-properties/pom.xml
+++ b/spring-boot-modules/spring-boot-properties/pom.xml
@@ -128,6 +128,7 @@
4.4.11
@
2.2.4.RELEASE
+ com.baeldung.buildproperties.Application
diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/JdbcProperties.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/JdbcProperties.java
new file mode 100644
index 0000000000..bbd193acba
--- /dev/null
+++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/JdbcProperties.java
@@ -0,0 +1,21 @@
+package com.baeldung.configuration.processor;
+
+import org.springframework.boot.context.properties.*;
+import org.springframework.context.annotation.*;
+import org.springframework.beans.factory.annotation.*;
+
+@Configuration
+@ConfigurationProperties(prefix = "com.baeldung")
+public class JdbcProperties {
+
+ @Value("${jdbc.url:jdbc:postgresql:/localhost:5432}")
+ private String jdbcUrl;
+
+ public String getJdbcUrl() {
+ return jdbcUrl;
+ }
+
+ public void setJdbcUrl(String jdbcUrl) {
+ this.jdbcUrl = jdbcUrl;
+ }
+}
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/PropertyBeanInjection.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/PropertyBeanInjection.java
index 3bcbf41f54..89a8f9458c 100644
--- a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/PropertyBeanInjection.java
+++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/PropertyBeanInjection.java
@@ -6,16 +6,23 @@ import org.springframework.stereotype.*;
@Component
public class PropertyBeanInjection {
- private final CustomProperties customProperties;
+ private CustomProperties customProperties;
- PropertyBeanInjection(@Autowired CustomProperties customProperties) {
+ private JdbcProperties jdbcProperties;
+
+ PropertyBeanInjection(@Autowired CustomProperties customProperties, @Autowired JdbcProperties jdbcProperties) {
this.customProperties = customProperties;
+ this.jdbcProperties = jdbcProperties;
}
String getUrl() {
return customProperties.getUrl();
}
+ String getJdbcUrl() {
+ return jdbcProperties.getJdbcUrl();
+ }
+
int getTimeoutInMilliseconds() {
return customProperties.getTimeoutInMilliSeconds();
}
diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/Database.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/Database.java
new file mode 100644
index 0000000000..990ede35cd
--- /dev/null
+++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/Database.java
@@ -0,0 +1,36 @@
+package com.baeldung.configurationproperties;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+
+@ConfigurationProperties(prefix = "database")
+public class Database {
+
+ String url;
+ String username;
+ String password;
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+}
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/DatabaseConfig.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/DatabaseConfig.java
new file mode 100644
index 0000000000..8f17c98f03
--- /dev/null
+++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/DatabaseConfig.java
@@ -0,0 +1,23 @@
+package com.baeldung.configurationproperties;
+
+import org.springframework.core.env.Environment;
+import org.springframework.beans.factory.annotation.*;
+import org.springframework.context.annotation.*;
+
+@Configuration
+public class DatabaseConfig {
+
+ @Autowired private Environment env;
+
+ @Bean(name="dataSource")
+ public Database dataSource() {
+
+ Database dataSource = new Database();
+ dataSource.setUrl(env.getProperty("jdbc.url"));
+ dataSource.setUsername(env.getProperty("database.username"));
+ dataSource.setPassword(env.getProperty("database.password"));
+
+ return dataSource;
+ }
+
+}
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/DatabaseConfigPropertiesApp.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/DatabaseConfigPropertiesApp.java
new file mode 100644
index 0000000000..bb1c937f60
--- /dev/null
+++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/DatabaseConfigPropertiesApp.java
@@ -0,0 +1,13 @@
+package com.baeldung.configurationproperties;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+@SpringBootApplication
+@ComponentScan(basePackageClasses = {Database.class,DatabaseConfig.class})
+public class DatabaseConfigPropertiesApp{
+
+ public static void main(String[]args) {SpringApplication.run(DatabaseConfigPropertiesApp.class,args);}
+
+}
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertyPlaceholderConfig.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertyPlaceholderConfig.java
new file mode 100644
index 0000000000..0d1eb4ccf7
--- /dev/null
+++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertyPlaceholderConfig.java
@@ -0,0 +1,23 @@
+package com.baeldung.properties.spring;
+
+import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.*;
+
+@Configuration
+public class PropertyPlaceholderConfig {
+
+ public PropertyPlaceholderConfig(){
+ super();
+ }
+
+ @Bean
+ public static PropertyPlaceholderConfigurer properties() {
+ PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
+ Resource[] resources = new ClassPathResource[]{ new ClassPathResource("foo.properties") };
+ ppc.setLocations( resources );
+ ppc.setIgnoreUnresolvablePlaceholders( true );
+ return ppc;
+ }
+}
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertySourcesPlaceholderConfig.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertySourcesPlaceholderConfig.java
new file mode 100644
index 0000000000..8ff464e4cf
--- /dev/null
+++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertySourcesPlaceholderConfig.java
@@ -0,0 +1,24 @@
+package com.baeldung.properties.spring;
+
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.*;
+
+@Configuration
+public class PropertySourcesPlaceholderConfig{
+
+ public PropertySourcesPlaceholderConfig(){
+ super();
+ }
+
+ @Bean
+ public static PropertySourcesPlaceholderConfigurer properties(){
+ PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
+ Resource[] resources = new ClassPathResource[]{ new ClassPathResource("foo.properties") };
+ pspc.setLocations(resources);
+ pspc.setIgnoreUnresolvablePlaceholders(true);
+ return pspc;
+ }
+
+}
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/application.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/application.properties
index d4d1df7abc..af38556f81 100644
--- a/spring-boot-modules/spring-boot-properties/src/main/resources/application.properties
+++ b/spring-boot-modules/spring-boot-properties/src/main/resources/application.properties
@@ -3,6 +3,3 @@ spring.properties.refreshDelay=1000
spring.config.location=file:extra.properties
spring.main.allow-bean-definition-overriding=true
-database.url=jdbc:postgresql:/localhost:5432/instance
-database.username=foo
-database.password=bar
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/configForProperties.xml b/spring-boot-modules/spring-boot-properties/src/main/resources/configForProperties.xml
index d796f791cb..4468bb485f 100644
--- a/spring-boot-modules/spring-boot-properties/src/main/resources/configForProperties.xml
+++ b/spring-boot-modules/spring-boot-properties/src/main/resources/configForProperties.xml
@@ -7,10 +7,14 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
>
-
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/configForPropertyPlaceholderBeans.xml b/spring-boot-modules/spring-boot-properties/src/main/resources/configForPropertyPlaceholderBeans.xml
new file mode 100644
index 0000000000..a296cf5169
--- /dev/null
+++ b/spring-boot-modules/spring-boot-properties/src/main/resources/configForPropertyPlaceholderBeans.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+ classpath:foo.properties
+
+
+
+
+
+
+
+
+ classpath:foo.properties
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/configuration-processor.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/configuration-processor.properties
new file mode 100644
index 0000000000..b68a4fbda3
--- /dev/null
+++ b/spring-boot-modules/spring-boot-properties/src/main/resources/configuration-processor.properties
@@ -0,0 +1,3 @@
+com.baeldung.url=www.abc.test.com
+com.baeldung.jdbc.url=
+com.baeldung.timeout-in-milli-seconds=2000
diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/database.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/database.properties
new file mode 100644
index 0000000000..6524ce6109
--- /dev/null
+++ b/spring-boot-modules/spring-boot-properties/src/main/resources/database.properties
@@ -0,0 +1,4 @@
+database.url=jdbc:postgresql:/localhost:5432/instance
+database.username=foo
+database.password=bar
+jdbc.url=jdbc:postgresql:/localhost:5432
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/database.yml b/spring-boot-modules/spring-boot-properties/src/main/resources/database.yml
new file mode 100644
index 0000000000..8404d9411a
--- /dev/null
+++ b/spring-boot-modules/spring-boot-properties/src/main/resources/database.yml
@@ -0,0 +1,5 @@
+database:
+ url: jdbc:postresql:/localhost:5432/instance
+ username: foo
+ password: bar
+secret: foo
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configuration/processor/PropertyBeanInjectionUnitTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configuration/processor/PropertyBeanInjectionUnitTest.java
index bdeb6547c3..eb6add2b94 100644
--- a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configuration/processor/PropertyBeanInjectionUnitTest.java
+++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configuration/processor/PropertyBeanInjectionUnitTest.java
@@ -15,6 +15,11 @@ class PropertyBeanInjectionUnitTest {
@Autowired
private PropertyBeanInjection propertyBeanInjection;
+ @Test
+ void checkThatJdbcPropertiesHaveTheCorrectValueFromPropertiesFile() {
+ Assertions.assertEquals("jdbc:postgresql:/localhost:5432", propertyBeanInjection.getJdbcUrl());
+ }
+
@Test
void checkThatCustomPropertiesHaveTheCorrectValueFromPropertiesFile() {
Assertions.assertEquals("www.abc.test.com", propertyBeanInjection.getUrl());
diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ConfigPropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ConfigPropertiesIntegrationTest.java
index 141400b1fe..2b0833c387 100644
--- a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ConfigPropertiesIntegrationTest.java
+++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ConfigPropertiesIntegrationTest.java
@@ -4,6 +4,7 @@ import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
@@ -13,13 +14,17 @@ import com.baeldung.properties.AdditionalProperties;
import com.baeldung.properties.ConfigPropertiesDemoApplication;
@RunWith(SpringRunner.class)
-@SpringBootTest(classes = ConfigPropertiesDemoApplication.class)
-@TestPropertySource("classpath:configprops-test.properties")
+@SpringBootTest(classes = {ConfigPropertiesDemoApplication.class, DatabaseConfigPropertiesApp.class})
+@TestPropertySource(locations = {"classpath:configprops-test.properties", "classpath:database-test.properties"})
public class ConfigPropertiesIntegrationTest {
@Autowired
private ConfigProperties properties;
+ @Autowired
+ @Qualifier("dataSource")
+ private Database databaseProperties;
+
@Autowired
private AdditionalProperties additionalProperties;
@@ -53,4 +58,11 @@ public class ConfigPropertiesIntegrationTest {
Assert.assertTrue(additionalProperties.getUnit().equals("km"));
Assert.assertTrue(additionalProperties.getMax() == 100);
}
+
+ @Test
+ public void whenDatabasePropertyQueriedthenReturnsProperty() {
+ Assert.assertTrue(databaseProperties.getUrl().equals("jdbc:postgresql:/localhost:5432"));
+ Assert.assertTrue(databaseProperties.getUsername().equals("foo"));
+ Assert.assertTrue(databaseProperties.getPassword().equals("bar"));
+ }
}
diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersJavaConfigIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersJavaConfigIntegrationTest.java
new file mode 100644
index 0000000000..8ebda90321
--- /dev/null
+++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersJavaConfigIntegrationTest.java
@@ -0,0 +1,23 @@
+package com.baeldung.properties.multiple;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
+
+import com.baeldung.properties.spring.PropertyPlaceholderConfig;
+import com.baeldung.properties.spring.PropertySourcesPlaceholderConfig;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@SpringJUnitConfig({PropertyPlaceholderConfig.class, PropertySourcesPlaceholderConfig.class})
+public class MultiplePlaceholdersJavaConfigIntegrationTest {
+
+ @Value("${key.something}")
+ private String something;
+
+
+ @Test
+ public void whenReadInjectedValues_thenGetCorrectValues() {
+ assertThat(something).isEqualTo("val");
+ }
+}
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersXmlConfigIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersXmlConfigIntegrationTest.java
new file mode 100644
index 0000000000..b863e2e080
--- /dev/null
+++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersXmlConfigIntegrationTest.java
@@ -0,0 +1,25 @@
+package com.baeldung.properties.multiple;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+
+@SpringJUnitConfig(locations = "classpath:configForPropertyPlaceholderBeans.xml")
+public class MultiplePlaceholdersXmlConfigIntegrationTest {
+
+ @Value("${foo}")
+ private String something;
+
+ @Value("${key.something}")
+ private String something2;
+
+
+ @Test
+ public void whenReadInjectedValues_thenGetCorrectValues() {
+ assertThat(something).isEqualTo("bar");
+ assertThat(something2).isEqualTo("val");
+ }
+}
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesXmlConfigIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesXmlConfigIntegrationTest.java
index db71e816dd..6827ee1cf1 100644
--- a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesXmlConfigIntegrationTest.java
+++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesXmlConfigIntegrationTest.java
@@ -13,9 +13,12 @@ public class MultiplePropertiesXmlConfigIntegrationTest {
@Value("${key.something2}") private String something2;
+ @Value("${jdbc.url}") private String jdbcUrl;
+
@Test
public void whenReadInjectedValues_thenGetCorrectValues() {
assertThat(something).isEqualTo("val");
assertThat(something2).isEqualTo("val2");
+ assertThat(jdbcUrl).isEqualTo("jdbc:postgresql:/localhost:5432");
}
}
diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/test/IntegrationTestSuite.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/test/IntegrationTestSuite.java
index d41d328867..0e0f8f6230 100644
--- a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/test/IntegrationTestSuite.java
+++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/test/IntegrationTestSuite.java
@@ -10,6 +10,8 @@ import com.baeldung.properties.basic.PropertiesWithXmlIntegrationTest;
import com.baeldung.properties.external.ExternalPropertiesWithJavaIntegrationTest;
import com.baeldung.properties.external.ExternalPropertiesWithMultipleXmlsIntegrationTest;
import com.baeldung.properties.external.ExternalPropertiesWithXmlManualTest;
+import com.baeldung.properties.multiple.MultiplePropertiesXmlConfigIntegrationTest;
+import com.baeldung.properties.multiple.MultiplePlaceholdersXmlConfigIntegrationTest;
@RunWith(Suite.class)
@SuiteClasses({ //@formatter:off
@@ -17,8 +19,8 @@ import com.baeldung.properties.external.ExternalPropertiesWithXmlManualTest;
ExternalPropertiesWithJavaIntegrationTest.class,
ExternalPropertiesWithMultipleXmlsIntegrationTest.class,
ExternalPropertiesWithXmlManualTest.class,
- ExtendedPropertiesWithJavaIntegrationTest.class,
- PropertiesWithMultipleXmlsIntegrationTest.class,
+ ExtendedPropertiesWithJavaIntegrationTest.class, MultiplePropertiesXmlConfigIntegrationTest.class,
+ PropertiesWithMultipleXmlsIntegrationTest.class, MultiplePlaceholdersXmlConfigIntegrationTest.class
})// @formatter:on
public final class IntegrationTestSuite {
//
diff --git a/spring-boot-modules/spring-boot-properties/src/test/resources/configuration-processor.properties b/spring-boot-modules/spring-boot-properties/src/test/resources/configuration-processor.properties
index 00369f2eff..b68a4fbda3 100644
--- a/spring-boot-modules/spring-boot-properties/src/test/resources/configuration-processor.properties
+++ b/spring-boot-modules/spring-boot-properties/src/test/resources/configuration-processor.properties
@@ -1,2 +1,3 @@
com.baeldung.url=www.abc.test.com
+com.baeldung.jdbc.url=
com.baeldung.timeout-in-milli-seconds=2000
diff --git a/spring-boot-modules/spring-boot-properties/src/test/resources/database-test.properties b/spring-boot-modules/spring-boot-properties/src/test/resources/database-test.properties
new file mode 100644
index 0000000000..384d0850ab
--- /dev/null
+++ b/spring-boot-modules/spring-boot-properties/src/test/resources/database-test.properties
@@ -0,0 +1,3 @@
+jdbc.url=jdbc:postgresql:/localhost:5432
+database.username=foo
+database.password=bar
diff --git a/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/pom.xml b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/pom.xml
index 8ea9c8366d..e38a2742d5 100644
--- a/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/pom.xml
+++ b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/pom.xml
@@ -24,6 +24,12 @@
spring-boot-starter-test
${spring-boot.version}
test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
@@ -72,7 +78,7 @@
- 1.5.10.RELEASE
+ 2.2.6.RELEASE
Custom Property Value
2.7
1.6.0
diff --git a/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/com/baeldung/SpringContextTest.java
similarity index 100%
rename from spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java
rename to spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/com/baeldung/SpringContextTest.java
diff --git a/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/pom.xml b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/pom.xml
index aa5b8ef34a..79e194a3b5 100644
--- a/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/pom.xml
+++ b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/pom.xml
@@ -9,9 +9,9 @@
com.baeldung
- parent-boot-1
+ parent-boot-2
0.0.1-SNAPSHOT
- ../../../parent-boot-1
+ ../../../parent-boot-2
diff --git a/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/com/baeldung/SpringContextTest.java
similarity index 100%
rename from spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java
rename to spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/com/baeldung/SpringContextTest.java
diff --git a/spring-boot-modules/spring-boot/src/test/resources/README.md b/spring-boot-modules/spring-boot/src/test/resources/README.md
new file mode 100644
index 0000000000..51c95afd9d
--- /dev/null
+++ b/spring-boot-modules/spring-boot/src/test/resources/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles:
+
+- [How to Test GraphQL Using Postman](https://www.baeldung.com/graphql-postman)
diff --git a/spring-caching/pom.xml b/spring-caching/pom.xml
index f56d3cf328..80644f8a5f 100644
--- a/spring-caching/pom.xml
+++ b/spring-caching/pom.xml
@@ -2,66 +2,64 @@
- 4.0.0
- spring-caching
- 0.1-SNAPSHOT
- spring-caching
- war
+ 4.0.0
+ spring-caching
+ 0.1-SNAPSHOT
+ spring-caching
+ war
-
- com.baeldung
- parent-boot-2
- 0.0.1-SNAPSHOT
- ../parent-boot-2
-
+
+ com.baeldung
+ parent-boot-2
+ 0.0.1-SNAPSHOT
+ ../parent-boot-2
+
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework
- spring-context
-
-
- org.springframework.boot
- spring-boot-starter-cache
-
-
- org.springframework
- spring-web
-
-
- org.springframework
- spring-webmvc
-
-
- org.ehcache
- ehcache
-
-
- org.springframework
- spring-test
- test
-
-
- com.github.ben-manes.caffeine
- caffeine
-
-
- com.h2database
- h2
- runtime
-
-
- org.springframework.boot
- spring-boot-starter-jdbc
-
-
-
-
- 3.5.2
-
-
-
\ No newline at end of file
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework
+ spring-context
+
+
+ org.springframework.boot
+ spring-boot-starter-cache
+
+
+ org.springframework
+ spring-web
+
+
+ org.springframework
+ spring-webmvc
+
+
+ org.ehcache
+ ehcache
+
+
+ org.springframework
+ spring-test
+ test
+
+
+ com.github.ben-manes.caffeine
+ caffeine
+
+
+ com.h2database
+ h2
+ runtime
+
+
+ org.springframework.boot
+ spring-boot-starter-jdbc
+
+
+
+ 3.5.2
+
+
diff --git a/spring-caching/src/test/java/com/baeldung/caching/boot/SimpleCacheCustomizerIntegrationTest.java b/spring-caching/src/test/java/com/baeldung/caching/boot/SimpleCacheCustomizerIntegrationTest.java
index 56a4bd4745..3c83065c5c 100644
--- a/spring-caching/src/test/java/com/baeldung/caching/boot/SimpleCacheCustomizerIntegrationTest.java
+++ b/spring-caching/src/test/java/com/baeldung/caching/boot/SimpleCacheCustomizerIntegrationTest.java
@@ -10,7 +10,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
-@SpringBootTest
+@SpringBootTest("spring.cache.type=simple")
public class SimpleCacheCustomizerIntegrationTest {
@Autowired
diff --git a/spring-cloud/spring-cloud-aws/README.md b/spring-cloud/spring-cloud-aws/README.md
index bf33728c74..ddcc97420f 100644
--- a/spring-cloud/spring-cloud-aws/README.md
+++ b/spring-cloud/spring-cloud-aws/README.md
@@ -23,7 +23,6 @@ Let's say that the RDS instance is called `spring-cloud-test-db` having the mast
to write the following in `application.properties`:
```
-cloud.aws.rds.spring-cloud-test-db
cloud.aws.rds.spring-cloud-test-db.password=se3retpass
```
Multiple application classes are available under this project. To launch InstanceProfileAwsApplication application, replace `start-class` under `pom.xml`:
diff --git a/spring-cloud/spring-cloud-aws/pom.xml b/spring-cloud/spring-cloud-aws/pom.xml
index abf9363288..2b05020888 100644
--- a/spring-cloud/spring-cloud-aws/pom.xml
+++ b/spring-cloud/spring-cloud-aws/pom.xml
@@ -10,9 +10,9 @@
com.baeldung
- parent-boot-1
+ parent-boot-2
0.0.1-SNAPSHOT
- ../../parent-boot-1
+ ../../parent-boot-2
@@ -43,6 +43,12 @@
org.postgresql
postgresql
+
+
+ mysql
+ mysql-connector-java
+
+
@@ -60,7 +66,7 @@
com.baeldung.spring.cloud.aws.SpringCloudAwsApplication
Dalston.SR4
- 2.0.1.RELEASE
+ 2.2.1.RELEASE
diff --git a/spring-cloud/spring-cloud-aws/src/main/java/com/baeldung/spring/cloud/aws/s3/SpringCloudS3.java b/spring-cloud/spring-cloud-aws/src/main/java/com/baeldung/spring/cloud/aws/s3/SpringCloudS3.java
index cfad6e904f..acfd6d339e 100644
--- a/spring-cloud/spring-cloud-aws/src/main/java/com/baeldung/spring/cloud/aws/s3/SpringCloudS3.java
+++ b/spring-cloud/spring-cloud-aws/src/main/java/com/baeldung/spring/cloud/aws/s3/SpringCloudS3.java
@@ -1,12 +1,5 @@
package com.baeldung.spring.cloud.aws.s3;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.ResourceLoader;
-import org.springframework.core.io.WritableResource;
-import org.springframework.core.io.support.ResourcePatternResolver;
-import org.springframework.stereotype.Component;
-
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -14,14 +7,29 @@ import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cloud.aws.core.io.s3.PathMatchingSimpleStorageResourcePatternResolver;
+import org.springframework.context.ApplicationContext;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.core.io.WritableResource;
+import org.springframework.core.io.support.ResourcePatternResolver;
+import org.springframework.stereotype.Component;
+
+import com.amazonaws.services.s3.AmazonS3;
+
@Component
public class SpringCloudS3 {
@Autowired
ResourceLoader resourceLoader;
+ private ResourcePatternResolver resourcePatternResolver;
+
@Autowired
- ResourcePatternResolver resourcePatternResolver;
+ public void setupResolver(ApplicationContext applicationContext, AmazonS3 amazonS3) {
+ this.resourcePatternResolver = new PathMatchingSimpleStorageResourcePatternResolver(amazonS3, applicationContext);
+ }
public void downloadS3Object(String s3Url) throws IOException {
Resource resource = resourceLoader.getResource(s3Url);
diff --git a/spring-cloud/spring-cloud-aws/src/main/resources/application.properties b/spring-cloud/spring-cloud-aws/src/main/resources/application.properties
index 690eda13a2..e8139326b9 100644
--- a/spring-cloud/spring-cloud-aws/src/main/resources/application.properties
+++ b/spring-cloud/spring-cloud-aws/src/main/resources/application.properties
@@ -2,7 +2,6 @@ cloud.aws.credentials.accessKey=YourAccessKey
cloud.aws.credentials.secretKey=YourSecretKey
cloud.aws.region.static=us-east-1
-cloud.aws.rds.spring-cloud-test-db
cloud.aws.rds.spring-cloud-test-db.password=se3retpass
# These 3 properties are optional
diff --git a/spring-cloud/spring-cloud-circuit-breaker/README.md b/spring-cloud/spring-cloud-circuit-breaker/README.md
index 040eb0ccee..894be93408 100644
--- a/spring-cloud/spring-cloud-circuit-breaker/README.md
+++ b/spring-cloud/spring-cloud-circuit-breaker/README.md
@@ -3,3 +3,5 @@
This module contains articles about Spring Cloud Circuit Breaker
### Relevant Articles:
+
+- [Quick Guide to Spring Cloud Circuit Breaker](https://www.baeldung.com/spring-cloud-circuit-breaker)
diff --git a/spring-cloud/spring-cloud-gateway/pom.xml b/spring-cloud/spring-cloud-gateway/pom.xml
index 0f62c031cf..c692eed7ec 100644
--- a/spring-cloud/spring-cloud-gateway/pom.xml
+++ b/spring-cloud/spring-cloud-gateway/pom.xml
@@ -1,7 +1,7 @@
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
spring-cloud-gateway
spring-cloud-gateway
@@ -49,6 +49,26 @@
spring-cloud-starter-gateway
+
+
+ org.springframework.cloud
+ spring-cloud-starter-circuitbreaker-reactor-resilience4j
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis-reactive
+
+
+
+
+ it.ozimov
+ embedded-redis
+ ${redis.version}
+ test
+
+
org.hibernate
hibernate-validator-cdi
@@ -69,8 +89,8 @@
test
- org.springframework.boot
- spring-boot-devtools
+ org.springframework.boot
+ spring-boot-devtools
@@ -84,11 +104,10 @@
- Greenwich.SR3
-
-
- 2.1.9.RELEASE
+ Hoxton.SR3
+ 2.2.6.RELEASE
6.0.2.Final
+ 0.7.2
diff --git a/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/WebFilterGatewayApplication.java b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/WebFilterGatewayApplication.java
new file mode 100644
index 0000000000..852e5cadba
--- /dev/null
+++ b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/WebFilterGatewayApplication.java
@@ -0,0 +1,15 @@
+package com.baeldung.springcloudgateway.webfilters;
+
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+
+@SpringBootApplication
+public class WebFilterGatewayApplication {
+
+ public static void main(String[] args) {
+ new SpringApplicationBuilder(WebFilterGatewayApplication.class)
+ .profiles("webfilters")
+ .run(args);
+ }
+
+}
\ No newline at end of file
diff --git a/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/ModifyBodyRouteConfig.java b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/ModifyBodyRouteConfig.java
new file mode 100644
index 0000000000..7b6188b66a
--- /dev/null
+++ b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/ModifyBodyRouteConfig.java
@@ -0,0 +1,49 @@
+package com.baeldung.springcloudgateway.webfilters.config;
+
+import org.springframework.cloud.gateway.route.RouteLocator;
+import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.MediaType;
+
+import reactor.core.publisher.Mono;
+
+@Configuration
+public class ModifyBodyRouteConfig {
+
+ @Bean
+ public RouteLocator routes(RouteLocatorBuilder builder) {
+ return builder.routes()
+ .route("modify_request_body", r -> r.path("/post")
+ .filters(f -> f.modifyRequestBody(String.class, Hello.class, MediaType.APPLICATION_JSON_VALUE,
+ (exchange, s) -> Mono.just(new Hello(s.toUpperCase())))).uri("https://httpbin.org"))
+ .build();
+ }
+
+ @Bean
+ public RouteLocator responseRoutes(RouteLocatorBuilder builder) {
+ return builder.routes()
+ .route("modify_response_body", r -> r.path("/put/**")
+ .filters(f -> f.modifyResponseBody(String.class, Hello.class, MediaType.APPLICATION_JSON_VALUE,
+ (exchange, s) -> Mono.just(new Hello("New Body")))).uri("https://httpbin.org"))
+ .build();
+ }
+
+ static class Hello {
+ String message;
+
+ public Hello() { }
+
+ public Hello(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+ }
+}
diff --git a/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/RequestRateLimiterResolverConfig.java b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/RequestRateLimiterResolverConfig.java
new file mode 100644
index 0000000000..f80a742fa6
--- /dev/null
+++ b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/RequestRateLimiterResolverConfig.java
@@ -0,0 +1,16 @@
+package com.baeldung.springcloudgateway.webfilters.config;
+
+import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import reactor.core.publisher.Mono;
+
+@Configuration
+public class RequestRateLimiterResolverConfig {
+
+ @Bean
+ KeyResolver userKeyResolver() {
+ return exchange -> Mono.just("1");
+ }
+}
diff --git a/spring-cloud/spring-cloud-gateway/src/main/resources/application-webfilters.yml b/spring-cloud/spring-cloud-gateway/src/main/resources/application-webfilters.yml
new file mode 100644
index 0000000000..3348cbbba0
--- /dev/null
+++ b/spring-cloud/spring-cloud-gateway/src/main/resources/application-webfilters.yml
@@ -0,0 +1,102 @@
+logging:
+ level:
+ org.springframework.cloud.gateway: INFO
+ reactor.netty.http.client: INFO
+
+spring:
+ redis:
+ host: localhost
+ port: 6379
+ cloud:
+ gateway:
+ routes:
+ - id: request_header_route
+ uri: https://httpbin.org
+ predicates:
+ - Path=/get/**
+ filters:
+ - AddRequestHeader=My-Header-Good,Good
+ - AddRequestHeader=My-Header-Remove,Remove
+ - AddRequestParameter=var, good
+ - AddRequestParameter=var2, remove
+ - MapRequestHeader=My-Header-Good, My-Header-Bad
+ - MapRequestHeader=My-Header-Set, My-Header-Bad
+ - SetRequestHeader=My-Header-Set, Set
+ - RemoveRequestHeader=My-Header-Remove
+ - RemoveRequestParameter=var2
+ - PreserveHostHeader
+
+ - id: response_header_route
+ uri: https://httpbin.org
+ predicates:
+ - Path=/header/post/**
+ filters:
+ - AddResponseHeader=My-Header-Good,Good
+ - AddResponseHeader=My-Header-Set,Good
+ - AddResponseHeader=My-Header-Rewrite, password=12345678
+ - DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin
+ - AddResponseHeader=My-Header-Remove,Remove
+ - SetResponseHeader=My-Header-Set, Set
+ - RemoveResponseHeader=My-Header-Remove
+ - RewriteResponseHeader=My-Header-Rewrite, password=[^&]+, password=***
+ - RewriteLocationResponseHeader=AS_IN_REQUEST, Location, ,
+ - StripPrefix=1
+
+ - id: path_route
+ uri: https://httpbin.org
+ predicates:
+ - Path=/new/post/**
+ filters:
+ - RewritePath=/new(?/?.*), $\{segment}
+ - SetPath=/post
+
+ - id: redirect_route
+ uri: https://httpbin.org
+ predicates:
+ - Path=/fake/post/**
+ filters:
+ - RedirectTo=302, https://httpbin.org
+
+ - id: status_route
+ uri: https://httpbin.org
+ predicates:
+ - Path=/delete/**
+ filters:
+ - SetStatus=401
+
+ - id: size_route
+ uri: https://httpbin.org
+ predicates:
+ - Path=/anything
+ filters:
+ - name: RequestSize
+ args:
+ maxSize: 5000000
+
+ - id: retry_test
+ uri: https://httpbin.org
+ predicates:
+ - Path=/status/502
+ filters:
+ - name: Retry
+ args:
+ retries: 3
+ statuses: BAD_GATEWAY
+ methods: GET,POST
+ backoff:
+ firstBackoff: 10ms
+ maxBackoff: 50ms
+ factor: 2
+ basedOnPreviousValue: false
+
+ - id: request_rate_limiter
+ uri: https://httpbin.org
+ predicates:
+ - Path=/redis/get/**
+ filters:
+ - StripPrefix=1
+ - name: RequestRateLimiter
+ args:
+ redis-rate-limiter.replenishRate: 10
+ redis-rate-limiter.burstCapacity: 5
+ key-resolver: "#{@userKeyResolver}"
\ No newline at end of file
diff --git a/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/RedisWebFilterFactoriesLiveTest.java b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/RedisWebFilterFactoriesLiveTest.java
new file mode 100644
index 0000000000..a28eb68775
--- /dev/null
+++ b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/RedisWebFilterFactoriesLiveTest.java
@@ -0,0 +1,64 @@
+package com.baeldung.springcloudgateway.webfilters;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.jupiter.api.RepeatedTest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.context.TestConfiguration;
+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.ActiveProfiles;
+
+import redis.embedded.RedisServer;
+
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("webfilters")
+@TestConfiguration
+public class RedisWebFilterFactoriesLiveTest {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(RedisWebFilterFactoriesLiveTest.class);
+
+ private RedisServer redisServer;
+
+ public RedisWebFilterFactoriesLiveTest() {
+ }
+
+ @Before
+ public void postConstruct() {
+ this.redisServer = new RedisServer(6379);
+ redisServer.start();
+ }
+
+ @LocalServerPort
+ String port;
+
+ @Autowired
+ private TestRestTemplate restTemplate;
+
+ @Autowired
+ TestRestTemplate template;
+
+ @RepeatedTest(25)
+ public void whenCallRedisGetThroughGateway_thenOKStatusOrIsReceived() {
+ String url = "http://localhost:" + port + "/redis/get";
+
+ ResponseEntity r = restTemplate.getForEntity(url, String.class);
+ // assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
+
+ LOGGER.info("Received: status->{}, reason->{}, remaining->{}",
+ r.getStatusCodeValue(), r.getStatusCode().getReasonPhrase(),
+ r.getHeaders().get("X-RateLimit-Remaining"));
+ }
+
+ @After
+ public void preDestroy() {
+ redisServer.stop();
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/WebFilterFactoriesLiveTest.java b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/WebFilterFactoriesLiveTest.java
new file mode 100644
index 0000000000..67e00a42fc
--- /dev/null
+++ b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/WebFilterFactoriesLiveTest.java
@@ -0,0 +1,136 @@
+package com.baeldung.springcloudgateway.webfilters;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.assertj.core.api.Condition;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.web.reactive.server.WebTestClient;
+import org.springframework.test.web.reactive.server.WebTestClient.ResponseSpec;
+
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("webfilters")
+public class WebFilterFactoriesLiveTest {
+
+ @LocalServerPort
+ String port;
+
+ @Autowired
+ private WebTestClient client;
+
+ @Autowired
+ private TestRestTemplate restTemplate;
+
+ @BeforeEach
+ public void configureClient() {
+ client = WebTestClient.bindToServer()
+ .baseUrl("http://localhost:" + port)
+ .build();
+ }
+
+ @Test
+ public void whenCallGetThroughGateway_thenAllHTTPRequestHeadersParametersAreSet() throws JSONException {
+ String url = "http://localhost:" + port + "/get";
+ ResponseEntity response = restTemplate.getForEntity(url, String.class);
+ assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
+
+ JSONObject json = new JSONObject(response.getBody());
+ JSONObject headers = json.getJSONObject("headers");
+ assertThat(headers.getString("My-Header-Good")).isEqualTo("Good");
+ assertThat(headers.getString("My-Header-Bad")).isEqualTo("Good");
+ assertThat(headers.getString("My-Header-Set")).isEqualTo("Set");
+ assertTrue(headers.isNull("My-Header-Remove"));
+ JSONObject vars = json.getJSONObject("args");
+ assertThat(vars.getString("var")).isEqualTo("good");
+ }
+
+ @Test
+ public void whenCallHeaderPostThroughGateway_thenAllHTTPResponseHeadersAreSet() {
+ ResponseSpec response = client.post()
+ .uri("/header/post")
+ .exchange();
+
+ response.expectStatus()
+ .isOk()
+ .expectHeader()
+ .valueEquals("My-Header-Rewrite", "password=***")
+ .expectHeader()
+ .valueEquals("My-Header-Set", "Set")
+ .expectHeader()
+ .valueEquals("My-Header-Good", "Good")
+ .expectHeader()
+ .doesNotExist("My-Header-Remove");
+ }
+
+ @Test
+ public void whenCallPostThroughGateway_thenBodyIsRetrieved() throws JSONException {
+ String url = "http://localhost:" + port + "/post";
+
+ HttpEntity entity = new HttpEntity<>("content", new HttpHeaders());
+
+ ResponseEntity response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
+ assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
+
+ JSONObject json = new JSONObject(response.getBody());
+ JSONObject data = json.getJSONObject("json");
+ assertThat(data.getString("message")).isEqualTo("CONTENT");
+ }
+
+ @Test
+ public void whenCallPutThroughGateway_thenBodyIsRetrieved() throws JSONException {
+ String url = "http://localhost:" + port + "/put";
+
+ HttpEntity entity = new HttpEntity<>("CONTENT", new HttpHeaders());
+
+ ResponseEntity response = restTemplate.exchange(url, HttpMethod.PUT, entity, String.class);
+ assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
+
+ JSONObject json = new JSONObject(response.getBody());
+ assertThat(json.getString("message")).isEqualTo("New Body");
+ }
+
+ @Test
+ public void whenCallDeleteThroughGateway_thenIsUnauthorizedCodeIsSet() {
+ ResponseSpec response = client.delete()
+ .uri("/delete")
+ .exchange();
+
+ response.expectStatus()
+ .isUnauthorized();
+ }
+
+ @Test
+ public void whenCallFakePostThroughGateway_thenIsUnauthorizedCodeIsSet() {
+ ResponseSpec response = client.post()
+ .uri("/fake/post")
+ .exchange();
+
+ response.expectStatus()
+ .is3xxRedirection();
+ }
+
+ @Test
+ public void whenCallStatus504ThroughGateway_thenCircuitBreakerIsExecuted() throws JSONException {
+ String url = "http://localhost:" + port + "/status/504";
+ ResponseEntity response = restTemplate.getForEntity(url, String.class);
+
+ JSONObject json = new JSONObject(response.getBody());
+ assertThat(json.getString("url")).contains("anything");
+ }
+}
diff --git a/spring-cloud/spring-cloud-gateway/src/test/resources/logback-test.xml b/spring-cloud/spring-cloud-gateway/src/test/resources/logback-test.xml
index 6fcdb6317f..6980d119b1 100644
--- a/spring-cloud/spring-cloud-gateway/src/test/resources/logback-test.xml
+++ b/spring-cloud/spring-cloud-gateway/src/test/resources/logback-test.xml
@@ -3,7 +3,15 @@
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-core-2/README.md b/spring-core-2/README.md
index d9110f629d..10d3080b45 100644
--- a/spring-core-2/README.md
+++ b/spring-core-2/README.md
@@ -14,5 +14,5 @@ This module contains articles about core Spring functionality
- [Spring Events](https://www.baeldung.com/spring-events)
- [Spring Null-Safety Annotations](https://www.baeldung.com/spring-null-safety-annotations)
- [Using @Autowired in Abstract Classes](https://www.baeldung.com/spring-autowired-abstract-class)
-- [Running Setup Data in Startup](https://www.baeldung.com/running-setup-logic-on-startup-in-spring)
+- [Running Setup Data on Startup in Spring](https://www.baeldung.com/running-setup-logic-on-startup-in-spring)
- More articles: [[<-- prev]](/spring-core)[[next -->]](/spring-core-3)
diff --git a/spring-core-4/README.md b/spring-core-4/README.md
new file mode 100644
index 0000000000..f882c77179
--- /dev/null
+++ b/spring-core-4/README.md
@@ -0,0 +1,7 @@
+## Spring Core
+
+This module contains articles about core Spring functionality
+
+## Relevant Articles:
+
+- More articles: [[<-- prev]](/spring-core-3)
diff --git a/spring-core-4/pom.xml b/spring-core-4/pom.xml
new file mode 100644
index 0000000000..53f7ca6912
--- /dev/null
+++ b/spring-core-4/pom.xml
@@ -0,0 +1,63 @@
+
+
+ 4.0.0
+ spring-core-4
+ spring-core-4
+
+
+ com.baeldung
+ parent-spring-5
+ 0.0.1-SNAPSHOT
+ ../parent-spring-5
+
+
+
+
+ org.springframework
+ spring-context
+ ${spring.version}
+
+
+ org.springframework
+ spring-core
+ ${spring.version}
+
+
+ org.springframework
+ spring-test
+ ${spring.version}
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit-jupiter.version}
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ ${junit-jupiter.version}
+ test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven.surefire.version}
+
+
+
+
+
+ 2.22.1
+ 1.3.2
+ 2.2.2.RELEASE
+
+
+
\ No newline at end of file
diff --git a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/BeanFactoryDynamicAutowireService.java b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/BeanFactoryDynamicAutowireService.java
new file mode 100644
index 0000000000..4ad4420489
--- /dev/null
+++ b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/BeanFactoryDynamicAutowireService.java
@@ -0,0 +1,27 @@
+package com.baeldung.dynamic.autowire;
+
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class BeanFactoryDynamicAutowireService {
+ private static final String SERVICE_NAME_SUFFIX = "regionService";
+ private final BeanFactory beanFactory;
+
+ @Autowired
+ public BeanFactoryDynamicAutowireService(BeanFactory beanFactory) {
+ this.beanFactory = beanFactory;
+ }
+
+ public boolean isServerActive(String isoCountryCode, int serverId) {
+ RegionService service = beanFactory.getBean(getRegionServiceBeanName(isoCountryCode), RegionService.class);
+
+ return service.isServerActive(serverId);
+ }
+
+ private String getRegionServiceBeanName(String isoCountryCode) {
+ return isoCountryCode + SERVICE_NAME_SUFFIX;
+ }
+
+}
diff --git a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/CustomMapFromListDynamicAutowireService.java b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/CustomMapFromListDynamicAutowireService.java
new file mode 100644
index 0000000000..e04c345d51
--- /dev/null
+++ b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/CustomMapFromListDynamicAutowireService.java
@@ -0,0 +1,26 @@
+package com.baeldung.dynamic.autowire;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+@Service
+public class CustomMapFromListDynamicAutowireService {
+ private final Map servicesByCountryCode;
+
+ @Autowired
+ public CustomMapFromListDynamicAutowireService(List regionServices) {
+ servicesByCountryCode = regionServices.stream()
+ .collect(Collectors.toMap(RegionService::getISOCountryCode, Function.identity()));
+ }
+
+ public boolean isServerActive(String isoCountryCode, int serverId) {
+ RegionService service = servicesByCountryCode.get(isoCountryCode);
+
+ return service.isServerActive(serverId);
+ }
+}
diff --git a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/DynamicAutowireConfig.java b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/DynamicAutowireConfig.java
new file mode 100644
index 0000000000..256bd9b495
--- /dev/null
+++ b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/DynamicAutowireConfig.java
@@ -0,0 +1,9 @@
+package com.baeldung.dynamic.autowire;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@ComponentScan("com.baeldung.dynamic.autowire")
+public class DynamicAutowireConfig {
+}
diff --git a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/GBRegionService.java b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/GBRegionService.java
new file mode 100644
index 0000000000..8c6a1372d4
--- /dev/null
+++ b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/GBRegionService.java
@@ -0,0 +1,16 @@
+package com.baeldung.dynamic.autowire;
+
+import org.springframework.stereotype.Service;
+
+@Service("GBregionService")
+public class GBRegionService implements RegionService {
+ @Override
+ public boolean isServerActive(int serverId) {
+ return false;
+ }
+
+ @Override
+ public String getISOCountryCode() {
+ return "GB";
+ }
+}
diff --git a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/RegionService.java b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/RegionService.java
new file mode 100644
index 0000000000..a2caf38ab3
--- /dev/null
+++ b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/RegionService.java
@@ -0,0 +1,7 @@
+package com.baeldung.dynamic.autowire;
+
+public interface RegionService {
+ boolean isServerActive(int serverId);
+
+ String getISOCountryCode();
+}
diff --git a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/USRegionService.java b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/USRegionService.java
new file mode 100644
index 0000000000..a2d5f47553
--- /dev/null
+++ b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/USRegionService.java
@@ -0,0 +1,16 @@
+package com.baeldung.dynamic.autowire;
+
+import org.springframework.stereotype.Service;
+
+@Service("USregionService")
+public class USRegionService implements RegionService {
+ @Override
+ public boolean isServerActive(int serverId) {
+ return true;
+ }
+
+ @Override
+ public String getISOCountryCode() {
+ return "US";
+ }
+}
diff --git a/spring-core-4/src/main/java/com/baeldung/factorymethod/Bar.java b/spring-core-4/src/main/java/com/baeldung/factorymethod/Bar.java
new file mode 100644
index 0000000000..22ef5b3429
--- /dev/null
+++ b/spring-core-4/src/main/java/com/baeldung/factorymethod/Bar.java
@@ -0,0 +1,18 @@
+package com.baeldung.factorymethod;
+
+public class Bar {
+
+ private String name;
+
+ public Bar(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/spring-core-4/src/main/java/com/baeldung/factorymethod/Foo.java b/spring-core-4/src/main/java/com/baeldung/factorymethod/Foo.java
new file mode 100644
index 0000000000..54bd0c9ff4
--- /dev/null
+++ b/spring-core-4/src/main/java/com/baeldung/factorymethod/Foo.java
@@ -0,0 +1,5 @@
+package com.baeldung.factorymethod;
+
+public class Foo {
+
+}
diff --git a/spring-core-4/src/main/java/com/baeldung/factorymethod/InstanceBarFactory.java b/spring-core-4/src/main/java/com/baeldung/factorymethod/InstanceBarFactory.java
new file mode 100644
index 0000000000..f834b82aee
--- /dev/null
+++ b/spring-core-4/src/main/java/com/baeldung/factorymethod/InstanceBarFactory.java
@@ -0,0 +1,8 @@
+package com.baeldung.factorymethod;
+
+public class InstanceBarFactory {
+
+ public Bar createInstance(String name) {
+ return new Bar(name);
+ }
+}
diff --git a/spring-core-4/src/main/java/com/baeldung/factorymethod/InstanceFooFactory.java b/spring-core-4/src/main/java/com/baeldung/factorymethod/InstanceFooFactory.java
new file mode 100644
index 0000000000..c3125d3339
--- /dev/null
+++ b/spring-core-4/src/main/java/com/baeldung/factorymethod/InstanceFooFactory.java
@@ -0,0 +1,8 @@
+package com.baeldung.factorymethod;
+
+public class InstanceFooFactory {
+
+ public Foo createInstance() {
+ return new Foo();
+ }
+}
diff --git a/spring-core-4/src/main/java/com/baeldung/factorymethod/SingletonBarFactory.java b/spring-core-4/src/main/java/com/baeldung/factorymethod/SingletonBarFactory.java
new file mode 100644
index 0000000000..93802819b1
--- /dev/null
+++ b/spring-core-4/src/main/java/com/baeldung/factorymethod/SingletonBarFactory.java
@@ -0,0 +1,11 @@
+package com.baeldung.factorymethod;
+
+public class SingletonBarFactory {
+
+ private static final Bar INSTANCE = new Bar("unnamed");
+
+ public static Bar createInstance(String name) {
+ INSTANCE.setName(name);
+ return INSTANCE;
+ }
+}
diff --git a/spring-core-4/src/main/java/com/baeldung/factorymethod/SingletonFooFactory.java b/spring-core-4/src/main/java/com/baeldung/factorymethod/SingletonFooFactory.java
new file mode 100644
index 0000000000..77d56cc7f6
--- /dev/null
+++ b/spring-core-4/src/main/java/com/baeldung/factorymethod/SingletonFooFactory.java
@@ -0,0 +1,10 @@
+package com.baeldung.factorymethod;
+
+public class SingletonFooFactory {
+
+ private static final Foo INSTANCE = new Foo();
+
+ public static Foo createInstance() {
+ return INSTANCE;
+ }
+}
diff --git a/spring-core-4/src/test/java/com/baeldung/dynamic/autowire/DynamicAutowireIntegrationTest.java b/spring-core-4/src/test/java/com/baeldung/dynamic/autowire/DynamicAutowireIntegrationTest.java
new file mode 100644
index 0000000000..56582ecb66
--- /dev/null
+++ b/spring-core-4/src/test/java/com/baeldung/dynamic/autowire/DynamicAutowireIntegrationTest.java
@@ -0,0 +1,33 @@
+package com.baeldung.dynamic.autowire;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = DynamicAutowireConfig.class)
+public class DynamicAutowireIntegrationTest {
+
+ @Autowired
+ private BeanFactoryDynamicAutowireService beanFactoryDynamicAutowireService;
+
+ @Autowired
+ private CustomMapFromListDynamicAutowireService customMapFromListDynamicAutowireService;
+
+ @Test
+ public void givenDynamicallyAutowiredBean_whenCheckingServerInGB_thenServerIsNotActive() {
+ assertThat(beanFactoryDynamicAutowireService.isServerActive("GB", 101), is(false));
+ assertThat(customMapFromListDynamicAutowireService.isServerActive("GB", 101), is(false));
+ }
+
+ @Test
+ public void givenDynamicallyAutowiredBean_whenCheckingServerInUS_thenServerIsActive() {
+ assertThat(beanFactoryDynamicAutowireService.isServerActive("US", 101), is(true));
+ assertThat(customMapFromListDynamicAutowireService.isServerActive("US", 101), is(true));
+ }
+}
diff --git a/spring-core-4/src/test/java/com/baeldung/factorymethod/InstanceBarFactoryIntegrationTest.java b/spring-core-4/src/test/java/com/baeldung/factorymethod/InstanceBarFactoryIntegrationTest.java
new file mode 100644
index 0000000000..b5728316e7
--- /dev/null
+++ b/spring-core-4/src/test/java/com/baeldung/factorymethod/InstanceBarFactoryIntegrationTest.java
@@ -0,0 +1,24 @@
+package com.baeldung.factorymethod;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("/factorymethod/instance-bar-config.xml")
+public class InstanceBarFactoryIntegrationTest {
+
+ @Autowired
+ private Bar instance;
+
+ @Test
+ public void givenValidInstanceFactoryConfig_whenCreateInstance_thenNameIsCorrect() {
+ assertNotNull(instance);
+ assertEquals("someName", instance.getName());
+ }
+}
diff --git a/spring-core-4/src/test/java/com/baeldung/factorymethod/InstanceFooFactoryIntegrationTest.java b/spring-core-4/src/test/java/com/baeldung/factorymethod/InstanceFooFactoryIntegrationTest.java
new file mode 100644
index 0000000000..6b1857c2f2
--- /dev/null
+++ b/spring-core-4/src/test/java/com/baeldung/factorymethod/InstanceFooFactoryIntegrationTest.java
@@ -0,0 +1,22 @@
+package com.baeldung.factorymethod;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("/factorymethod/instance-foo-config.xml")
+public class InstanceFooFactoryIntegrationTest {
+
+ @Autowired
+ private Foo foo;
+
+ @Test
+ public void givenValidInstanceFactoryConfig_whenCreateFooInstance_thenInstanceIsNotNull() {
+ assertNotNull(foo);
+ }
+}
diff --git a/spring-core-4/src/test/java/com/baeldung/factorymethod/SingletonBarFactoryIntegrationTest.java b/spring-core-4/src/test/java/com/baeldung/factorymethod/SingletonBarFactoryIntegrationTest.java
new file mode 100644
index 0000000000..403b46156b
--- /dev/null
+++ b/spring-core-4/src/test/java/com/baeldung/factorymethod/SingletonBarFactoryIntegrationTest.java
@@ -0,0 +1,24 @@
+package com.baeldung.factorymethod;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("/factorymethod/static-bar-config.xml")
+public class SingletonBarFactoryIntegrationTest {
+
+ @Autowired
+ private Bar instance;
+
+ @Test
+ public void givenValidStaticFactoryConfig_whenCreateInstance_thenNameIsCorrect() {
+ assertNotNull(instance);
+ assertEquals("someName", instance.getName());
+ }
+}
diff --git a/spring-core-4/src/test/java/com/baeldung/factorymethod/SingletonFooFactoryIntegrationTest.java b/spring-core-4/src/test/java/com/baeldung/factorymethod/SingletonFooFactoryIntegrationTest.java
new file mode 100644
index 0000000000..52154b81ab
--- /dev/null
+++ b/spring-core-4/src/test/java/com/baeldung/factorymethod/SingletonFooFactoryIntegrationTest.java
@@ -0,0 +1,22 @@
+package com.baeldung.factorymethod;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("/factorymethod/static-foo-config.xml")
+public class SingletonFooFactoryIntegrationTest {
+
+ @Autowired
+ private Foo singleton;
+
+ @Test
+ public void givenValidStaticFactoryConfig_whenCreateInstance_thenInstanceIsNotNull() {
+ assertNotNull(singleton);
+ }
+}
diff --git a/spring-core-4/src/test/resources/factorymethod/instance-bar-config.xml b/spring-core-4/src/test/resources/factorymethod/instance-bar-config.xml
new file mode 100644
index 0000000000..a4281aee4e
--- /dev/null
+++ b/spring-core-4/src/test/resources/factorymethod/instance-bar-config.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-core-4/src/test/resources/factorymethod/instance-foo-config.xml b/spring-core-4/src/test/resources/factorymethod/instance-foo-config.xml
new file mode 100644
index 0000000000..0f21f06f5a
--- /dev/null
+++ b/spring-core-4/src/test/resources/factorymethod/instance-foo-config.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-core-4/src/test/resources/factorymethod/static-bar-config.xml b/spring-core-4/src/test/resources/factorymethod/static-bar-config.xml
new file mode 100644
index 0000000000..2cacc293bc
--- /dev/null
+++ b/spring-core-4/src/test/resources/factorymethod/static-bar-config.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-core-4/src/test/resources/factorymethod/static-foo-config.xml b/spring-core-4/src/test/resources/factorymethod/static-foo-config.xml
new file mode 100644
index 0000000000..ffe1480638
--- /dev/null
+++ b/spring-core-4/src/test/resources/factorymethod/static-foo-config.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-jenkins-pipeline/scripted-pipeline-unix-nonunix b/spring-jenkins-pipeline/scripted-pipeline-unix-nonunix
index b76bb8a81a..871fee4ccb 100644
--- a/spring-jenkins-pipeline/scripted-pipeline-unix-nonunix
+++ b/spring-jenkins-pipeline/scripted-pipeline-unix-nonunix
@@ -72,7 +72,7 @@ node {
if (isUnix()) {
sh 'nohup ./mvnw spring-boot:run -Dserver.port=8989 &'
} else {
- bat 'start ./mvnw.cmd spring-boot:run -Dserver.port=8989'
+ bat 'start mvnw.cmd spring-boot:run -Dserver.port=8989'
}
}
}
diff --git a/spring-mvc-basics-2/README.md b/spring-mvc-basics-2/README.md
index e52459bd6e..673b7b1fef 100644
--- a/spring-mvc-basics-2/README.md
+++ b/spring-mvc-basics-2/README.md
@@ -9,7 +9,7 @@ This module contains articles about Spring MVC
- [Servlet Redirect vs Forward](https://www.baeldung.com/servlet-redirect-forward)
- [Apache Tiles Integration with Spring MVC](https://www.baeldung.com/spring-mvc-apache-tiles)
- [Guide to Spring Email](https://www.baeldung.com/spring-email)
-- [Using ThymeLeaf and FreeMarker Emails Templates with Spring](https://www.baeldung.com/thymeleaf-freemarker-email)
+- [Using ThymeLeaf and FreeMarker Emails Templates with Spring](https://www.baeldung.com/spring-email-templates)
- [Request Method Not Supported (405) in Spring](https://www.baeldung.com/spring-request-method-not-supported-405)
- [Spring @RequestParam Annotation](https://www.baeldung.com/spring-request-param)
- More articles: [[more -->]](/spring-mvc-basics-3)
diff --git a/spring-mvc-java-2/README.md b/spring-mvc-java-2/README.md
index b5d5df3cd4..09c8d8b294 100644
--- a/spring-mvc-java-2/README.md
+++ b/spring-mvc-java-2/README.md
@@ -1,3 +1,6 @@
### Relevant Articles:
- [Cache Headers in Spring MVC](https://www.baeldung.com/spring-mvc-cache-headers)
+- [Working with Date Parameters in Spring](https://www.baeldung.com/spring-date-parameters)
+- [Spring MVC @PathVariable with a dot (.) gets truncated](https://www.baeldung.com/spring-mvc-pathvariable-dot)
+- [A Quick Guide to Spring MVC Matrix Variables](https://www.baeldung.com/spring-mvc-matrix-variables)
\ No newline at end of file
diff --git a/spring-mvc-java-2/pom.xml b/spring-mvc-java-2/pom.xml
index d5b7d087ab..af622321cb 100644
--- a/spring-mvc-java-2/pom.xml
+++ b/spring-mvc-java-2/pom.xml
@@ -7,14 +7,14 @@
0.1-SNAPSHOT
spring-mvc-java-2
war
-
+
com.baeldung
parent-boot-2
0.0.1-SNAPSHOT
../parent-boot-2
-
+
javax.servlet
@@ -26,14 +26,27 @@
spring-webmvc
${spring.mvc.version}
-
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson.version}
+
-
+
+
+ spring-mvc-java-2
+
+
+ src/main/resources
+ true
+
+
+
+
4.0.1
5.2.2.RELEASE
-
\ No newline at end of file
diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/cache/WebConfig.java b/spring-mvc-java-2/src/main/java/com/baeldung/cache/CacheWebConfig.java
similarity index 96%
rename from spring-mvc-java-2/src/main/java/com/baeldung/cache/WebConfig.java
rename to spring-mvc-java-2/src/main/java/com/baeldung/cache/CacheWebConfig.java
index 2f07912e80..95367077bd 100644
--- a/spring-mvc-java-2/src/main/java/com/baeldung/cache/WebConfig.java
+++ b/spring-mvc-java-2/src/main/java/com/baeldung/cache/CacheWebConfig.java
@@ -15,7 +15,7 @@ import java.util.concurrent.TimeUnit;
@EnableWebMvc
@Configuration
@ComponentScan(basePackages = {"com.baeldung.cache"})
-public class WebConfig implements WebMvcConfigurer {
+public class CacheWebConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(final ViewControllerRegistry registry) {
diff --git a/spring-mvc-java/src/main/java/com/baeldung/datetime/DateTimeConfig.java b/spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeConfig.java
similarity index 100%
rename from spring-mvc-java/src/main/java/com/baeldung/datetime/DateTimeConfig.java
rename to spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeConfig.java
diff --git a/spring-mvc-java/src/main/java/com/baeldung/datetime/DateTimeController.java b/spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeController.java
similarity index 100%
rename from spring-mvc-java/src/main/java/com/baeldung/datetime/DateTimeController.java
rename to spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeController.java
diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/matrix/config/MatrixWebConfig.java b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/config/MatrixWebConfig.java
new file mode 100644
index 0000000000..489740fd33
--- /dev/null
+++ b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/config/MatrixWebConfig.java
@@ -0,0 +1,18 @@
+package com.baeldung.matrix.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import org.springframework.web.util.UrlPathHelper;
+
+@Configuration
+public class MatrixWebConfig implements WebMvcConfigurer {
+
+ @Override
+ public void configurePathMatch(PathMatchConfigurer configurer) {
+ final UrlPathHelper urlPathHelper = new UrlPathHelper();
+ urlPathHelper.setRemoveSemicolonContent(false);
+
+ configurer.setUrlPathHelper(urlPathHelper);
+ }
+}
diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/CompanyController.java b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/CompanyController.java
similarity index 81%
rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/CompanyController.java
rename to spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/CompanyController.java
index af1e729c13..7a21ded026 100644
--- a/spring-mvc-java/src/main/java/com/baeldung/web/controller/CompanyController.java
+++ b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/CompanyController.java
@@ -1,23 +1,16 @@
-package com.baeldung.web.controller;
-
-import java.util.HashMap;
-import java.util.Map;
+package com.baeldung.matrix.controller;
+import com.baeldung.matrix.model.Company;
import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
-import org.springframework.web.bind.annotation.MatrixVariable;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
-import com.baeldung.model.Company;
+import java.util.HashMap;
+import java.util.Map;
@Controller
public class CompanyController {
diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/EmployeeController.java b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/EmployeeController.java
similarity index 86%
rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/EmployeeController.java
rename to spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/EmployeeController.java
index 251287dff8..3f9de2179a 100644
--- a/spring-mvc-java/src/main/java/com/baeldung/web/controller/EmployeeController.java
+++ b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/EmployeeController.java
@@ -1,32 +1,22 @@
-package com.baeldung.web.controller;
+package com.baeldung.matrix.controller;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
+import com.baeldung.matrix.model.Employee;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
-import org.springframework.web.bind.annotation.MatrixVariable;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.SessionAttributes;
+import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
-import com.baeldung.model.Employee;
+import java.util.*;
@SessionAttributes("employees")
@Controller
public class EmployeeController {
- Map employeeMap = new HashMap<>();
+ public Map employeeMap = new HashMap<>();
@ModelAttribute("employees")
public void initEmployees() {
diff --git a/spring-mvc-java/src/main/java/com/baeldung/model/Company.java b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Company.java
similarity index 94%
rename from spring-mvc-java/src/main/java/com/baeldung/model/Company.java
rename to spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Company.java
index 558507268a..cdf6cb0fd6 100644
--- a/spring-mvc-java/src/main/java/com/baeldung/model/Company.java
+++ b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Company.java
@@ -1,4 +1,4 @@
-package com.baeldung.model;
+package com.baeldung.matrix.model;
public class Company {
diff --git a/spring-mvc-java/src/main/java/com/baeldung/model/Employee.java b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Employee.java
similarity index 97%
rename from spring-mvc-java/src/main/java/com/baeldung/model/Employee.java
rename to spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Employee.java
index fb0a452219..c3384122b4 100644
--- a/spring-mvc-java/src/main/java/com/baeldung/model/Employee.java
+++ b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Employee.java
@@ -1,4 +1,4 @@
-package com.baeldung.model;
+package com.baeldung.matrix.model;
import javax.xml.bind.annotation.XmlRootElement;
diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/CustomWebMvcConfigurationSupport.java b/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/CustomWebMvcConfigurationSupport.java
similarity index 93%
rename from spring-mvc-java/src/main/java/com/baeldung/spring/web/config/CustomWebMvcConfigurationSupport.java
rename to spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/CustomWebMvcConfigurationSupport.java
index a0dd7358d0..12c208c623 100644
--- a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/CustomWebMvcConfigurationSupport.java
+++ b/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/CustomWebMvcConfigurationSupport.java
@@ -1,4 +1,4 @@
-package com.baeldung.spring.web.config;
+package com.baeldung.pathvariable;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/SiteController.java b/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/SiteController.java
similarity index 69%
rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/SiteController.java
rename to spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/SiteController.java
index 3867380665..493161b0eb 100644
--- a/spring-mvc-java/src/main/java/com/baeldung/web/controller/SiteController.java
+++ b/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/SiteController.java
@@ -1,27 +1,30 @@
-package com.baeldung.web.controller;
+package com.baeldung.pathvariable;
+import org.springframework.stereotype.Controller;
+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.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+@RestController
@RequestMapping("/site")
public class SiteController {
- @RequestMapping(value = "/{firstValue}/{secondValue}", method = RequestMethod.GET)
+ @GetMapping("/{firstValue}/{secondValue}")
public String requestWithError(@PathVariable("firstValue") String firstValue,
@PathVariable("secondValue") String secondValue) {
return firstValue + " - " + secondValue;
}
- @RequestMapping(value = "/{firstValue}/{secondValue:.+}", method = RequestMethod.GET)
+ @GetMapping("/{firstValue}/{secondValue:.+}")
public String requestWithRegex(@PathVariable("firstValue") String firstValue,
@PathVariable("secondValue") String secondValue) {
return firstValue + " - " + secondValue;
}
- @RequestMapping(value = "/{firstValue}/{secondValue}/", method = RequestMethod.GET)
+ @GetMapping("/{firstValue}/{secondValue}/")
public String requestWithSlash(@PathVariable("firstValue") String firstValue,
@PathVariable("secondValue") String secondValue) {
diff --git a/spring-mvc-java-2/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-mvc-java-2/src/main/webapp/WEB-INF/mvc-servlet.xml
new file mode 100644
index 0000000000..00dac5f8cb
--- /dev/null
+++ b/spring-mvc-java-2/src/main/webapp/WEB-INF/mvc-servlet.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+ /WEB-INF/view/
+
+
+ .jsp
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/view/companyHome.jsp b/spring-mvc-java-2/src/main/webapp/WEB-INF/view/companyHome.jsp
similarity index 100%
rename from spring-mvc-java/src/main/webapp/WEB-INF/view/companyHome.jsp
rename to spring-mvc-java-2/src/main/webapp/WEB-INF/view/companyHome.jsp
diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/view/companyView.jsp b/spring-mvc-java-2/src/main/webapp/WEB-INF/view/companyView.jsp
similarity index 100%
rename from spring-mvc-java/src/main/webapp/WEB-INF/view/companyView.jsp
rename to spring-mvc-java-2/src/main/webapp/WEB-INF/view/companyView.jsp
diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/view/employeeHome.jsp b/spring-mvc-java-2/src/main/webapp/WEB-INF/view/employeeHome.jsp
similarity index 100%
rename from spring-mvc-java/src/main/webapp/WEB-INF/view/employeeHome.jsp
rename to spring-mvc-java-2/src/main/webapp/WEB-INF/view/employeeHome.jsp
diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/view/employeeView.jsp b/spring-mvc-java-2/src/main/webapp/WEB-INF/view/employeeView.jsp
similarity index 100%
rename from spring-mvc-java/src/main/webapp/WEB-INF/view/employeeView.jsp
rename to spring-mvc-java-2/src/main/webapp/WEB-INF/view/employeeView.jsp
diff --git a/spring-mvc-java-2/src/main/webapp/WEB-INF/web.xml b/spring-mvc-java-2/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..86a24e7646
--- /dev/null
+++ b/spring-mvc-java-2/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,22 @@
+
+
+ Spring MVC Application 2
+
+
+ mvc
+
+ org.springframework.web.servlet.DispatcherServlet
+
+
+ contextConfigLocation
+ /WEB-INF/mvc-servlet.xml
+
+ 1
+
+
+
+ mvc
+ /
+
+
\ No newline at end of file
diff --git a/spring-mvc-java-2/src/test/java/com/baeldung/cache/CacheControlControllerIntegrationTest.java b/spring-mvc-java-2/src/test/java/com/baeldung/cache/CacheControlControllerIntegrationTest.java
index 7acfe5e480..1e34dd182b 100644
--- a/spring-mvc-java-2/src/test/java/com/baeldung/cache/CacheControlControllerIntegrationTest.java
+++ b/spring-mvc-java-2/src/test/java/com/baeldung/cache/CacheControlControllerIntegrationTest.java
@@ -19,7 +19,7 @@ import static org.springframework.http.HttpHeaders.IF_UNMODIFIED_SINCE;
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
-@ContextConfiguration(classes = {WebConfig.class, WebConfig.class})
+@ContextConfiguration(classes = {CacheWebConfig.class, CacheWebConfig.class})
public class CacheControlControllerIntegrationTest {
@Autowired
diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/EmployeeMvcIntegrationTest.java b/spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeMvcIntegrationTest.java
similarity index 81%
rename from spring-mvc-java/src/test/java/com/baeldung/web/controller/EmployeeMvcIntegrationTest.java
rename to spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeMvcIntegrationTest.java
index 86420a5fbd..c061c1efc7 100644
--- a/spring-mvc-java/src/test/java/com/baeldung/web/controller/EmployeeMvcIntegrationTest.java
+++ b/spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeMvcIntegrationTest.java
@@ -1,11 +1,7 @@
-package com.baeldung.web.controller;
-
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
+package com.baeldung.matrix;
+import com.baeldung.matrix.config.MatrixWebConfig;
+import com.baeldung.matrix.controller.EmployeeController;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -18,11 +14,13 @@ import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
-import com.baeldung.spring.web.config.WebConfig;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
-@ContextConfiguration(classes = WebConfig.class)
+@ContextConfiguration(classes = { MatrixWebConfig.class, EmployeeController.class })
public class EmployeeMvcIntegrationTest {
@Autowired
diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/EmployeeNoMvcIntegrationTest.java b/spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeNoMvcIntegrationTest.java
similarity index 86%
rename from spring-mvc-java/src/test/java/com/baeldung/web/controller/EmployeeNoMvcIntegrationTest.java
rename to spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeNoMvcIntegrationTest.java
index e84c20c973..2ca70cc0b9 100644
--- a/spring-mvc-java/src/test/java/com/baeldung/web/controller/EmployeeNoMvcIntegrationTest.java
+++ b/spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeNoMvcIntegrationTest.java
@@ -1,5 +1,8 @@
-package com.baeldung.web.controller;
+package com.baeldung.matrix;
+import com.baeldung.matrix.config.MatrixWebConfig;
+import com.baeldung.matrix.controller.EmployeeController;
+import com.baeldung.matrix.model.Employee;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -9,12 +12,9 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
-import com.baeldung.model.Employee;
-import com.baeldung.spring.web.config.WebConfig;
-
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
-@ContextConfiguration(classes = WebConfig.class)
+@ContextConfiguration(classes = { MatrixWebConfig.class, EmployeeController.class })
public class EmployeeNoMvcIntegrationTest {
@Autowired
diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md
index f1263860f9..877d92901a 100644
--- a/spring-mvc-java/README.md
+++ b/spring-mvc-java/README.md
@@ -8,12 +8,9 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
### Relevant Articles:
- [Integration Testing in Spring](https://www.baeldung.com/integration-testing-in-spring)
-- [A Quick Guide to Spring MVC Matrix Variables](https://www.baeldung.com/spring-mvc-matrix-variables)
- [File Upload with Spring MVC](https://www.baeldung.com/spring-file-upload)
- [Introduction to HtmlUnit](https://www.baeldung.com/htmlunit)
- [Upload and Display Excel Files with Spring MVC](https://www.baeldung.com/spring-mvc-excel-files)
- [web.xml vs Initializer with Spring](https://www.baeldung.com/spring-xml-vs-java-config)
-- [Spring MVC @PathVariable with a dot (.) gets truncated](https://www.baeldung.com/spring-mvc-pathvariable-dot)
-- [Working with Date Parameters in Spring](https://www.baeldung.com/spring-date-parameters)
- [A Java Web Application Without a web.xml](https://www.baeldung.com/java-web-app-without-web-xml)
- [Accessing Spring MVC Model Objects in JavaScript](https://www.baeldung.com/spring-mvc-model-objects-js)
diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml
index 079a664a5d..9e3457aa8a 100644
--- a/spring-mvc-java/pom.xml
+++ b/spring-mvc-java/pom.xml
@@ -69,6 +69,12 @@
commons-io
${commons-io.version}
+
+ commons-fileupload
+ commons-fileupload
+ ${commons-fileupload.version}
+
+
@@ -237,6 +243,7 @@
3.5
1.3.2
2.5
+ 1.4
2.2.0
diff --git a/spring-security-modules/pom.xml b/spring-security-modules/pom.xml
index 49a0db03ed..7ce33dd3e3 100644
--- a/spring-security-modules/pom.xml
+++ b/spring-security-modules/pom.xml
@@ -31,6 +31,7 @@
spring-security-mvc-persisted-remember-me
spring-security-mvc-socket
spring-security-oidc
+ spring-security-okta
spring-security-react
spring-security-rest
spring-security-rest-basic-auth
diff --git a/spring-security-modules/spring-security-core/README.md b/spring-security-modules/spring-security-core/README.md
index e42dfecaa0..f28b3abb2b 100644
--- a/spring-security-modules/spring-security-core/README.md
+++ b/spring-security-modules/spring-security-core/README.md
@@ -8,6 +8,7 @@ This module contains articles about core Spring Security
- [Introduction to Spring Method Security](https://www.baeldung.com/spring-security-method-security)
- [Overview and Need for DelegatingFilterProxy in Spring](https://www.baeldung.com/spring-delegating-filter-proxy)
- [Deny Access on Missing @PreAuthorize to Spring Controller Methods](https://www.baeldung.com/spring-deny-access)
+- [Spring Security: Check If a User Has a Role in Java](https://www.baeldung.com/spring-security-check-user-role)
### Build the Project
diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java
index a084f14eca..7e6b2c3d9c 100644
--- a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java
+++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java
@@ -1,8 +1,15 @@
package com.baeldung.app.controller;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -10,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import com.baeldung.app.entity.Task;
import com.baeldung.app.service.TaskService;
+import javax.servlet.http.HttpServletRequest;
+
@Controller
@RequestMapping("api/tasks")
public class TaskController {
@@ -17,6 +26,9 @@ public class TaskController {
@Autowired
private TaskService taskService;
+ @Autowired(required = false)
+ private UserDetailsService userDetailsService;
+
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity> findAllTasks() {
Iterable tasks = taskService.findAll();
diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/App.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/App.java
new file mode 100644
index 0000000000..357583a572
--- /dev/null
+++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/App.java
@@ -0,0 +1,11 @@
+package com.baeldung.checkrolejava;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class App {
+ public static void main(String[] args) {
+ SpringApplication.run(com.baeldung.app.App.class, args);
+ }
+}
diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/UnauthorizedException.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/UnauthorizedException.java
new file mode 100644
index 0000000000..11fe9f9e5f
--- /dev/null
+++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/UnauthorizedException.java
@@ -0,0 +1,8 @@
+package com.baeldung.checkrolejava;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+@ResponseStatus(value = HttpStatus.UNAUTHORIZED)
+public class UnauthorizedException extends RuntimeException {
+}
diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/UserController.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/UserController.java
new file mode 100644
index 0000000000..3092e94c7f
--- /dev/null
+++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/UserController.java
@@ -0,0 +1,62 @@
+package com.baeldung.checkrolejava;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+
+import javax.servlet.http.HttpServletRequest;
+
+@Controller
+public class UserController {
+
+ @Autowired
+ private UserDetailsService userDetailsService;
+
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
+ @GetMapping("/user/{id}")
+ public String getUser(@PathVariable("id") String id) {
+ return "user";
+ }
+
+ @PreAuthorize("hasAnyRole('ROLE_ADMIN','ROLE_MANAGER')")
+ @GetMapping("/users")
+ public String getUsers() {
+ return "users";
+ }
+
+ @GetMapping("v2/user/{id}")
+ public String getUserUsingSecurityContext() {
+ Authentication auth = SecurityContextHolder.getContext().getAuthentication();
+ if (auth != null && auth.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ADMIN"))) {
+ return "user";
+ }
+
+ throw new UnauthorizedException();
+ }
+
+ @GetMapping("v2/users")
+ public String getUsersUsingDetailsService() {
+ UserDetails details = userDetailsService.loadUserByUsername("mike");
+ if (details != null && details.getAuthorities().stream()
+ .anyMatch(a -> a.getAuthority().equals("ADMIN"))) {
+ return "users";
+ }
+
+ throw new UnauthorizedException();
+ }
+
+ @GetMapping("v3/users")
+ public String getUsers(HttpServletRequest request) {
+ if (request.isUserInRole("ROLE_ADMIN")) {
+ return "users";
+ }
+
+ throw new UnauthorizedException();
+ }
+}
diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/CustomLogoutApplication.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/CustomLogoutApplication.java
new file mode 100644
index 0000000000..39d867b1f4
--- /dev/null
+++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/CustomLogoutApplication.java
@@ -0,0 +1,13 @@
+package com.baeldung.customlogouthandler;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class CustomLogoutApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(CustomLogoutApplication.class, args);
+ }
+
+}
diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/MvcConfiguration.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/MvcConfiguration.java
new file mode 100644
index 0000000000..c363effb4e
--- /dev/null
+++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/MvcConfiguration.java
@@ -0,0 +1,55 @@
+package com.baeldung.customlogouthandler;
+
+import javax.sql.DataSource;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler;
+
+import com.baeldung.customlogouthandler.web.CustomLogoutHandler;
+
+@Configuration
+@EnableWebSecurity
+public class MvcConfiguration extends WebSecurityConfigurerAdapter {
+
+ @Autowired
+ private DataSource dataSource;
+
+ @Autowired
+ private CustomLogoutHandler logoutHandler;
+
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http.httpBasic()
+ .and()
+ .authorizeRequests()
+ .antMatchers(HttpMethod.GET, "/user/**")
+ .hasRole("USER")
+ .and()
+ .logout()
+ .logoutUrl("/user/logout")
+ .addLogoutHandler(logoutHandler)
+ .logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler(HttpStatus.OK))
+ .permitAll()
+ .and()
+ .csrf()
+ .disable()
+ .formLogin()
+ .disable();
+ }
+
+ @Override
+ protected void configure(AuthenticationManagerBuilder auth) throws Exception {
+ auth.jdbcAuthentication()
+ .dataSource(dataSource)
+ .usersByUsernameQuery("select login, password, true from users where login=?")
+ .authoritiesByUsernameQuery("select login, role from users where login=?");
+ }
+
+}
diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/services/UserCache.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/services/UserCache.java
new file mode 100644
index 0000000000..b86edc0dee
--- /dev/null
+++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/services/UserCache.java
@@ -0,0 +1,35 @@
+package com.baeldung.customlogouthandler.services;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.springframework.stereotype.Service;
+
+import com.baeldung.customlogouthandler.user.User;
+
+@Service
+public class UserCache {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ private final ConcurrentMap store = new ConcurrentHashMap<>(256);
+
+ public User getByUserName(String userName) {
+ return store.computeIfAbsent(userName, k -> entityManager.createQuery("from User where login=:login", User.class)
+ .setParameter("login", k)
+ .getSingleResult());
+ }
+
+ public void evictUser(String userName) {
+ store.remove(userName);
+ }
+
+ public int size() {
+ return store.size();
+ }
+
+}
diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/User.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/User.java
new file mode 100644
index 0000000000..ca3a998c5c
--- /dev/null
+++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/User.java
@@ -0,0 +1,61 @@
+package com.baeldung.customlogouthandler.user;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "users")
+public class User {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Integer id;
+
+ @Column(unique = true)
+ private String login;
+
+ private String password;
+
+ private String role;
+
+ private String language;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getLogin() {
+ return login;
+ }
+
+ public void setLogin(String login) {
+ this.login = login;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+}
diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/UserUtils.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/UserUtils.java
new file mode 100644
index 0000000000..aa9a521b01
--- /dev/null
+++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/UserUtils.java
@@ -0,0 +1,14 @@
+package com.baeldung.customlogouthandler.user;
+
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+
+public class UserUtils {
+
+ public static String getAuthenticatedUserName() {
+ Authentication auth = SecurityContextHolder.getContext()
+ .getAuthentication();
+ return auth != null ? ((org.springframework.security.core.userdetails.User) auth.getPrincipal()).getUsername() : null;
+ }
+
+}
diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/CustomLogoutHandler.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/CustomLogoutHandler.java
new file mode 100644
index 0000000000..a89c9a570d
--- /dev/null
+++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/CustomLogoutHandler.java
@@ -0,0 +1,28 @@
+package com.baeldung.customlogouthandler.web;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.security.core.Authentication;
+import org.springframework.security.web.authentication.logout.LogoutHandler;
+import org.springframework.stereotype.Service;
+
+import com.baeldung.customlogouthandler.services.UserCache;
+import com.baeldung.customlogouthandler.user.UserUtils;
+
+@Service
+public class CustomLogoutHandler implements LogoutHandler {
+
+ private final UserCache userCache;
+
+ public CustomLogoutHandler(UserCache userCache) {
+ this.userCache = userCache;
+ }
+
+ @Override
+ public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
+ String userName = UserUtils.getAuthenticatedUserName();
+ userCache.evictUser(userName);
+ }
+
+}
diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/UserController.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/UserController.java
new file mode 100644
index 0000000000..b2d332a1bb
--- /dev/null
+++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/UserController.java
@@ -0,0 +1,30 @@
+package com.baeldung.customlogouthandler.web;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.baeldung.customlogouthandler.services.UserCache;
+import com.baeldung.customlogouthandler.user.User;
+import com.baeldung.customlogouthandler.user.UserUtils;
+
+@Controller
+@RequestMapping(path = "/user")
+public class UserController {
+
+ private final UserCache userCache;
+
+ public UserController(UserCache userCache) {
+ this.userCache = userCache;
+ }
+
+ @GetMapping(path = "/language")
+ @ResponseBody
+ public String getLanguage() {
+ String userName = UserUtils.getAuthenticatedUserName();
+ User user = userCache.getByUserName(userName);
+ return user.getLanguage();
+ }
+
+}
diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/application-customlogouthandler.properties b/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/application-customlogouthandler.properties
new file mode 100644
index 0000000000..2cb766378d
--- /dev/null
+++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/application-customlogouthandler.properties
@@ -0,0 +1,5 @@
+spring.datasource.url=jdbc:postgresql://localhost:5432/test
+spring.datasource.username=test
+spring.datasource.password=test
+
+spring.jpa.hibernate.ddl-auto=create
\ No newline at end of file
diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/customlogouthandler/CustomLogoutHandlerIntegrationTest.java b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/customlogouthandler/CustomLogoutHandlerIntegrationTest.java
new file mode 100644
index 0000000000..cd8a1a72d6
--- /dev/null
+++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/customlogouthandler/CustomLogoutHandlerIntegrationTest.java
@@ -0,0 +1,108 @@
+package com.baeldung.customlogouthandler;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+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.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.jdbc.Sql;
+import org.springframework.test.context.jdbc.SqlGroup;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.baeldung.customlogouthandler.services.UserCache;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringBootTest(classes = { CustomLogoutApplication.class }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@SqlGroup({ @Sql(value = "classpath:customlogouthandler/before.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD), @Sql(value = "classpath:customlogouthandler/after.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) })
+@TestPropertySource(locations="classpath:customlogouthandler/application.properties")
+class CustomLogoutHandlerIntegrationTest {
+
+ @Autowired
+ private TestRestTemplate restTemplate;
+
+ @Autowired
+ private UserCache userCache;
+
+ @LocalServerPort
+ private int port;
+
+ @Test
+ public void whenLogin_thenUseUserCache() {
+ // User cache should be empty on start
+ assertThat(userCache.size()).isEqualTo(0);
+
+ // Request using first login
+ ResponseEntity response = restTemplate.withBasicAuth("user", "pass")
+ .getForEntity(getLanguageUrl(), String.class);
+
+ assertThat(response.getBody()).contains("english");
+
+ // User cache must contain the user
+ assertThat(userCache.size()).isEqualTo(1);
+
+ // Getting the session cookie
+ HttpHeaders requestHeaders = new HttpHeaders();
+ requestHeaders.add("Cookie", response.getHeaders()
+ .getFirst(HttpHeaders.SET_COOKIE));
+
+ // Request with the session cookie
+ response = restTemplate.exchange(getLanguageUrl(), HttpMethod.GET, new HttpEntity(requestHeaders), String.class);
+ assertThat(response.getBody()).contains("english");
+
+ // Logging out using the session cookies
+ response = restTemplate.exchange(getLogoutUrl(), HttpMethod.GET, new HttpEntity(requestHeaders), String.class);
+ assertThat(response.getStatusCode()
+ .value()).isEqualTo(200);
+ }
+
+ @Test
+ public void whenLogout_thenCacheIsEmpty() {
+ // User cache should be empty on start
+ assertThat(userCache.size()).isEqualTo(0);
+
+ // Request using first login
+ ResponseEntity response = restTemplate.withBasicAuth("user", "pass")
+ .getForEntity(getLanguageUrl(), String.class);
+
+ assertThat(response.getBody()).contains("english");
+
+ // User cache must contain the user
+ assertThat(userCache.size()).isEqualTo(1);
+
+ // Getting the session cookie
+ HttpHeaders requestHeaders = new HttpHeaders();
+ requestHeaders.add("Cookie", response.getHeaders()
+ .getFirst(HttpHeaders.SET_COOKIE));
+
+ // Logging out using the session cookies
+ response = restTemplate.exchange(getLogoutUrl(), HttpMethod.GET, new HttpEntity(requestHeaders), String.class);
+ assertThat(response.getStatusCode()
+ .value()).isEqualTo(200);
+
+ // User cache must be empty now
+ // this is the reaction on custom logout filter execution
+ assertThat(userCache.size()).isEqualTo(0);
+
+ // Assert unauthorized request
+ response = restTemplate.exchange(getLanguageUrl(), HttpMethod.GET, new HttpEntity(requestHeaders), String.class);
+ assertThat(response.getStatusCode()
+ .value()).isEqualTo(401);
+ }
+
+ private String getLanguageUrl() {
+ return "http://localhost:" + port + "/user/language";
+ }
+
+ private String getLogoutUrl() {
+ return "http://localhost:" + port + "/user/logout";
+ }
+
+}
diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/after.sql b/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/after.sql
new file mode 100644
index 0000000000..df6f312987
--- /dev/null
+++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/after.sql
@@ -0,0 +1 @@
+delete from users;
\ No newline at end of file
diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/application.properties b/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/application.properties
new file mode 100644
index 0000000000..84347c2664
--- /dev/null
+++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/application.properties
@@ -0,0 +1,4 @@
+spring.datasource.driver-class-name=org.h2.Driver
+spring.datasource.url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
+spring.datasource.username=test
+spring.datasource.password=test
\ No newline at end of file
diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/before.sql b/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/before.sql
new file mode 100644
index 0000000000..bb0a85f613
--- /dev/null
+++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/before.sql
@@ -0,0 +1 @@
+insert into users (login, password, role, language) values ('user', '{noop}pass', 'ROLE_USER', 'english');
\ No newline at end of file
diff --git a/spring-security-modules/spring-security-okta/pom.xml b/spring-security-modules/spring-security-okta/pom.xml
new file mode 100644
index 0000000000..c5ff9013b5
--- /dev/null
+++ b/spring-security-modules/spring-security-okta/pom.xml
@@ -0,0 +1,62 @@
+
+
+ 4.0.0
+ spring-security-okta
+ 1.0-SNAPSHOT
+ spring-security-okta
+ war
+
+
+ com.baeldung
+ parent-boot-2
+ 0.0.1-SNAPSHOT
+ ../../parent-boot-2
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ com.okta.spring
+ okta-spring-boot-starter
+ ${okta.spring.version}
+
+
+ com.okta.spring
+ okta-spring-sdk
+ ${okta.spring.version}
+
+
+
+
+ spring-security-okta
+
+
+ src/main/resources
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+ true
+
+
+
+
+ repackage
+
+
+
+
+
+
+
+
+ 1.4.0
+
+
diff --git a/spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/Application.java b/spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/Application.java
new file mode 100644
index 0000000000..0c5cc94f10
--- /dev/null
+++ b/spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/Application.java
@@ -0,0 +1,13 @@
+package com.baeldung.okta;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class Application {
+
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+
+}
diff --git a/spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/controller/AdminController.java b/spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/controller/AdminController.java
new file mode 100644
index 0000000000..c7786c4006
--- /dev/null
+++ b/spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/controller/AdminController.java
@@ -0,0 +1,43 @@
+package com.baeldung.okta.controller;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.okta.sdk.client.Client;
+import com.okta.sdk.resource.user.User;
+import com.okta.sdk.resource.user.UserBuilder;
+import com.okta.sdk.resource.user.UserList;
+
+@RestController
+public class AdminController {
+
+ @Autowired
+ public Client client;
+
+ @GetMapping("/users")
+ public UserList getUsers() {
+ return client.listUsers();
+ }
+
+ @GetMapping("/user")
+ public UserList searchUserByEmail(@RequestParam String query) {
+ return client.listUsers(query, null, null, null, null);
+ }
+
+ @GetMapping("/createUser")
+ public User createUser() {
+ char[] tempPassword = {'P','a','$','$','w','0','r','d'};
+ User user = UserBuilder.instance()
+ .setEmail("norman.lewis@email.com")
+ .setFirstName("Norman")
+ .setLastName("Lewis")
+ .setPassword(tempPassword)
+ .setActive(true)
+ .buildAndCreate(client);
+ return user;
+ }
+
+}
+
diff --git a/spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/controller/HomeController.java b/spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/controller/HomeController.java
new file mode 100644
index 0000000000..b8f3ec4e10
--- /dev/null
+++ b/spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/controller/HomeController.java
@@ -0,0 +1,16 @@
+package com.baeldung.okta.controller;
+
+import org.springframework.security.core.annotation.AuthenticationPrincipal;
+import org.springframework.security.oauth2.core.oidc.user.OidcUser;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class HomeController {
+
+ @GetMapping("/")
+ public String home(@AuthenticationPrincipal OidcUser user) {
+ return "Welcome, "+ user.getFullName() +"!";
+ }
+
+}
diff --git a/spring-security-modules/spring-security-okta/src/main/resources/application.properties b/spring-security-modules/spring-security-okta/src/main/resources/application.properties
new file mode 100644
index 0000000000..4a584e3c29
--- /dev/null
+++ b/spring-security-modules/spring-security-okta/src/main/resources/application.properties
@@ -0,0 +1,8 @@
+okta.oauth2.issuer= //Auth server issuer URL
+okta.oauth2.client-id= //Client ID of our Okta application
+okta.oauth2.client-secret= //Client secret of our Okta application
+okta.oauth2.redirect-uri=/authorization-code/callback
+
+#Okta Spring SDK configs
+okta.client.orgUrl= //orgURL
+okta.client.token= //token generated
\ No newline at end of file
diff --git a/spring-swagger-codegen/spring-swagger-codegen-app/README.md b/spring-swagger-codegen/spring-swagger-codegen-app/README.md
index 1cb9e35d99..8740b17ba3 100644
--- a/spring-swagger-codegen/spring-swagger-codegen-app/README.md
+++ b/spring-swagger-codegen/spring-swagger-codegen-app/README.md
@@ -1,3 +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).
+This module contains the code for Generate Spring Boot REST Client with Swagger.
diff --git a/spring-thymeleaf-2/README.md b/spring-thymeleaf-2/README.md
index d5c5ead43d..a8c067a443 100644
--- a/spring-thymeleaf-2/README.md
+++ b/spring-thymeleaf-2/README.md
@@ -13,4 +13,5 @@ This module contains articles about Spring with Thymeleaf
- [Working with Boolean in Thymeleaf](https://www.baeldung.com/thymeleaf-boolean)
- [Working With Custom HTML Attributes in Thymeleaf](https://www.baeldung.com/thymeleaf-custom-html-attributes)
- [How to Create an Executable JAR with Maven](https://www.baeldung.com/executable-jar-with-maven)
+- [Spring MVC Data and Thymeleaf](https://www.baeldung.com/spring-mvc-thymeleaf-data)
- [[<-- prev]](/spring-thymeleaf)
diff --git a/stripe/pom.xml b/stripe/pom.xml
index 07d2968f5f..48505c9e4e 100644
--- a/stripe/pom.xml
+++ b/stripe/pom.xml
@@ -11,9 +11,9 @@
com.baeldung
- parent-boot-1
+ parent-boot-2
0.0.1-SNAPSHOT
- ../parent-boot-1
+ ../parent-boot-2
@@ -28,9 +28,6 @@
org.projectlombok
lombok
- ${lombok.version}
-
com.stripe
diff --git a/stripe/src/main/java/com/baeldung/stripe/ChargeRequest.java b/stripe/src/main/java/com/baeldung/stripe/ChargeRequest.java
index a5c056b659..190911afb3 100644
--- a/stripe/src/main/java/com/baeldung/stripe/ChargeRequest.java
+++ b/stripe/src/main/java/com/baeldung/stripe/ChargeRequest.java
@@ -13,4 +13,27 @@ public class ChargeRequest {
private Currency currency;
private String stripeEmail;
private String stripeToken;
+ public String getDescription() {
+ return description;
+ }
+ public int getAmount() {
+ return amount;
+ }
+ public Currency getCurrency() {
+ return currency;
+ }
+ public String getStripeEmail() {
+ return stripeEmail;
+ }
+ public String getStripeToken() {
+ return stripeToken;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ public void setCurrency(Currency currency) {
+ this.currency = currency;
+ }
+
+
}
diff --git a/stripe/src/main/resources/application.properties b/stripe/src/main/resources/application.properties
new file mode 100644
index 0000000000..f36df33897
--- /dev/null
+++ b/stripe/src/main/resources/application.properties
@@ -0,0 +1,2 @@
+STRIPE_SECRET_KEY=
+STRIPE_PUBLIC_KEY=
\ No newline at end of file
diff --git a/stripe/src/main/resources/static/index.html b/stripe/src/main/resources/static/index.html
index 090a01e91d..d7ba2bef91 100644
--- a/stripe/src/main/resources/static/index.html
+++ b/stripe/src/main/resources/static/index.html
@@ -1,7 +1,7 @@
-
+
diff --git a/terraform/README.md b/terraform/README.md
new file mode 100644
index 0000000000..19abd2ff20
--- /dev/null
+++ b/terraform/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles:
+
+- [Introduction to Terraform](https://www.baeldung.com/ops/terraform-intro)
diff --git a/testing-modules/junit5-annotations/README.md b/testing-modules/junit5-annotations/README.md
index 02d4cd652a..bd51bb3d2d 100644
--- a/testing-modules/junit5-annotations/README.md
+++ b/testing-modules/junit5-annotations/README.md
@@ -7,3 +7,4 @@ This module contains articles about JUnit 5 Annotations
- [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)
+- [Writing Templates for Test Cases Using JUnit 5](https://www.baeldung.com/junit5-test-templates)
diff --git a/testing-modules/mockito-2/README.md b/testing-modules/mockito-2/README.md
index 6c9ddee01d..329228186f 100644
--- a/testing-modules/mockito-2/README.md
+++ b/testing-modules/mockito-2/README.md
@@ -5,3 +5,4 @@
- [Mockito Strict Stubbing and The UnnecessaryStubbingException](https://www.baeldung.com/mockito-unnecessary-stubbing-exception)
- [Mockito and Fluent APIs](https://www.baeldung.com/mockito-fluent-apis)
- [Mocking the ObjectMapper readValue() Method](https://www.baeldung.com/mockito-mock-jackson-read-value)
+- [Introduction to Mockito’s AdditionalAnswers](https://www.baeldung.com/mockito-additionalanswers)
diff --git a/testing-modules/pom.xml b/testing-modules/pom.xml
index 951909b36f..b467b3c503 100644
--- a/testing-modules/pom.xml
+++ b/testing-modules/pom.xml
@@ -33,6 +33,7 @@
selenium-junit-testng
spring-testing
test-containers
+ testing-assertions
testng
junit-5-basics
easymock
diff --git a/testing-modules/testing-assertions/pom.xml b/testing-modules/testing-assertions/pom.xml
new file mode 100644
index 0000000000..0a7c4b0860
--- /dev/null
+++ b/testing-modules/testing-assertions/pom.xml
@@ -0,0 +1,28 @@
+
+ 4.0.0
+ testing-assertions
+ 0.0.1-SNAPSHOT
+
+
+ com.baeldung
+ parent-java
+ 0.0.1-SNAPSHOT
+ ../../parent-java
+
+
+
+
+ ch.qos.logback
+ logback-classic
+ 1.2.3
+
+
+ org.assertj
+ assertj-core
+ 3.15.0
+ test
+
+
+
diff --git a/testing-modules/testing-assertions/src/main/java/com/baeldung/junit/log/BusinessWorker.java b/testing-modules/testing-assertions/src/main/java/com/baeldung/junit/log/BusinessWorker.java
new file mode 100644
index 0000000000..86cd38824c
--- /dev/null
+++ b/testing-modules/testing-assertions/src/main/java/com/baeldung/junit/log/BusinessWorker.java
@@ -0,0 +1,16 @@
+package com.baeldung.junit.log;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BusinessWorker {
+ private static Logger LOGGER = LoggerFactory.getLogger(BusinessWorker.class);
+
+ public void generateLogs(String msg) {
+ LOGGER.trace(msg);
+ LOGGER.debug(msg);
+ LOGGER.info(msg);
+ LOGGER.warn(msg);
+ LOGGER.error(msg);
+ }
+}
diff --git a/testing-modules/testing-assertions/src/main/resources/logback.xml b/testing-modules/testing-assertions/src/main/resources/logback.xml
new file mode 100644
index 0000000000..d485da62ff
--- /dev/null
+++ b/testing-modules/testing-assertions/src/main/resources/logback.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+ %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/BusinessWorkerUnitTest.java b/testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/BusinessWorkerUnitTest.java
new file mode 100644
index 0000000000..9200caf13d
--- /dev/null
+++ b/testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/BusinessWorkerUnitTest.java
@@ -0,0 +1,48 @@
+package com.baeldung.junit.log;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
+
+public class BusinessWorkerUnitTest {
+ private static MemoryAppender memoryAppender;
+ private static final String LOGGER_NAME = "com.baeldung.junit.log";
+ private static final String MSG = "This is a test message!!!";
+
+ @Before
+ public void setup() {
+ Logger logger = (Logger) LoggerFactory.getLogger(LOGGER_NAME);
+ memoryAppender = new MemoryAppender();
+ memoryAppender.setContext((LoggerContext) LoggerFactory.getILoggerFactory());
+ logger.setLevel(Level.DEBUG);
+ logger.addAppender(memoryAppender);
+ memoryAppender.start();
+
+ }
+
+ @After
+ public void cleanUp() {
+ memoryAppender.reset();
+ memoryAppender.stop();
+ }
+
+ @Test
+ public void test() {
+ BusinessWorker worker = new BusinessWorker();
+ worker.generateLogs(MSG);
+
+ // I check that I only have 4 messages (all but trace)
+ assertThat(memoryAppender.countEventsForLogger(LOGGER_NAME)).isEqualTo(4);
+ // I look for a specific message at a specific level, and I only have 1
+ assertThat(memoryAppender.search(MSG, Level.INFO).size()).isEqualTo(1);
+ // I check that the entry that is not present is the trace level
+ assertThat(memoryAppender.contains(MSG, Level.TRACE)).isFalse();
+ }
+}
diff --git a/testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/MemoryAppender.java b/testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/MemoryAppender.java
new file mode 100644
index 0000000000..31c5c69766
--- /dev/null
+++ b/testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/MemoryAppender.java
@@ -0,0 +1,51 @@
+package com.baeldung.junit.log;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.read.ListAppender;
+
+/**
+ * In memory slf4j appender
+ * Convenient appender to be able to check slf4j invocations
+ */
+public class MemoryAppender extends ListAppender {
+ public void reset() {
+ this.list.clear();
+ }
+
+ public boolean contains(String string, Level level) {
+ return this.list.stream()
+ .anyMatch(event -> event.getMessage().toString().contains(string)
+ && event.getLevel().equals(level));
+ }
+
+ public int countEventsForLogger(String loggerName) {
+ return (int) this.list.stream()
+ .filter(event -> event.getLoggerName().contains(loggerName)).count();
+ }
+
+ public List search(String string) {
+ return this.list.stream()
+ .filter(event -> event.getMessage().toString().contains(string))
+ .collect(Collectors.toList());
+ }
+
+ public List search(String string, Level level) {
+ return this.list.stream()
+ .filter(event -> event.getMessage().toString().contains(string)
+ && event.getLevel().equals(level))
+ .collect(Collectors.toList());
+ }
+
+ public int getSize() {
+ return this.list.size();
+ }
+
+ public List getLoggedEvents() {
+ return Collections.unmodifiableList(this.list);
+ }
+}
diff --git a/testing-modules/testing-assertions/src/test/resources/logback.xml b/testing-modules/testing-assertions/src/test/resources/logback.xml
new file mode 100644
index 0000000000..980ce897ff
--- /dev/null
+++ b/testing-modules/testing-assertions/src/test/resources/logback.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+ %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/vavr-2/README.md b/vavr-2/README.md
new file mode 100644
index 0000000000..71814a08fd
--- /dev/null
+++ b/vavr-2/README.md
@@ -0,0 +1,8 @@
+## Vavr
+
+This module contains articles about Vavr.
+
+### Relevant Articles:
+- [Introduction to Vavr’s Either](https://www.baeldung.com/vavr-either)
+- [Interoperability Between Java and Vavr](https://www.baeldung.com/java-vavr)
+- [[<-- prev]](/vavr)
diff --git a/vavr-2/pom.xml b/vavr-2/pom.xml
new file mode 100644
index 0000000000..d20dd9afef
--- /dev/null
+++ b/vavr-2/pom.xml
@@ -0,0 +1,27 @@
+
+
+
+ parent-modules
+ com.baeldung
+ 1.0.0-SNAPSHOT
+
+ 4.0.0
+
+ vavr-2
+ vavr-2
+ jar
+
+
+
+ io.vavr
+ vavr-test
+ ${vavr.version}
+
+
+
+
+ 0.9.1
+
+
\ No newline at end of file
diff --git a/vavr/src/main/java/com/baeldung/vavr/either/EitherDemo.java b/vavr-2/src/main/java/com/baeldung/vavr/either/EitherDemo.java
similarity index 100%
rename from vavr/src/main/java/com/baeldung/vavr/either/EitherDemo.java
rename to vavr-2/src/main/java/com/baeldung/vavr/either/EitherDemo.java
diff --git a/vavr/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java b/vavr-2/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java
similarity index 100%
rename from vavr/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java
rename to vavr-2/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java
diff --git a/vavr/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java b/vavr-2/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java
similarity index 100%
rename from vavr/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java
rename to vavr-2/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java
diff --git a/vavr/README.md b/vavr/README.md
index 2b8bb25356..e04e02069f 100644
--- a/vavr/README.md
+++ b/vavr/README.md
@@ -13,5 +13,4 @@ This module contains articles about Vavr.
- [Guide to Collections API in Vavr](https://www.baeldung.com/vavr-collections)
- [Collection Factory Methods for Vavr](https://www.baeldung.com/vavr-collection-factory-methods)
- [Introduction to Future in Vavr](https://www.baeldung.com/vavr-future)
-- [Introduction to Vavr’s Either](https://www.baeldung.com/vavr-either)
-- [Interoperability Between Java and Vavr](https://www.baeldung.com/java-vavr)
+- [[next -->]](/vavr-2)