From 38abc7d450a47df45c729e838adef0ec171123d7 Mon Sep 17 00:00:00 2001 From: snyk-bot Date: Tue, 7 Jun 2022 09:17:47 +0000 Subject: [PATCH 01/53] fix: pom.xml to reduce vulnerabilities The following vulnerabilities are fixed with an upgrade: - https://snyk.io/vuln/SNYK-JAVA-CHQOSLOGBACK-1726923 - https://snyk.io/vuln/SNYK-JAVA-ORGSPRINGFRAMEWORK-2434828 - https://snyk.io/vuln/SNYK-JAVA-ORGSPRINGFRAMEWORK-2436751 - https://snyk.io/vuln/SNYK-JAVA-ORGSPRINGFRAMEWORK-2689634 - https://snyk.io/vuln/SNYK-JAVA-ORGSPRINGFRAMEWORK-2823310 - https://snyk.io/vuln/SNYK-JAVA-ORGSPRINGFRAMEWORK-2823313 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index fccf6aafe7..47e7760f27 100644 --- a/pom.xml +++ b/pom.xml @@ -259,7 +259,7 @@ - + @@ -278,7 +278,7 @@ - + @@ -1411,7 +1411,7 @@ 1.7.32 - 1.2.6 + 1.2.7 2.22.2 From 1b29276c17a2810a2bcd8d4b49f09f916531a878 Mon Sep 17 00:00:00 2001 From: opokharel Date: Sat, 25 Jun 2022 11:00:26 -0600 Subject: [PATCH 02/53] [BAEL-5421] by @opokharel [BAEL-5421] by @opokharel --- .../com/baeldung/jar/MySampleGUIAppn.java | 26 +++++++++++++++++++ .../baeldung/jar/MySampleGUIAppnUnitTest.java | 14 ++++++++++ 2 files changed, 40 insertions(+) create mode 100644 core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java create mode 100644 core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java diff --git a/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java b/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java new file mode 100644 index 0000000000..cc0a161d0f --- /dev/null +++ b/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java @@ -0,0 +1,26 @@ +package com.baeldung.jar; + +import java.awt.event.*; +import java.awt.*; + +import javax.swing.*; + +public class MySampleGUIAppn extends JFrame{ + public MySampleGUIAppn() { + setSize(300,300); + setTitle("MySampleGUIAppn"); + Button b = new Button("Click Me!"); + b.setBounds(30,100,80,30); + add(b); + setVisible(true); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(); + System.exit(0); + } + }); + } + public static void main(String[] args) { + MySampleGUIAppn app=new MySampleGUIAppn(); + } +} diff --git a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java new file mode 100644 index 0000000000..af5643cf40 --- /dev/null +++ b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java @@ -0,0 +1,14 @@ +package com.baeldung.jar; + +import org.junit.jupiter.api.Test; + +class MySampleGUIAppnUnitTest extends MySampleGUIAppn { + + @Test + void testMain() { + MySampleGUIAppn instance = new MySampleGUIAppn(); + String [] args = null; + System.exit(DO_NOTHING_ON_CLOSE); + main(args); + } +} \ No newline at end of file From c2bfe407de76d8f76208fd28435790305ca7c312 Mon Sep 17 00:00:00 2001 From: opokharel Date: Sat, 25 Jun 2022 11:09:55 -0600 Subject: [PATCH 03/53] BAEL-5421 --- .../src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java index af5643cf40..7084c1468d 100644 --- a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java +++ b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java @@ -5,7 +5,7 @@ import org.junit.jupiter.api.Test; class MySampleGUIAppnUnitTest extends MySampleGUIAppn { @Test - void testMain() { + void testMain() throws IOException { MySampleGUIAppn instance = new MySampleGUIAppn(); String [] args = null; System.exit(DO_NOTHING_ON_CLOSE); From acd0dc78946ff8d3b04a1903c457bb8fbb63f4bb Mon Sep 17 00:00:00 2001 From: opokharel Date: Sat, 25 Jun 2022 11:29:08 -0600 Subject: [PATCH 04/53] BAEL-5421 --- .../src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java index 7084c1468d..2fbd6cf510 100644 --- a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java +++ b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java @@ -2,7 +2,7 @@ package com.baeldung.jar; import org.junit.jupiter.api.Test; -class MySampleGUIAppnUnitTest extends MySampleGUIAppn { +class MySampleGUIAppnUnitTest extends IOException { @Test void testMain() throws IOException { From d29b19e148bdc8e3a84193d8fd9a371cf6140823 Mon Sep 17 00:00:00 2001 From: opokharel Date: Sat, 25 Jun 2022 11:30:29 -0600 Subject: [PATCH 05/53] BAEL-5421 --- .../src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java index 2fbd6cf510..f13b55158c 100644 --- a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java +++ b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java @@ -2,7 +2,7 @@ package com.baeldung.jar; import org.junit.jupiter.api.Test; -class MySampleGUIAppnUnitTest extends IOException { +class MySampleGUIAppnUnitTest throws IOException { @Test void testMain() throws IOException { From ded7b0af8f215075e586a128a13caafba2aeb015 Mon Sep 17 00:00:00 2001 From: opokharel Date: Sat, 25 Jun 2022 11:35:39 -0600 Subject: [PATCH 06/53] BAEL-5421 --- .../java/com/baeldung/jar/MySampleGUIAppnUnitTest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java index f13b55158c..28bb7cc7a8 100644 --- a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java +++ b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java @@ -1,14 +1,16 @@ package com.baeldung.jar; +import java.io.IOException; + import org.junit.jupiter.api.Test; -class MySampleGUIAppnUnitTest throws IOException { +class MySampleGUIAppnUnitTest { @Test void testMain() throws IOException { MySampleGUIAppn instance = new MySampleGUIAppn(); String [] args = null; - System.exit(DO_NOTHING_ON_CLOSE); - main(args); + System.exit(0); + MySampleGUIAppn.main(args); } } \ No newline at end of file From baa612d3bb687b9ac96ba8ae904fe45f55488370 Mon Sep 17 00:00:00 2001 From: opokharel Date: Sat, 25 Jun 2022 11:42:18 -0600 Subject: [PATCH 07/53] BAEL-5421 --- .../src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java index 28bb7cc7a8..ad1728bed8 100644 --- a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java +++ b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java @@ -8,6 +8,8 @@ class MySampleGUIAppnUnitTest { @Test void testMain() throws IOException { + System.setProperty("java.awt.headless", "false"); + System.out.println(java.awt.GraphicsEnvironment.isHeadless()); MySampleGUIAppn instance = new MySampleGUIAppn(); String [] args = null; System.exit(0); From ca767321f77b4fad21d8b4305e738b7efb6cc530 Mon Sep 17 00:00:00 2001 From: opokharel Date: Sat, 25 Jun 2022 11:46:51 -0600 Subject: [PATCH 08/53] BAEL-5421 --- .../src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java index ad1728bed8..86f09ccd25 100644 --- a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java +++ b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java @@ -8,7 +8,7 @@ class MySampleGUIAppnUnitTest { @Test void testMain() throws IOException { - System.setProperty("java.awt.headless", "false"); + System.setProperty("java.awt.headless", "true"); System.out.println(java.awt.GraphicsEnvironment.isHeadless()); MySampleGUIAppn instance = new MySampleGUIAppn(); String [] args = null; From 380b86b50edbc6229f41056a15f813a94c1cc38f Mon Sep 17 00:00:00 2001 From: opokharel Date: Sat, 25 Jun 2022 11:57:23 -0600 Subject: [PATCH 09/53] BAEL-5421 --- .../src/main/java/com/baeldung/jar/MySampleGUIAppn.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java b/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java index cc0a161d0f..2be8cef717 100644 --- a/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java +++ b/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java @@ -12,7 +12,9 @@ public class MySampleGUIAppn extends JFrame{ Button b = new Button("Click Me!"); b.setBounds(30,100,80,30); add(b); - setVisible(true); + if (!GraphicsEnvironment.isHeadless()) { + setVisible(true); + } addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); From 38664852dd5f8446a52a4ac8fea6e3d84adce94d Mon Sep 17 00:00:00 2001 From: opokharel Date: Sat, 25 Jun 2022 12:11:40 -0600 Subject: [PATCH 10/53] BAEL-5421 --- .../test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java index 86f09ccd25..ff534b9323 100644 --- a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java +++ b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java @@ -8,8 +8,8 @@ class MySampleGUIAppnUnitTest { @Test void testMain() throws IOException { - System.setProperty("java.awt.headless", "true"); - System.out.println(java.awt.GraphicsEnvironment.isHeadless()); + //System.setProperty("java.awt.headless", "true"); + //System.out.println(java.awt.GraphicsEnvironment.isHeadless()); MySampleGUIAppn instance = new MySampleGUIAppn(); String [] args = null; System.exit(0); From db1bf15694024281339d6c5690b6bcf10cfe620e Mon Sep 17 00:00:00 2001 From: opokharel Date: Sat, 25 Jun 2022 12:16:04 -0600 Subject: [PATCH 11/53] BAEL-5421 --- .../test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java index ff534b9323..5842a2042c 100644 --- a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java +++ b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java @@ -8,8 +8,7 @@ class MySampleGUIAppnUnitTest { @Test void testMain() throws IOException { - //System.setProperty("java.awt.headless", "true"); - //System.out.println(java.awt.GraphicsEnvironment.isHeadless()); + System.setProperty("java.awt.headless", "true"); MySampleGUIAppn instance = new MySampleGUIAppn(); String [] args = null; System.exit(0); From 8991dbe2dff3de80e9a1bb2f3a9c9ab8e4e5aa18 Mon Sep 17 00:00:00 2001 From: opokharel Date: Sat, 25 Jun 2022 12:36:55 -0600 Subject: [PATCH 12/53] BAEL-5421 --- .../com/baeldung/jar/MySampleGUIAppn.java | 26 +++++++++++-------- .../baeldung/jar/MySampleGUIAppnUnitTest.java | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java b/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java index 2be8cef717..95f3fff2a3 100644 --- a/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java +++ b/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java @@ -7,20 +7,24 @@ import javax.swing.*; public class MySampleGUIAppn extends JFrame{ public MySampleGUIAppn() { - setSize(300,300); - setTitle("MySampleGUIAppn"); - Button b = new Button("Click Me!"); - b.setBounds(30,100,80,30); - add(b); if (!GraphicsEnvironment.isHeadless()) { + setSize(300,300); + setTitle("MySampleGUIAppn"); + Button b = new Button("Click Me!"); + b.setBounds(30,100,80,30); + add(b); setVisible(true); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(); + System.exit(0); + } + }); + + } + else { + System.exit(0); } - addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - dispose(); - System.exit(0); - } - }); } public static void main(String[] args) { MySampleGUIAppn app=new MySampleGUIAppn(); diff --git a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java index 5842a2042c..ba44f24685 100644 --- a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java +++ b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java @@ -8,7 +8,7 @@ class MySampleGUIAppnUnitTest { @Test void testMain() throws IOException { - System.setProperty("java.awt.headless", "true"); + System.setProperty("java.awt.headless", "false"); MySampleGUIAppn instance = new MySampleGUIAppn(); String [] args = null; System.exit(0); From fac1883733bbf2503f1517b36cb8daef533ce3fe Mon Sep 17 00:00:00 2001 From: opokharel Date: Sat, 25 Jun 2022 12:41:04 -0600 Subject: [PATCH 13/53] BAEL-5421 --- .../src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java index ba44f24685..5842a2042c 100644 --- a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java +++ b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java @@ -8,7 +8,7 @@ class MySampleGUIAppnUnitTest { @Test void testMain() throws IOException { - System.setProperty("java.awt.headless", "false"); + System.setProperty("java.awt.headless", "true"); MySampleGUIAppn instance = new MySampleGUIAppn(); String [] args = null; System.exit(0); From 6ff0745dce6b1d582c9daa7fcbce374ba848c292 Mon Sep 17 00:00:00 2001 From: opokharel Date: Sat, 25 Jun 2022 12:45:17 -0600 Subject: [PATCH 14/53] BAEL-5421 --- .../src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java index 5842a2042c..8c53613d5a 100644 --- a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java +++ b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java @@ -9,7 +9,7 @@ class MySampleGUIAppnUnitTest { @Test void testMain() throws IOException { System.setProperty("java.awt.headless", "true"); - MySampleGUIAppn instance = new MySampleGUIAppn(); + //MySampleGUIAppn instance = new MySampleGUIAppn(); String [] args = null; System.exit(0); MySampleGUIAppn.main(args); From 99a902b27b92bb83bf172d98ddcb7c8197196c0a Mon Sep 17 00:00:00 2001 From: opokharel Date: Sat, 25 Jun 2022 12:48:16 -0600 Subject: [PATCH 15/53] BAEL-5421 --- .../src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java index 8c53613d5a..878d65e01d 100644 --- a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java +++ b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java @@ -9,7 +9,6 @@ class MySampleGUIAppnUnitTest { @Test void testMain() throws IOException { System.setProperty("java.awt.headless", "true"); - //MySampleGUIAppn instance = new MySampleGUIAppn(); String [] args = null; System.exit(0); MySampleGUIAppn.main(args); From 90aa4a12395379698bb12ec857c4a865d91ef5d1 Mon Sep 17 00:00:00 2001 From: opokharel Date: Sat, 25 Jun 2022 17:21:34 -0600 Subject: [PATCH 16/53] BAEL-5421 by @opokharel BAEL-5421 by @opokharel --- .../src/main/java/com/baeldung/jar/MySampleGUIAppn.java | 3 +-- .../test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java b/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java index 95f3fff2a3..86d52eed56 100644 --- a/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java +++ b/core-java-modules/core-java-jar/src/main/java/com/baeldung/jar/MySampleGUIAppn.java @@ -5,7 +5,7 @@ import java.awt.*; import javax.swing.*; -public class MySampleGUIAppn extends JFrame{ +public class MySampleGUIAppn extends JFrame { public MySampleGUIAppn() { if (!GraphicsEnvironment.isHeadless()) { setSize(300,300); @@ -20,7 +20,6 @@ public class MySampleGUIAppn extends JFrame{ System.exit(0); } }); - } else { System.exit(0); diff --git a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java index 878d65e01d..106531008c 100644 --- a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java +++ b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jar/MySampleGUIAppnUnitTest.java @@ -5,7 +5,6 @@ import java.io.IOException; import org.junit.jupiter.api.Test; class MySampleGUIAppnUnitTest { - @Test void testMain() throws IOException { System.setProperty("java.awt.headless", "true"); From 9fab7ade08087b8924a1b1187fde39fbe701c596 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Thu, 30 Jun 2022 20:05:54 +0530 Subject: [PATCH 17/53] JAVA-12732: rename spring-social-login to spring-security-social-login --- .../README.md | 0 .../pom.xml | 6 +++--- .../src/main/java/com/baeldung/config/Application.java | 0 .../src/main/java/com/baeldung/config/SecurityConfig.java | 0 .../src/main/java/com/baeldung/config/WebConfig.java | 0 .../java/com/baeldung/persistence/dao/UserRepository.java | 0 .../src/main/java/com/baeldung/persistence/model/User.java | 0 .../com/baeldung/security/FacebookConnectionSignup.java | 0 .../java/com/baeldung/security/FacebookSignInAdapter.java | 0 .../java/com/baeldung/security/MyUserDetailsService.java | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/data.sql | 0 .../src/main/resources/logback.xml | 0 .../src/main/resources/templates/index.html | 0 .../src/main/resources/templates/login.html | 0 .../src/test/java/com/baeldung/SpringContextTest.java | 0 16 files changed, 3 insertions(+), 3 deletions(-) rename spring-security-modules/{spring-social-login => spring-security-social-login}/README.md (100%) rename spring-security-modules/{spring-social-login => spring-security-social-login}/pom.xml (94%) rename spring-security-modules/{spring-social-login => spring-security-social-login}/src/main/java/com/baeldung/config/Application.java (100%) rename spring-security-modules/{spring-social-login => spring-security-social-login}/src/main/java/com/baeldung/config/SecurityConfig.java (100%) rename spring-security-modules/{spring-social-login => spring-security-social-login}/src/main/java/com/baeldung/config/WebConfig.java (100%) rename spring-security-modules/{spring-social-login => spring-security-social-login}/src/main/java/com/baeldung/persistence/dao/UserRepository.java (100%) rename spring-security-modules/{spring-social-login => spring-security-social-login}/src/main/java/com/baeldung/persistence/model/User.java (100%) rename spring-security-modules/{spring-social-login => spring-security-social-login}/src/main/java/com/baeldung/security/FacebookConnectionSignup.java (100%) rename spring-security-modules/{spring-social-login => spring-security-social-login}/src/main/java/com/baeldung/security/FacebookSignInAdapter.java (100%) rename spring-security-modules/{spring-social-login => spring-security-social-login}/src/main/java/com/baeldung/security/MyUserDetailsService.java (100%) rename spring-security-modules/{spring-social-login => spring-security-social-login}/src/main/resources/application.properties (100%) rename spring-security-modules/{spring-social-login => spring-security-social-login}/src/main/resources/data.sql (100%) rename spring-security-modules/{spring-social-login => spring-security-social-login}/src/main/resources/logback.xml (100%) rename spring-security-modules/{spring-social-login => spring-security-social-login}/src/main/resources/templates/index.html (100%) rename spring-security-modules/{spring-social-login => spring-security-social-login}/src/main/resources/templates/login.html (100%) rename spring-security-modules/{spring-social-login => spring-security-social-login}/src/test/java/com/baeldung/SpringContextTest.java (100%) diff --git a/spring-security-modules/spring-social-login/README.md b/spring-security-modules/spring-security-social-login/README.md similarity index 100% rename from spring-security-modules/spring-social-login/README.md rename to spring-security-modules/spring-security-social-login/README.md diff --git a/spring-security-modules/spring-social-login/pom.xml b/spring-security-modules/spring-security-social-login/pom.xml similarity index 94% rename from spring-security-modules/spring-social-login/pom.xml rename to spring-security-modules/spring-security-social-login/pom.xml index ad4b7c72a6..ddda4235be 100644 --- a/spring-security-modules/spring-social-login/pom.xml +++ b/spring-security-modules/spring-security-social-login/pom.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - spring-social-login - spring-social-login + spring-security-social-login + spring-security-social-login war @@ -66,7 +66,7 @@ - spring-social-login + spring-security-social-login src/main/resources diff --git a/spring-security-modules/spring-social-login/src/main/java/com/baeldung/config/Application.java b/spring-security-modules/spring-security-social-login/src/main/java/com/baeldung/config/Application.java similarity index 100% rename from spring-security-modules/spring-social-login/src/main/java/com/baeldung/config/Application.java rename to spring-security-modules/spring-security-social-login/src/main/java/com/baeldung/config/Application.java diff --git a/spring-security-modules/spring-social-login/src/main/java/com/baeldung/config/SecurityConfig.java b/spring-security-modules/spring-security-social-login/src/main/java/com/baeldung/config/SecurityConfig.java similarity index 100% rename from spring-security-modules/spring-social-login/src/main/java/com/baeldung/config/SecurityConfig.java rename to spring-security-modules/spring-security-social-login/src/main/java/com/baeldung/config/SecurityConfig.java diff --git a/spring-security-modules/spring-social-login/src/main/java/com/baeldung/config/WebConfig.java b/spring-security-modules/spring-security-social-login/src/main/java/com/baeldung/config/WebConfig.java similarity index 100% rename from spring-security-modules/spring-social-login/src/main/java/com/baeldung/config/WebConfig.java rename to spring-security-modules/spring-security-social-login/src/main/java/com/baeldung/config/WebConfig.java diff --git a/spring-security-modules/spring-social-login/src/main/java/com/baeldung/persistence/dao/UserRepository.java b/spring-security-modules/spring-security-social-login/src/main/java/com/baeldung/persistence/dao/UserRepository.java similarity index 100% rename from spring-security-modules/spring-social-login/src/main/java/com/baeldung/persistence/dao/UserRepository.java rename to spring-security-modules/spring-security-social-login/src/main/java/com/baeldung/persistence/dao/UserRepository.java diff --git a/spring-security-modules/spring-social-login/src/main/java/com/baeldung/persistence/model/User.java b/spring-security-modules/spring-security-social-login/src/main/java/com/baeldung/persistence/model/User.java similarity index 100% rename from spring-security-modules/spring-social-login/src/main/java/com/baeldung/persistence/model/User.java rename to spring-security-modules/spring-security-social-login/src/main/java/com/baeldung/persistence/model/User.java diff --git a/spring-security-modules/spring-social-login/src/main/java/com/baeldung/security/FacebookConnectionSignup.java b/spring-security-modules/spring-security-social-login/src/main/java/com/baeldung/security/FacebookConnectionSignup.java similarity index 100% rename from spring-security-modules/spring-social-login/src/main/java/com/baeldung/security/FacebookConnectionSignup.java rename to spring-security-modules/spring-security-social-login/src/main/java/com/baeldung/security/FacebookConnectionSignup.java diff --git a/spring-security-modules/spring-social-login/src/main/java/com/baeldung/security/FacebookSignInAdapter.java b/spring-security-modules/spring-security-social-login/src/main/java/com/baeldung/security/FacebookSignInAdapter.java similarity index 100% rename from spring-security-modules/spring-social-login/src/main/java/com/baeldung/security/FacebookSignInAdapter.java rename to spring-security-modules/spring-security-social-login/src/main/java/com/baeldung/security/FacebookSignInAdapter.java diff --git a/spring-security-modules/spring-social-login/src/main/java/com/baeldung/security/MyUserDetailsService.java b/spring-security-modules/spring-security-social-login/src/main/java/com/baeldung/security/MyUserDetailsService.java similarity index 100% rename from spring-security-modules/spring-social-login/src/main/java/com/baeldung/security/MyUserDetailsService.java rename to spring-security-modules/spring-security-social-login/src/main/java/com/baeldung/security/MyUserDetailsService.java diff --git a/spring-security-modules/spring-social-login/src/main/resources/application.properties b/spring-security-modules/spring-security-social-login/src/main/resources/application.properties similarity index 100% rename from spring-security-modules/spring-social-login/src/main/resources/application.properties rename to spring-security-modules/spring-security-social-login/src/main/resources/application.properties diff --git a/spring-security-modules/spring-social-login/src/main/resources/data.sql b/spring-security-modules/spring-security-social-login/src/main/resources/data.sql similarity index 100% rename from spring-security-modules/spring-social-login/src/main/resources/data.sql rename to spring-security-modules/spring-security-social-login/src/main/resources/data.sql diff --git a/spring-security-modules/spring-social-login/src/main/resources/logback.xml b/spring-security-modules/spring-security-social-login/src/main/resources/logback.xml similarity index 100% rename from spring-security-modules/spring-social-login/src/main/resources/logback.xml rename to spring-security-modules/spring-security-social-login/src/main/resources/logback.xml diff --git a/spring-security-modules/spring-social-login/src/main/resources/templates/index.html b/spring-security-modules/spring-security-social-login/src/main/resources/templates/index.html similarity index 100% rename from spring-security-modules/spring-social-login/src/main/resources/templates/index.html rename to spring-security-modules/spring-security-social-login/src/main/resources/templates/index.html diff --git a/spring-security-modules/spring-social-login/src/main/resources/templates/login.html b/spring-security-modules/spring-security-social-login/src/main/resources/templates/login.html similarity index 100% rename from spring-security-modules/spring-social-login/src/main/resources/templates/login.html rename to spring-security-modules/spring-security-social-login/src/main/resources/templates/login.html diff --git a/spring-security-modules/spring-social-login/src/test/java/com/baeldung/SpringContextTest.java b/spring-security-modules/spring-security-social-login/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-security-modules/spring-social-login/src/test/java/com/baeldung/SpringContextTest.java rename to spring-security-modules/spring-security-social-login/src/test/java/com/baeldung/SpringContextTest.java From e6faed98b67047bf1aa7660c52dda8b1886c2675 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Thu, 30 Jun 2022 20:06:28 +0530 Subject: [PATCH 18/53] JAVA-12732: rename spring-5-security-cognito to spring-security-cognito --- .../README.md | 0 .../pom.xml | 4 ++-- .../java/com/baeldung/cognito/CognitoWebConfiguration.java | 0 .../main/java/com/baeldung/cognito/SecurityConfiguration.java | 0 .../java/com/baeldung/cognito/SpringCognitoApplication.java | 0 .../src/main/resources/application.yml | 0 .../src/main/resources/logback.xml | 0 .../src/main/resources/templates/home.html | 0 8 files changed, 2 insertions(+), 2 deletions(-) rename spring-security-modules/{spring-5-security-cognito => spring-security-cognito}/README.md (100%) rename spring-security-modules/{spring-5-security-cognito => spring-security-cognito}/pom.xml (96%) rename spring-security-modules/{spring-5-security-cognito => spring-security-cognito}/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java (100%) rename spring-security-modules/{spring-5-security-cognito => spring-security-cognito}/src/main/java/com/baeldung/cognito/SecurityConfiguration.java (100%) rename spring-security-modules/{spring-5-security-cognito => spring-security-cognito}/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java (100%) rename spring-security-modules/{spring-5-security-cognito => spring-security-cognito}/src/main/resources/application.yml (100%) rename spring-security-modules/{spring-5-security-cognito => spring-security-cognito}/src/main/resources/logback.xml (100%) rename spring-security-modules/{spring-5-security-cognito => spring-security-cognito}/src/main/resources/templates/home.html (100%) diff --git a/spring-security-modules/spring-5-security-cognito/README.md b/spring-security-modules/spring-security-cognito/README.md similarity index 100% rename from spring-security-modules/spring-5-security-cognito/README.md rename to spring-security-modules/spring-security-cognito/README.md diff --git a/spring-security-modules/spring-5-security-cognito/pom.xml b/spring-security-modules/spring-security-cognito/pom.xml similarity index 96% rename from spring-security-modules/spring-5-security-cognito/pom.xml rename to spring-security-modules/spring-security-cognito/pom.xml index 4da8b2fae5..56754ddf99 100644 --- a/spring-security-modules/spring-5-security-cognito/pom.xml +++ b/spring-security-modules/spring-security-cognito/pom.xml @@ -3,9 +3,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - spring-5-security-cognito + spring-security-cognito 0.0.1-SNAPSHOT - spring-5-security-cognito + spring-security-cognito jar spring 5 security oauth cognito sample project diff --git a/spring-security-modules/spring-5-security-cognito/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java b/spring-security-modules/spring-security-cognito/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java similarity index 100% rename from spring-security-modules/spring-5-security-cognito/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java rename to spring-security-modules/spring-security-cognito/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java diff --git a/spring-security-modules/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SecurityConfiguration.java b/spring-security-modules/spring-security-cognito/src/main/java/com/baeldung/cognito/SecurityConfiguration.java similarity index 100% rename from spring-security-modules/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SecurityConfiguration.java rename to spring-security-modules/spring-security-cognito/src/main/java/com/baeldung/cognito/SecurityConfiguration.java diff --git a/spring-security-modules/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java b/spring-security-modules/spring-security-cognito/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java similarity index 100% rename from spring-security-modules/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java rename to spring-security-modules/spring-security-cognito/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java diff --git a/spring-security-modules/spring-5-security-cognito/src/main/resources/application.yml b/spring-security-modules/spring-security-cognito/src/main/resources/application.yml similarity index 100% rename from spring-security-modules/spring-5-security-cognito/src/main/resources/application.yml rename to spring-security-modules/spring-security-cognito/src/main/resources/application.yml diff --git a/spring-security-modules/spring-5-security-cognito/src/main/resources/logback.xml b/spring-security-modules/spring-security-cognito/src/main/resources/logback.xml similarity index 100% rename from spring-security-modules/spring-5-security-cognito/src/main/resources/logback.xml rename to spring-security-modules/spring-security-cognito/src/main/resources/logback.xml diff --git a/spring-security-modules/spring-5-security-cognito/src/main/resources/templates/home.html b/spring-security-modules/spring-security-cognito/src/main/resources/templates/home.html similarity index 100% rename from spring-security-modules/spring-5-security-cognito/src/main/resources/templates/home.html rename to spring-security-modules/spring-security-cognito/src/main/resources/templates/home.html From 2df103484d32f5fcdb8f34e6c9551893ce60e212 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Thu, 30 Jun 2022 20:07:18 +0530 Subject: [PATCH 19/53] JAVA-12732: rename spring-5-security-oauth to spring-security-oauth2 --- .../README.md | 0 .../pom.xml | 4 ++-- .../src/main/java/com/baeldung/jersey/JerseyApplication.java | 0 .../src/main/java/com/baeldung/jersey/JerseyResource.java | 0 .../src/main/java/com/baeldung/jersey/RestConfig.java | 0 .../src/main/java/com/baeldung/jersey/SecurityConfig.java | 0 .../java/com/baeldung/oauth2/CustomRequestSecurityConfig.java | 0 .../src/main/java/com/baeldung/oauth2/LoginController.java | 0 .../src/main/java/com/baeldung/oauth2/MvcConfig.java | 0 .../src/main/java/com/baeldung/oauth2/SecurityConfig.java | 0 .../main/java/com/baeldung/oauth2/SpringOAuthApplication.java | 0 .../com/baeldung/oauth2extractors/ExtractorsApplication.java | 0 .../oauth2extractors/configuration/SecurityConfig.java | 0 .../extractor/custom/BaeldungAuthoritiesExtractor.java | 0 .../extractor/custom/BaeldungPrincipalExtractor.java | 0 .../extractor/github/GithubAuthoritiesExtractor.java | 0 .../extractor/github/GithubPrincipalExtractor.java | 0 .../oauth2request/CustomAuthorizationRequestResolver.java | 0 .../baeldung/oauth2request/CustomRequestEntityConverter.java | 0 .../baeldung/oauth2request/CustomTokenResponseConverter.java | 0 .../oauth2request/LinkedinTokenResponseConverter.java | 0 .../java/com/baeldung/oauth2resttemplate/AppController.java | 0 .../main/java/com/baeldung/oauth2resttemplate/GithubRepo.java | 0 .../java/com/baeldung/oauth2resttemplate/SecurityConfig.java | 0 .../SpringSecurityOauth2ClientApplication.java | 0 .../application-oauth2-extractors-baeldung.properties | 0 .../resources/application-oauth2-extractors-github.properties | 0 .../resources/application-oauth2-rest-template.properties | 0 .../src/main/resources/application-oauth2.properties | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/default-application.properties | 0 .../src/main/resources/jersey-application.properties | 0 .../src/main/resources/logback.xml | 0 .../src/main/resources/static/css/main.css | 0 .../src/main/resources/templates/index.html | 0 .../src/main/resources/templates/loginFailure.html | 0 .../src/main/resources/templates/loginSuccess.html | 0 .../src/main/resources/templates/oauth2_extractors.html | 0 .../main/resources/templates/oauth2resttemplate/error.html | 0 .../src/main/resources/templates/oauth2resttemplate/home.html | 0 .../main/resources/templates/oauth2resttemplate/index.html | 0 .../resources/templates/oauth2resttemplate/repositories.html | 0 .../src/main/resources/templates/oauth_login.html | 0 .../src/main/resources/templates/securedPage.html | 0 .../test/java/com/baeldung/jersey/JerseyResourceUnitTest.java | 0 .../com/baeldung/oauth2extractors/ExtractorsUnitTest.java | 0 46 files changed, 2 insertions(+), 2 deletions(-) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/README.md (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/pom.xml (97%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/jersey/JerseyApplication.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/jersey/JerseyResource.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/jersey/RestConfig.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/jersey/SecurityConfig.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2/CustomRequestSecurityConfig.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2/LoginController.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2/MvcConfig.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2/SecurityConfig.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2/SpringOAuthApplication.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2extractors/ExtractorsApplication.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2extractors/configuration/SecurityConfig.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungAuthoritiesExtractor.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungPrincipalExtractor.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubAuthoritiesExtractor.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubPrincipalExtractor.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2request/CustomAuthorizationRequestResolver.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2request/CustomRequestEntityConverter.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2request/CustomTokenResponseConverter.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2request/LinkedinTokenResponseConverter.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2resttemplate/AppController.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2resttemplate/GithubRepo.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2resttemplate/SecurityConfig.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/java/com/baeldung/oauth2resttemplate/SpringSecurityOauth2ClientApplication.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/application-oauth2-extractors-baeldung.properties (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/application-oauth2-extractors-github.properties (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/application-oauth2-rest-template.properties (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/application-oauth2.properties (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/application.properties (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/default-application.properties (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/jersey-application.properties (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/logback.xml (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/static/css/main.css (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/templates/index.html (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/templates/loginFailure.html (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/templates/loginSuccess.html (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/templates/oauth2_extractors.html (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/templates/oauth2resttemplate/error.html (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/templates/oauth2resttemplate/home.html (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/templates/oauth2resttemplate/index.html (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/templates/oauth2resttemplate/repositories.html (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/templates/oauth_login.html (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/main/resources/templates/securedPage.html (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/test/java/com/baeldung/jersey/JerseyResourceUnitTest.java (100%) rename spring-security-modules/{spring-5-security-oauth => spring-security-oauth2}/src/test/java/com/baeldung/oauth2extractors/ExtractorsUnitTest.java (100%) diff --git a/spring-security-modules/spring-5-security-oauth/README.md b/spring-security-modules/spring-security-oauth2/README.md similarity index 100% rename from spring-security-modules/spring-5-security-oauth/README.md rename to spring-security-modules/spring-security-oauth2/README.md diff --git a/spring-security-modules/spring-5-security-oauth/pom.xml b/spring-security-modules/spring-security-oauth2/pom.xml similarity index 97% rename from spring-security-modules/spring-5-security-oauth/pom.xml rename to spring-security-modules/spring-security-oauth2/pom.xml index 8449b01ec0..e2ff51f98f 100644 --- a/spring-security-modules/spring-5-security-oauth/pom.xml +++ b/spring-security-modules/spring-security-oauth2/pom.xml @@ -3,9 +3,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - spring-5-security-oauth + spring-5-oauth2 0.0.1-SNAPSHOT - spring-5-security-oauth + spring-security-oauth2 jar spring 5 security oauth sample project diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyApplication.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/jersey/JerseyApplication.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyApplication.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/jersey/JerseyApplication.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyResource.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/jersey/JerseyResource.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyResource.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/jersey/JerseyResource.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/jersey/RestConfig.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/jersey/RestConfig.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/jersey/RestConfig.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/jersey/RestConfig.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/jersey/SecurityConfig.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/jersey/SecurityConfig.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/jersey/SecurityConfig.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/jersey/SecurityConfig.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/CustomRequestSecurityConfig.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2/CustomRequestSecurityConfig.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/CustomRequestSecurityConfig.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2/CustomRequestSecurityConfig.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/LoginController.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2/LoginController.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/LoginController.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2/LoginController.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/MvcConfig.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2/MvcConfig.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/MvcConfig.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2/MvcConfig.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/SecurityConfig.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2/SecurityConfig.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/SecurityConfig.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2/SecurityConfig.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/SpringOAuthApplication.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2/SpringOAuthApplication.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/SpringOAuthApplication.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2/SpringOAuthApplication.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/ExtractorsApplication.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2extractors/ExtractorsApplication.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/ExtractorsApplication.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2extractors/ExtractorsApplication.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/configuration/SecurityConfig.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2extractors/configuration/SecurityConfig.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/configuration/SecurityConfig.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2extractors/configuration/SecurityConfig.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungAuthoritiesExtractor.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungAuthoritiesExtractor.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungAuthoritiesExtractor.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungAuthoritiesExtractor.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungPrincipalExtractor.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungPrincipalExtractor.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungPrincipalExtractor.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungPrincipalExtractor.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubAuthoritiesExtractor.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubAuthoritiesExtractor.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubAuthoritiesExtractor.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubAuthoritiesExtractor.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubPrincipalExtractor.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubPrincipalExtractor.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubPrincipalExtractor.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubPrincipalExtractor.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomAuthorizationRequestResolver.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2request/CustomAuthorizationRequestResolver.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomAuthorizationRequestResolver.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2request/CustomAuthorizationRequestResolver.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomRequestEntityConverter.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2request/CustomRequestEntityConverter.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomRequestEntityConverter.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2request/CustomRequestEntityConverter.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomTokenResponseConverter.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2request/CustomTokenResponseConverter.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomTokenResponseConverter.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2request/CustomTokenResponseConverter.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/LinkedinTokenResponseConverter.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2request/LinkedinTokenResponseConverter.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/LinkedinTokenResponseConverter.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2request/LinkedinTokenResponseConverter.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2resttemplate/AppController.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2resttemplate/AppController.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2resttemplate/AppController.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2resttemplate/AppController.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2resttemplate/GithubRepo.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2resttemplate/GithubRepo.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2resttemplate/GithubRepo.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2resttemplate/GithubRepo.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2resttemplate/SecurityConfig.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2resttemplate/SecurityConfig.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2resttemplate/SecurityConfig.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2resttemplate/SecurityConfig.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2resttemplate/SpringSecurityOauth2ClientApplication.java b/spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2resttemplate/SpringSecurityOauth2ClientApplication.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2resttemplate/SpringSecurityOauth2ClientApplication.java rename to spring-security-modules/spring-security-oauth2/src/main/java/com/baeldung/oauth2resttemplate/SpringSecurityOauth2ClientApplication.java diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/application-oauth2-extractors-baeldung.properties b/spring-security-modules/spring-security-oauth2/src/main/resources/application-oauth2-extractors-baeldung.properties similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/application-oauth2-extractors-baeldung.properties rename to spring-security-modules/spring-security-oauth2/src/main/resources/application-oauth2-extractors-baeldung.properties diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/application-oauth2-extractors-github.properties b/spring-security-modules/spring-security-oauth2/src/main/resources/application-oauth2-extractors-github.properties similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/application-oauth2-extractors-github.properties rename to spring-security-modules/spring-security-oauth2/src/main/resources/application-oauth2-extractors-github.properties diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/application-oauth2-rest-template.properties b/spring-security-modules/spring-security-oauth2/src/main/resources/application-oauth2-rest-template.properties similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/application-oauth2-rest-template.properties rename to spring-security-modules/spring-security-oauth2/src/main/resources/application-oauth2-rest-template.properties diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/application-oauth2.properties b/spring-security-modules/spring-security-oauth2/src/main/resources/application-oauth2.properties similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/application-oauth2.properties rename to spring-security-modules/spring-security-oauth2/src/main/resources/application-oauth2.properties diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/application.properties b/spring-security-modules/spring-security-oauth2/src/main/resources/application.properties similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/application.properties rename to spring-security-modules/spring-security-oauth2/src/main/resources/application.properties diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/default-application.properties b/spring-security-modules/spring-security-oauth2/src/main/resources/default-application.properties similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/default-application.properties rename to spring-security-modules/spring-security-oauth2/src/main/resources/default-application.properties diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/jersey-application.properties b/spring-security-modules/spring-security-oauth2/src/main/resources/jersey-application.properties similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/jersey-application.properties rename to spring-security-modules/spring-security-oauth2/src/main/resources/jersey-application.properties diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/logback.xml b/spring-security-modules/spring-security-oauth2/src/main/resources/logback.xml similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/logback.xml rename to spring-security-modules/spring-security-oauth2/src/main/resources/logback.xml diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/static/css/main.css b/spring-security-modules/spring-security-oauth2/src/main/resources/static/css/main.css similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/static/css/main.css rename to spring-security-modules/spring-security-oauth2/src/main/resources/static/css/main.css diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/templates/index.html b/spring-security-modules/spring-security-oauth2/src/main/resources/templates/index.html similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/templates/index.html rename to spring-security-modules/spring-security-oauth2/src/main/resources/templates/index.html diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/templates/loginFailure.html b/spring-security-modules/spring-security-oauth2/src/main/resources/templates/loginFailure.html similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/templates/loginFailure.html rename to spring-security-modules/spring-security-oauth2/src/main/resources/templates/loginFailure.html diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/templates/loginSuccess.html b/spring-security-modules/spring-security-oauth2/src/main/resources/templates/loginSuccess.html similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/templates/loginSuccess.html rename to spring-security-modules/spring-security-oauth2/src/main/resources/templates/loginSuccess.html diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/templates/oauth2_extractors.html b/spring-security-modules/spring-security-oauth2/src/main/resources/templates/oauth2_extractors.html similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/templates/oauth2_extractors.html rename to spring-security-modules/spring-security-oauth2/src/main/resources/templates/oauth2_extractors.html diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/templates/oauth2resttemplate/error.html b/spring-security-modules/spring-security-oauth2/src/main/resources/templates/oauth2resttemplate/error.html similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/templates/oauth2resttemplate/error.html rename to spring-security-modules/spring-security-oauth2/src/main/resources/templates/oauth2resttemplate/error.html diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/templates/oauth2resttemplate/home.html b/spring-security-modules/spring-security-oauth2/src/main/resources/templates/oauth2resttemplate/home.html similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/templates/oauth2resttemplate/home.html rename to spring-security-modules/spring-security-oauth2/src/main/resources/templates/oauth2resttemplate/home.html diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/templates/oauth2resttemplate/index.html b/spring-security-modules/spring-security-oauth2/src/main/resources/templates/oauth2resttemplate/index.html similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/templates/oauth2resttemplate/index.html rename to spring-security-modules/spring-security-oauth2/src/main/resources/templates/oauth2resttemplate/index.html diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/templates/oauth2resttemplate/repositories.html b/spring-security-modules/spring-security-oauth2/src/main/resources/templates/oauth2resttemplate/repositories.html similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/templates/oauth2resttemplate/repositories.html rename to spring-security-modules/spring-security-oauth2/src/main/resources/templates/oauth2resttemplate/repositories.html diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/templates/oauth_login.html b/spring-security-modules/spring-security-oauth2/src/main/resources/templates/oauth_login.html similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/templates/oauth_login.html rename to spring-security-modules/spring-security-oauth2/src/main/resources/templates/oauth_login.html diff --git a/spring-security-modules/spring-5-security-oauth/src/main/resources/templates/securedPage.html b/spring-security-modules/spring-security-oauth2/src/main/resources/templates/securedPage.html similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/main/resources/templates/securedPage.html rename to spring-security-modules/spring-security-oauth2/src/main/resources/templates/securedPage.html diff --git a/spring-security-modules/spring-5-security-oauth/src/test/java/com/baeldung/jersey/JerseyResourceUnitTest.java b/spring-security-modules/spring-security-oauth2/src/test/java/com/baeldung/jersey/JerseyResourceUnitTest.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/test/java/com/baeldung/jersey/JerseyResourceUnitTest.java rename to spring-security-modules/spring-security-oauth2/src/test/java/com/baeldung/jersey/JerseyResourceUnitTest.java diff --git a/spring-security-modules/spring-5-security-oauth/src/test/java/com/baeldung/oauth2extractors/ExtractorsUnitTest.java b/spring-security-modules/spring-security-oauth2/src/test/java/com/baeldung/oauth2extractors/ExtractorsUnitTest.java similarity index 100% rename from spring-security-modules/spring-5-security-oauth/src/test/java/com/baeldung/oauth2extractors/ExtractorsUnitTest.java rename to spring-security-modules/spring-security-oauth2/src/test/java/com/baeldung/oauth2extractors/ExtractorsUnitTest.java From d5d2705ac329ef7042bb1b2aebee44ba53c1ccae Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Thu, 30 Jun 2022 20:08:15 +0530 Subject: [PATCH 20/53] JAVA-12732: modify parent pom --- spring-security-modules/pom.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-security-modules/pom.xml b/spring-security-modules/pom.xml index 8d98395ab7..2123c03016 100644 --- a/spring-security-modules/pom.xml +++ b/spring-security-modules/pom.xml @@ -15,20 +15,21 @@ - spring-5-security - spring-5-security-cognito - spring-5-security-oauth + spring-5-security spring-ldap spring-security-acl spring-security-auth0 + spring-security-cognito spring-security-core spring-security-core-2 spring-security-ldap spring-security-legacy-oidc + spring-security-oauth2 spring-security-oauth2-sso spring-security-oidc spring-security-okta spring-security-saml + spring-security-social-login spring-security-web-angular spring-security-web-boot-1 spring-security-web-boot-2 @@ -45,8 +46,7 @@ spring-security-web-sockets spring-security-web-thymeleaf spring-security-web-x509 - spring-session - spring-social-login + spring-session spring-security-opa From 4298849d9e998b293b942189b1e9842dbe9567e0 Mon Sep 17 00:00:00 2001 From: "thibault.faure" Date: Sun, 19 Jun 2022 14:02:40 +0200 Subject: [PATCH 21/53] BAEL-5180 improvement on the article about sealed class move code to java 17 and use getPermittedSubClasses instead of permittedSubClasses --- core-java-modules/core-java-15/README.md | 1 - core-java-modules/core-java-17/README.md | 1 + .../main/java/com/baeldung/sealed/alternative/Vehicles.java | 0 .../src/main/java/com/baeldung/sealed/classes/Car.java | 0 .../src/main/java/com/baeldung/sealed/classes/Service.java | 0 .../src/main/java/com/baeldung/sealed/classes/Truck.java | 0 .../src/main/java/com/baeldung/sealed/classes/Vehicle.java | 0 .../src/main/java/com/baeldung/sealed/records/Car.java | 0 .../src/main/java/com/baeldung/sealed/records/Truck.java | 0 .../src/main/java/com/baeldung/sealed/records/Vehicle.java | 0 .../java/com/baeldung/sealed/classes/VehicleUnitTest.java | 4 ++-- .../java/com/baeldung/sealed/records/VehicleUnitTest.java | 0 12 files changed, 3 insertions(+), 3 deletions(-) rename core-java-modules/{core-java-15 => core-java-17}/src/main/java/com/baeldung/sealed/alternative/Vehicles.java (100%) rename core-java-modules/{core-java-15 => core-java-17}/src/main/java/com/baeldung/sealed/classes/Car.java (100%) rename core-java-modules/{core-java-15 => core-java-17}/src/main/java/com/baeldung/sealed/classes/Service.java (100%) rename core-java-modules/{core-java-15 => core-java-17}/src/main/java/com/baeldung/sealed/classes/Truck.java (100%) rename core-java-modules/{core-java-15 => core-java-17}/src/main/java/com/baeldung/sealed/classes/Vehicle.java (100%) rename core-java-modules/{core-java-15 => core-java-17}/src/main/java/com/baeldung/sealed/records/Car.java (100%) rename core-java-modules/{core-java-15 => core-java-17}/src/main/java/com/baeldung/sealed/records/Truck.java (100%) rename core-java-modules/{core-java-15 => core-java-17}/src/main/java/com/baeldung/sealed/records/Vehicle.java (100%) rename core-java-modules/{core-java-15 => core-java-17}/src/test/java/com/baeldung/sealed/classes/VehicleUnitTest.java (93%) rename core-java-modules/{core-java-15 => core-java-17}/src/test/java/com/baeldung/sealed/records/VehicleUnitTest.java (100%) diff --git a/core-java-modules/core-java-15/README.md b/core-java-modules/core-java-15/README.md index 4b163fcfb5..6c4fcff419 100644 --- a/core-java-modules/core-java-15/README.md +++ b/core-java-modules/core-java-15/README.md @@ -5,4 +5,3 @@ This module contains articles about Java 15. ### Relevant articles - [Hidden Classes in Java 15](https://www.baeldung.com/java-hidden-classes) -- [Sealed Classes and Interfaces in Java 15](https://www.baeldung.com/java-sealed-classes-interfaces) diff --git a/core-java-modules/core-java-17/README.md b/core-java-modules/core-java-17/README.md index 1f061bd7c1..d77a487932 100644 --- a/core-java-modules/core-java-17/README.md +++ b/core-java-modules/core-java-17/README.md @@ -5,3 +5,4 @@ - [Introduction to HexFormat in Java 17](https://www.baeldung.com/java-hexformat) - [New Features in Java 17](https://www.baeldung.com/java-17-new-features) - [Random Number Generators in Java 17](https://www.baeldung.com/java-17-random-number-generators) +- [Sealed Classes and Interfaces in Java 17](https://www.baeldung.com/java-sealed-classes-interfaces) diff --git a/core-java-modules/core-java-15/src/main/java/com/baeldung/sealed/alternative/Vehicles.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/sealed/alternative/Vehicles.java similarity index 100% rename from core-java-modules/core-java-15/src/main/java/com/baeldung/sealed/alternative/Vehicles.java rename to core-java-modules/core-java-17/src/main/java/com/baeldung/sealed/alternative/Vehicles.java diff --git a/core-java-modules/core-java-15/src/main/java/com/baeldung/sealed/classes/Car.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/sealed/classes/Car.java similarity index 100% rename from core-java-modules/core-java-15/src/main/java/com/baeldung/sealed/classes/Car.java rename to core-java-modules/core-java-17/src/main/java/com/baeldung/sealed/classes/Car.java diff --git a/core-java-modules/core-java-15/src/main/java/com/baeldung/sealed/classes/Service.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/sealed/classes/Service.java similarity index 100% rename from core-java-modules/core-java-15/src/main/java/com/baeldung/sealed/classes/Service.java rename to core-java-modules/core-java-17/src/main/java/com/baeldung/sealed/classes/Service.java diff --git a/core-java-modules/core-java-15/src/main/java/com/baeldung/sealed/classes/Truck.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/sealed/classes/Truck.java similarity index 100% rename from core-java-modules/core-java-15/src/main/java/com/baeldung/sealed/classes/Truck.java rename to core-java-modules/core-java-17/src/main/java/com/baeldung/sealed/classes/Truck.java diff --git a/core-java-modules/core-java-15/src/main/java/com/baeldung/sealed/classes/Vehicle.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/sealed/classes/Vehicle.java similarity index 100% rename from core-java-modules/core-java-15/src/main/java/com/baeldung/sealed/classes/Vehicle.java rename to core-java-modules/core-java-17/src/main/java/com/baeldung/sealed/classes/Vehicle.java diff --git a/core-java-modules/core-java-15/src/main/java/com/baeldung/sealed/records/Car.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/sealed/records/Car.java similarity index 100% rename from core-java-modules/core-java-15/src/main/java/com/baeldung/sealed/records/Car.java rename to core-java-modules/core-java-17/src/main/java/com/baeldung/sealed/records/Car.java diff --git a/core-java-modules/core-java-15/src/main/java/com/baeldung/sealed/records/Truck.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/sealed/records/Truck.java similarity index 100% rename from core-java-modules/core-java-15/src/main/java/com/baeldung/sealed/records/Truck.java rename to core-java-modules/core-java-17/src/main/java/com/baeldung/sealed/records/Truck.java diff --git a/core-java-modules/core-java-15/src/main/java/com/baeldung/sealed/records/Vehicle.java b/core-java-modules/core-java-17/src/main/java/com/baeldung/sealed/records/Vehicle.java similarity index 100% rename from core-java-modules/core-java-15/src/main/java/com/baeldung/sealed/records/Vehicle.java rename to core-java-modules/core-java-17/src/main/java/com/baeldung/sealed/records/Vehicle.java diff --git a/core-java-modules/core-java-15/src/test/java/com/baeldung/sealed/classes/VehicleUnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/sealed/classes/VehicleUnitTest.java similarity index 93% rename from core-java-modules/core-java-15/src/test/java/com/baeldung/sealed/classes/VehicleUnitTest.java rename to core-java-modules/core-java-17/src/test/java/com/baeldung/sealed/classes/VehicleUnitTest.java index b614981a43..73d8aad810 100644 --- a/core-java-modules/core-java-15/src/test/java/com/baeldung/sealed/classes/VehicleUnitTest.java +++ b/core-java-modules/core-java-17/src/test/java/com/baeldung/sealed/classes/VehicleUnitTest.java @@ -21,7 +21,7 @@ public class VehicleUnitTest { public void givenCar_whenUsingReflectionAPI_thenSuperClassIsSealed() { Assertions.assertThat(car.getClass().isSealed()).isEqualTo(false); Assertions.assertThat(car.getClass().getSuperclass().isSealed()).isEqualTo(true); - Assertions.assertThat(car.getClass().getSuperclass().permittedSubclasses()) + Assertions.assertThat(car.getClass().getSuperclass().getPermittedSubclasses()) .contains(ClassDesc.of(car.getClass().getCanonicalName())); } @@ -29,7 +29,7 @@ public class VehicleUnitTest { public void givenTruck_whenUsingReflectionAPI_thenSuperClassIsSealed() { Assertions.assertThat(truck.getClass().isSealed()).isEqualTo(false); Assertions.assertThat(truck.getClass().getSuperclass().isSealed()).isEqualTo(true); - Assertions.assertThat(truck.getClass().getSuperclass().permittedSubclasses()) + Assertions.assertThat(truck.getClass().getSuperclass().getPermittedSubclasses()) .contains(ClassDesc.of(truck.getClass().getCanonicalName())); } diff --git a/core-java-modules/core-java-15/src/test/java/com/baeldung/sealed/records/VehicleUnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/sealed/records/VehicleUnitTest.java similarity index 100% rename from core-java-modules/core-java-15/src/test/java/com/baeldung/sealed/records/VehicleUnitTest.java rename to core-java-modules/core-java-17/src/test/java/com/baeldung/sealed/records/VehicleUnitTest.java From c3d805e5c0781b61eaafc4bc439c304076a33bb1 Mon Sep 17 00:00:00 2001 From: emanueltrandafir1993 Date: Sat, 2 Jul 2022 17:55:17 +0200 Subject: [PATCH 22/53] BAEL-5639: added code samples for the article --- core-java-modules/core-java-14/pom.xml | 9 ++++ .../java14/recordvslombok/ColorData.java | 18 ++++++++ .../java14/recordvslombok/ColorRecord.java | 8 ++++ .../recordvslombok/ColorValueObject.java | 17 ++++++++ .../recordvslombok/MonochromeColor.java | 12 ++++++ .../java14/recordvslombok/StudentBuilder.java | 17 ++++++++ .../java14/recordvslombok/StudentRecord.java | 4 ++ .../recordvslombok/RecordVsLombokUntTest.java | 43 +++++++++++++++++++ 8 files changed, 128 insertions(+) create mode 100644 core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/ColorData.java create mode 100644 core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/ColorRecord.java create mode 100644 core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/ColorValueObject.java create mode 100644 core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/MonochromeColor.java create mode 100644 core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/StudentBuilder.java create mode 100644 core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/StudentRecord.java create mode 100644 core-java-modules/core-java-14/src/test/java/com/baeldung/java14/recordvslombok/RecordVsLombokUntTest.java diff --git a/core-java-modules/core-java-14/pom.xml b/core-java-modules/core-java-14/pom.xml index 35ea0bd2d0..f78edd622a 100644 --- a/core-java-modules/core-java-14/pom.xml +++ b/core-java-modules/core-java-14/pom.xml @@ -14,6 +14,15 @@ 1.0.0-SNAPSHOT + + + org.projectlombok + lombok + 1.18.24 + provided + + + diff --git a/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/ColorData.java b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/ColorData.java new file mode 100644 index 0000000000..6d50c63ba5 --- /dev/null +++ b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/ColorData.java @@ -0,0 +1,18 @@ +package com.baeldung.java14.recordvslombok; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class ColorData { + + private int red; + private int green; + private int blue; + + public String getHexString() { + return String.format("#%02X%02X%02X", red, green, blue); + } + +} diff --git a/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/ColorRecord.java b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/ColorRecord.java new file mode 100644 index 0000000000..03d1f5c264 --- /dev/null +++ b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/ColorRecord.java @@ -0,0 +1,8 @@ +package com.baeldung.java14.recordvslombok; + +public record ColorRecord(int red, int green, int blue) { + + public String getHexString() { + return String.format("#%02X%02X%02X", red, green, blue); + } +} diff --git a/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/ColorValueObject.java b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/ColorValueObject.java new file mode 100644 index 0000000000..eca33662c2 --- /dev/null +++ b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/ColorValueObject.java @@ -0,0 +1,17 @@ +package com.baeldung.java14.recordvslombok; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Value; + +@Value +@Getter(AccessLevel.NONE) +public class ColorValueObject { + int red; + int green; + int blue; + + public String getHexString() { + return String.format("#%02X%02X%02X", red, green, blue); + } +} diff --git a/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/MonochromeColor.java b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/MonochromeColor.java new file mode 100644 index 0000000000..6672cb49ea --- /dev/null +++ b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/MonochromeColor.java @@ -0,0 +1,12 @@ +package com.baeldung.java14.recordvslombok; + +import lombok.Value; + +@Value +public class MonochromeColor extends ColorData { + + public MonochromeColor(int grayScale) { + super(grayScale, grayScale, grayScale); + } + +} diff --git a/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/StudentBuilder.java b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/StudentBuilder.java new file mode 100644 index 0000000000..318634788e --- /dev/null +++ b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/StudentBuilder.java @@ -0,0 +1,17 @@ +package com.baeldung.java14.recordvslombok; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class StudentBuilder { + private String firstName; + private String lastName; + private Long studentId; + private String email; + private String phoneNumber; + private String address; + private String country; + private int age; +} \ No newline at end of file diff --git a/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/StudentRecord.java b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/StudentRecord.java new file mode 100644 index 0000000000..2d51fadd12 --- /dev/null +++ b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/recordvslombok/StudentRecord.java @@ -0,0 +1,4 @@ +package com.baeldung.java14.recordvslombok; + +public record StudentRecord(String firstName, String lastName, Long studentId, String email, String phoneNumber, String address, String country, int age) { +} diff --git a/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/recordvslombok/RecordVsLombokUntTest.java b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/recordvslombok/RecordVsLombokUntTest.java new file mode 100644 index 0000000000..1cca13133f --- /dev/null +++ b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/recordvslombok/RecordVsLombokUntTest.java @@ -0,0 +1,43 @@ +package com.baeldung.java14.recordvslombok; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +public class RecordVsLombokUntTest { + + @Test + public void givenAColorRecord_hexStringIsCorrect() { + var red = new ColorRecord(255, 0, 0); + + assertThat(red.getHexString()).isEqualTo("#FF0000"); + } + + @Test + public void givenAColorValueObject_hexStringIsCorrect() { + var red = new ColorValueObject(255, 0, 0); + + assertThat(red.getHexString()).isEqualTo("#FF0000"); + } + + @Test + public void givenRecordWithManyAttributes_firstNameShouldBeJohn() { + StudentRecord john = new StudentRecord("John", "Doe", null, "john@doe.com", null, null, "England", 20); + + assertThat(john.firstName()).isEqualTo("John"); + } + + @Test + public void givenBuilderWithManyAttributes_firstNameShouldBeJohn() { + StudentBuilder john = StudentBuilder.builder() + .firstName("John") + .lastName("Doe") + .email("john@doe.com") + .country("England") + .age(20) + .build(); + + assertThat(john.getFirstName()).isEqualTo("John"); + } + +} \ No newline at end of file From 535abc8f7aa4b132a21d15291c8f29a165fd9e96 Mon Sep 17 00:00:00 2001 From: jogra Date: Tue, 5 Jul 2022 13:26:34 +0000 Subject: [PATCH 23/53] close #12095 --- .../outputstream/InputStreamToOutputStreamUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/inputstream/outputstream/InputStreamToOutputStreamUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/inputstream/outputstream/InputStreamToOutputStreamUnitTest.java index 814824e580..69c2e7d69d 100644 --- a/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/inputstream/outputstream/InputStreamToOutputStreamUnitTest.java +++ b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/inputstream/outputstream/InputStreamToOutputStreamUnitTest.java @@ -20,7 +20,7 @@ public class InputStreamToOutputStreamUnitTest { void copy(InputStream source, OutputStream target) throws IOException { byte[] buf = new byte[8192]; int length; - while ((length = source.read(buf)) > 0) { + while ((length = source.read(buf)) != -1) { target.write(buf, 0, length); } } From acb9cc97cdd94d1d724edd92ad8c8191af29b23f Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Wed, 6 Jul 2022 15:10:08 +0530 Subject: [PATCH 24/53] JAVA-12732: move security filters article to spring-security-web-mvc --- spring-security-modules/spring-security-ldap/README.md | 1 - spring-security-modules/spring-security-web-mvc/README.md | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-security-modules/spring-security-ldap/README.md b/spring-security-modules/spring-security-ldap/README.md index 288791b389..f75c1bbaef 100644 --- a/spring-security-modules/spring-security-ldap/README.md +++ b/spring-security-modules/spring-security-ldap/README.md @@ -8,7 +8,6 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com ### Relevant Article: -- [Spring Security – security none, filters none, access permitAll](https://www.baeldung.com/security-none-filters-none-access-permitAll) - [Intro to Spring Security LDAP](https://www.baeldung.com/spring-security-ldap) ### Notes diff --git a/spring-security-modules/spring-security-web-mvc/README.md b/spring-security-modules/spring-security-web-mvc/README.md index bb4cfe1a4f..49831ea970 100644 --- a/spring-security-modules/spring-security-web-mvc/README.md +++ b/spring-security-modules/spring-security-web-mvc/README.md @@ -11,6 +11,7 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com - [HttpSessionListener Example – Monitoring](https://www.baeldung.com/httpsessionlistener_with_metrics) - [Control the Session with Spring Security](https://www.baeldung.com/spring-security-session) - [The Clear-Site-Data Header in Spring Security](https://www.baeldung.com/spring-security-clear-site-data-header) +- [Spring Security – security none, filters none, access permitAll](https://www.baeldung.com/security-none-filters-none-access-permitAll) ### Build the Project From 6ae4a1aaf78e94078577ce0eaa4f4702e5c0b075 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Wed, 6 Jul 2022 15:25:12 +0530 Subject: [PATCH 25/53] JAVA-12732: move spring-ldap into spring-security-ldap --- spring-security-modules/pom.xml | 1 - .../spring-ldap/.gitignore | 13 -- spring-security-modules/spring-ldap/README.md | 8 - spring-security-modules/spring-ldap/pom.xml | 141 ------------------ .../src/main/resources/application.properties | 6 - .../src/main/resources/logback.xml | 19 --- .../java/org/baeldung/SpringContextTest.java | 17 --- .../spring-security-ldap/README.md | 2 + .../spring-security-ldap/pom.xml | 21 +++ .../com/baeldung/ldap/client/LdapClient.java | 0 .../baeldung/ldap/data/repository/User.java | 0 .../ldap/data/repository/UserRepository.java | 0 .../ldap/data/service/LdapClient.java | 0 .../ldap/data/service/UserService.java | 0 .../baeldung/ldap/javaconfig/AppConfig.java | 0 .../src/main/resources/application.properties | 9 +- .../ldap/client/LdapClientLiveTest.java | 0 .../LdapDataRepositoryIntegrationTest.java | 0 .../baeldung/ldap/javaconfig/TestConfig.java | 0 .../src/test/resources/test.ldif | 0 .../resources/test_application.properties | 0 21 files changed, 31 insertions(+), 206 deletions(-) delete mode 100644 spring-security-modules/spring-ldap/.gitignore delete mode 100644 spring-security-modules/spring-ldap/README.md delete mode 100644 spring-security-modules/spring-ldap/pom.xml delete mode 100644 spring-security-modules/spring-ldap/src/main/resources/application.properties delete mode 100644 spring-security-modules/spring-ldap/src/main/resources/logback.xml delete mode 100644 spring-security-modules/spring-ldap/src/test/java/org/baeldung/SpringContextTest.java rename spring-security-modules/{spring-ldap => spring-security-ldap}/src/main/java/com/baeldung/ldap/client/LdapClient.java (100%) rename spring-security-modules/{spring-ldap => spring-security-ldap}/src/main/java/com/baeldung/ldap/data/repository/User.java (100%) rename spring-security-modules/{spring-ldap => spring-security-ldap}/src/main/java/com/baeldung/ldap/data/repository/UserRepository.java (100%) rename spring-security-modules/{spring-ldap => spring-security-ldap}/src/main/java/com/baeldung/ldap/data/service/LdapClient.java (100%) rename spring-security-modules/{spring-ldap => spring-security-ldap}/src/main/java/com/baeldung/ldap/data/service/UserService.java (100%) rename spring-security-modules/{spring-ldap => spring-security-ldap}/src/main/java/com/baeldung/ldap/javaconfig/AppConfig.java (100%) rename spring-security-modules/{spring-ldap => spring-security-ldap}/src/test/java/com/baeldung/ldap/client/LdapClientLiveTest.java (100%) rename spring-security-modules/{spring-ldap => spring-security-ldap}/src/test/java/com/baeldung/ldap/client/LdapDataRepositoryIntegrationTest.java (100%) rename spring-security-modules/{spring-ldap => spring-security-ldap}/src/test/java/com/baeldung/ldap/javaconfig/TestConfig.java (100%) rename spring-security-modules/{spring-ldap => spring-security-ldap}/src/test/resources/test.ldif (100%) rename spring-security-modules/{spring-ldap => spring-security-ldap}/src/test/resources/test_application.properties (100%) diff --git a/spring-security-modules/pom.xml b/spring-security-modules/pom.xml index 2123c03016..c82614a3af 100644 --- a/spring-security-modules/pom.xml +++ b/spring-security-modules/pom.xml @@ -16,7 +16,6 @@ spring-5-security - spring-ldap spring-security-acl spring-security-auth0 spring-security-cognito diff --git a/spring-security-modules/spring-ldap/.gitignore b/spring-security-modules/spring-ldap/.gitignore deleted file mode 100644 index 83c05e60c8..0000000000 --- a/spring-security-modules/spring-ldap/.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/spring-security-modules/spring-ldap/README.md b/spring-security-modules/spring-ldap/README.md deleted file mode 100644 index 4872f897e1..0000000000 --- a/spring-security-modules/spring-ldap/README.md +++ /dev/null @@ -1,8 +0,0 @@ -## Spring LDAP - -This module contains articles about Spring LDAP - -### Relevant articles - -- [Spring LDAP Overview](https://www.baeldung.com/spring-ldap) -- [Guide to Spring Data LDAP](https://www.baeldung.com/spring-data-ldap) diff --git a/spring-security-modules/spring-ldap/pom.xml b/spring-security-modules/spring-ldap/pom.xml deleted file mode 100644 index 086be2df5a..0000000000 --- a/spring-security-modules/spring-ldap/pom.xml +++ /dev/null @@ -1,141 +0,0 @@ - - - 4.0.0 - spring-ldap - 0.1-SNAPSHOT - spring-ldap - jar - - - com.baeldung - spring-security-modules - 0.0.1-SNAPSHOT - - - - - org.springframework.ldap - spring-ldap-core - ${spring-ldap.version} - - - commons-logging - commons-logging - - - - - org.springframework - spring-context - ${spring-context.version} - - - - org.springframework.ldap - spring-ldap-test - ${spring-ldap.version} - test - - - commons-logging - commons-logging - - - - - - org.apache.directory.server - apacheds-core - ${apacheds.version} - test - - - org.apache.directory.server - apacheds-core-entry - ${apacheds.version} - test - - - org.apache.directory.server - apacheds-protocol-shared - ${apacheds.version} - test - - - org.apache.directory.server - apacheds-protocol-ldap - ${apacheds.version} - test - - - org.apache.directory.server - apacheds-server-jndi - ${apacheds.version} - test - - - org.apache.directory.shared - shared-ldap - ${shared-ldap.version} - test - - - - org.springframework.data - spring-data-ldap - ${spring-data-ldap.version} - - - org.springframework.data - spring-data-jpa - ${spring-data-jpa.version} - - - - - spring-ldap - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration-test - - test - - - - **/*IntegrationTest.java - **/*IntTest.java - - - **/*LiveTest.java - - - - - - - - - - - - 2.3.1.RELEASE - 4.3.6.RELEASE - 1.5.5 - 0.9.15 - 1.0.6.RELEASE - 1.11.6.RELEASE - - - \ No newline at end of file diff --git a/spring-security-modules/spring-ldap/src/main/resources/application.properties b/spring-security-modules/spring-ldap/src/main/resources/application.properties deleted file mode 100644 index 670fb79234..0000000000 --- a/spring-security-modules/spring-ldap/src/main/resources/application.properties +++ /dev/null @@ -1,6 +0,0 @@ -ldap.partitionSuffix=dc=example,dc=com -ldap.partition=example -ldap.principal=uid=admin,ou=system -ldap.password=secret -ldap.port=18889 -ldap.url=ldap://localhost:18889 \ No newline at end of file diff --git a/spring-security-modules/spring-ldap/src/main/resources/logback.xml b/spring-security-modules/spring-ldap/src/main/resources/logback.xml deleted file mode 100644 index 7bd5154680..0000000000 --- a/spring-security-modules/spring-ldap/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/spring-security-modules/spring-ldap/src/test/java/org/baeldung/SpringContextTest.java b/spring-security-modules/spring-ldap/src/test/java/org/baeldung/SpringContextTest.java deleted file mode 100644 index 8f0c3d4612..0000000000 --- a/spring-security-modules/spring-ldap/src/test/java/org/baeldung/SpringContextTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import com.baeldung.ldap.javaconfig.AppConfig; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = AppConfig.class) -public class SpringContextTest { - - @Test - public void whenSpringContextIsBootstrapped_thenNoExceptions() { - } -} diff --git a/spring-security-modules/spring-security-ldap/README.md b/spring-security-modules/spring-security-ldap/README.md index f75c1bbaef..d396d67f56 100644 --- a/spring-security-modules/spring-security-ldap/README.md +++ b/spring-security-modules/spring-security-ldap/README.md @@ -9,6 +9,8 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com ### Relevant Article: - [Intro to Spring Security LDAP](https://www.baeldung.com/spring-security-ldap) +- [Spring LDAP Overview](https://www.baeldung.com/spring-ldap) +- [Guide to Spring Data LDAP](https://www.baeldung.com/spring-data-ldap) ### Notes diff --git a/spring-security-modules/spring-security-ldap/pom.xml b/spring-security-modules/spring-security-ldap/pom.xml index 3755c33125..73b77184d1 100644 --- a/spring-security-modules/spring-security-ldap/pom.xml +++ b/spring-security-modules/spring-security-ldap/pom.xml @@ -44,6 +44,27 @@ apacheds-server-jndi ${apacheds.version} + + + org.springframework.data + spring-data-ldap + + + org.springframework.data + spring-data-jpa + + + + org.springframework.ldap + spring-ldap-test + test + + + commons-logging + commons-logging + + + diff --git a/spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/client/LdapClient.java b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/ldap/client/LdapClient.java similarity index 100% rename from spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/client/LdapClient.java rename to spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/ldap/client/LdapClient.java diff --git a/spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/data/repository/User.java b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/ldap/data/repository/User.java similarity index 100% rename from spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/data/repository/User.java rename to spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/ldap/data/repository/User.java diff --git a/spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/data/repository/UserRepository.java b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/ldap/data/repository/UserRepository.java similarity index 100% rename from spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/data/repository/UserRepository.java rename to spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/ldap/data/repository/UserRepository.java diff --git a/spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/data/service/LdapClient.java b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/ldap/data/service/LdapClient.java similarity index 100% rename from spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/data/service/LdapClient.java rename to spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/ldap/data/service/LdapClient.java diff --git a/spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/data/service/UserService.java b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/ldap/data/service/UserService.java similarity index 100% rename from spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/data/service/UserService.java rename to spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/ldap/data/service/UserService.java diff --git a/spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/javaconfig/AppConfig.java b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/ldap/javaconfig/AppConfig.java similarity index 100% rename from spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/javaconfig/AppConfig.java rename to spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/ldap/javaconfig/AppConfig.java diff --git a/spring-security-modules/spring-security-ldap/src/main/resources/application.properties b/spring-security-modules/spring-security-ldap/src/main/resources/application.properties index 3d0221bb7b..cbe57f420f 100644 --- a/spring-security-modules/spring-security-ldap/src/main/resources/application.properties +++ b/spring-security-modules/spring-security-ldap/src/main/resources/application.properties @@ -1 +1,8 @@ -management.health.ldap.enabled=false \ No newline at end of file +management.health.ldap.enabled=false + +ldap.partitionSuffix=dc=example,dc=com +ldap.partition=example +ldap.principal=uid=admin,ou=system +ldap.password=secret +ldap.port=18889 +ldap.url=ldap://localhost:18889 \ No newline at end of file diff --git a/spring-security-modules/spring-ldap/src/test/java/com/baeldung/ldap/client/LdapClientLiveTest.java b/spring-security-modules/spring-security-ldap/src/test/java/com/baeldung/ldap/client/LdapClientLiveTest.java similarity index 100% rename from spring-security-modules/spring-ldap/src/test/java/com/baeldung/ldap/client/LdapClientLiveTest.java rename to spring-security-modules/spring-security-ldap/src/test/java/com/baeldung/ldap/client/LdapClientLiveTest.java diff --git a/spring-security-modules/spring-ldap/src/test/java/com/baeldung/ldap/client/LdapDataRepositoryIntegrationTest.java b/spring-security-modules/spring-security-ldap/src/test/java/com/baeldung/ldap/client/LdapDataRepositoryIntegrationTest.java similarity index 100% rename from spring-security-modules/spring-ldap/src/test/java/com/baeldung/ldap/client/LdapDataRepositoryIntegrationTest.java rename to spring-security-modules/spring-security-ldap/src/test/java/com/baeldung/ldap/client/LdapDataRepositoryIntegrationTest.java diff --git a/spring-security-modules/spring-ldap/src/test/java/com/baeldung/ldap/javaconfig/TestConfig.java b/spring-security-modules/spring-security-ldap/src/test/java/com/baeldung/ldap/javaconfig/TestConfig.java similarity index 100% rename from spring-security-modules/spring-ldap/src/test/java/com/baeldung/ldap/javaconfig/TestConfig.java rename to spring-security-modules/spring-security-ldap/src/test/java/com/baeldung/ldap/javaconfig/TestConfig.java diff --git a/spring-security-modules/spring-ldap/src/test/resources/test.ldif b/spring-security-modules/spring-security-ldap/src/test/resources/test.ldif similarity index 100% rename from spring-security-modules/spring-ldap/src/test/resources/test.ldif rename to spring-security-modules/spring-security-ldap/src/test/resources/test.ldif diff --git a/spring-security-modules/spring-ldap/src/test/resources/test_application.properties b/spring-security-modules/spring-security-ldap/src/test/resources/test_application.properties similarity index 100% rename from spring-security-modules/spring-ldap/src/test/resources/test_application.properties rename to spring-security-modules/spring-security-ldap/src/test/resources/test_application.properties From 6f91643aa2452516cbc575b6972f300c70b5de4b Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Wed, 6 Jul 2022 15:34:15 +0530 Subject: [PATCH 26/53] resolve conflict --- spring-security-modules/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-security-modules/pom.xml b/spring-security-modules/pom.xml index c82614a3af..16eb288200 100644 --- a/spring-security-modules/pom.xml +++ b/spring-security-modules/pom.xml @@ -45,7 +45,6 @@ spring-security-web-sockets spring-security-web-thymeleaf spring-security-web-x509 - spring-session spring-security-opa From f7c39d586e02975c405f558f03c951d864ded00a Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Wed, 6 Jul 2022 12:00:41 +0100 Subject: [PATCH 27/53] [JAVA-12757] Update code for OpenCSV article --- .../libraries/opencsv/Application.java | 129 ++++++------------ .../opencsv/beans/NamedColumnBean.java | 5 + .../opencsv/beans/SimplePositionBean.java | 4 + .../opencsv/beans/WriteExampleBean.java | 5 + .../opencsv/examples/sync/BeanExamples.java | 55 +++----- .../examples/sync/CsvReaderExamples.java | 65 +++++---- .../examples/sync/CsvWriterExamples.java | 25 ++-- .../libraries/opencsv/helpers/Helpers.java | 52 ++----- .../src/main/resources/csv/twoColumn.csv | 10 +- .../opencsv/OpenCsvIntegrationTest.java | 115 +++++++++++----- 10 files changed, 212 insertions(+), 253 deletions(-) diff --git a/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/Application.java b/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/Application.java index ee819b844b..cee73f674e 100644 --- a/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/Application.java +++ b/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/Application.java @@ -1,5 +1,6 @@ package com.baeldung.libraries.opencsv; +import com.baeldung.libraries.opencsv.beans.CsvBean; import com.baeldung.libraries.opencsv.beans.NamedColumnBean; import com.baeldung.libraries.opencsv.beans.SimplePositionBean; import com.baeldung.libraries.opencsv.examples.sync.BeanExamples; @@ -7,102 +8,60 @@ import com.baeldung.libraries.opencsv.examples.sync.CsvReaderExamples; import com.baeldung.libraries.opencsv.examples.sync.CsvWriterExamples; import com.baeldung.libraries.opencsv.helpers.Helpers; -import java.io.Reader; -import java.nio.file.Files; import java.nio.file.Path; +import java.util.List; public class Application { - /* - * Bean Examples. - */ - - public static String simpleSyncPositionBeanExample() { - Path path = null; - try { - path = Helpers.twoColumnCsvPath(); - } catch (Exception ex) { - Helpers.err(ex); - } - return BeanExamples.beanBuilderExample(path, SimplePositionBean.class).toString(); + // CSV Reader Examples + public static List readLineByLineSyncExample() throws Exception { + Path path = Helpers.twoColumnCsvPath(); + return CsvReaderExamples.readLineByLine(path); } - public static String namedSyncColumnBeanExample() { - Path path = null; - try { - path = Helpers.namedColumnCsvPath(); - } catch (Exception ex) { - Helpers.err(ex); - } - return BeanExamples.beanBuilderExample(path, NamedColumnBean.class).toString(); + public static List readAllLinesSyncExample() throws Exception { + Path path = Helpers.twoColumnCsvPath(); + return CsvReaderExamples.readAllLines(path); } - public static String writeSyncCsvFromBeanExample() { - Path path = null; - try { - path = Helpers.fileOutBeanPath(); - } catch (Exception ex) { - Helpers.err(ex); - } + // CSV Writer Examples + public static String writeLineByLineSyncExample() throws Exception { + Path path = Helpers.fileOutOnePath(); + return CsvWriterExamples.writeLineByLine(Helpers.fourColumnCsvString(), path); + } + + public static String writeAllLinesSyncExample() throws Exception { + Path path = Helpers.fileOutAllPath(); + return CsvWriterExamples.writeAllLines(Helpers.fourColumnCsvString(), path); + } + + // Bean Examples + public static List simpleSyncPositionBeanExample() throws Exception { + Path path = Helpers.twoColumnCsvPath(); + return BeanExamples.beanBuilderExample(path, SimplePositionBean.class); + } + + public static List namedSyncColumnBeanExample() throws Exception { + Path path = Helpers.namedColumnCsvPath(); + return BeanExamples.beanBuilderExample(path, NamedColumnBean.class); + } + + public static String writeSyncCsvFromBeanExample() throws Exception { + Path path = Helpers.fileOutBeanPath(); return BeanExamples.writeCsvFromBean(path); } - /* - * CSV Reader Examples. - */ - - public static String oneByOneSyncExample() { - Reader reader = null; - try { - reader = Files.newBufferedReader(Helpers.twoColumnCsvPath()); - } catch (Exception ex) { - Helpers.err(ex); - } - return CsvReaderExamples.oneByOne(reader).toString(); - } - - public static String readAllSyncExample() { - Reader reader = null; - try { - reader = Files.newBufferedReader(Helpers.twoColumnCsvPath()); - } catch (Exception ex) { - Helpers.err(ex); - } - return CsvReaderExamples.readAll(reader).toString(); - } - - /* - * CSV Writer Examples. - */ - - - public static String csvWriterSyncOneByOne() { - Path path = null; - try { - path = Helpers.fileOutOnePath(); - } catch (Exception ex) { - Helpers.err(ex); - } - return CsvWriterExamples.csvWriterOneByOne(Helpers.fourColumnCsvString(), path); - } - - public static String csvWriterSyncAll() { - Path path = null; - try { - path = Helpers.fileOutAllPath(); - } catch (Exception ex) { - Helpers.err(ex); - } - return CsvWriterExamples.csvWriterAll(Helpers.fourColumnCsvString(), path); - } - public static void main(String[] args) { - simpleSyncPositionBeanExample(); - namedSyncColumnBeanExample(); - writeSyncCsvFromBeanExample(); - oneByOneSyncExample(); - readAllSyncExample(); - csvWriterSyncOneByOne(); - csvWriterSyncAll(); + try { + simpleSyncPositionBeanExample(); + namedSyncColumnBeanExample(); + writeSyncCsvFromBeanExample(); + readLineByLineSyncExample(); + readAllLinesSyncExample(); + writeLineByLineSyncExample(); + writeAllLinesSyncExample(); + } catch (Exception e) { + throw new RuntimeException("Error during csv processing", e); + } } } diff --git a/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/beans/NamedColumnBean.java b/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/beans/NamedColumnBean.java index 0021584e4f..f8c6537d3a 100644 --- a/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/beans/NamedColumnBean.java +++ b/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/beans/NamedColumnBean.java @@ -27,5 +27,10 @@ public class NamedColumnBean extends CsvBean { this.age = age; } + @Override + public String toString() { + return name + ',' + age; + } + } diff --git a/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/beans/SimplePositionBean.java b/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/beans/SimplePositionBean.java index c1710d784a..2306ccc560 100644 --- a/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/beans/SimplePositionBean.java +++ b/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/beans/SimplePositionBean.java @@ -26,4 +26,8 @@ public class SimplePositionBean extends CsvBean { this.exampleColTwo = exampleColTwo; } + @Override + public String toString() { + return exampleColOne + ',' + exampleColTwo; + } } diff --git a/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/beans/WriteExampleBean.java b/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/beans/WriteExampleBean.java index f5e6466512..62b14dc321 100644 --- a/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/beans/WriteExampleBean.java +++ b/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/beans/WriteExampleBean.java @@ -37,4 +37,9 @@ public class WriteExampleBean extends CsvBean { public void setColC(String colC) { this.colC = colC; } + + @Override + public String toString() { + return colA + ',' + colB + "," + colC; + } } diff --git a/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/examples/sync/BeanExamples.java b/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/examples/sync/BeanExamples.java index f401c7c77c..b2a00be0ee 100644 --- a/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/examples/sync/BeanExamples.java +++ b/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/examples/sync/BeanExamples.java @@ -4,60 +4,49 @@ import com.baeldung.libraries.opencsv.beans.CsvBean; import com.baeldung.libraries.opencsv.beans.WriteExampleBean; import com.baeldung.libraries.opencsv.helpers.Helpers; import com.baeldung.libraries.opencsv.pojos.CsvTransfer; -import com.opencsv.CSVWriter; -import com.opencsv.bean.*; +import com.opencsv.bean.CsvToBean; +import com.opencsv.bean.CsvToBeanBuilder; +import com.opencsv.bean.StatefulBeanToCsv; +import com.opencsv.bean.StatefulBeanToCsvBuilder; import java.io.FileWriter; import java.io.Reader; import java.io.Writer; import java.nio.file.Files; import java.nio.file.Path; -import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class BeanExamples { - public static List beanBuilderExample(Path path, Class clazz) { - ColumnPositionMappingStrategy ms = new ColumnPositionMappingStrategy(); - return beanBuilderExample(path, clazz, ms); - } - - public static List beanBuilderExample(Path path, Class clazz, MappingStrategy ms) { + public static List beanBuilderExample(Path path, Class clazz) throws Exception { CsvTransfer csvTransfer = new CsvTransfer(); - try { - ms.setType(clazz); - - Reader reader = Files.newBufferedReader(path); - CsvToBean cb = new CsvToBeanBuilder(reader).withType(clazz) - .withMappingStrategy(ms) - .build(); + try (Reader reader = Files.newBufferedReader(path)) { + CsvToBean cb = new CsvToBeanBuilder(reader) + .withType(clazz) + .build(); csvTransfer.setCsvList(cb.parse()); - reader.close(); - - } catch (Exception ex) { - Helpers.err(ex); } + return csvTransfer.getCsvList(); } - public static String writeCsvFromBean(Path path) { - try { - Writer writer = new FileWriter(path.toString()); + public static String writeCsvFromBean(Path path) throws Exception { - StatefulBeanToCsv sbc = new StatefulBeanToCsvBuilder(writer).withSeparator(CSVWriter.DEFAULT_SEPARATOR) - .build(); + List sampleData = Arrays.asList( + new WriteExampleBean("Test1", "sample", "data"), + new WriteExampleBean("Test2", "ipso", "facto") + ); - List list = new ArrayList<>(); - list.add(new WriteExampleBean("Test1", "sfdsf", "fdfd")); - list.add(new WriteExampleBean("Test2", "ipso", "facto")); + try (Writer writer = new FileWriter(path.toString())) { + StatefulBeanToCsv sbc = new StatefulBeanToCsvBuilder(writer) + .withQuotechar('\'') + .build(); - sbc.write(list); - writer.close(); - - } catch (Exception ex) { - Helpers.err(ex); + sbc.write(sampleData); } + return Helpers.readFile(path); } } \ No newline at end of file diff --git a/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/examples/sync/CsvReaderExamples.java b/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/examples/sync/CsvReaderExamples.java index 2f7d979b2f..2bafe0d764 100644 --- a/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/examples/sync/CsvReaderExamples.java +++ b/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/examples/sync/CsvReaderExamples.java @@ -1,61 +1,58 @@ package com.baeldung.libraries.opencsv.examples.sync; -import com.baeldung.libraries.opencsv.helpers.Helpers; import com.opencsv.CSVParser; import com.opencsv.CSVParserBuilder; import com.opencsv.CSVReader; import com.opencsv.CSVReaderBuilder; import java.io.Reader; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.ArrayList; import java.util.List; public class CsvReaderExamples { - public static List readAll(Reader reader) { + public static List readAllLines(Path filePath) throws Exception { CSVParser parser = new CSVParserBuilder() - .withSeparator(',') - .withIgnoreQuotations(true) - .build(); + .withSeparator(',') + .withIgnoreQuotations(true) + .build(); - CSVReader csvReader = new CSVReaderBuilder(reader) - .withSkipLines(0) - .withCSVParser(parser) - .build(); + try (Reader reader = Files.newBufferedReader(filePath)) { + CSVReaderBuilder csvReaderBuilder = new CSVReaderBuilder(reader) + .withSkipLines(0) + .withCSVParser(parser); - List list = new ArrayList<>(); - try { - list = csvReader.readAll(); - reader.close(); - csvReader.close(); - } catch (Exception ex) { - Helpers.err(ex); + try (CSVReader csvReader = csvReaderBuilder.build()) { + return csvReader.readAll(); + } } - return list; + } - public static List oneByOne(Reader reader) { + public static List readLineByLine(Path filePath) throws Exception { List list = new ArrayList<>(); - try { - CSVParser parser = new CSVParserBuilder() - .withSeparator(',') - .withIgnoreQuotations(true) - .build(); - CSVReader csvReader = new CSVReaderBuilder(reader) - .withSkipLines(0) - .withCSVParser(parser) - .build(); + CSVParser parser = new CSVParserBuilder() + .withSeparator(',') + .withIgnoreQuotations(true) + .build(); - String[] line; - while ((line = csvReader.readNext()) != null) { - list.add(line); + try (Reader reader = Files.newBufferedReader(filePath)) { + + CSVReaderBuilder csvReaderBuilder = new CSVReaderBuilder(reader) + .withSkipLines(0) + .withCSVParser(parser); + + try (CSVReader csvReader = csvReaderBuilder.build()) { + String[] line; + while ((line = csvReader.readNext()) != null) { + list.add(line); + } } - reader.close(); - csvReader.close(); - } catch (Exception ex) { - Helpers.err(ex); + } return list; } diff --git a/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/examples/sync/CsvWriterExamples.java b/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/examples/sync/CsvWriterExamples.java index b5c23bd99d..7f14b2547f 100644 --- a/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/examples/sync/CsvWriterExamples.java +++ b/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/examples/sync/CsvWriterExamples.java @@ -9,26 +9,21 @@ import java.util.List; public class CsvWriterExamples { - public static String csvWriterOneByOne(List stringArray, Path path) { - try { - CSVWriter writer = new CSVWriter(new FileWriter(path.toString())); - for (String[] array : stringArray) { - writer.writeNext(array); + public static String writeLineByLine(List lines, Path path) throws Exception { + + try (CSVWriter writer = new CSVWriter(new FileWriter(path.toString()))) { + for (String[] line : lines) { + writer.writeNext(line); } - writer.close(); - } catch (Exception ex) { - Helpers.err(ex); } + return Helpers.readFile(path); } - public static String csvWriterAll(List stringArray, Path path) { - try { - CSVWriter writer = new CSVWriter(new FileWriter(path.toString())); - writer.writeAll(stringArray); - writer.close(); - } catch (Exception ex) { - Helpers.err(ex); + public static String writeAllLines(List lines, Path path) throws Exception { + + try (CSVWriter writer = new CSVWriter(new FileWriter(path.toString()))) { + writer.writeAll(lines); } return Helpers.readFile(path); } diff --git a/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/helpers/Helpers.java b/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/helpers/Helpers.java index b703d0e82d..fd9e0ba386 100644 --- a/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/helpers/Helpers.java +++ b/libraries-data-io/src/main/java/com/baeldung/libraries/opencsv/helpers/Helpers.java @@ -1,9 +1,9 @@ package com.baeldung.libraries.opencsv.helpers; import com.baeldung.libraries.opencsv.Constants; +import org.apache.commons.io.IOUtils; -import java.io.BufferedReader; -import java.io.FileReader; +import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.nio.file.Path; @@ -13,9 +13,7 @@ import java.util.List; public class Helpers { - /** - * Write Files - */ + // Write Files public static Path fileOutAllPath() throws URISyntaxException { URI uri = ClassLoader.getSystemResource(Constants.CSV_All).toURI(); @@ -32,9 +30,7 @@ public class Helpers { return Paths.get(uri); } - /** - * Read Files - */ + // Read Files public static Path twoColumnCsvPath() throws URISyntaxException { URI uri = ClassLoader.getSystemResource(Constants.TWO_COLUMN_CSV).toURI(); @@ -51,33 +47,12 @@ public class Helpers { return Paths.get(uri); } - /** - * Simple File Reader - */ - - public static String readFile(Path path) { - String response = ""; - try { - FileReader fr = new FileReader(path.toString()); - BufferedReader br = new BufferedReader(fr); - String strLine; - StringBuffer sb = new StringBuffer(); - while ((strLine = br.readLine()) != null) { - sb.append(strLine); - } - response = sb.toString(); - System.out.println(response); - fr.close(); - br.close(); - } catch (Exception ex) { - Helpers.err(ex); - } - return response; + public static String readFile(Path path) throws IOException { + return IOUtils.toString(path.toUri()); } - /** - * Dummy Data for Writing. - */ + + // Dummy Data for Writing public static List twoColumnCsvString() { List list = new ArrayList<>(); @@ -94,15 +69,4 @@ public class Helpers { return list; } - /** - * Message Helpers - */ - - public static void print(String msg) { - System.out.println(msg); - } - - public static void err(Exception ex) { - System.out.println(Constants.GENERIC_EXCEPTION + " " + ex); - } } diff --git a/libraries-data-io/src/main/resources/csv/twoColumn.csv b/libraries-data-io/src/main/resources/csv/twoColumn.csv index 56d8fa1901..527e15af72 100644 --- a/libraries-data-io/src/main/resources/csv/twoColumn.csv +++ b/libraries-data-io/src/main/resources/csv/twoColumn.csv @@ -1,5 +1,5 @@ -colA, ColB -A, B -C, D -G, G -G, F \ No newline at end of file +colA,colB +A,B +C,D +G,G +G,F \ No newline at end of file diff --git a/libraries-data-io/src/test/java/com/baeldung/libraries/opencsv/OpenCsvIntegrationTest.java b/libraries-data-io/src/test/java/com/baeldung/libraries/opencsv/OpenCsvIntegrationTest.java index b0db4309d9..7cfe8984e7 100644 --- a/libraries-data-io/src/test/java/com/baeldung/libraries/opencsv/OpenCsvIntegrationTest.java +++ b/libraries-data-io/src/test/java/com/baeldung/libraries/opencsv/OpenCsvIntegrationTest.java @@ -1,66 +1,107 @@ package com.baeldung.libraries.opencsv; -import com.baeldung.libraries.opencsv.helpers.Helpers; -import org.junit.After; -import org.junit.Before; +import com.baeldung.libraries.opencsv.beans.CsvBean; import org.junit.Test; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + public class OpenCsvIntegrationTest { - private Object testReadCsv(Object result) { - assert (result != null); - assert (result instanceof String); - assert (!((String) result).isEmpty()); - System.out.println(result); - return result; - } + private static final String NEW_LINE = System.lineSeparator(); - private Object testWriteCsv(Object result) { - assert (result instanceof String); - assert (!((String) result).isEmpty()); - return result; - } + @Test + public void givenSampleData_whenReadUsingPosition_thenContentsRead() throws Exception { + List values = Application.simpleSyncPositionBeanExample(); - @Before - public void setup() { + assertThat(values) + .extracting(Object::toString) + .containsExactly( + "colA,colB", + "A,B", + "C,D", + "G,G", + "G,F" + ); } @Test - public void positionExampleTest() { - testReadCsv(Application.simpleSyncPositionBeanExample()); + public void givenSampleData_whenReadUsingNamedColumn_thenContentsRead() throws Exception { + List values = Application.namedSyncColumnBeanExample(); + + assertThat(values) + .extracting(Object::toString) + .containsExactly( + "Joe,27", + "Jane,32", + "Bob,53" + ); } @Test - public void namedColumnExampleTest() { - testReadCsv(Application.namedSyncColumnBeanExample()); + public void givenSampleData_whenReadLineByLine_thenContentsRead() throws Exception { + List lineByLineContents = Application.readLineByLineSyncExample(); + + assertThat(lineByLineContents) + .containsExactly( + new String[] {"colA", "colB"}, + new String[] {"A", "B"}, + new String[] {"C", "D"}, + new String[] {"G", "G"}, + new String[] {"G", "F"} + ); } @Test - public void writeCsvUsingBeanBuilderTest() { - testWriteCsv(Application.writeSyncCsvFromBeanExample()); + public void givenSampleData_whenReadAllLines_thenContentsRead() throws Exception { + + List contents = Application.readAllLinesSyncExample(); + + assertThat(contents) + .containsExactly( + new String[] {"colA", "colB"}, + new String[] {"A", "B"}, + new String[] {"C", "D"}, + new String[] {"G", "G"}, + new String[] {"G", "F"} + ); } @Test - public void oneByOneExampleTest() { - testReadCsv(Application.oneByOneSyncExample()); + public void givenSampleData_whenWriteCsvUsingBean_thenContentsWritten() throws Exception { + String contents = Application.writeSyncCsvFromBeanExample(); + + assertThat(contents.split(NEW_LINE)) + .containsExactly( + "'colA','colB','colC'", + "'Test1','sample','data'", + "'Test2','ipso','facto'" + ); } @Test - public void readAllExampleTest() { - testReadCsv(Application.readAllSyncExample()); + public void givenSampleData_whenWriteCsvLineByLine_thenContentsWritten() throws Exception { + String contents = Application.writeLineByLineSyncExample(); + + assertThat(contents.split(NEW_LINE)) + .containsExactly( + "\"ColA\",\"ColB\",\"ColC\",\"ColD\"", + "\"A\",\"B\",\"A\",\"B\"", + "\"BB\",\"AB\",\"AA\",\"B\"" + ); } @Test - public void csvWriterOneByOneTest() { - testWriteCsv(Application.csvWriterSyncOneByOne()); + public void givenSampleData_whenWriteCsvAllLines_thenContentsWritten() throws Exception { + String contents = Application.writeAllLinesSyncExample(); + + assertThat(contents.split(NEW_LINE)) + .containsExactly( + "\"ColA\",\"ColB\",\"ColC\",\"ColD\"", + "\"A\",\"B\",\"A\",\"B\"", + "\"BB\",\"AB\",\"AA\",\"B\"" + ); } - @Test - public void csvWriterAllTest() { - testWriteCsv(Application.csvWriterSyncAll()); - } - - @After - public void close() { - } } \ No newline at end of file From 7b1b24ad7c736a376c665d9aa9be2cc27621ae8c Mon Sep 17 00:00:00 2001 From: freelansam <79205526+freelansam@users.noreply.github.com> Date: Thu, 7 Jul 2022 19:08:27 +0530 Subject: [PATCH 28/53] update pom to remove spring-social-login --- spring-security-modules/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-security-modules/pom.xml b/spring-security-modules/pom.xml index 303968c52e..a75638d085 100644 --- a/spring-security-modules/pom.xml +++ b/spring-security-modules/pom.xml @@ -45,7 +45,6 @@ spring-security-web-sockets spring-security-web-thymeleaf spring-security-web-x509 - spring-social-login spring-security-opa From b045e8309d0c3d7566b1fb0c657ad99b7e1b7c3d Mon Sep 17 00:00:00 2001 From: chrisjaimes <45322800+chrisjaimes@users.noreply.github.com> Date: Thu, 7 Jul 2022 12:41:30 -0400 Subject: [PATCH 29/53] BAEL-5363 Fixed pom files, assertions instead of console output, and fixed package folders (#12462) Co-authored-by: Christian Jaimes --- persistence-modules/java-mongodb-queries/pom.xml | 3 +-- .../baeldung/mongo}/crud/CrudClient.java | 0 .../baeldung/mongo}/crud/model/Event.java | 0 .../baeldung/mongo/crud}/CrudClientLiveTest.java | 8 ++++++++ persistence-modules/pom.xml | 1 + pom.xml | 3 --- 6 files changed, 10 insertions(+), 5 deletions(-) rename persistence-modules/java-mongodb-queries/src/main/java/{com.baeldung.mongo => com/baeldung/mongo}/crud/CrudClient.java (100%) rename persistence-modules/java-mongodb-queries/src/main/java/{com.baeldung.mongo => com/baeldung/mongo}/crud/model/Event.java (100%) rename persistence-modules/java-mongodb-queries/src/test/java/{com.baeldung.mongo.crud => com/baeldung/mongo/crud}/CrudClientLiveTest.java (83%) diff --git a/persistence-modules/java-mongodb-queries/pom.xml b/persistence-modules/java-mongodb-queries/pom.xml index 731d61f013..58d7af1bc9 100644 --- a/persistence-modules/java-mongodb-queries/pom.xml +++ b/persistence-modules/java-mongodb-queries/pom.xml @@ -3,10 +3,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - parent-modules com.baeldung + persistence-modules 1.0.0-SNAPSHOT - ../../pom.xml 4.0.0 diff --git a/persistence-modules/java-mongodb-queries/src/main/java/com.baeldung.mongo/crud/CrudClient.java b/persistence-modules/java-mongodb-queries/src/main/java/com/baeldung/mongo/crud/CrudClient.java similarity index 100% rename from persistence-modules/java-mongodb-queries/src/main/java/com.baeldung.mongo/crud/CrudClient.java rename to persistence-modules/java-mongodb-queries/src/main/java/com/baeldung/mongo/crud/CrudClient.java diff --git a/persistence-modules/java-mongodb-queries/src/main/java/com.baeldung.mongo/crud/model/Event.java b/persistence-modules/java-mongodb-queries/src/main/java/com/baeldung/mongo/crud/model/Event.java similarity index 100% rename from persistence-modules/java-mongodb-queries/src/main/java/com.baeldung.mongo/crud/model/Event.java rename to persistence-modules/java-mongodb-queries/src/main/java/com/baeldung/mongo/crud/model/Event.java diff --git a/persistence-modules/java-mongodb-queries/src/test/java/com.baeldung.mongo.crud/CrudClientLiveTest.java b/persistence-modules/java-mongodb-queries/src/test/java/com/baeldung/mongo/crud/CrudClientLiveTest.java similarity index 83% rename from persistence-modules/java-mongodb-queries/src/test/java/com.baeldung.mongo.crud/CrudClientLiveTest.java rename to persistence-modules/java-mongodb-queries/src/test/java/com/baeldung/mongo/crud/CrudClientLiveTest.java index db2f35f634..5b5004fd9f 100644 --- a/persistence-modules/java-mongodb-queries/src/test/java/com.baeldung.mongo.crud/CrudClientLiveTest.java +++ b/persistence-modules/java-mongodb-queries/src/test/java/com/baeldung/mongo/crud/CrudClientLiveTest.java @@ -31,6 +31,11 @@ public class CrudClientLiveTest { @Order(2) public void whenReadingEventsByDate_thenCheckForReturnedDocument() { Assertions.assertNotNull(CrudClient.readEventsByDate(CrudClient.dateQuery)); + Event event = CrudClient.readEventsByDate(CrudClient.dateQuery); + Assertions.assertNotNull(event); + Assertions.assertEquals("Soccer game", event.title); + Assertions.assertEquals("Bar Avenue", event.location); + Assertions.assertEquals(CrudClient.soccerGame.dateTime, event.dateTime); } @Test @@ -39,6 +44,9 @@ public class CrudClientLiveTest { List events = CrudClient.readEventsByDateRange(CrudClient.from, CrudClient.to); Assertions.assertNotNull(events); Assertions.assertEquals(1, events.size()); + Assertions.assertEquals("Soccer game", events.get(0).title); + Assertions.assertEquals("Bar Avenue", events.get(0).location); + Assertions.assertEquals(CrudClient.soccerGame.dateTime, events.get(0).dateTime); } @Test diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index 4bab0631bd..ee4807933a 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -45,6 +45,7 @@ java-mongodb java-mongodb-2 java-mongodb-3 + java-mongodb-queries jnosql jooq jpa-hibernate-cascade-type diff --git a/pom.xml b/pom.xml index 046f59de53..24aa678523 100644 --- a/pom.xml +++ b/pom.xml @@ -7,9 +7,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - - persistence-modules/java-mongodb-queries - parent-modules pom From 2fe4ccbead7e7c5c20099115c912d10343e40b19 Mon Sep 17 00:00:00 2001 From: Sumit Kumar Date: Fri, 8 Jul 2022 09:14:24 +0530 Subject: [PATCH 30/53] BAEL-5449 Instantiating Multiple Beans of the Same Class with Spring Annotations (#12446) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * added multiple bean instantiation * added module /spring-core-6 and formatting changes * resolved formatting issues as suggested * resolved formatting issues and changed package names * formatting changes in XML files * Reformatted XML files as per the instructions * FIXED Example in Section 3 and some changes in Pom.xml * changed xml config to Java config in solution 3 * Project updated to spring boot application * Removed unwanted spring dependencies from pom.xml * moved the project under new module spring-core-6 * added spring-core-6 module in parent's pom.xml * resolved formatting issue in parent's pom.xml * new module entry in parent's pom * final commit * Added spring-core-6 in parent's pom.xml  * fixed some merging issues. * added spring-core-6 module entry under jdk9-and-above profile in main pom * removed App.java from multibeaninstantiation directory --- pom.xml | 4 +- spring-core-6/pom.xml | 76 +++++++++++++++++++ .../solution1/Person.java | 17 +++++ .../solution1/PersonConfig.java | 17 +++++ .../solution1/SpringApp1.java | 11 +++ .../solution2/Person.java | 17 +++++ .../solution2/PersonConfig.java | 10 +++ .../solution2/PersonOne.java | 13 ++++ .../solution2/PersonTwo.java | 13 ++++ .../solution2/SpringApp2.java | 11 +++ .../solution3/Human.java | 33 ++++++++ .../solution3/MultiBeanFactory.java | 9 +++ .../solution3/Person.java | 49 ++++++++++++ .../solution3/PersonConfig.java | 22 ++++++ .../solution3/PersonFactoryPostProcessor.java | 33 ++++++++ .../solution3/SpringApp3.java | 11 +++ 16 files changed, 345 insertions(+), 1 deletion(-) create mode 100644 spring-core-6/pom.xml create mode 100644 spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution1/Person.java create mode 100644 spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution1/PersonConfig.java create mode 100644 spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution1/SpringApp1.java create mode 100644 spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/Person.java create mode 100644 spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/PersonConfig.java create mode 100644 spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/PersonOne.java create mode 100644 spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/PersonTwo.java create mode 100644 spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/SpringApp2.java create mode 100644 spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/Human.java create mode 100644 spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/MultiBeanFactory.java create mode 100644 spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/Person.java create mode 100644 spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/PersonConfig.java create mode 100644 spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/PersonFactoryPostProcessor.java create mode 100644 spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/SpringApp3.java diff --git a/pom.xml b/pom.xml index 24aa678523..6daf0e3fa5 100644 --- a/pom.xml +++ b/pom.xml @@ -1246,6 +1246,7 @@ core-java-modules/core-java-networking-3 core-java-modules/core-java-strings core-java-modules/core-java-httpclient + spring-core-6 ddd-contexts docker-modules apache-httpclient-2 @@ -1328,6 +1329,7 @@ testing-modules/testing-assertions persistence-modules/fauna lightrun + spring-core-6 @@ -1400,4 +1402,4 @@ 31.0.1-jre - + \ No newline at end of file diff --git a/spring-core-6/pom.xml b/spring-core-6/pom.xml new file mode 100644 index 0000000000..92cd343234 --- /dev/null +++ b/spring-core-6/pom.xml @@ -0,0 +1,76 @@ + + + 4.0.0 + + com.baeldung + spring-core-6 + 0.0.1-SNAPSHOT + spring-core-6 + http://www.baeldung.com + + + UTF-8 + 11 + 11 + + + + + junit + junit + 4.11 + test + + + org.springframework.boot + spring-boot-starter-web + 2.0.0.RELEASE + + + + + + + + maven-clean-plugin + 3.1.0 + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + + \ No newline at end of file diff --git a/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution1/Person.java b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution1/Person.java new file mode 100644 index 0000000000..04fa6577ac --- /dev/null +++ b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution1/Person.java @@ -0,0 +1,17 @@ +package com.baeldung.multibeaninstantiation.solution1; + +public class Person { + private String firstName; + private String lastName; + + public Person(String firstName, String secondName) { + super(); + this.firstName = firstName; + this.lastName = secondName; + } + + @Override + public String toString() { + return "Person [firstName=" + firstName + ", secondName=" + lastName + "]"; + } +} \ No newline at end of file diff --git a/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution1/PersonConfig.java b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution1/PersonConfig.java new file mode 100644 index 0000000000..ac05ffc0fa --- /dev/null +++ b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution1/PersonConfig.java @@ -0,0 +1,17 @@ +package com.baeldung.multibeaninstantiation.solution1; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class PersonConfig { + @Bean + public Person personOne() { + return new Person("Harold", "Finch"); + } + + @Bean + public Person personTwo() { + return new Person("John", "Reese"); + } +} \ No newline at end of file diff --git a/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution1/SpringApp1.java b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution1/SpringApp1.java new file mode 100644 index 0000000000..c2bc70f3ba --- /dev/null +++ b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution1/SpringApp1.java @@ -0,0 +1,11 @@ +package com.baeldung.multibeaninstantiation.solution1; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringApp1 { + public static void main(String[] args) { + SpringApplication.run(SpringApp1.class, args); + } +} \ No newline at end of file diff --git a/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/Person.java b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/Person.java new file mode 100644 index 0000000000..a1801d1fd2 --- /dev/null +++ b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/Person.java @@ -0,0 +1,17 @@ +package com.baeldung.multibeaninstantiation.solution2; + +public class Person { + private String firstName; + private String lastName; + + public Person(String firstName, String secondName) { + super(); + this.firstName = firstName; + this.lastName = secondName; + } + + @Override + public String toString() { + return "Person [firstName=" + firstName + ", secondName=" + lastName + "]"; + } +} \ No newline at end of file diff --git a/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/PersonConfig.java b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/PersonConfig.java new file mode 100644 index 0000000000..da97314579 --- /dev/null +++ b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/PersonConfig.java @@ -0,0 +1,10 @@ +package com.baeldung.multibeaninstantiation.solution2; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("com.baeldung.multibeaninstantiation.solution2") +public class PersonConfig { + +} \ No newline at end of file diff --git a/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/PersonOne.java b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/PersonOne.java new file mode 100644 index 0000000000..5d56082f71 --- /dev/null +++ b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/PersonOne.java @@ -0,0 +1,13 @@ +package com.baeldung.multibeaninstantiation.solution2; + +import org.springframework.stereotype.Component; + +import com.baeldung.multibeaninstantiation.solution2.Person; + +@Component +public class PersonOne extends Person { + + public PersonOne() { + super("Harold", "Finch"); + } +} \ No newline at end of file diff --git a/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/PersonTwo.java b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/PersonTwo.java new file mode 100644 index 0000000000..436bd0e96e --- /dev/null +++ b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/PersonTwo.java @@ -0,0 +1,13 @@ +package com.baeldung.multibeaninstantiation.solution2; + +import org.springframework.stereotype.Component; + +import com.baeldung.multibeaninstantiation.solution2.Person; + +@Component +public class PersonTwo extends Person { + + public PersonTwo() { + super("John", "Reese"); + } +} \ No newline at end of file diff --git a/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/SpringApp2.java b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/SpringApp2.java new file mode 100644 index 0000000000..328ba32777 --- /dev/null +++ b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution2/SpringApp2.java @@ -0,0 +1,11 @@ +package com.baeldung.multibeaninstantiation.solution2; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringApp2 { + public static void main(String[] args) { + SpringApplication.run(SpringApp2.class, args); + } +} \ No newline at end of file diff --git a/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/Human.java b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/Human.java new file mode 100644 index 0000000000..d73bd9dfdc --- /dev/null +++ b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/Human.java @@ -0,0 +1,33 @@ +package com.baeldung.multibeaninstantiation.solution3; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.Assert; + +public class Human implements InitializingBean { + + private Person personOne; + + private Person personTwo; + + @Override + public void afterPropertiesSet() throws Exception { + Assert.notNull(personOne, "Harold is alive!"); + Assert.notNull(personTwo, "John is alive!"); + } + + /* Setter injection */ + @Autowired + public void setPersonOne(Person personOne) { + this.personOne = personOne; + this.personOne.setFirstName("Harold"); + this.personOne.setSecondName("Finch"); + } + + @Autowired + public void setPersonTwo(Person personTwo) { + this.personTwo = personTwo; + this.personTwo.setFirstName("John"); + this.personTwo.setSecondName("Reese"); + } +} \ No newline at end of file diff --git a/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/MultiBeanFactory.java b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/MultiBeanFactory.java new file mode 100644 index 0000000000..1753d28d7e --- /dev/null +++ b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/MultiBeanFactory.java @@ -0,0 +1,9 @@ +package com.baeldung.multibeaninstantiation.solution3; + +import java.util.List; + +public interface MultiBeanFactory { + List getObject(String name) throws Exception; + + Class getObjectType(); +} \ No newline at end of file diff --git a/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/Person.java b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/Person.java new file mode 100644 index 0000000000..a26aee121f --- /dev/null +++ b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/Person.java @@ -0,0 +1,49 @@ +package com.baeldung.multibeaninstantiation.solution3; + +import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.annotation.Qualifier; + +@Qualifier(value = "personOne, personTwo") +public class Person implements FactoryBean { + private String firstName; + private String secondName; + + public Person() { + // initialization code (optional) + } + + @Override + public Class getObjectType() { + return Person.class; + } + + @Override + public Object getObject() throws Exception { + return new Person(); + } + + public boolean isSingleton() { + return true; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getSecondName() { + return secondName; + } + + public void setSecondName(String secondName) { + this.secondName = secondName; + } + + @Override + public String toString() { + return "Person [firstName=" + firstName + ", secondName=" + secondName + "]"; + } +} \ No newline at end of file diff --git a/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/PersonConfig.java b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/PersonConfig.java new file mode 100644 index 0000000000..12b93ff860 --- /dev/null +++ b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/PersonConfig.java @@ -0,0 +1,22 @@ +package com.baeldung.multibeaninstantiation.solution3; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class PersonConfig { + @Bean + public PersonFactoryPostProcessor PersonFactoryPostProcessor() { + return new PersonFactoryPostProcessor(); + } + + @Bean + public Person person() { + return new Person(); + } + + @Bean + public Human human() { + return new Human(); + } +} \ No newline at end of file diff --git a/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/PersonFactoryPostProcessor.java b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/PersonFactoryPostProcessor.java new file mode 100644 index 0000000000..7eb124e1b0 --- /dev/null +++ b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/PersonFactoryPostProcessor.java @@ -0,0 +1,33 @@ +package com.baeldung.multibeaninstantiation.solution3; + +import java.util.Map; + +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.config.BeanFactoryPostProcessor; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; + +public class PersonFactoryPostProcessor implements BeanFactoryPostProcessor { + + @Override + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { + Map map = beanFactory.getBeansWithAnnotation(Qualifier.class); + for (Map.Entry entry : map.entrySet()) { + createInstances(beanFactory, entry.getKey(), entry.getValue()); + } + } + + private void createInstances(ConfigurableListableBeanFactory beanFactory, String beanName, Object bean) { + Qualifier qualifier = bean.getClass() + .getAnnotation(Qualifier.class); + for (String name : extractNames(qualifier)) { + Object newBean = beanFactory.getBean(beanName); + beanFactory.registerSingleton(name.trim(), newBean); + } + } + + private String[] extractNames(Qualifier qualifier) { + return qualifier.value() + .split(","); + } +} \ No newline at end of file diff --git a/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/SpringApp3.java b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/SpringApp3.java new file mode 100644 index 0000000000..10cb6c0c1a --- /dev/null +++ b/spring-core-6/src/main/java/com/baeldung/multibeaninstantiation/solution3/SpringApp3.java @@ -0,0 +1,11 @@ +package com.baeldung.multibeaninstantiation.solution3; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringApp3 { + public static void main(String[] args) { + SpringApplication.run(SpringApp3.class, args); + } +} \ No newline at end of file From 138c22490744a52ccbc63ce08fcd4add7d099994 Mon Sep 17 00:00:00 2001 From: anuragkumawat Date: Sat, 9 Jul 2022 15:07:47 +0530 Subject: [PATCH 31/53] JAVA-13089 Verify Java Base64 Encoding and Decoding article --- .../Java8EncodeDecodeUnitTest.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/core-java-modules/core-java-string-operations/src/test/java/com/baeldung/base64encodinganddecoding/Java8EncodeDecodeUnitTest.java b/core-java-modules/core-java-string-operations/src/test/java/com/baeldung/base64encodinganddecoding/Java8EncodeDecodeUnitTest.java index 191a3628e8..f7efd7c731 100644 --- a/core-java-modules/core-java-string-operations/src/test/java/com/baeldung/base64encodinganddecoding/Java8EncodeDecodeUnitTest.java +++ b/core-java-modules/core-java-string-operations/src/test/java/com/baeldung/base64encodinganddecoding/Java8EncodeDecodeUnitTest.java @@ -96,7 +96,23 @@ public class Java8EncodeDecodeUnitTest { assertNotNull(decodedMime); } - // + @Test + public void whenEncodedStringHasValidCharacters_thenStringCanBeDecoded() { + final String encodedString = "dGVzdCMkaW5wdXQ+"; + final byte[] decodedBytes = Base64.getDecoder().decode(encodedString); + final String decodedString = new String(decodedBytes); + + assertNotNull(decodedString); + } + + @Test(expected = IllegalArgumentException.class) + public void whenEncodedStringHasInvalidCharacters_thenIllegalArgumentException() { + final String encodedString = "dGVzdCMkaW5wdXQ#"; + final byte[] decodedBytes = Base64.getDecoder().decode(encodedString); + final String decodedString = new String(decodedBytes); + + assertNotNull(decodedString); + } private static StringBuilder getMimeBuffer() { final StringBuilder buffer = new StringBuilder(); From 84c06c772b9375aba0842331d7ac71a44f4ede29 Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Sat, 9 Jul 2022 20:10:23 +0530 Subject: [PATCH 32/53] JAVA-11495 Moved gradle modules to gradle-modules --- gradle-modules/README.md | 3 +++ {gradle-5 => gradle-modules/gradle-5}/.gitignore | 0 {gradle-5 => gradle-modules/gradle-5}/README.md | 0 {gradle-5 => gradle-modules/gradle-5}/build.gradle | 0 .../gradle-5}/cmd-line-args/README.md | 0 .../gradle-5}/cmd-line-args/build.gradle | 0 .../src/main/java/com/baeldung/cmd/MainClass.java | 0 .../gradle-5}/gradle/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 0 {gradle-5 => gradle-modules/gradle-5}/gradlew | 0 {gradle-5 => gradle-modules/gradle-5}/gradlew.bat | 0 .../gradle-5}/java-exec/.gitignore | 0 .../gradle-5}/java-exec/build.gradle | 0 .../java/com/baeldung/gradle/exec/MainClass.java | 0 .../gradle-5}/settings.gradle | 0 .../gradle-5}/source-sets/.gitignore | 0 .../gradle-5}/source-sets/README.md | 0 .../gradle-5}/source-sets/build.gradle | 0 .../java/com/baeldung/itest/SourceSetsItest.java | 0 .../java/com/baeldung/main/SourceSetsMain.java | 0 .../java/com/baeldung/main/SourceSetsObject.java | 0 .../java/com/baeldung/test/SourceSetsTest.java | 0 .../gradle-5}/unused-dependencies/.gitignore | 0 .../gradle-5}/unused-dependencies/build.gradle | 0 .../com/baeldung/unused/UnusedDependencies.java | 0 {gradle-6 => gradle-modules/gradle-6}/.gitignore | 0 {gradle-6 => gradle-modules/gradle-6}/README.md | 0 .../gradle-6}/build.gradle.kts | 0 .../configuration-avoidance/build.gradle.kts | 0 .../dependency-constraints/build.gradle.kts | 0 .../java/com/baeldung/gradle/RxHelloWorld.java | 0 .../com/baeldung/gradle/RxHelloWorldUnitTest.java | 0 .../gradle-6}/fibonacci-recursive/build.gradle.kts | 0 .../fibonacci/impl/RecursiveFibonacci.java | 0 .../fibonacci/impl/RecursiveFibonacciUnitTest.java | 0 .../gradle-6}/fibonacci-spi/build.gradle.kts | 0 .../fibonacci/FibonacciSequenceGenerator.java | 0 .../FibonacciSequenceGeneratorFixture.java | 0 .../gradle-6}/gradle.properties | 0 .../gradle-6}/gradle/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 0 {gradle-6 => gradle-modules/gradle-6}/gradlew | 0 {gradle-6 => gradle-modules/gradle-6}/gradlew.bat | 0 .../gradle-6}/httpclient-platform/build.gradle.kts | 0 .../module-metadata-publishing/build.gradle.kts | 0 .../gradle-6}/person-rest-client/build.gradle.kts | 0 .../gradle-6}/settings.gradle.kts | 0 .../gradle-6}/widget-rest-client/build.gradle.kts | 0 {gradle => gradle-modules/gradle}/.gitignore | 0 {gradle => gradle-modules/gradle}/.travis.yml | 0 {gradle => gradle-modules/gradle}/README.md | 0 {gradle => gradle-modules/gradle}/build.gradle | 0 .../baeldung/PrintToolVersionBuildSrcTask.groovy | 0 .../gradle}/gradle-cucumber/README.md | 0 .../gradle}/gradle-cucumber/build.gradle | 0 .../gradle/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 0 .../gradle}/gradle-cucumber/gradlew | 0 .../gradle}/gradle-cucumber/gradlew.bat | 0 .../gradle}/gradle-cucumber/settings.gradle | 0 .../src/main/java/com/baeldung/Account.java | 0 .../com/baeldung/cucumber/RunCucumberTest.java | 0 .../com/baeldung/cucumber/StepDefinitions.java | 0 .../resources/features/account_credited.feature | 0 .../gradle}/gradle-dependency-management/README.md | 0 .../gradle-dependency-management/build.gradle | 0 .../gradle/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 0 .../gradle}/gradle-dependency-management/gradlew | 0 .../gradle-dependency-management/gradlew.bat | 0 .../libs/sampleOne.jar | Bin .../libs/sampleTwo.jar | Bin .../gradle-dependency-management/settings.gradle | 0 .../DependencyManagementApplication.java | 0 .../src/main/resources/application.properties | 0 .../DependencyManagementApplicationUnitTests.java | 0 .../gradle}/gradle-employee-app/.gitignore | 0 .../gradle}/gradle-employee-app/README.md | 0 .../gradle}/gradle-employee-app/build.gradle | 0 .../gradle}/gradle-employee-app/settings.gradle | 0 .../src/main/java/employee/Employee.java | 0 .../src/main/java/employee/EmployeeApp.java | 0 .../src/test/java/employee/EmployeeAppTest.java | 0 .../gradle}/gradle-fat-jar/README.md | 0 .../gradle}/gradle-fat-jar/build.gradle | 0 .../gradle}/gradle-fat-jar/settings.gradle | 0 .../main/java/com/baeldung/fatjar/Application.java | 0 .../gradle}/gradle-jacoco/README.md | 0 .../gradle}/gradle-jacoco/build.gradle | 0 .../gradle/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 0 .../gradle}/gradle-jacoco/gradlew | 0 .../gradle}/gradle-jacoco/gradlew.bat | 0 .../gradle}/gradle-jacoco/lombok.config | 0 .../gradle}/gradle-jacoco/settings.gradle | 0 .../main/java/com/baeldung/config/AppConfig.java | 0 .../src/main/java/com/baeldung/domain/Product.java | 0 .../main/java/com/baeldung/dto/ExcludedPOJO.java | 0 .../src/main/java/com/baeldung/dto/ProductDTO.java | 0 .../main/java/com/baeldung/generated/Customer.java | 0 .../java/com/baeldung/generated/Generated.java | 0 .../java/com/baeldung/service/CustomerService.java | 0 .../java/com/baeldung/service/ProductService.java | 0 .../baeldung/service/CustomerServiceUnitTest.java | 0 .../baeldung/service/ProductServiceUnitTest.java | 0 .../resources/features/account_credited.feature | 0 .../README.md | 0 .../build.gradle | 0 .../settings.gradle | 0 .../com/baeldung/helloworld/HelloWorldApp.java | 0 .../gradle}/gradle-to-maven/README.md | 0 .../gradle}/gradle-to-maven/build.gradle | 0 .../gradle}/gradle-to-maven/settings.gradle | 0 .../gradle}/gradle-wrapper/README.md | 0 .../gradle-wrapper/gradle/wrapper/README.md | 0 .../gradle/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 0 .../gradle}/gradle-wrapper/gradlew | 0 .../gradle}/gradle-wrapper/gradlew.bat | 0 .../gradle}/gradle-wrapper/settings.gradle | 0 .../gradle}/gradle/shipkit.gradle | 0 .../gradle/wrapper/gradle-wrapper.properties | 0 .../gradle}/gradletaskdemo/aplugin.gradle | 0 .../gradle}/gradletaskdemo/build.gradle | 0 {gradle => gradle-modules/gradle}/gradlew | 0 {gradle => gradle-modules/gradle}/gradlew.bat | 0 .../gradle}/greeter/.gitignore | 0 .../gradle}/greeter/build.gradle | 0 .../greeter/src/main/java/greeter/Greeter.java | 0 .../src/test/java/greetertest/TestGreeting.java | 0 .../gradle}/greeting-library-java/.gitignore | 0 .../gradle}/greeting-library-java/build.gradle | 0 .../src/main/java/baeldunggreeter/Formatter.java | 0 .../java/baeldunggreetertest/FormatterTest.java | 0 .../gradle}/greeting-library/.gitignore | 0 .../bin/greeter/GreetingFormatter.groovy | 0 .../gradle}/greeting-library/build.gradle | 0 .../main/groovy/greeter/GreetingFormatter.groovy | 0 .../groovy}/greeter/GreetingFormatterSpec.groovy | 0 {gradle => gradle-modules/gradle}/junit5/README.md | 0 .../gradle}/junit5/build.gradle | 0 .../gradle}/junit5/settings.gradle | 0 .../java/com/example/CalculatorJUnit4Test.java | 0 .../java/com/example/CalculatorJUnit5Test.java | 0 .../gradle}/maven-to-gradle/README.md | 0 .../gradle}/maven-to-gradle/build.gradle | 0 .../gradle/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 0 .../gradle}/maven-to-gradle/gradlew | 0 .../gradle}/maven-to-gradle/gradlew.bat | 0 .../gradle}/maven-to-gradle/pom.xml | 0 .../gradle}/maven-to-gradle/settings.gradle | 0 .../main/java/com/sample/javacode/DisplayTime.java | 0 .../gradle}/plugin/build.gradle | 0 .../src/main/java/com/baeldung/GreetingPlugin.java | 0 .../java/com/baeldung/GreetingPluginExtension.java | 0 {gradle => gradle-modules/gradle}/settings.gradle | 0 .../gradle}/version.properties | 0 gradle-modules/settings.gradle | 3 +++ .../groovy/greeter/GreetingFormatterSpec.groovy | 13 ------------- 160 files changed, 6 insertions(+), 13 deletions(-) create mode 100644 gradle-modules/README.md rename {gradle-5 => gradle-modules/gradle-5}/.gitignore (100%) rename {gradle-5 => gradle-modules/gradle-5}/README.md (100%) rename {gradle-5 => gradle-modules/gradle-5}/build.gradle (100%) rename {gradle-5 => gradle-modules/gradle-5}/cmd-line-args/README.md (100%) rename {gradle-5 => gradle-modules/gradle-5}/cmd-line-args/build.gradle (100%) rename {gradle-5 => gradle-modules/gradle-5}/cmd-line-args/src/main/java/com/baeldung/cmd/MainClass.java (100%) rename {gradle-5 => gradle-modules/gradle-5}/gradle/wrapper/gradle-wrapper.jar (100%) rename {gradle-5 => gradle-modules/gradle-5}/gradle/wrapper/gradle-wrapper.properties (100%) rename {gradle-5 => gradle-modules/gradle-5}/gradlew (100%) rename {gradle-5 => gradle-modules/gradle-5}/gradlew.bat (100%) rename {gradle-5 => gradle-modules/gradle-5}/java-exec/.gitignore (100%) rename {gradle-5 => gradle-modules/gradle-5}/java-exec/build.gradle (100%) rename {gradle-5 => gradle-modules/gradle-5}/java-exec/src/main/java/com/baeldung/gradle/exec/MainClass.java (100%) rename {gradle-5 => gradle-modules/gradle-5}/settings.gradle (100%) rename {gradle-5 => gradle-modules/gradle-5}/source-sets/.gitignore (100%) rename {gradle-5 => gradle-modules/gradle-5}/source-sets/README.md (100%) rename {gradle-5 => gradle-modules/gradle-5}/source-sets/build.gradle (100%) rename {gradle-5 => gradle-modules/gradle-5}/source-sets/src/itest/java/com/baeldung/itest/SourceSetsItest.java (100%) rename {gradle-5 => gradle-modules/gradle-5}/source-sets/src/main/java/com/baeldung/main/SourceSetsMain.java (100%) rename {gradle-5 => gradle-modules/gradle-5}/source-sets/src/main/java/com/baeldung/main/SourceSetsObject.java (100%) rename {gradle-5 => gradle-modules/gradle-5}/source-sets/src/test/java/com/baeldung/test/SourceSetsTest.java (100%) rename {gradle-5 => gradle-modules/gradle-5}/unused-dependencies/.gitignore (100%) rename {gradle-5 => gradle-modules/gradle-5}/unused-dependencies/build.gradle (100%) rename {gradle-5 => gradle-modules/gradle-5}/unused-dependencies/src/main/java/com/baeldung/unused/UnusedDependencies.java (100%) rename {gradle-6 => gradle-modules/gradle-6}/.gitignore (100%) rename {gradle-6 => gradle-modules/gradle-6}/README.md (100%) rename {gradle-6 => gradle-modules/gradle-6}/build.gradle.kts (100%) rename {gradle-6 => gradle-modules/gradle-6}/configuration-avoidance/build.gradle.kts (100%) rename {gradle-6 => gradle-modules/gradle-6}/dependency-constraints/build.gradle.kts (100%) rename {gradle-6 => gradle-modules/gradle-6}/dependency-constraints/src/main/java/com/baeldung/gradle/RxHelloWorld.java (100%) rename {gradle-6 => gradle-modules/gradle-6}/dependency-constraints/src/test/java/com/baeldung/gradle/RxHelloWorldUnitTest.java (100%) rename {gradle-6 => gradle-modules/gradle-6}/fibonacci-recursive/build.gradle.kts (100%) rename {gradle-6 => gradle-modules/gradle-6}/fibonacci-recursive/src/main/java/com/baeldung/fibonacci/impl/RecursiveFibonacci.java (100%) rename {gradle-6 => gradle-modules/gradle-6}/fibonacci-recursive/src/test/java/com/baeldung/fibonacci/impl/RecursiveFibonacciUnitTest.java (100%) rename {gradle-6 => gradle-modules/gradle-6}/fibonacci-spi/build.gradle.kts (100%) rename {gradle-6 => gradle-modules/gradle-6}/fibonacci-spi/src/main/java/com/baeldung/fibonacci/FibonacciSequenceGenerator.java (100%) rename {gradle-6 => gradle-modules/gradle-6}/fibonacci-spi/src/testFixtures/java/com/baeldung/fibonacci/FibonacciSequenceGeneratorFixture.java (100%) rename {gradle-6 => gradle-modules/gradle-6}/gradle.properties (100%) rename {gradle-6 => gradle-modules/gradle-6}/gradle/wrapper/gradle-wrapper.jar (100%) rename {gradle-6 => gradle-modules/gradle-6}/gradle/wrapper/gradle-wrapper.properties (100%) rename {gradle-6 => gradle-modules/gradle-6}/gradlew (100%) rename {gradle-6 => gradle-modules/gradle-6}/gradlew.bat (100%) rename {gradle-6 => gradle-modules/gradle-6}/httpclient-platform/build.gradle.kts (100%) rename {gradle-6 => gradle-modules/gradle-6}/module-metadata-publishing/build.gradle.kts (100%) rename {gradle-6 => gradle-modules/gradle-6}/person-rest-client/build.gradle.kts (100%) rename {gradle-6 => gradle-modules/gradle-6}/settings.gradle.kts (100%) rename {gradle-6 => gradle-modules/gradle-6}/widget-rest-client/build.gradle.kts (100%) rename {gradle => gradle-modules/gradle}/.gitignore (100%) rename {gradle => gradle-modules/gradle}/.travis.yml (100%) rename {gradle => gradle-modules/gradle}/README.md (100%) rename {gradle => gradle-modules/gradle}/build.gradle (100%) rename {gradle => gradle-modules/gradle}/buildSrc/src/main/groovy/com/baeldung/PrintToolVersionBuildSrcTask.groovy (100%) rename {gradle => gradle-modules/gradle}/gradle-cucumber/README.md (100%) rename {gradle => gradle-modules/gradle}/gradle-cucumber/build.gradle (100%) rename {gradle => gradle-modules/gradle}/gradle-cucumber/gradle/wrapper/gradle-wrapper.jar (100%) rename {gradle => gradle-modules/gradle}/gradle-cucumber/gradle/wrapper/gradle-wrapper.properties (100%) rename {gradle => gradle-modules/gradle}/gradle-cucumber/gradlew (100%) rename {gradle => gradle-modules/gradle}/gradle-cucumber/gradlew.bat (100%) rename {gradle => gradle-modules/gradle}/gradle-cucumber/settings.gradle (100%) rename {gradle => gradle-modules/gradle}/gradle-cucumber/src/main/java/com/baeldung/Account.java (100%) rename {gradle => gradle-modules/gradle}/gradle-cucumber/src/test/java/com/baeldung/cucumber/RunCucumberTest.java (100%) rename {gradle => gradle-modules/gradle}/gradle-cucumber/src/test/java/com/baeldung/cucumber/StepDefinitions.java (100%) rename {gradle => gradle-modules/gradle}/gradle-cucumber/src/test/resources/features/account_credited.feature (100%) rename {gradle => gradle-modules/gradle}/gradle-dependency-management/README.md (100%) rename {gradle => gradle-modules/gradle}/gradle-dependency-management/build.gradle (100%) rename {gradle => gradle-modules/gradle}/gradle-dependency-management/gradle/wrapper/gradle-wrapper.jar (100%) rename {gradle => gradle-modules/gradle}/gradle-dependency-management/gradle/wrapper/gradle-wrapper.properties (100%) rename {gradle => gradle-modules/gradle}/gradle-dependency-management/gradlew (100%) rename {gradle => gradle-modules/gradle}/gradle-dependency-management/gradlew.bat (100%) rename {gradle => gradle-modules/gradle}/gradle-dependency-management/libs/sampleOne.jar (100%) rename {gradle => gradle-modules/gradle}/gradle-dependency-management/libs/sampleTwo.jar (100%) rename {gradle => gradle-modules/gradle}/gradle-dependency-management/settings.gradle (100%) rename {gradle => gradle-modules/gradle}/gradle-dependency-management/src/main/java/com/gradle/dependencymanagement/DependencyManagementApplication.java (100%) rename {gradle => gradle-modules/gradle}/gradle-dependency-management/src/main/resources/application.properties (100%) rename {gradle => gradle-modules/gradle}/gradle-dependency-management/src/test/java/com/gradle/dependencymanagement/DependencyManagementApplicationUnitTests.java (100%) rename {gradle => gradle-modules/gradle}/gradle-employee-app/.gitignore (100%) rename {gradle => gradle-modules/gradle}/gradle-employee-app/README.md (100%) rename {gradle => gradle-modules/gradle}/gradle-employee-app/build.gradle (100%) rename {gradle => gradle-modules/gradle}/gradle-employee-app/settings.gradle (100%) rename {gradle => gradle-modules/gradle}/gradle-employee-app/src/main/java/employee/Employee.java (100%) rename {gradle => gradle-modules/gradle}/gradle-employee-app/src/main/java/employee/EmployeeApp.java (100%) rename {gradle => gradle-modules/gradle}/gradle-employee-app/src/test/java/employee/EmployeeAppTest.java (100%) rename {gradle => gradle-modules/gradle}/gradle-fat-jar/README.md (100%) rename {gradle => gradle-modules/gradle}/gradle-fat-jar/build.gradle (100%) rename {gradle => gradle-modules/gradle}/gradle-fat-jar/settings.gradle (100%) rename {gradle => gradle-modules/gradle}/gradle-fat-jar/src/main/java/com/baeldung/fatjar/Application.java (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/README.md (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/build.gradle (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/gradle/wrapper/gradle-wrapper.jar (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/gradle/wrapper/gradle-wrapper.properties (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/gradlew (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/gradlew.bat (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/lombok.config (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/settings.gradle (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/src/main/java/com/baeldung/config/AppConfig.java (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/src/main/java/com/baeldung/domain/Product.java (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/src/main/java/com/baeldung/dto/ExcludedPOJO.java (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/src/main/java/com/baeldung/dto/ProductDTO.java (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/src/main/java/com/baeldung/generated/Customer.java (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/src/main/java/com/baeldung/generated/Generated.java (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/src/main/java/com/baeldung/service/CustomerService.java (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/src/main/java/com/baeldung/service/ProductService.java (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/src/test/java/com/baeldung/service/CustomerServiceUnitTest.java (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/src/test/java/com/baeldung/service/ProductServiceUnitTest.java (100%) rename {gradle => gradle-modules/gradle}/gradle-jacoco/src/test/resources/features/account_credited.feature (100%) rename {gradle => gradle-modules/gradle}/gradle-source-vs-target-compatibility/README.md (100%) rename {gradle => gradle-modules/gradle}/gradle-source-vs-target-compatibility/build.gradle (100%) rename {gradle => gradle-modules/gradle}/gradle-source-vs-target-compatibility/settings.gradle (100%) rename {gradle => gradle-modules/gradle}/gradle-source-vs-target-compatibility/src/main/java/com/baeldung/helloworld/HelloWorldApp.java (100%) rename {gradle => gradle-modules/gradle}/gradle-to-maven/README.md (100%) rename {gradle => gradle-modules/gradle}/gradle-to-maven/build.gradle (100%) rename {gradle => gradle-modules/gradle}/gradle-to-maven/settings.gradle (100%) rename {gradle => gradle-modules/gradle}/gradle-wrapper/README.md (100%) rename {gradle => gradle-modules/gradle}/gradle-wrapper/gradle/wrapper/README.md (100%) rename {gradle => gradle-modules/gradle}/gradle-wrapper/gradle/wrapper/gradle-wrapper.jar (100%) rename {gradle => gradle-modules/gradle}/gradle-wrapper/gradle/wrapper/gradle-wrapper.properties (100%) rename {gradle => gradle-modules/gradle}/gradle-wrapper/gradlew (100%) rename {gradle => gradle-modules/gradle}/gradle-wrapper/gradlew.bat (100%) rename {gradle => gradle-modules/gradle}/gradle-wrapper/settings.gradle (100%) rename {gradle => gradle-modules/gradle}/gradle/shipkit.gradle (100%) rename {gradle => gradle-modules/gradle}/gradle/wrapper/gradle-wrapper.properties (100%) rename {gradle => gradle-modules/gradle}/gradletaskdemo/aplugin.gradle (100%) rename {gradle => gradle-modules/gradle}/gradletaskdemo/build.gradle (100%) rename {gradle => gradle-modules/gradle}/gradlew (100%) rename {gradle => gradle-modules/gradle}/gradlew.bat (100%) rename {gradle => gradle-modules/gradle}/greeter/.gitignore (100%) rename {gradle => gradle-modules/gradle}/greeter/build.gradle (100%) rename {gradle => gradle-modules/gradle}/greeter/src/main/java/greeter/Greeter.java (100%) rename {gradle => gradle-modules/gradle}/greeter/src/test/java/greetertest/TestGreeting.java (100%) rename {gradle => gradle-modules/gradle}/greeting-library-java/.gitignore (100%) rename {gradle => gradle-modules/gradle}/greeting-library-java/build.gradle (100%) rename {gradle => gradle-modules/gradle}/greeting-library-java/src/main/java/baeldunggreeter/Formatter.java (100%) rename {gradle => gradle-modules/gradle}/greeting-library-java/src/test/java/baeldunggreetertest/FormatterTest.java (100%) rename {gradle => gradle-modules/gradle}/greeting-library/.gitignore (100%) rename {gradle => gradle-modules/gradle}/greeting-library/bin/greeter/GreetingFormatter.groovy (100%) rename {gradle => gradle-modules/gradle}/greeting-library/build.gradle (100%) rename {gradle => gradle-modules/gradle}/greeting-library/src/main/groovy/greeter/GreetingFormatter.groovy (100%) rename {gradle/greeting-library/bin => gradle-modules/gradle/greeting-library/src/test/groovy}/greeter/GreetingFormatterSpec.groovy (100%) rename {gradle => gradle-modules/gradle}/junit5/README.md (100%) rename {gradle => gradle-modules/gradle}/junit5/build.gradle (100%) rename {gradle => gradle-modules/gradle}/junit5/settings.gradle (100%) rename {gradle => gradle-modules/gradle}/junit5/src/test/java/com/example/CalculatorJUnit4Test.java (100%) rename {gradle => gradle-modules/gradle}/junit5/src/test/java/com/example/CalculatorJUnit5Test.java (100%) rename {gradle => gradle-modules/gradle}/maven-to-gradle/README.md (100%) rename {gradle => gradle-modules/gradle}/maven-to-gradle/build.gradle (100%) rename {gradle => gradle-modules/gradle}/maven-to-gradle/gradle/wrapper/gradle-wrapper.jar (100%) rename {gradle => gradle-modules/gradle}/maven-to-gradle/gradle/wrapper/gradle-wrapper.properties (100%) rename {gradle => gradle-modules/gradle}/maven-to-gradle/gradlew (100%) rename {gradle => gradle-modules/gradle}/maven-to-gradle/gradlew.bat (100%) rename {gradle => gradle-modules/gradle}/maven-to-gradle/pom.xml (100%) rename {gradle => gradle-modules/gradle}/maven-to-gradle/settings.gradle (100%) rename {gradle => gradle-modules/gradle}/maven-to-gradle/src/main/java/com/sample/javacode/DisplayTime.java (100%) rename {gradle => gradle-modules/gradle}/plugin/build.gradle (100%) rename {gradle => gradle-modules/gradle}/plugin/buildSrc/src/main/java/com/baeldung/GreetingPlugin.java (100%) rename {gradle => gradle-modules/gradle}/plugin/buildSrc/src/main/java/com/baeldung/GreetingPluginExtension.java (100%) rename {gradle => gradle-modules/gradle}/settings.gradle (100%) rename {gradle => gradle-modules/gradle}/version.properties (100%) create mode 100644 gradle-modules/settings.gradle delete mode 100644 gradle/greeting-library/src/test/groovy/greeter/GreetingFormatterSpec.groovy diff --git a/gradle-modules/README.md b/gradle-modules/README.md new file mode 100644 index 0000000000..b85789407f --- /dev/null +++ b/gradle-modules/README.md @@ -0,0 +1,3 @@ +## Akka + +This module contains modules about Akka. \ No newline at end of file diff --git a/gradle-5/.gitignore b/gradle-modules/gradle-5/.gitignore similarity index 100% rename from gradle-5/.gitignore rename to gradle-modules/gradle-5/.gitignore diff --git a/gradle-5/README.md b/gradle-modules/gradle-5/README.md similarity index 100% rename from gradle-5/README.md rename to gradle-modules/gradle-5/README.md diff --git a/gradle-5/build.gradle b/gradle-modules/gradle-5/build.gradle similarity index 100% rename from gradle-5/build.gradle rename to gradle-modules/gradle-5/build.gradle diff --git a/gradle-5/cmd-line-args/README.md b/gradle-modules/gradle-5/cmd-line-args/README.md similarity index 100% rename from gradle-5/cmd-line-args/README.md rename to gradle-modules/gradle-5/cmd-line-args/README.md diff --git a/gradle-5/cmd-line-args/build.gradle b/gradle-modules/gradle-5/cmd-line-args/build.gradle similarity index 100% rename from gradle-5/cmd-line-args/build.gradle rename to gradle-modules/gradle-5/cmd-line-args/build.gradle diff --git a/gradle-5/cmd-line-args/src/main/java/com/baeldung/cmd/MainClass.java b/gradle-modules/gradle-5/cmd-line-args/src/main/java/com/baeldung/cmd/MainClass.java similarity index 100% rename from gradle-5/cmd-line-args/src/main/java/com/baeldung/cmd/MainClass.java rename to gradle-modules/gradle-5/cmd-line-args/src/main/java/com/baeldung/cmd/MainClass.java diff --git a/gradle-5/gradle/wrapper/gradle-wrapper.jar b/gradle-modules/gradle-5/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from gradle-5/gradle/wrapper/gradle-wrapper.jar rename to gradle-modules/gradle-5/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle-5/gradle/wrapper/gradle-wrapper.properties b/gradle-modules/gradle-5/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from gradle-5/gradle/wrapper/gradle-wrapper.properties rename to gradle-modules/gradle-5/gradle/wrapper/gradle-wrapper.properties diff --git a/gradle-5/gradlew b/gradle-modules/gradle-5/gradlew similarity index 100% rename from gradle-5/gradlew rename to gradle-modules/gradle-5/gradlew diff --git a/gradle-5/gradlew.bat b/gradle-modules/gradle-5/gradlew.bat similarity index 100% rename from gradle-5/gradlew.bat rename to gradle-modules/gradle-5/gradlew.bat diff --git a/gradle-5/java-exec/.gitignore b/gradle-modules/gradle-5/java-exec/.gitignore similarity index 100% rename from gradle-5/java-exec/.gitignore rename to gradle-modules/gradle-5/java-exec/.gitignore diff --git a/gradle-5/java-exec/build.gradle b/gradle-modules/gradle-5/java-exec/build.gradle similarity index 100% rename from gradle-5/java-exec/build.gradle rename to gradle-modules/gradle-5/java-exec/build.gradle diff --git a/gradle-5/java-exec/src/main/java/com/baeldung/gradle/exec/MainClass.java b/gradle-modules/gradle-5/java-exec/src/main/java/com/baeldung/gradle/exec/MainClass.java similarity index 100% rename from gradle-5/java-exec/src/main/java/com/baeldung/gradle/exec/MainClass.java rename to gradle-modules/gradle-5/java-exec/src/main/java/com/baeldung/gradle/exec/MainClass.java diff --git a/gradle-5/settings.gradle b/gradle-modules/gradle-5/settings.gradle similarity index 100% rename from gradle-5/settings.gradle rename to gradle-modules/gradle-5/settings.gradle diff --git a/gradle-5/source-sets/.gitignore b/gradle-modules/gradle-5/source-sets/.gitignore similarity index 100% rename from gradle-5/source-sets/.gitignore rename to gradle-modules/gradle-5/source-sets/.gitignore diff --git a/gradle-5/source-sets/README.md b/gradle-modules/gradle-5/source-sets/README.md similarity index 100% rename from gradle-5/source-sets/README.md rename to gradle-modules/gradle-5/source-sets/README.md diff --git a/gradle-5/source-sets/build.gradle b/gradle-modules/gradle-5/source-sets/build.gradle similarity index 100% rename from gradle-5/source-sets/build.gradle rename to gradle-modules/gradle-5/source-sets/build.gradle diff --git a/gradle-5/source-sets/src/itest/java/com/baeldung/itest/SourceSetsItest.java b/gradle-modules/gradle-5/source-sets/src/itest/java/com/baeldung/itest/SourceSetsItest.java similarity index 100% rename from gradle-5/source-sets/src/itest/java/com/baeldung/itest/SourceSetsItest.java rename to gradle-modules/gradle-5/source-sets/src/itest/java/com/baeldung/itest/SourceSetsItest.java diff --git a/gradle-5/source-sets/src/main/java/com/baeldung/main/SourceSetsMain.java b/gradle-modules/gradle-5/source-sets/src/main/java/com/baeldung/main/SourceSetsMain.java similarity index 100% rename from gradle-5/source-sets/src/main/java/com/baeldung/main/SourceSetsMain.java rename to gradle-modules/gradle-5/source-sets/src/main/java/com/baeldung/main/SourceSetsMain.java diff --git a/gradle-5/source-sets/src/main/java/com/baeldung/main/SourceSetsObject.java b/gradle-modules/gradle-5/source-sets/src/main/java/com/baeldung/main/SourceSetsObject.java similarity index 100% rename from gradle-5/source-sets/src/main/java/com/baeldung/main/SourceSetsObject.java rename to gradle-modules/gradle-5/source-sets/src/main/java/com/baeldung/main/SourceSetsObject.java diff --git a/gradle-5/source-sets/src/test/java/com/baeldung/test/SourceSetsTest.java b/gradle-modules/gradle-5/source-sets/src/test/java/com/baeldung/test/SourceSetsTest.java similarity index 100% rename from gradle-5/source-sets/src/test/java/com/baeldung/test/SourceSetsTest.java rename to gradle-modules/gradle-5/source-sets/src/test/java/com/baeldung/test/SourceSetsTest.java diff --git a/gradle-5/unused-dependencies/.gitignore b/gradle-modules/gradle-5/unused-dependencies/.gitignore similarity index 100% rename from gradle-5/unused-dependencies/.gitignore rename to gradle-modules/gradle-5/unused-dependencies/.gitignore diff --git a/gradle-5/unused-dependencies/build.gradle b/gradle-modules/gradle-5/unused-dependencies/build.gradle similarity index 100% rename from gradle-5/unused-dependencies/build.gradle rename to gradle-modules/gradle-5/unused-dependencies/build.gradle diff --git a/gradle-5/unused-dependencies/src/main/java/com/baeldung/unused/UnusedDependencies.java b/gradle-modules/gradle-5/unused-dependencies/src/main/java/com/baeldung/unused/UnusedDependencies.java similarity index 100% rename from gradle-5/unused-dependencies/src/main/java/com/baeldung/unused/UnusedDependencies.java rename to gradle-modules/gradle-5/unused-dependencies/src/main/java/com/baeldung/unused/UnusedDependencies.java diff --git a/gradle-6/.gitignore b/gradle-modules/gradle-6/.gitignore similarity index 100% rename from gradle-6/.gitignore rename to gradle-modules/gradle-6/.gitignore diff --git a/gradle-6/README.md b/gradle-modules/gradle-6/README.md similarity index 100% rename from gradle-6/README.md rename to gradle-modules/gradle-6/README.md diff --git a/gradle-6/build.gradle.kts b/gradle-modules/gradle-6/build.gradle.kts similarity index 100% rename from gradle-6/build.gradle.kts rename to gradle-modules/gradle-6/build.gradle.kts diff --git a/gradle-6/configuration-avoidance/build.gradle.kts b/gradle-modules/gradle-6/configuration-avoidance/build.gradle.kts similarity index 100% rename from gradle-6/configuration-avoidance/build.gradle.kts rename to gradle-modules/gradle-6/configuration-avoidance/build.gradle.kts diff --git a/gradle-6/dependency-constraints/build.gradle.kts b/gradle-modules/gradle-6/dependency-constraints/build.gradle.kts similarity index 100% rename from gradle-6/dependency-constraints/build.gradle.kts rename to gradle-modules/gradle-6/dependency-constraints/build.gradle.kts diff --git a/gradle-6/dependency-constraints/src/main/java/com/baeldung/gradle/RxHelloWorld.java b/gradle-modules/gradle-6/dependency-constraints/src/main/java/com/baeldung/gradle/RxHelloWorld.java similarity index 100% rename from gradle-6/dependency-constraints/src/main/java/com/baeldung/gradle/RxHelloWorld.java rename to gradle-modules/gradle-6/dependency-constraints/src/main/java/com/baeldung/gradle/RxHelloWorld.java diff --git a/gradle-6/dependency-constraints/src/test/java/com/baeldung/gradle/RxHelloWorldUnitTest.java b/gradle-modules/gradle-6/dependency-constraints/src/test/java/com/baeldung/gradle/RxHelloWorldUnitTest.java similarity index 100% rename from gradle-6/dependency-constraints/src/test/java/com/baeldung/gradle/RxHelloWorldUnitTest.java rename to gradle-modules/gradle-6/dependency-constraints/src/test/java/com/baeldung/gradle/RxHelloWorldUnitTest.java diff --git a/gradle-6/fibonacci-recursive/build.gradle.kts b/gradle-modules/gradle-6/fibonacci-recursive/build.gradle.kts similarity index 100% rename from gradle-6/fibonacci-recursive/build.gradle.kts rename to gradle-modules/gradle-6/fibonacci-recursive/build.gradle.kts diff --git a/gradle-6/fibonacci-recursive/src/main/java/com/baeldung/fibonacci/impl/RecursiveFibonacci.java b/gradle-modules/gradle-6/fibonacci-recursive/src/main/java/com/baeldung/fibonacci/impl/RecursiveFibonacci.java similarity index 100% rename from gradle-6/fibonacci-recursive/src/main/java/com/baeldung/fibonacci/impl/RecursiveFibonacci.java rename to gradle-modules/gradle-6/fibonacci-recursive/src/main/java/com/baeldung/fibonacci/impl/RecursiveFibonacci.java diff --git a/gradle-6/fibonacci-recursive/src/test/java/com/baeldung/fibonacci/impl/RecursiveFibonacciUnitTest.java b/gradle-modules/gradle-6/fibonacci-recursive/src/test/java/com/baeldung/fibonacci/impl/RecursiveFibonacciUnitTest.java similarity index 100% rename from gradle-6/fibonacci-recursive/src/test/java/com/baeldung/fibonacci/impl/RecursiveFibonacciUnitTest.java rename to gradle-modules/gradle-6/fibonacci-recursive/src/test/java/com/baeldung/fibonacci/impl/RecursiveFibonacciUnitTest.java diff --git a/gradle-6/fibonacci-spi/build.gradle.kts b/gradle-modules/gradle-6/fibonacci-spi/build.gradle.kts similarity index 100% rename from gradle-6/fibonacci-spi/build.gradle.kts rename to gradle-modules/gradle-6/fibonacci-spi/build.gradle.kts diff --git a/gradle-6/fibonacci-spi/src/main/java/com/baeldung/fibonacci/FibonacciSequenceGenerator.java b/gradle-modules/gradle-6/fibonacci-spi/src/main/java/com/baeldung/fibonacci/FibonacciSequenceGenerator.java similarity index 100% rename from gradle-6/fibonacci-spi/src/main/java/com/baeldung/fibonacci/FibonacciSequenceGenerator.java rename to gradle-modules/gradle-6/fibonacci-spi/src/main/java/com/baeldung/fibonacci/FibonacciSequenceGenerator.java diff --git a/gradle-6/fibonacci-spi/src/testFixtures/java/com/baeldung/fibonacci/FibonacciSequenceGeneratorFixture.java b/gradle-modules/gradle-6/fibonacci-spi/src/testFixtures/java/com/baeldung/fibonacci/FibonacciSequenceGeneratorFixture.java similarity index 100% rename from gradle-6/fibonacci-spi/src/testFixtures/java/com/baeldung/fibonacci/FibonacciSequenceGeneratorFixture.java rename to gradle-modules/gradle-6/fibonacci-spi/src/testFixtures/java/com/baeldung/fibonacci/FibonacciSequenceGeneratorFixture.java diff --git a/gradle-6/gradle.properties b/gradle-modules/gradle-6/gradle.properties similarity index 100% rename from gradle-6/gradle.properties rename to gradle-modules/gradle-6/gradle.properties diff --git a/gradle-6/gradle/wrapper/gradle-wrapper.jar b/gradle-modules/gradle-6/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from gradle-6/gradle/wrapper/gradle-wrapper.jar rename to gradle-modules/gradle-6/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle-6/gradle/wrapper/gradle-wrapper.properties b/gradle-modules/gradle-6/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from gradle-6/gradle/wrapper/gradle-wrapper.properties rename to gradle-modules/gradle-6/gradle/wrapper/gradle-wrapper.properties diff --git a/gradle-6/gradlew b/gradle-modules/gradle-6/gradlew similarity index 100% rename from gradle-6/gradlew rename to gradle-modules/gradle-6/gradlew diff --git a/gradle-6/gradlew.bat b/gradle-modules/gradle-6/gradlew.bat similarity index 100% rename from gradle-6/gradlew.bat rename to gradle-modules/gradle-6/gradlew.bat diff --git a/gradle-6/httpclient-platform/build.gradle.kts b/gradle-modules/gradle-6/httpclient-platform/build.gradle.kts similarity index 100% rename from gradle-6/httpclient-platform/build.gradle.kts rename to gradle-modules/gradle-6/httpclient-platform/build.gradle.kts diff --git a/gradle-6/module-metadata-publishing/build.gradle.kts b/gradle-modules/gradle-6/module-metadata-publishing/build.gradle.kts similarity index 100% rename from gradle-6/module-metadata-publishing/build.gradle.kts rename to gradle-modules/gradle-6/module-metadata-publishing/build.gradle.kts diff --git a/gradle-6/person-rest-client/build.gradle.kts b/gradle-modules/gradle-6/person-rest-client/build.gradle.kts similarity index 100% rename from gradle-6/person-rest-client/build.gradle.kts rename to gradle-modules/gradle-6/person-rest-client/build.gradle.kts diff --git a/gradle-6/settings.gradle.kts b/gradle-modules/gradle-6/settings.gradle.kts similarity index 100% rename from gradle-6/settings.gradle.kts rename to gradle-modules/gradle-6/settings.gradle.kts diff --git a/gradle-6/widget-rest-client/build.gradle.kts b/gradle-modules/gradle-6/widget-rest-client/build.gradle.kts similarity index 100% rename from gradle-6/widget-rest-client/build.gradle.kts rename to gradle-modules/gradle-6/widget-rest-client/build.gradle.kts diff --git a/gradle/.gitignore b/gradle-modules/gradle/.gitignore similarity index 100% rename from gradle/.gitignore rename to gradle-modules/gradle/.gitignore diff --git a/gradle/.travis.yml b/gradle-modules/gradle/.travis.yml similarity index 100% rename from gradle/.travis.yml rename to gradle-modules/gradle/.travis.yml diff --git a/gradle/README.md b/gradle-modules/gradle/README.md similarity index 100% rename from gradle/README.md rename to gradle-modules/gradle/README.md diff --git a/gradle/build.gradle b/gradle-modules/gradle/build.gradle similarity index 100% rename from gradle/build.gradle rename to gradle-modules/gradle/build.gradle diff --git a/gradle/buildSrc/src/main/groovy/com/baeldung/PrintToolVersionBuildSrcTask.groovy b/gradle-modules/gradle/buildSrc/src/main/groovy/com/baeldung/PrintToolVersionBuildSrcTask.groovy similarity index 100% rename from gradle/buildSrc/src/main/groovy/com/baeldung/PrintToolVersionBuildSrcTask.groovy rename to gradle-modules/gradle/buildSrc/src/main/groovy/com/baeldung/PrintToolVersionBuildSrcTask.groovy diff --git a/gradle/gradle-cucumber/README.md b/gradle-modules/gradle/gradle-cucumber/README.md similarity index 100% rename from gradle/gradle-cucumber/README.md rename to gradle-modules/gradle/gradle-cucumber/README.md diff --git a/gradle/gradle-cucumber/build.gradle b/gradle-modules/gradle/gradle-cucumber/build.gradle similarity index 100% rename from gradle/gradle-cucumber/build.gradle rename to gradle-modules/gradle/gradle-cucumber/build.gradle diff --git a/gradle/gradle-cucumber/gradle/wrapper/gradle-wrapper.jar b/gradle-modules/gradle/gradle-cucumber/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from gradle/gradle-cucumber/gradle/wrapper/gradle-wrapper.jar rename to gradle-modules/gradle/gradle-cucumber/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/gradle-cucumber/gradle/wrapper/gradle-wrapper.properties b/gradle-modules/gradle/gradle-cucumber/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from gradle/gradle-cucumber/gradle/wrapper/gradle-wrapper.properties rename to gradle-modules/gradle/gradle-cucumber/gradle/wrapper/gradle-wrapper.properties diff --git a/gradle/gradle-cucumber/gradlew b/gradle-modules/gradle/gradle-cucumber/gradlew similarity index 100% rename from gradle/gradle-cucumber/gradlew rename to gradle-modules/gradle/gradle-cucumber/gradlew diff --git a/gradle/gradle-cucumber/gradlew.bat b/gradle-modules/gradle/gradle-cucumber/gradlew.bat similarity index 100% rename from gradle/gradle-cucumber/gradlew.bat rename to gradle-modules/gradle/gradle-cucumber/gradlew.bat diff --git a/gradle/gradle-cucumber/settings.gradle b/gradle-modules/gradle/gradle-cucumber/settings.gradle similarity index 100% rename from gradle/gradle-cucumber/settings.gradle rename to gradle-modules/gradle/gradle-cucumber/settings.gradle diff --git a/gradle/gradle-cucumber/src/main/java/com/baeldung/Account.java b/gradle-modules/gradle/gradle-cucumber/src/main/java/com/baeldung/Account.java similarity index 100% rename from gradle/gradle-cucumber/src/main/java/com/baeldung/Account.java rename to gradle-modules/gradle/gradle-cucumber/src/main/java/com/baeldung/Account.java diff --git a/gradle/gradle-cucumber/src/test/java/com/baeldung/cucumber/RunCucumberTest.java b/gradle-modules/gradle/gradle-cucumber/src/test/java/com/baeldung/cucumber/RunCucumberTest.java similarity index 100% rename from gradle/gradle-cucumber/src/test/java/com/baeldung/cucumber/RunCucumberTest.java rename to gradle-modules/gradle/gradle-cucumber/src/test/java/com/baeldung/cucumber/RunCucumberTest.java diff --git a/gradle/gradle-cucumber/src/test/java/com/baeldung/cucumber/StepDefinitions.java b/gradle-modules/gradle/gradle-cucumber/src/test/java/com/baeldung/cucumber/StepDefinitions.java similarity index 100% rename from gradle/gradle-cucumber/src/test/java/com/baeldung/cucumber/StepDefinitions.java rename to gradle-modules/gradle/gradle-cucumber/src/test/java/com/baeldung/cucumber/StepDefinitions.java diff --git a/gradle/gradle-cucumber/src/test/resources/features/account_credited.feature b/gradle-modules/gradle/gradle-cucumber/src/test/resources/features/account_credited.feature similarity index 100% rename from gradle/gradle-cucumber/src/test/resources/features/account_credited.feature rename to gradle-modules/gradle/gradle-cucumber/src/test/resources/features/account_credited.feature diff --git a/gradle/gradle-dependency-management/README.md b/gradle-modules/gradle/gradle-dependency-management/README.md similarity index 100% rename from gradle/gradle-dependency-management/README.md rename to gradle-modules/gradle/gradle-dependency-management/README.md diff --git a/gradle/gradle-dependency-management/build.gradle b/gradle-modules/gradle/gradle-dependency-management/build.gradle similarity index 100% rename from gradle/gradle-dependency-management/build.gradle rename to gradle-modules/gradle/gradle-dependency-management/build.gradle diff --git a/gradle/gradle-dependency-management/gradle/wrapper/gradle-wrapper.jar b/gradle-modules/gradle/gradle-dependency-management/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from gradle/gradle-dependency-management/gradle/wrapper/gradle-wrapper.jar rename to gradle-modules/gradle/gradle-dependency-management/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/gradle-dependency-management/gradle/wrapper/gradle-wrapper.properties b/gradle-modules/gradle/gradle-dependency-management/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from gradle/gradle-dependency-management/gradle/wrapper/gradle-wrapper.properties rename to gradle-modules/gradle/gradle-dependency-management/gradle/wrapper/gradle-wrapper.properties diff --git a/gradle/gradle-dependency-management/gradlew b/gradle-modules/gradle/gradle-dependency-management/gradlew similarity index 100% rename from gradle/gradle-dependency-management/gradlew rename to gradle-modules/gradle/gradle-dependency-management/gradlew diff --git a/gradle/gradle-dependency-management/gradlew.bat b/gradle-modules/gradle/gradle-dependency-management/gradlew.bat similarity index 100% rename from gradle/gradle-dependency-management/gradlew.bat rename to gradle-modules/gradle/gradle-dependency-management/gradlew.bat diff --git a/gradle/gradle-dependency-management/libs/sampleOne.jar b/gradle-modules/gradle/gradle-dependency-management/libs/sampleOne.jar similarity index 100% rename from gradle/gradle-dependency-management/libs/sampleOne.jar rename to gradle-modules/gradle/gradle-dependency-management/libs/sampleOne.jar diff --git a/gradle/gradle-dependency-management/libs/sampleTwo.jar b/gradle-modules/gradle/gradle-dependency-management/libs/sampleTwo.jar similarity index 100% rename from gradle/gradle-dependency-management/libs/sampleTwo.jar rename to gradle-modules/gradle/gradle-dependency-management/libs/sampleTwo.jar diff --git a/gradle/gradle-dependency-management/settings.gradle b/gradle-modules/gradle/gradle-dependency-management/settings.gradle similarity index 100% rename from gradle/gradle-dependency-management/settings.gradle rename to gradle-modules/gradle/gradle-dependency-management/settings.gradle diff --git a/gradle/gradle-dependency-management/src/main/java/com/gradle/dependencymanagement/DependencyManagementApplication.java b/gradle-modules/gradle/gradle-dependency-management/src/main/java/com/gradle/dependencymanagement/DependencyManagementApplication.java similarity index 100% rename from gradle/gradle-dependency-management/src/main/java/com/gradle/dependencymanagement/DependencyManagementApplication.java rename to gradle-modules/gradle/gradle-dependency-management/src/main/java/com/gradle/dependencymanagement/DependencyManagementApplication.java diff --git a/gradle/gradle-dependency-management/src/main/resources/application.properties b/gradle-modules/gradle/gradle-dependency-management/src/main/resources/application.properties similarity index 100% rename from gradle/gradle-dependency-management/src/main/resources/application.properties rename to gradle-modules/gradle/gradle-dependency-management/src/main/resources/application.properties diff --git a/gradle/gradle-dependency-management/src/test/java/com/gradle/dependencymanagement/DependencyManagementApplicationUnitTests.java b/gradle-modules/gradle/gradle-dependency-management/src/test/java/com/gradle/dependencymanagement/DependencyManagementApplicationUnitTests.java similarity index 100% rename from gradle/gradle-dependency-management/src/test/java/com/gradle/dependencymanagement/DependencyManagementApplicationUnitTests.java rename to gradle-modules/gradle/gradle-dependency-management/src/test/java/com/gradle/dependencymanagement/DependencyManagementApplicationUnitTests.java diff --git a/gradle/gradle-employee-app/.gitignore b/gradle-modules/gradle/gradle-employee-app/.gitignore similarity index 100% rename from gradle/gradle-employee-app/.gitignore rename to gradle-modules/gradle/gradle-employee-app/.gitignore diff --git a/gradle/gradle-employee-app/README.md b/gradle-modules/gradle/gradle-employee-app/README.md similarity index 100% rename from gradle/gradle-employee-app/README.md rename to gradle-modules/gradle/gradle-employee-app/README.md diff --git a/gradle/gradle-employee-app/build.gradle b/gradle-modules/gradle/gradle-employee-app/build.gradle similarity index 100% rename from gradle/gradle-employee-app/build.gradle rename to gradle-modules/gradle/gradle-employee-app/build.gradle diff --git a/gradle/gradle-employee-app/settings.gradle b/gradle-modules/gradle/gradle-employee-app/settings.gradle similarity index 100% rename from gradle/gradle-employee-app/settings.gradle rename to gradle-modules/gradle/gradle-employee-app/settings.gradle diff --git a/gradle/gradle-employee-app/src/main/java/employee/Employee.java b/gradle-modules/gradle/gradle-employee-app/src/main/java/employee/Employee.java similarity index 100% rename from gradle/gradle-employee-app/src/main/java/employee/Employee.java rename to gradle-modules/gradle/gradle-employee-app/src/main/java/employee/Employee.java diff --git a/gradle/gradle-employee-app/src/main/java/employee/EmployeeApp.java b/gradle-modules/gradle/gradle-employee-app/src/main/java/employee/EmployeeApp.java similarity index 100% rename from gradle/gradle-employee-app/src/main/java/employee/EmployeeApp.java rename to gradle-modules/gradle/gradle-employee-app/src/main/java/employee/EmployeeApp.java diff --git a/gradle/gradle-employee-app/src/test/java/employee/EmployeeAppTest.java b/gradle-modules/gradle/gradle-employee-app/src/test/java/employee/EmployeeAppTest.java similarity index 100% rename from gradle/gradle-employee-app/src/test/java/employee/EmployeeAppTest.java rename to gradle-modules/gradle/gradle-employee-app/src/test/java/employee/EmployeeAppTest.java diff --git a/gradle/gradle-fat-jar/README.md b/gradle-modules/gradle/gradle-fat-jar/README.md similarity index 100% rename from gradle/gradle-fat-jar/README.md rename to gradle-modules/gradle/gradle-fat-jar/README.md diff --git a/gradle/gradle-fat-jar/build.gradle b/gradle-modules/gradle/gradle-fat-jar/build.gradle similarity index 100% rename from gradle/gradle-fat-jar/build.gradle rename to gradle-modules/gradle/gradle-fat-jar/build.gradle diff --git a/gradle/gradle-fat-jar/settings.gradle b/gradle-modules/gradle/gradle-fat-jar/settings.gradle similarity index 100% rename from gradle/gradle-fat-jar/settings.gradle rename to gradle-modules/gradle/gradle-fat-jar/settings.gradle diff --git a/gradle/gradle-fat-jar/src/main/java/com/baeldung/fatjar/Application.java b/gradle-modules/gradle/gradle-fat-jar/src/main/java/com/baeldung/fatjar/Application.java similarity index 100% rename from gradle/gradle-fat-jar/src/main/java/com/baeldung/fatjar/Application.java rename to gradle-modules/gradle/gradle-fat-jar/src/main/java/com/baeldung/fatjar/Application.java diff --git a/gradle/gradle-jacoco/README.md b/gradle-modules/gradle/gradle-jacoco/README.md similarity index 100% rename from gradle/gradle-jacoco/README.md rename to gradle-modules/gradle/gradle-jacoco/README.md diff --git a/gradle/gradle-jacoco/build.gradle b/gradle-modules/gradle/gradle-jacoco/build.gradle similarity index 100% rename from gradle/gradle-jacoco/build.gradle rename to gradle-modules/gradle/gradle-jacoco/build.gradle diff --git a/gradle/gradle-jacoco/gradle/wrapper/gradle-wrapper.jar b/gradle-modules/gradle/gradle-jacoco/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from gradle/gradle-jacoco/gradle/wrapper/gradle-wrapper.jar rename to gradle-modules/gradle/gradle-jacoco/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/gradle-jacoco/gradle/wrapper/gradle-wrapper.properties b/gradle-modules/gradle/gradle-jacoco/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from gradle/gradle-jacoco/gradle/wrapper/gradle-wrapper.properties rename to gradle-modules/gradle/gradle-jacoco/gradle/wrapper/gradle-wrapper.properties diff --git a/gradle/gradle-jacoco/gradlew b/gradle-modules/gradle/gradle-jacoco/gradlew similarity index 100% rename from gradle/gradle-jacoco/gradlew rename to gradle-modules/gradle/gradle-jacoco/gradlew diff --git a/gradle/gradle-jacoco/gradlew.bat b/gradle-modules/gradle/gradle-jacoco/gradlew.bat similarity index 100% rename from gradle/gradle-jacoco/gradlew.bat rename to gradle-modules/gradle/gradle-jacoco/gradlew.bat diff --git a/gradle/gradle-jacoco/lombok.config b/gradle-modules/gradle/gradle-jacoco/lombok.config similarity index 100% rename from gradle/gradle-jacoco/lombok.config rename to gradle-modules/gradle/gradle-jacoco/lombok.config diff --git a/gradle/gradle-jacoco/settings.gradle b/gradle-modules/gradle/gradle-jacoco/settings.gradle similarity index 100% rename from gradle/gradle-jacoco/settings.gradle rename to gradle-modules/gradle/gradle-jacoco/settings.gradle diff --git a/gradle/gradle-jacoco/src/main/java/com/baeldung/config/AppConfig.java b/gradle-modules/gradle/gradle-jacoco/src/main/java/com/baeldung/config/AppConfig.java similarity index 100% rename from gradle/gradle-jacoco/src/main/java/com/baeldung/config/AppConfig.java rename to gradle-modules/gradle/gradle-jacoco/src/main/java/com/baeldung/config/AppConfig.java diff --git a/gradle/gradle-jacoco/src/main/java/com/baeldung/domain/Product.java b/gradle-modules/gradle/gradle-jacoco/src/main/java/com/baeldung/domain/Product.java similarity index 100% rename from gradle/gradle-jacoco/src/main/java/com/baeldung/domain/Product.java rename to gradle-modules/gradle/gradle-jacoco/src/main/java/com/baeldung/domain/Product.java diff --git a/gradle/gradle-jacoco/src/main/java/com/baeldung/dto/ExcludedPOJO.java b/gradle-modules/gradle/gradle-jacoco/src/main/java/com/baeldung/dto/ExcludedPOJO.java similarity index 100% rename from gradle/gradle-jacoco/src/main/java/com/baeldung/dto/ExcludedPOJO.java rename to gradle-modules/gradle/gradle-jacoco/src/main/java/com/baeldung/dto/ExcludedPOJO.java diff --git a/gradle/gradle-jacoco/src/main/java/com/baeldung/dto/ProductDTO.java b/gradle-modules/gradle/gradle-jacoco/src/main/java/com/baeldung/dto/ProductDTO.java similarity index 100% rename from gradle/gradle-jacoco/src/main/java/com/baeldung/dto/ProductDTO.java rename to gradle-modules/gradle/gradle-jacoco/src/main/java/com/baeldung/dto/ProductDTO.java diff --git a/gradle/gradle-jacoco/src/main/java/com/baeldung/generated/Customer.java b/gradle-modules/gradle/gradle-jacoco/src/main/java/com/baeldung/generated/Customer.java similarity index 100% rename from gradle/gradle-jacoco/src/main/java/com/baeldung/generated/Customer.java rename to gradle-modules/gradle/gradle-jacoco/src/main/java/com/baeldung/generated/Customer.java diff --git a/gradle/gradle-jacoco/src/main/java/com/baeldung/generated/Generated.java b/gradle-modules/gradle/gradle-jacoco/src/main/java/com/baeldung/generated/Generated.java similarity index 100% rename from gradle/gradle-jacoco/src/main/java/com/baeldung/generated/Generated.java rename to gradle-modules/gradle/gradle-jacoco/src/main/java/com/baeldung/generated/Generated.java diff --git a/gradle/gradle-jacoco/src/main/java/com/baeldung/service/CustomerService.java b/gradle-modules/gradle/gradle-jacoco/src/main/java/com/baeldung/service/CustomerService.java similarity index 100% rename from gradle/gradle-jacoco/src/main/java/com/baeldung/service/CustomerService.java rename to gradle-modules/gradle/gradle-jacoco/src/main/java/com/baeldung/service/CustomerService.java diff --git a/gradle/gradle-jacoco/src/main/java/com/baeldung/service/ProductService.java b/gradle-modules/gradle/gradle-jacoco/src/main/java/com/baeldung/service/ProductService.java similarity index 100% rename from gradle/gradle-jacoco/src/main/java/com/baeldung/service/ProductService.java rename to gradle-modules/gradle/gradle-jacoco/src/main/java/com/baeldung/service/ProductService.java diff --git a/gradle/gradle-jacoco/src/test/java/com/baeldung/service/CustomerServiceUnitTest.java b/gradle-modules/gradle/gradle-jacoco/src/test/java/com/baeldung/service/CustomerServiceUnitTest.java similarity index 100% rename from gradle/gradle-jacoco/src/test/java/com/baeldung/service/CustomerServiceUnitTest.java rename to gradle-modules/gradle/gradle-jacoco/src/test/java/com/baeldung/service/CustomerServiceUnitTest.java diff --git a/gradle/gradle-jacoco/src/test/java/com/baeldung/service/ProductServiceUnitTest.java b/gradle-modules/gradle/gradle-jacoco/src/test/java/com/baeldung/service/ProductServiceUnitTest.java similarity index 100% rename from gradle/gradle-jacoco/src/test/java/com/baeldung/service/ProductServiceUnitTest.java rename to gradle-modules/gradle/gradle-jacoco/src/test/java/com/baeldung/service/ProductServiceUnitTest.java diff --git a/gradle/gradle-jacoco/src/test/resources/features/account_credited.feature b/gradle-modules/gradle/gradle-jacoco/src/test/resources/features/account_credited.feature similarity index 100% rename from gradle/gradle-jacoco/src/test/resources/features/account_credited.feature rename to gradle-modules/gradle/gradle-jacoco/src/test/resources/features/account_credited.feature diff --git a/gradle/gradle-source-vs-target-compatibility/README.md b/gradle-modules/gradle/gradle-source-vs-target-compatibility/README.md similarity index 100% rename from gradle/gradle-source-vs-target-compatibility/README.md rename to gradle-modules/gradle/gradle-source-vs-target-compatibility/README.md diff --git a/gradle/gradle-source-vs-target-compatibility/build.gradle b/gradle-modules/gradle/gradle-source-vs-target-compatibility/build.gradle similarity index 100% rename from gradle/gradle-source-vs-target-compatibility/build.gradle rename to gradle-modules/gradle/gradle-source-vs-target-compatibility/build.gradle diff --git a/gradle/gradle-source-vs-target-compatibility/settings.gradle b/gradle-modules/gradle/gradle-source-vs-target-compatibility/settings.gradle similarity index 100% rename from gradle/gradle-source-vs-target-compatibility/settings.gradle rename to gradle-modules/gradle/gradle-source-vs-target-compatibility/settings.gradle diff --git a/gradle/gradle-source-vs-target-compatibility/src/main/java/com/baeldung/helloworld/HelloWorldApp.java b/gradle-modules/gradle/gradle-source-vs-target-compatibility/src/main/java/com/baeldung/helloworld/HelloWorldApp.java similarity index 100% rename from gradle/gradle-source-vs-target-compatibility/src/main/java/com/baeldung/helloworld/HelloWorldApp.java rename to gradle-modules/gradle/gradle-source-vs-target-compatibility/src/main/java/com/baeldung/helloworld/HelloWorldApp.java diff --git a/gradle/gradle-to-maven/README.md b/gradle-modules/gradle/gradle-to-maven/README.md similarity index 100% rename from gradle/gradle-to-maven/README.md rename to gradle-modules/gradle/gradle-to-maven/README.md diff --git a/gradle/gradle-to-maven/build.gradle b/gradle-modules/gradle/gradle-to-maven/build.gradle similarity index 100% rename from gradle/gradle-to-maven/build.gradle rename to gradle-modules/gradle/gradle-to-maven/build.gradle diff --git a/gradle/gradle-to-maven/settings.gradle b/gradle-modules/gradle/gradle-to-maven/settings.gradle similarity index 100% rename from gradle/gradle-to-maven/settings.gradle rename to gradle-modules/gradle/gradle-to-maven/settings.gradle diff --git a/gradle/gradle-wrapper/README.md b/gradle-modules/gradle/gradle-wrapper/README.md similarity index 100% rename from gradle/gradle-wrapper/README.md rename to gradle-modules/gradle/gradle-wrapper/README.md diff --git a/gradle/gradle-wrapper/gradle/wrapper/README.md b/gradle-modules/gradle/gradle-wrapper/gradle/wrapper/README.md similarity index 100% rename from gradle/gradle-wrapper/gradle/wrapper/README.md rename to gradle-modules/gradle/gradle-wrapper/gradle/wrapper/README.md diff --git a/gradle/gradle-wrapper/gradle/wrapper/gradle-wrapper.jar b/gradle-modules/gradle/gradle-wrapper/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from gradle/gradle-wrapper/gradle/wrapper/gradle-wrapper.jar rename to gradle-modules/gradle/gradle-wrapper/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/gradle-wrapper/gradle/wrapper/gradle-wrapper.properties b/gradle-modules/gradle/gradle-wrapper/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from gradle/gradle-wrapper/gradle/wrapper/gradle-wrapper.properties rename to gradle-modules/gradle/gradle-wrapper/gradle/wrapper/gradle-wrapper.properties diff --git a/gradle/gradle-wrapper/gradlew b/gradle-modules/gradle/gradle-wrapper/gradlew similarity index 100% rename from gradle/gradle-wrapper/gradlew rename to gradle-modules/gradle/gradle-wrapper/gradlew diff --git a/gradle/gradle-wrapper/gradlew.bat b/gradle-modules/gradle/gradle-wrapper/gradlew.bat similarity index 100% rename from gradle/gradle-wrapper/gradlew.bat rename to gradle-modules/gradle/gradle-wrapper/gradlew.bat diff --git a/gradle/gradle-wrapper/settings.gradle b/gradle-modules/gradle/gradle-wrapper/settings.gradle similarity index 100% rename from gradle/gradle-wrapper/settings.gradle rename to gradle-modules/gradle/gradle-wrapper/settings.gradle diff --git a/gradle/gradle/shipkit.gradle b/gradle-modules/gradle/gradle/shipkit.gradle similarity index 100% rename from gradle/gradle/shipkit.gradle rename to gradle-modules/gradle/gradle/shipkit.gradle diff --git a/gradle/gradle/wrapper/gradle-wrapper.properties b/gradle-modules/gradle/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from gradle/gradle/wrapper/gradle-wrapper.properties rename to gradle-modules/gradle/gradle/wrapper/gradle-wrapper.properties diff --git a/gradle/gradletaskdemo/aplugin.gradle b/gradle-modules/gradle/gradletaskdemo/aplugin.gradle similarity index 100% rename from gradle/gradletaskdemo/aplugin.gradle rename to gradle-modules/gradle/gradletaskdemo/aplugin.gradle diff --git a/gradle/gradletaskdemo/build.gradle b/gradle-modules/gradle/gradletaskdemo/build.gradle similarity index 100% rename from gradle/gradletaskdemo/build.gradle rename to gradle-modules/gradle/gradletaskdemo/build.gradle diff --git a/gradle/gradlew b/gradle-modules/gradle/gradlew similarity index 100% rename from gradle/gradlew rename to gradle-modules/gradle/gradlew diff --git a/gradle/gradlew.bat b/gradle-modules/gradle/gradlew.bat similarity index 100% rename from gradle/gradlew.bat rename to gradle-modules/gradle/gradlew.bat diff --git a/gradle/greeter/.gitignore b/gradle-modules/gradle/greeter/.gitignore similarity index 100% rename from gradle/greeter/.gitignore rename to gradle-modules/gradle/greeter/.gitignore diff --git a/gradle/greeter/build.gradle b/gradle-modules/gradle/greeter/build.gradle similarity index 100% rename from gradle/greeter/build.gradle rename to gradle-modules/gradle/greeter/build.gradle diff --git a/gradle/greeter/src/main/java/greeter/Greeter.java b/gradle-modules/gradle/greeter/src/main/java/greeter/Greeter.java similarity index 100% rename from gradle/greeter/src/main/java/greeter/Greeter.java rename to gradle-modules/gradle/greeter/src/main/java/greeter/Greeter.java diff --git a/gradle/greeter/src/test/java/greetertest/TestGreeting.java b/gradle-modules/gradle/greeter/src/test/java/greetertest/TestGreeting.java similarity index 100% rename from gradle/greeter/src/test/java/greetertest/TestGreeting.java rename to gradle-modules/gradle/greeter/src/test/java/greetertest/TestGreeting.java diff --git a/gradle/greeting-library-java/.gitignore b/gradle-modules/gradle/greeting-library-java/.gitignore similarity index 100% rename from gradle/greeting-library-java/.gitignore rename to gradle-modules/gradle/greeting-library-java/.gitignore diff --git a/gradle/greeting-library-java/build.gradle b/gradle-modules/gradle/greeting-library-java/build.gradle similarity index 100% rename from gradle/greeting-library-java/build.gradle rename to gradle-modules/gradle/greeting-library-java/build.gradle diff --git a/gradle/greeting-library-java/src/main/java/baeldunggreeter/Formatter.java b/gradle-modules/gradle/greeting-library-java/src/main/java/baeldunggreeter/Formatter.java similarity index 100% rename from gradle/greeting-library-java/src/main/java/baeldunggreeter/Formatter.java rename to gradle-modules/gradle/greeting-library-java/src/main/java/baeldunggreeter/Formatter.java diff --git a/gradle/greeting-library-java/src/test/java/baeldunggreetertest/FormatterTest.java b/gradle-modules/gradle/greeting-library-java/src/test/java/baeldunggreetertest/FormatterTest.java similarity index 100% rename from gradle/greeting-library-java/src/test/java/baeldunggreetertest/FormatterTest.java rename to gradle-modules/gradle/greeting-library-java/src/test/java/baeldunggreetertest/FormatterTest.java diff --git a/gradle/greeting-library/.gitignore b/gradle-modules/gradle/greeting-library/.gitignore similarity index 100% rename from gradle/greeting-library/.gitignore rename to gradle-modules/gradle/greeting-library/.gitignore diff --git a/gradle/greeting-library/bin/greeter/GreetingFormatter.groovy b/gradle-modules/gradle/greeting-library/bin/greeter/GreetingFormatter.groovy similarity index 100% rename from gradle/greeting-library/bin/greeter/GreetingFormatter.groovy rename to gradle-modules/gradle/greeting-library/bin/greeter/GreetingFormatter.groovy diff --git a/gradle/greeting-library/build.gradle b/gradle-modules/gradle/greeting-library/build.gradle similarity index 100% rename from gradle/greeting-library/build.gradle rename to gradle-modules/gradle/greeting-library/build.gradle diff --git a/gradle/greeting-library/src/main/groovy/greeter/GreetingFormatter.groovy b/gradle-modules/gradle/greeting-library/src/main/groovy/greeter/GreetingFormatter.groovy similarity index 100% rename from gradle/greeting-library/src/main/groovy/greeter/GreetingFormatter.groovy rename to gradle-modules/gradle/greeting-library/src/main/groovy/greeter/GreetingFormatter.groovy diff --git a/gradle/greeting-library/bin/greeter/GreetingFormatterSpec.groovy b/gradle-modules/gradle/greeting-library/src/test/groovy/greeter/GreetingFormatterSpec.groovy similarity index 100% rename from gradle/greeting-library/bin/greeter/GreetingFormatterSpec.groovy rename to gradle-modules/gradle/greeting-library/src/test/groovy/greeter/GreetingFormatterSpec.groovy diff --git a/gradle/junit5/README.md b/gradle-modules/gradle/junit5/README.md similarity index 100% rename from gradle/junit5/README.md rename to gradle-modules/gradle/junit5/README.md diff --git a/gradle/junit5/build.gradle b/gradle-modules/gradle/junit5/build.gradle similarity index 100% rename from gradle/junit5/build.gradle rename to gradle-modules/gradle/junit5/build.gradle diff --git a/gradle/junit5/settings.gradle b/gradle-modules/gradle/junit5/settings.gradle similarity index 100% rename from gradle/junit5/settings.gradle rename to gradle-modules/gradle/junit5/settings.gradle diff --git a/gradle/junit5/src/test/java/com/example/CalculatorJUnit4Test.java b/gradle-modules/gradle/junit5/src/test/java/com/example/CalculatorJUnit4Test.java similarity index 100% rename from gradle/junit5/src/test/java/com/example/CalculatorJUnit4Test.java rename to gradle-modules/gradle/junit5/src/test/java/com/example/CalculatorJUnit4Test.java diff --git a/gradle/junit5/src/test/java/com/example/CalculatorJUnit5Test.java b/gradle-modules/gradle/junit5/src/test/java/com/example/CalculatorJUnit5Test.java similarity index 100% rename from gradle/junit5/src/test/java/com/example/CalculatorJUnit5Test.java rename to gradle-modules/gradle/junit5/src/test/java/com/example/CalculatorJUnit5Test.java diff --git a/gradle/maven-to-gradle/README.md b/gradle-modules/gradle/maven-to-gradle/README.md similarity index 100% rename from gradle/maven-to-gradle/README.md rename to gradle-modules/gradle/maven-to-gradle/README.md diff --git a/gradle/maven-to-gradle/build.gradle b/gradle-modules/gradle/maven-to-gradle/build.gradle similarity index 100% rename from gradle/maven-to-gradle/build.gradle rename to gradle-modules/gradle/maven-to-gradle/build.gradle diff --git a/gradle/maven-to-gradle/gradle/wrapper/gradle-wrapper.jar b/gradle-modules/gradle/maven-to-gradle/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from gradle/maven-to-gradle/gradle/wrapper/gradle-wrapper.jar rename to gradle-modules/gradle/maven-to-gradle/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/maven-to-gradle/gradle/wrapper/gradle-wrapper.properties b/gradle-modules/gradle/maven-to-gradle/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from gradle/maven-to-gradle/gradle/wrapper/gradle-wrapper.properties rename to gradle-modules/gradle/maven-to-gradle/gradle/wrapper/gradle-wrapper.properties diff --git a/gradle/maven-to-gradle/gradlew b/gradle-modules/gradle/maven-to-gradle/gradlew similarity index 100% rename from gradle/maven-to-gradle/gradlew rename to gradle-modules/gradle/maven-to-gradle/gradlew diff --git a/gradle/maven-to-gradle/gradlew.bat b/gradle-modules/gradle/maven-to-gradle/gradlew.bat similarity index 100% rename from gradle/maven-to-gradle/gradlew.bat rename to gradle-modules/gradle/maven-to-gradle/gradlew.bat diff --git a/gradle/maven-to-gradle/pom.xml b/gradle-modules/gradle/maven-to-gradle/pom.xml similarity index 100% rename from gradle/maven-to-gradle/pom.xml rename to gradle-modules/gradle/maven-to-gradle/pom.xml diff --git a/gradle/maven-to-gradle/settings.gradle b/gradle-modules/gradle/maven-to-gradle/settings.gradle similarity index 100% rename from gradle/maven-to-gradle/settings.gradle rename to gradle-modules/gradle/maven-to-gradle/settings.gradle diff --git a/gradle/maven-to-gradle/src/main/java/com/sample/javacode/DisplayTime.java b/gradle-modules/gradle/maven-to-gradle/src/main/java/com/sample/javacode/DisplayTime.java similarity index 100% rename from gradle/maven-to-gradle/src/main/java/com/sample/javacode/DisplayTime.java rename to gradle-modules/gradle/maven-to-gradle/src/main/java/com/sample/javacode/DisplayTime.java diff --git a/gradle/plugin/build.gradle b/gradle-modules/gradle/plugin/build.gradle similarity index 100% rename from gradle/plugin/build.gradle rename to gradle-modules/gradle/plugin/build.gradle diff --git a/gradle/plugin/buildSrc/src/main/java/com/baeldung/GreetingPlugin.java b/gradle-modules/gradle/plugin/buildSrc/src/main/java/com/baeldung/GreetingPlugin.java similarity index 100% rename from gradle/plugin/buildSrc/src/main/java/com/baeldung/GreetingPlugin.java rename to gradle-modules/gradle/plugin/buildSrc/src/main/java/com/baeldung/GreetingPlugin.java diff --git a/gradle/plugin/buildSrc/src/main/java/com/baeldung/GreetingPluginExtension.java b/gradle-modules/gradle/plugin/buildSrc/src/main/java/com/baeldung/GreetingPluginExtension.java similarity index 100% rename from gradle/plugin/buildSrc/src/main/java/com/baeldung/GreetingPluginExtension.java rename to gradle-modules/gradle/plugin/buildSrc/src/main/java/com/baeldung/GreetingPluginExtension.java diff --git a/gradle/settings.gradle b/gradle-modules/gradle/settings.gradle similarity index 100% rename from gradle/settings.gradle rename to gradle-modules/gradle/settings.gradle diff --git a/gradle/version.properties b/gradle-modules/gradle/version.properties similarity index 100% rename from gradle/version.properties rename to gradle-modules/gradle/version.properties diff --git a/gradle-modules/settings.gradle b/gradle-modules/settings.gradle new file mode 100644 index 0000000000..a550970612 --- /dev/null +++ b/gradle-modules/settings.gradle @@ -0,0 +1,3 @@ +rootProject.name = 'gradle-modules' +include 'gradletutorial' +include 'gradle-5-articles' diff --git a/gradle/greeting-library/src/test/groovy/greeter/GreetingFormatterSpec.groovy b/gradle/greeting-library/src/test/groovy/greeter/GreetingFormatterSpec.groovy deleted file mode 100644 index f1c1211552..0000000000 --- a/gradle/greeting-library/src/test/groovy/greeter/GreetingFormatterSpec.groovy +++ /dev/null @@ -1,13 +0,0 @@ -package greeter - -import spock.lang.Specification - -class GreetingFormatterSpec extends Specification { - - def 'Creating a greeting'() { - - expect: 'The greeeting to be correctly capitalized' - GreetingFormatter.greeting('gradlephant') == 'Hello, Gradlephant' - - } -} From 58c738502951b5bb03ce2480989f1b02b28204a3 Mon Sep 17 00:00:00 2001 From: Sumit Pal Singh Date: Sat, 9 Jul 2022 20:12:38 +0530 Subject: [PATCH 33/53] BAEL-5633 - dockersing a simple java jar (#12454) --- docker-modules/docker-java-jar/Dockerfile | 4 ++ docker-modules/docker-java-jar/pom.xml | 37 +++++++++++++++++++ .../main/java/com/baeldung/HelloWorld.java | 8 ++++ docker-modules/pom.xml | 1 + pom.xml | 1 + 5 files changed, 51 insertions(+) create mode 100644 docker-modules/docker-java-jar/Dockerfile create mode 100644 docker-modules/docker-java-jar/pom.xml create mode 100644 docker-modules/docker-java-jar/src/main/java/com/baeldung/HelloWorld.java diff --git a/docker-modules/docker-java-jar/Dockerfile b/docker-modules/docker-java-jar/Dockerfile new file mode 100644 index 0000000000..bc26e031c3 --- /dev/null +++ b/docker-modules/docker-java-jar/Dockerfile @@ -0,0 +1,4 @@ +FROM openjdk:11 +MAINTAINER baeldung.com +COPY target/docker-java-jar-0.0.1-SNAPSHOT.jar app.jar +ENTRYPOINT ["java","-jar","/app.jar"] diff --git a/docker-modules/docker-java-jar/pom.xml b/docker-modules/docker-java-jar/pom.xml new file mode 100644 index 0000000000..0ca0146ac0 --- /dev/null +++ b/docker-modules/docker-java-jar/pom.xml @@ -0,0 +1,37 @@ + + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + 4.0.0 + + docker-java-jar + + + 11 + 11 + + + + + + org.apache.maven.plugins + maven-jar-plugin + ${maven-jar-plugin.version} + + + + com.baeldung.HelloWorld + + + + + + + + \ No newline at end of file diff --git a/docker-modules/docker-java-jar/src/main/java/com/baeldung/HelloWorld.java b/docker-modules/docker-java-jar/src/main/java/com/baeldung/HelloWorld.java new file mode 100644 index 0000000000..50e0044c48 --- /dev/null +++ b/docker-modules/docker-java-jar/src/main/java/com/baeldung/HelloWorld.java @@ -0,0 +1,8 @@ +package com.baeldung; + +public class HelloWorld { + + public static void main(String[] args){ + System.out.println("Welcome to our application"); + } +} diff --git a/docker-modules/pom.xml b/docker-modules/pom.xml index f2b8f059a1..d80e5341b0 100644 --- a/docker-modules/pom.xml +++ b/docker-modules/pom.xml @@ -23,6 +23,7 @@ docker-images docker-spring-boot docker-spring-boot-postgres + docker-java-jar diff --git a/pom.xml b/pom.xml index 6daf0e3fa5..0e0aa876eb 100644 --- a/pom.xml +++ b/pom.xml @@ -1400,6 +1400,7 @@ 1.18.20 1.4.200 31.0.1-jre + 3.2.2 \ No newline at end of file From eda84c24b93754aaadfdac4195d921392ce763a7 Mon Sep 17 00:00:00 2001 From: anuragkumawat Date: Sun, 10 Jul 2022 13:40:05 +0530 Subject: [PATCH 34/53] JAVA-12627 Fix DatasetUnitTest in apache-spark module --- .../CustomerToDataFrameConverterAppUnitTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apache-spark/src/test/java/com/baeldung/dataframes/CustomerToDataFrameConverterAppUnitTest.java b/apache-spark/src/test/java/com/baeldung/dataframes/CustomerToDataFrameConverterAppUnitTest.java index 06c8f66bcd..c16ca34fdc 100644 --- a/apache-spark/src/test/java/com/baeldung/dataframes/CustomerToDataFrameConverterAppUnitTest.java +++ b/apache-spark/src/test/java/com/baeldung/dataframes/CustomerToDataFrameConverterAppUnitTest.java @@ -8,6 +8,8 @@ import java.util.List; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; +import org.apache.spark.sql.SparkSession; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; class CustomerToDataFrameConverterAppUnitTest { @@ -59,4 +61,9 @@ class CustomerToDataFrameConverterAppUnitTest { assertEquals( "Male", row2.getAs("gender")); assertEquals( 1200, (int)row2.getAs("transaction_amount")); } + + @AfterEach + public void cleanup() { + SparkSession.getActiveSession().get().close(); + } } From 4c1e18b15efb30de8f5eaf5622bcfdbccf65fb49 Mon Sep 17 00:00:00 2001 From: thibaultfaure Date: Sun, 10 Jul 2022 14:22:08 +0200 Subject: [PATCH 35/53] BAEL-5610 Code for the clearing stringbuilder or stringbuffer article (#12378) Co-authored-by: thibault.faure --- .../PersonAndEmployeeReflectionUnitTest.java | 1 - .../BenchmarkRunner.java | 32 +++++++++ ...arStringBuilderOrStringBufferUnitTest.java | 66 +++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 core-java-modules/core-java-string-apis/src/main/java/com/baeldung/clearstringbuilderorstringbuffer/BenchmarkRunner.java create mode 100644 core-java-modules/core-java-string-apis/src/test/java/com/baeldung/clearstringbuilderorstringbuffer/ClearStringBuilderOrStringBufferUnitTest.java diff --git a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionUnitTest.java b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionUnitTest.java index b1a6a1fe57..cb1b5e926a 100644 --- a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionUnitTest.java +++ b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionUnitTest.java @@ -9,7 +9,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; -import java.util.stream.Stream; import static org.junit.Assert.*; diff --git a/core-java-modules/core-java-string-apis/src/main/java/com/baeldung/clearstringbuilderorstringbuffer/BenchmarkRunner.java b/core-java-modules/core-java-string-apis/src/main/java/com/baeldung/clearstringbuilderorstringbuffer/BenchmarkRunner.java new file mode 100644 index 0000000000..e0cead9c77 --- /dev/null +++ b/core-java-modules/core-java-string-apis/src/main/java/com/baeldung/clearstringbuilderorstringbuffer/BenchmarkRunner.java @@ -0,0 +1,32 @@ +package com.baeldung.clearstringbuilderorstringbuffer; + +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.infra.Blackhole; + +public class BenchmarkRunner { + + public static void main(String[] args) throws Exception { + org.openjdk.jmh.Main.main(args); + } + + @State(Scope.Benchmark) + public static class MyState { + final String HELLO = "Hello World"; + final StringBuilder sb = new StringBuilder().append(HELLO); + } + + @Benchmark + public void evaluateSetLength(Blackhole blackhole, MyState state) { + state.sb.setLength(0); + blackhole.consume(state.sb.toString()); + } + + @Benchmark + public void evaluateDelete(Blackhole blackhole, MyState state) { + state.sb.delete(0, state.sb.length()); + blackhole.consume(state.sb.toString()); + } + +} diff --git a/core-java-modules/core-java-string-apis/src/test/java/com/baeldung/clearstringbuilderorstringbuffer/ClearStringBuilderOrStringBufferUnitTest.java b/core-java-modules/core-java-string-apis/src/test/java/com/baeldung/clearstringbuilderorstringbuffer/ClearStringBuilderOrStringBufferUnitTest.java new file mode 100644 index 0000000000..ad46c23969 --- /dev/null +++ b/core-java-modules/core-java-string-apis/src/test/java/com/baeldung/clearstringbuilderorstringbuffer/ClearStringBuilderOrStringBufferUnitTest.java @@ -0,0 +1,66 @@ +package com.baeldung.clearstringbuilderorstringbuffer; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ClearStringBuilderOrStringBufferUnitTest { + + @Test + void whenSetLengthToZero_ThenStringBuilderIsCleared() { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("Hello World"); + int initialCapacity = stringBuilder.capacity(); + stringBuilder.setLength(0); + assertEquals("", stringBuilder.toString()); + assertEquals(initialCapacity, stringBuilder.capacity()); + } + + @Test + void whenDeleteAll_ThenStringBuilderIsCleared() { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("Hello World"); + int initialCapacity = stringBuilder.capacity(); + stringBuilder.delete(0, stringBuilder.length()); + assertEquals("", stringBuilder.toString()); + assertEquals(initialCapacity, stringBuilder.capacity()); + } + + @Test + void whenSetLengthToZero_ThenStringBufferIsCleared() { + StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append("Hello World"); + int initialCapacity = stringBuffer.capacity(); + stringBuffer.setLength(0); + assertEquals("", stringBuffer.toString()); + assertEquals(initialCapacity, stringBuffer.capacity()); + } + + @Test + void whenDeleteAll_ThenStringBufferIsCleared() { + StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append("Hello World"); + int initialCapacity = stringBuffer.capacity(); + stringBuffer.delete(0, stringBuffer.length()); + assertEquals("", stringBuffer.toString()); + assertEquals(initialCapacity, stringBuffer.capacity()); + } + + // Note: It did not make the cut to the article, but here is another way to reset a StringBuilder + @Test + void whenAssignedToNewStringBuilder_ThenStringBuilderIsCleared() { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("Hello World"); + stringBuilder = new StringBuilder(); + assertEquals("", stringBuilder.toString()); + } + + @Test + void whenAssignedToNewStringBuffer_ThenStringBufferIsCleared() { + StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append("Hello World"); + stringBuffer = new StringBuffer(); + assertEquals("", stringBuffer.toString()); + } + +} From b372864029de888933bb6be4293097699acd32a2 Mon Sep 17 00:00:00 2001 From: Kai Yuan Date: Mon, 11 Jul 2022 04:09:49 +0200 Subject: [PATCH 36/53] BAEL-5650 jar file path (#12463) * BAEL-5650 jar file path * move to jar module --- core-java-modules/core-java-jar/pom.xml | 9 ++- .../baeldung/jarfile/JarFilePathResolver.java | 42 ++++++++++++++ .../jarfile/JarFilePathResolverUnitTest.java | 55 +++++++++++++++++++ core-java-modules/core-java-lang-5/pom.xml | 4 +- 4 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 core-java-modules/core-java-jar/src/main/java/com/baeldung/jarfile/JarFilePathResolver.java create mode 100644 core-java-modules/core-java-jar/src/test/java/com/baeldung/jarfile/JarFilePathResolverUnitTest.java diff --git a/core-java-modules/core-java-jar/pom.xml b/core-java-modules/core-java-jar/pom.xml index 19da9b8a56..c56fcbd8b5 100644 --- a/core-java-modules/core-java-jar/pom.xml +++ b/core-java-modules/core-java-jar/pom.xml @@ -54,6 +54,12 @@ moneta ${javamoney.moneta.version} + + org.mockito + mockito-junit-jupiter + ${mockito.version} + test + @@ -266,6 +272,7 @@ 0.4 1.8.7 + 4.6.1 1.1 3.0.0-M1 @@ -279,4 +286,4 @@ 1.8 - \ No newline at end of file + diff --git a/core-java-modules/core-java-jar/src/main/java/com/baeldung/jarfile/JarFilePathResolver.java b/core-java-modules/core-java-jar/src/main/java/com/baeldung/jarfile/JarFilePathResolver.java new file mode 100644 index 0000000000..3dab91f31a --- /dev/null +++ b/core-java-modules/core-java-jar/src/main/java/com/baeldung/jarfile/JarFilePathResolver.java @@ -0,0 +1,42 @@ +package com.baeldung.jarfile; + +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Paths; + +public class JarFilePathResolver { + + public String getJarFilePath(Class clazz) { + try { + return byGetProtectionDomain(clazz); + } catch (Exception e) { + // cannot get jar file path using byGetProtectionDomain + // Exception handling omitted + } + return byGetResource(clazz); + } + + String byGetProtectionDomain(Class clazz) throws URISyntaxException { + URL url = clazz.getProtectionDomain().getCodeSource().getLocation(); + return Paths.get(url.toURI()).toString(); + } + + String byGetResource(Class clazz) { + final URL classResource = clazz.getResource(clazz.getSimpleName() + ".class"); + if (classResource == null) { + throw new RuntimeException("class resource is null"); + } + + final String url = classResource.toString(); + if (url.startsWith("jar:file:")) { + // extract 'file:......jarName.jar' part from the url string + String path = url.replaceAll("^jar:(file:.*[.]jar)!/.*", "$1"); + try { + return Paths.get(new URL(path).toURI()).toString(); + } catch (Exception e) { + throw new RuntimeException("Invalid Jar File URL String"); + } + } + throw new RuntimeException("Invalid Jar File URL String"); + } +} diff --git a/core-java-modules/core-java-jar/src/test/java/com/baeldung/jarfile/JarFilePathResolverUnitTest.java b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jarfile/JarFilePathResolverUnitTest.java new file mode 100644 index 0000000000..ad84bd9379 --- /dev/null +++ b/core-java-modules/core-java-jar/src/test/java/com/baeldung/jarfile/JarFilePathResolverUnitTest.java @@ -0,0 +1,55 @@ +package com.baeldung.jarfile; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import com.google.common.base.Ascii; +import java.io.File; +import java.net.URISyntaxException; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Spy; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class JarFilePathResolverUnitTest { + @Spy + JarFilePathResolver jarFilePathResolver; + + @Test + void givenClassObjectWhenCallingByGetProtectionDomainShouldGetExpectedPath() throws Exception { + String jarPath = jarFilePathResolver.byGetProtectionDomain(Ascii.class); + assertThat(jarPath).endsWith(".jar").contains("guava"); + assertThat(new File(jarPath)).exists(); + } + + @Test + void givenClassObjectWhenCallingByGetResourceShouldGetExpectedPath() { + String jarPath = jarFilePathResolver.byGetResource(Ascii.class); + assertThat(jarPath).endsWith(".jar").contains("guava"); + assertThat(new File(jarPath)).exists(); + } + + @Test + void givenClassObjectWhenNoSecurityExceptionRaisedShouldGetExpectedPath() throws URISyntaxException { + String jarPath = jarFilePathResolver.getJarFilePath(Ascii.class); + assertThat(jarPath).endsWith(".jar").contains("guava"); + assertThat(new File(jarPath)).exists(); + verify(jarFilePathResolver, times(1)).byGetProtectionDomain(Ascii.class); + verify(jarFilePathResolver, never()).byGetResource(Ascii.class); + } + + @Test + void givenClassObjectWhenSecurityExceptionRaisedShouldGetExpectedPath() throws URISyntaxException { + when(jarFilePathResolver.byGetProtectionDomain(Ascii.class)).thenThrow(new SecurityException("not allowed")); + String jarPath = jarFilePathResolver.getJarFilePath(Ascii.class); + assertThat(jarPath).endsWith(".jar").contains("guava"); + assertThat(new File(jarPath)).exists(); + verify(jarFilePathResolver, times(1)).byGetProtectionDomain(Ascii.class); + verify(jarFilePathResolver, times(1)).byGetResource(Ascii.class); + } + +} diff --git a/core-java-modules/core-java-lang-5/pom.xml b/core-java-modules/core-java-lang-5/pom.xml index 6d3771bd31..5255866f03 100644 --- a/core-java-modules/core-java-lang-5/pom.xml +++ b/core-java-modules/core-java-lang-5/pom.xml @@ -13,7 +13,6 @@ core-java-modules 0.0.1-SNAPSHOT - core-java-lang-5 @@ -23,5 +22,4 @@ - - \ No newline at end of file + From c0bba594a206b37ab15bcce280c6673318c39862 Mon Sep 17 00:00:00 2001 From: Abdul Wahab Date: Mon, 11 Jul 2022 06:42:14 +0300 Subject: [PATCH 37/53] BAEL-5616: Added java wildcard imports example (#12448) Co-authored-by: Abdul Wahab --- .../com/baeldung/imports/specific/Book.java | 17 +++++++++++++++++ .../com/baeldung/imports/wildcard/Book.java | 15 +++++++++++++++ .../baeldung/imports/wildcard/BookView.java | 17 +++++++++++++++++ .../baeldung/imports/wildcard/Library.java | 19 +++++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 core-java-modules/core-java-lang-5/src/main/java/com/baeldung/imports/specific/Book.java create mode 100644 core-java-modules/core-java-lang-5/src/main/java/com/baeldung/imports/wildcard/Book.java create mode 100644 core-java-modules/core-java-lang-5/src/main/java/com/baeldung/imports/wildcard/BookView.java create mode 100644 core-java-modules/core-java-lang-5/src/main/java/com/baeldung/imports/wildcard/Library.java diff --git a/core-java-modules/core-java-lang-5/src/main/java/com/baeldung/imports/specific/Book.java b/core-java-modules/core-java-lang-5/src/main/java/com/baeldung/imports/specific/Book.java new file mode 100644 index 0000000000..5877147082 --- /dev/null +++ b/core-java-modules/core-java-lang-5/src/main/java/com/baeldung/imports/specific/Book.java @@ -0,0 +1,17 @@ +package com.baeldung.imports.specific; + +import java.util.Date; +import java.util.List; +import java.util.UUID; + +public class Book { + + private UUID id; + + private String name; + + private Date datePublished; + + private List authors; + +} \ No newline at end of file diff --git a/core-java-modules/core-java-lang-5/src/main/java/com/baeldung/imports/wildcard/Book.java b/core-java-modules/core-java-lang-5/src/main/java/com/baeldung/imports/wildcard/Book.java new file mode 100644 index 0000000000..18754cdd28 --- /dev/null +++ b/core-java-modules/core-java-lang-5/src/main/java/com/baeldung/imports/wildcard/Book.java @@ -0,0 +1,15 @@ +package com.baeldung.imports.wildcard; + +import java.util.*; + +public class Book { + + private UUID id; + + private String name; + + private Date datePublished; + + private List authors; + +} \ No newline at end of file diff --git a/core-java-modules/core-java-lang-5/src/main/java/com/baeldung/imports/wildcard/BookView.java b/core-java-modules/core-java-lang-5/src/main/java/com/baeldung/imports/wildcard/BookView.java new file mode 100644 index 0000000000..e6e21ab03d --- /dev/null +++ b/core-java-modules/core-java-lang-5/src/main/java/com/baeldung/imports/wildcard/BookView.java @@ -0,0 +1,17 @@ +package com.baeldung.imports.wildcard; + +import java.awt.*; +import java.util.*; +import java.util.List; + +public class BookView extends Frame { + + private UUID id; + + private String name; + + private Date datePublished; + + private List authors; + +} \ No newline at end of file diff --git a/core-java-modules/core-java-lang-5/src/main/java/com/baeldung/imports/wildcard/Library.java b/core-java-modules/core-java-lang-5/src/main/java/com/baeldung/imports/wildcard/Library.java new file mode 100644 index 0000000000..8e1d79aca4 --- /dev/null +++ b/core-java-modules/core-java-lang-5/src/main/java/com/baeldung/imports/wildcard/Library.java @@ -0,0 +1,19 @@ +package com.baeldung.imports.wildcard; + +import java.util.*; +import java.sql.*; +import java.sql.Date; + +public class Library { + + private UUID id; + + private String name; + + private Time openingTime; + + private Time closingTime; + + private List datesClosed; + +} \ No newline at end of file From a9c0015e6403b35ccf93c1d9dfeafa9c684b6a4a Mon Sep 17 00:00:00 2001 From: panos-kakos <102670093+panos-kakos@users.noreply.github.com> Date: Mon, 11 Jul 2022 16:29:42 +0100 Subject: [PATCH 38/53] Moved spring-mockito to testing-modules (#12476) Co-authored-by: panagiotiskakos --- pom.xml | 2 -- testing-modules/pom.xml | 1 + {spring-mockito => testing-modules/spring-mockito}/.gitignore | 0 {spring-mockito => testing-modules/spring-mockito}/README.md | 0 {spring-mockito => testing-modules/spring-mockito}/pom.xml | 2 +- .../src/main/java/com/baeldung/MocksApplication.java | 0 .../spring-mockito}/src/main/java/com/baeldung/NameService.java | 0 .../spring-mockito}/src/main/java/com/baeldung/UserService.java | 0 .../src/main/java/com/baeldung/app/api/Flower.java | 0 .../src/main/java/com/baeldung/app/api/MessageApi.java | 0 .../src/main/java/com/baeldung/app/rest/FlowerController.java | 0 .../src/main/java/com/baeldung/app/rest/MessageController.java | 0 .../src/main/java/com/baeldung/domain/model/Message.java | 0 .../main/java/com/baeldung/domain/service/FlowerService.java | 0 .../main/java/com/baeldung/domain/service/MessageService.java | 0 .../src/main/java/com/baeldung/domain/util/MessageMatcher.java | 0 .../spring-mockito}/src/main/resources/application.properties | 0 .../spring-mockito}/src/main/resources/logback.xml | 0 .../test/java/com/baeldung/NameServiceTestConfiguration.java | 0 .../src/test/java/com/baeldung/UserServiceUnitTest.java | 0 .../java/com/baeldung/app/rest/FlowerControllerUnitTest.java | 0 .../java/com/baeldung/app/rest/MessageControllerUnitTest.java | 0 .../src/test/java/org/baeldung/SpringContextTest.java | 0 23 files changed, 2 insertions(+), 3 deletions(-) rename {spring-mockito => testing-modules/spring-mockito}/.gitignore (100%) rename {spring-mockito => testing-modules/spring-mockito}/README.md (100%) rename {spring-mockito => testing-modules/spring-mockito}/pom.xml (94%) rename {spring-mockito => testing-modules/spring-mockito}/src/main/java/com/baeldung/MocksApplication.java (100%) rename {spring-mockito => testing-modules/spring-mockito}/src/main/java/com/baeldung/NameService.java (100%) rename {spring-mockito => testing-modules/spring-mockito}/src/main/java/com/baeldung/UserService.java (100%) rename {spring-mockito => testing-modules/spring-mockito}/src/main/java/com/baeldung/app/api/Flower.java (100%) rename {spring-mockito => testing-modules/spring-mockito}/src/main/java/com/baeldung/app/api/MessageApi.java (100%) rename {spring-mockito => testing-modules/spring-mockito}/src/main/java/com/baeldung/app/rest/FlowerController.java (100%) rename {spring-mockito => testing-modules/spring-mockito}/src/main/java/com/baeldung/app/rest/MessageController.java (100%) rename {spring-mockito => testing-modules/spring-mockito}/src/main/java/com/baeldung/domain/model/Message.java (100%) rename {spring-mockito => testing-modules/spring-mockito}/src/main/java/com/baeldung/domain/service/FlowerService.java (100%) rename {spring-mockito => testing-modules/spring-mockito}/src/main/java/com/baeldung/domain/service/MessageService.java (100%) rename {spring-mockito => testing-modules/spring-mockito}/src/main/java/com/baeldung/domain/util/MessageMatcher.java (100%) rename {spring-mockito => testing-modules/spring-mockito}/src/main/resources/application.properties (100%) rename {spring-mockito => testing-modules/spring-mockito}/src/main/resources/logback.xml (100%) rename {spring-mockito => testing-modules/spring-mockito}/src/test/java/com/baeldung/NameServiceTestConfiguration.java (100%) rename {spring-mockito => testing-modules/spring-mockito}/src/test/java/com/baeldung/UserServiceUnitTest.java (100%) rename {spring-mockito => testing-modules/spring-mockito}/src/test/java/com/baeldung/app/rest/FlowerControllerUnitTest.java (100%) rename {spring-mockito => testing-modules/spring-mockito}/src/test/java/com/baeldung/app/rest/MessageControllerUnitTest.java (100%) rename {spring-mockito => testing-modules/spring-mockito}/src/test/java/org/baeldung/SpringContextTest.java (100%) diff --git a/pom.xml b/pom.xml index ff8336d890..1fe42bd734 100644 --- a/pom.xml +++ b/pom.xml @@ -621,7 +621,6 @@ spring-katharsis spring-mobile - spring-mockito spring-native spring-protobuf spring-quartz @@ -1050,7 +1049,6 @@ spring-katharsis spring-mobile - spring-mockito spring-native spring-protobuf spring-quartz diff --git a/testing-modules/pom.xml b/testing-modules/pom.xml index 3d5db76827..8213637631 100644 --- a/testing-modules/pom.xml +++ b/testing-modules/pom.xml @@ -39,6 +39,7 @@ rest-assured rest-testing selenium-junit-testng + spring-mockito spring-testing-2 spring-testing test-containers diff --git a/spring-mockito/.gitignore b/testing-modules/spring-mockito/.gitignore similarity index 100% rename from spring-mockito/.gitignore rename to testing-modules/spring-mockito/.gitignore diff --git a/spring-mockito/README.md b/testing-modules/spring-mockito/README.md similarity index 100% rename from spring-mockito/README.md rename to testing-modules/spring-mockito/README.md diff --git a/spring-mockito/pom.xml b/testing-modules/spring-mockito/pom.xml similarity index 94% rename from spring-mockito/pom.xml rename to testing-modules/spring-mockito/pom.xml index e0d7bee6f3..117da9478e 100644 --- a/spring-mockito/pom.xml +++ b/testing-modules/spring-mockito/pom.xml @@ -13,7 +13,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-mockito/src/main/java/com/baeldung/MocksApplication.java b/testing-modules/spring-mockito/src/main/java/com/baeldung/MocksApplication.java similarity index 100% rename from spring-mockito/src/main/java/com/baeldung/MocksApplication.java rename to testing-modules/spring-mockito/src/main/java/com/baeldung/MocksApplication.java diff --git a/spring-mockito/src/main/java/com/baeldung/NameService.java b/testing-modules/spring-mockito/src/main/java/com/baeldung/NameService.java similarity index 100% rename from spring-mockito/src/main/java/com/baeldung/NameService.java rename to testing-modules/spring-mockito/src/main/java/com/baeldung/NameService.java diff --git a/spring-mockito/src/main/java/com/baeldung/UserService.java b/testing-modules/spring-mockito/src/main/java/com/baeldung/UserService.java similarity index 100% rename from spring-mockito/src/main/java/com/baeldung/UserService.java rename to testing-modules/spring-mockito/src/main/java/com/baeldung/UserService.java diff --git a/spring-mockito/src/main/java/com/baeldung/app/api/Flower.java b/testing-modules/spring-mockito/src/main/java/com/baeldung/app/api/Flower.java similarity index 100% rename from spring-mockito/src/main/java/com/baeldung/app/api/Flower.java rename to testing-modules/spring-mockito/src/main/java/com/baeldung/app/api/Flower.java diff --git a/spring-mockito/src/main/java/com/baeldung/app/api/MessageApi.java b/testing-modules/spring-mockito/src/main/java/com/baeldung/app/api/MessageApi.java similarity index 100% rename from spring-mockito/src/main/java/com/baeldung/app/api/MessageApi.java rename to testing-modules/spring-mockito/src/main/java/com/baeldung/app/api/MessageApi.java diff --git a/spring-mockito/src/main/java/com/baeldung/app/rest/FlowerController.java b/testing-modules/spring-mockito/src/main/java/com/baeldung/app/rest/FlowerController.java similarity index 100% rename from spring-mockito/src/main/java/com/baeldung/app/rest/FlowerController.java rename to testing-modules/spring-mockito/src/main/java/com/baeldung/app/rest/FlowerController.java diff --git a/spring-mockito/src/main/java/com/baeldung/app/rest/MessageController.java b/testing-modules/spring-mockito/src/main/java/com/baeldung/app/rest/MessageController.java similarity index 100% rename from spring-mockito/src/main/java/com/baeldung/app/rest/MessageController.java rename to testing-modules/spring-mockito/src/main/java/com/baeldung/app/rest/MessageController.java diff --git a/spring-mockito/src/main/java/com/baeldung/domain/model/Message.java b/testing-modules/spring-mockito/src/main/java/com/baeldung/domain/model/Message.java similarity index 100% rename from spring-mockito/src/main/java/com/baeldung/domain/model/Message.java rename to testing-modules/spring-mockito/src/main/java/com/baeldung/domain/model/Message.java diff --git a/spring-mockito/src/main/java/com/baeldung/domain/service/FlowerService.java b/testing-modules/spring-mockito/src/main/java/com/baeldung/domain/service/FlowerService.java similarity index 100% rename from spring-mockito/src/main/java/com/baeldung/domain/service/FlowerService.java rename to testing-modules/spring-mockito/src/main/java/com/baeldung/domain/service/FlowerService.java diff --git a/spring-mockito/src/main/java/com/baeldung/domain/service/MessageService.java b/testing-modules/spring-mockito/src/main/java/com/baeldung/domain/service/MessageService.java similarity index 100% rename from spring-mockito/src/main/java/com/baeldung/domain/service/MessageService.java rename to testing-modules/spring-mockito/src/main/java/com/baeldung/domain/service/MessageService.java diff --git a/spring-mockito/src/main/java/com/baeldung/domain/util/MessageMatcher.java b/testing-modules/spring-mockito/src/main/java/com/baeldung/domain/util/MessageMatcher.java similarity index 100% rename from spring-mockito/src/main/java/com/baeldung/domain/util/MessageMatcher.java rename to testing-modules/spring-mockito/src/main/java/com/baeldung/domain/util/MessageMatcher.java diff --git a/spring-mockito/src/main/resources/application.properties b/testing-modules/spring-mockito/src/main/resources/application.properties similarity index 100% rename from spring-mockito/src/main/resources/application.properties rename to testing-modules/spring-mockito/src/main/resources/application.properties diff --git a/spring-mockito/src/main/resources/logback.xml b/testing-modules/spring-mockito/src/main/resources/logback.xml similarity index 100% rename from spring-mockito/src/main/resources/logback.xml rename to testing-modules/spring-mockito/src/main/resources/logback.xml diff --git a/spring-mockito/src/test/java/com/baeldung/NameServiceTestConfiguration.java b/testing-modules/spring-mockito/src/test/java/com/baeldung/NameServiceTestConfiguration.java similarity index 100% rename from spring-mockito/src/test/java/com/baeldung/NameServiceTestConfiguration.java rename to testing-modules/spring-mockito/src/test/java/com/baeldung/NameServiceTestConfiguration.java diff --git a/spring-mockito/src/test/java/com/baeldung/UserServiceUnitTest.java b/testing-modules/spring-mockito/src/test/java/com/baeldung/UserServiceUnitTest.java similarity index 100% rename from spring-mockito/src/test/java/com/baeldung/UserServiceUnitTest.java rename to testing-modules/spring-mockito/src/test/java/com/baeldung/UserServiceUnitTest.java diff --git a/spring-mockito/src/test/java/com/baeldung/app/rest/FlowerControllerUnitTest.java b/testing-modules/spring-mockito/src/test/java/com/baeldung/app/rest/FlowerControllerUnitTest.java similarity index 100% rename from spring-mockito/src/test/java/com/baeldung/app/rest/FlowerControllerUnitTest.java rename to testing-modules/spring-mockito/src/test/java/com/baeldung/app/rest/FlowerControllerUnitTest.java diff --git a/spring-mockito/src/test/java/com/baeldung/app/rest/MessageControllerUnitTest.java b/testing-modules/spring-mockito/src/test/java/com/baeldung/app/rest/MessageControllerUnitTest.java similarity index 100% rename from spring-mockito/src/test/java/com/baeldung/app/rest/MessageControllerUnitTest.java rename to testing-modules/spring-mockito/src/test/java/com/baeldung/app/rest/MessageControllerUnitTest.java diff --git a/spring-mockito/src/test/java/org/baeldung/SpringContextTest.java b/testing-modules/spring-mockito/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-mockito/src/test/java/org/baeldung/SpringContextTest.java rename to testing-modules/spring-mockito/src/test/java/org/baeldung/SpringContextTest.java From 412c18b921d3f0be67ff5cf166db3f0c1b33b706 Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Tue, 12 Jul 2022 21:28:39 +0530 Subject: [PATCH 39/53] JAVA-11495 Further cleanup and fixes --- gradle-modules/README.md | 4 ++-- gradle-modules/gradle-5/settings.gradle | 2 +- gradle-modules/gradle/settings.gradle | 2 +- gradle-modules/settings.gradle | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gradle-modules/README.md b/gradle-modules/README.md index b85789407f..a4d8875b15 100644 --- a/gradle-modules/README.md +++ b/gradle-modules/README.md @@ -1,3 +1,3 @@ -## Akka +## Gradle Modules -This module contains modules about Akka. \ No newline at end of file +This module contains submodules of Gradle. \ No newline at end of file diff --git a/gradle-modules/gradle-5/settings.gradle b/gradle-modules/gradle-5/settings.gradle index ede73daf0a..c73af319a3 100644 --- a/gradle-modules/gradle-5/settings.gradle +++ b/gradle-modules/gradle-5/settings.gradle @@ -1,4 +1,4 @@ -rootProject.name='gradle-5-articles' +rootProject.name='gradle-5' include 'java-exec' include 'unused-dependencies' include 'source-sets' diff --git a/gradle-modules/gradle/settings.gradle b/gradle-modules/gradle/settings.gradle index ba255f25c2..c049dbc7e9 100644 --- a/gradle-modules/gradle/settings.gradle +++ b/gradle-modules/gradle/settings.gradle @@ -1,4 +1,4 @@ -rootProject.name = 'gradletutorial' +rootProject.name = 'gradle' include 'greeting-library' include 'greeting-library-java' diff --git a/gradle-modules/settings.gradle b/gradle-modules/settings.gradle index a550970612..f6e0614a10 100644 --- a/gradle-modules/settings.gradle +++ b/gradle-modules/settings.gradle @@ -1,3 +1,4 @@ rootProject.name = 'gradle-modules' -include 'gradletutorial' -include 'gradle-5-articles' +include 'gradle' +include 'gradle-5' +include 'gradle-6' From 6cb32c1060061fce7484e7816f4c79f5277908f8 Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Tue, 12 Jul 2022 21:33:48 +0530 Subject: [PATCH 40/53] JAVA-11495 Removed gradle submodules from main pom --- pom.xml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 912a13f402..a5fe564da8 100644 --- a/pom.xml +++ b/pom.xml @@ -397,9 +397,7 @@ geotools google-cloud google-web-toolkit - - - + graphql-modules grpc @@ -505,7 +503,7 @@ protobuffer quarkus-modules - + rabbitmq ratpack @@ -831,9 +829,7 @@ geotools google-cloud google-web-toolkit - - - + graphql-modules grpc From ef07ee6cac956e7f22e32ee292dd469b3d33262b Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Tue, 12 Jul 2022 21:00:42 +0100 Subject: [PATCH 41/53] [JAVA-13264] Add missing classes --- .../constructordi/service/UserRepository.java | 7 +++++++ .../baeldung/constructordi/service/UserService.java | 11 +++++++++++ 2 files changed, 18 insertions(+) create mode 100644 spring-di-2/src/main/java/com/baeldung/constructordi/service/UserRepository.java create mode 100644 spring-di-2/src/main/java/com/baeldung/constructordi/service/UserService.java diff --git a/spring-di-2/src/main/java/com/baeldung/constructordi/service/UserRepository.java b/spring-di-2/src/main/java/com/baeldung/constructordi/service/UserRepository.java new file mode 100644 index 0000000000..aec9e51af9 --- /dev/null +++ b/spring-di-2/src/main/java/com/baeldung/constructordi/service/UserRepository.java @@ -0,0 +1,7 @@ +package com.baeldung.constructordi.service; + +import org.springframework.stereotype.Repository; + +@Repository +public class UserRepository { +} diff --git a/spring-di-2/src/main/java/com/baeldung/constructordi/service/UserService.java b/spring-di-2/src/main/java/com/baeldung/constructordi/service/UserService.java new file mode 100644 index 0000000000..7762ff324c --- /dev/null +++ b/spring-di-2/src/main/java/com/baeldung/constructordi/service/UserService.java @@ -0,0 +1,11 @@ +package com.baeldung.constructordi.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class UserService { + + @Autowired + private UserRepository userRepository; +} From ca850502be6cd294db2cfecd6da77428eba860b6 Mon Sep 17 00:00:00 2001 From: Asjad J <97493880+Asjad-J@users.noreply.github.com> Date: Thu, 14 Jul 2022 07:25:52 +0500 Subject: [PATCH 42/53] Created README.md added link back to the article: https://www.baeldung.com/spring-same-class-multiple-beans --- spring-core-6/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 spring-core-6/README.md diff --git a/spring-core-6/README.md b/spring-core-6/README.md new file mode 100644 index 0000000000..e5d425aa74 --- /dev/null +++ b/spring-core-6/README.md @@ -0,0 +1,3 @@ + +### Relevant Articles: +- [Instantiating Multiple Beans of the Same Class with Spring Annotations](https://www.baeldung.com/spring-same-class-multiple-beans) From 495b9b1ccf48048372513316cedda26421d8035f Mon Sep 17 00:00:00 2001 From: Asjad J <97493880+Asjad-J@users.noreply.github.com> Date: Thu, 14 Jul 2022 08:09:34 +0500 Subject: [PATCH 43/53] Updated README.md added link back to the article: https://www.baeldung.com/mongodb-java-date-operations --- persistence-modules/java-mongodb-queries/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/persistence-modules/java-mongodb-queries/README.md b/persistence-modules/java-mongodb-queries/README.md index e69de29bb2..30649b0db1 100644 --- a/persistence-modules/java-mongodb-queries/README.md +++ b/persistence-modules/java-mongodb-queries/README.md @@ -0,0 +1,3 @@ + +### Relevant Articles: +- [Using Dates in CRUD Operations in MongoDB](https://www.baeldung.com/mongodb-java-date-operations) From 24ace64b2ec793c4606f340f397282518a097400 Mon Sep 17 00:00:00 2001 From: Asjad J <97493880+Asjad-J@users.noreply.github.com> Date: Thu, 14 Jul 2022 08:13:33 +0500 Subject: [PATCH 44/53] Updated README.md added link back to the article: https://www.baeldung.com/java-record-vs-lombok --- core-java-modules/core-java-14/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-14/README.md b/core-java-modules/core-java-14/README.md index 07cdf9859c..00fd2fa320 100644 --- a/core-java-modules/core-java-14/README.md +++ b/core-java-modules/core-java-14/README.md @@ -11,3 +11,4 @@ This module contains articles about Java 14. - [Foreign Memory Access API in Java 14](https://www.baeldung.com/java-foreign-memory-access) - [Java 14 Record Keyword](https://www.baeldung.com/java-record-keyword) - [New Features in Java 14](https://www.baeldung.com/java-14-new-features) +- [Java 14 Record vs. Lombok](https://www.baeldung.com/java-record-vs-lombok) From 263803754abf21ed558ef74f42913ef664dad5db Mon Sep 17 00:00:00 2001 From: Asjad J <97493880+Asjad-J@users.noreply.github.com> Date: Thu, 14 Jul 2022 08:17:00 +0500 Subject: [PATCH 45/53] Updated README.md added link back to the article: https://www.baeldung.com/jar-windows-executables --- core-java-modules/core-java-jar/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-jar/README.md b/core-java-modules/core-java-jar/README.md index b1e24e3ab9..f7a65336bf 100644 --- a/core-java-modules/core-java-jar/README.md +++ b/core-java-modules/core-java-jar/README.md @@ -10,3 +10,4 @@ This module contains articles about JAR files - [Get Names of Classes Inside a JAR File](https://www.baeldung.com/jar-file-get-class-names) - [Find All Jars Containing Given Class](https://baeldung.com/find-all-jars-containing-given-class/) - [Creating JAR Files Programmatically](https://www.baeldung.com/jar-create-programatically) +- [Guide to Creating Jar Executables and Windows Executables from Java](https://www.baeldung.com/jar-windows-executables) From b4859d77785ddc5d8af468018b78c9beaafecb9d Mon Sep 17 00:00:00 2001 From: Asjad J <97493880+Asjad-J@users.noreply.github.com> Date: Thu, 14 Jul 2022 08:23:36 +0500 Subject: [PATCH 46/53] Updated README.md added link back to the article: https://www.baeldung.com/java-clear-stringbuilder-stringbuffer --- core-java-modules/core-java-string-apis/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-string-apis/README.md b/core-java-modules/core-java-string-apis/README.md index 0dd24d7e9a..68f2176ed6 100644 --- a/core-java-modules/core-java-string-apis/README.md +++ b/core-java-modules/core-java-string-apis/README.md @@ -11,3 +11,4 @@ This module contains articles about string APIs. - [StringBuilder vs StringBuffer in Java](https://www.baeldung.com/java-string-builder-string-buffer) - [Generate a Secure Random Password in Java](https://www.baeldung.com/java-generate-secure-password) - [Getting a Character by Index From a String in Java](https://www.baeldung.com/java-character-at-position) +- [Clearing a StringBuilder or StringBuffer](https://www.baeldung.com/java-clear-stringbuilder-stringbuffer) From 38ab64081aad7a7feca5e61e1e6148db66c7ee7e Mon Sep 17 00:00:00 2001 From: Asjad J <97493880+Asjad-J@users.noreply.github.com> Date: Thu, 14 Jul 2022 08:28:02 +0500 Subject: [PATCH 47/53] Updated README.md added link back to the article: https://www.baeldung.com/java-full-path-of-jar-from-class --- core-java-modules/core-java-jar/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-jar/README.md b/core-java-modules/core-java-jar/README.md index f7a65336bf..c99ea63b22 100644 --- a/core-java-modules/core-java-jar/README.md +++ b/core-java-modules/core-java-jar/README.md @@ -11,3 +11,4 @@ This module contains articles about JAR files - [Find All Jars Containing Given Class](https://baeldung.com/find-all-jars-containing-given-class/) - [Creating JAR Files Programmatically](https://www.baeldung.com/jar-create-programatically) - [Guide to Creating Jar Executables and Windows Executables from Java](https://www.baeldung.com/jar-windows-executables) +- [Get the Full Path of a JAR File From a Class](https://www.baeldung.com/java-full-path-of-jar-from-class) From 7bd70abf86f123d018e953e25c5b21cd565fef31 Mon Sep 17 00:00:00 2001 From: Asjad J <97493880+Asjad-J@users.noreply.github.com> Date: Thu, 14 Jul 2022 08:32:27 +0500 Subject: [PATCH 48/53] Updated README.md added link back to the article: https://www.baeldung.com/java-wildcard-imports --- core-java-modules/core-java-lang-5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-lang-5/README.md b/core-java-modules/core-java-lang-5/README.md index 8920e9c231..9505d02fc2 100644 --- a/core-java-modules/core-java-lang-5/README.md +++ b/core-java-modules/core-java-lang-5/README.md @@ -5,3 +5,4 @@ This module contains articles about core features in the Java language ### Relevant Articles: - [Difference Between == and equals() in Java](https://www.baeldung.com/java-equals-method-operator-difference) +- [Advantages and Disadvantages of Using Java Wildcard Imports](https://www.baeldung.com/java-wildcard-imports) From 5dd6471390501846296b4ded4abd89f0f3a7ca89 Mon Sep 17 00:00:00 2001 From: Asjad J <97493880+Asjad-J@users.noreply.github.com> Date: Thu, 14 Jul 2022 08:41:09 +0500 Subject: [PATCH 49/53] Updated README.md added link back to the article: https://www.baeldung.com/java-truncating-strings --- core-java-modules/core-java-string-operations-4/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-string-operations-4/README.md b/core-java-modules/core-java-string-operations-4/README.md index ff6d887154..ac52ee4ab5 100644 --- a/core-java-modules/core-java-string-operations-4/README.md +++ b/core-java-modules/core-java-string-operations-4/README.md @@ -7,4 +7,4 @@ - [String equals() Vs contentEquals() in Java](https://www.baeldung.com/java-string-equals-vs-contentequals) - [Check if a String Ends with a Certain Pattern in Java](https://www.baeldung.com/java-string-ends-pattern) - [Check if a Character is a Vowel in Java](https://www.baeldung.com/java-check-character-vowel) - +- [How to Truncate a String in Java](https://www.baeldung.com/java-truncating-strings) From 56fd1ef7b48ad3291cace341339b123e44e11586 Mon Sep 17 00:00:00 2001 From: Abhinav Pandey Date: Thu, 14 Jul 2022 09:50:08 +0530 Subject: [PATCH 50/53] BAEL-3201 - Unit testing with Redis test containers (#12441) * BAEL-3201 - Unit testing with Redis test containers * BAEL-3201 - Updated test method names Co-authored-by: Abhinav Pandey --- .../spring-boot-testing-2/pom.xml | 10 +++ .../RedisTestcontainersApplication.java | 13 ++++ .../redistestcontainers/hash/Product.java | 55 ++++++++++++++ .../repository/ProductRepository.java | 9 +++ .../service/ProductService.java | 31 ++++++++ .../ProductServiceIntegrationTest.java | 75 +++++++++++++++++++ 6 files changed, 193 insertions(+) create mode 100644 spring-boot-modules/spring-boot-testing-2/src/main/java/com/baeldung/redistestcontainers/RedisTestcontainersApplication.java create mode 100644 spring-boot-modules/spring-boot-testing-2/src/main/java/com/baeldung/redistestcontainers/hash/Product.java create mode 100644 spring-boot-modules/spring-boot-testing-2/src/main/java/com/baeldung/redistestcontainers/repository/ProductRepository.java create mode 100644 spring-boot-modules/spring-boot-testing-2/src/main/java/com/baeldung/redistestcontainers/service/ProductService.java create mode 100644 spring-boot-modules/spring-boot-testing-2/src/test/java/com/baeldung/redistestcontainers/service/ProductServiceIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-testing-2/pom.xml b/spring-boot-modules/spring-boot-testing-2/pom.xml index 556142b480..e4f3f122af 100644 --- a/spring-boot-modules/spring-boot-testing-2/pom.xml +++ b/spring-boot-modules/spring-boot-testing-2/pom.xml @@ -23,6 +23,10 @@ org.springframework.boot spring-boot-starter-web-services + + org.springframework.boot + spring-boot-starter-data-redis + wsdl4j wsdl4j @@ -38,6 +42,12 @@ 3.1.3 test + + org.testcontainers + testcontainers + 1.17.2 + test + diff --git a/spring-boot-modules/spring-boot-testing-2/src/main/java/com/baeldung/redistestcontainers/RedisTestcontainersApplication.java b/spring-boot-modules/spring-boot-testing-2/src/main/java/com/baeldung/redistestcontainers/RedisTestcontainersApplication.java new file mode 100644 index 0000000000..50efd56751 --- /dev/null +++ b/spring-boot-modules/spring-boot-testing-2/src/main/java/com/baeldung/redistestcontainers/RedisTestcontainersApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.redistestcontainers; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class RedisTestcontainersApplication { + + public static void main(String[] args) { + SpringApplication.run(RedisTestcontainersApplication.class, args); + } + +} diff --git a/spring-boot-modules/spring-boot-testing-2/src/main/java/com/baeldung/redistestcontainers/hash/Product.java b/spring-boot-modules/spring-boot-testing-2/src/main/java/com/baeldung/redistestcontainers/hash/Product.java new file mode 100644 index 0000000000..3345a17c79 --- /dev/null +++ b/spring-boot-modules/spring-boot-testing-2/src/main/java/com/baeldung/redistestcontainers/hash/Product.java @@ -0,0 +1,55 @@ +package com.baeldung.redistestcontainers.hash; + +import org.springframework.data.redis.core.RedisHash; + +import java.io.Serializable; + +@RedisHash("product") +public class Product implements Serializable { + private String id; + private String name; + private double price; + + // Constructor, getters and setters + public Product() { + } + + public Product(String id, String name, double price) { + this.id = id; + this.name = name; + this.price = price; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + + @Override + public String toString() { + return "Product{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", price=" + price + + '}'; + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-testing-2/src/main/java/com/baeldung/redistestcontainers/repository/ProductRepository.java b/spring-boot-modules/spring-boot-testing-2/src/main/java/com/baeldung/redistestcontainers/repository/ProductRepository.java new file mode 100644 index 0000000000..5851c282e0 --- /dev/null +++ b/spring-boot-modules/spring-boot-testing-2/src/main/java/com/baeldung/redistestcontainers/repository/ProductRepository.java @@ -0,0 +1,9 @@ +package com.baeldung.redistestcontainers.repository; + +import com.baeldung.redistestcontainers.hash.Product; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ProductRepository extends CrudRepository { +} diff --git a/spring-boot-modules/spring-boot-testing-2/src/main/java/com/baeldung/redistestcontainers/service/ProductService.java b/spring-boot-modules/spring-boot-testing-2/src/main/java/com/baeldung/redistestcontainers/service/ProductService.java new file mode 100644 index 0000000000..3eb0149ef1 --- /dev/null +++ b/spring-boot-modules/spring-boot-testing-2/src/main/java/com/baeldung/redistestcontainers/service/ProductService.java @@ -0,0 +1,31 @@ +package com.baeldung.redistestcontainers.service; + +import com.baeldung.redistestcontainers.hash.Product; +import com.baeldung.redistestcontainers.repository.ProductRepository; +import org.springframework.stereotype.Service; + +@Service +public class ProductService { + + private final ProductRepository productRepository; + + public ProductService(ProductRepository productRepository) { + this.productRepository = productRepository; + } + + public Product getProduct(String id) { + return productRepository.findById(id).orElse(null); + } + + void createProduct(Product product) { + productRepository.save(product); + } + + void updateProduct(Product product) { + productRepository.save(product); + } + + void deleteProduct(String id) { + productRepository.deleteById(id); + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-testing-2/src/test/java/com/baeldung/redistestcontainers/service/ProductServiceIntegrationTest.java b/spring-boot-modules/spring-boot-testing-2/src/test/java/com/baeldung/redistestcontainers/service/ProductServiceIntegrationTest.java new file mode 100644 index 0000000000..519db1b335 --- /dev/null +++ b/spring-boot-modules/spring-boot-testing-2/src/test/java/com/baeldung/redistestcontainers/service/ProductServiceIntegrationTest.java @@ -0,0 +1,75 @@ +package com.baeldung.redistestcontainers.service; + +import com.baeldung.redistestcontainers.hash.Product; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.utility.DockerImageName; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +@SpringBootTest +public class ProductServiceIntegrationTest { + + static { + GenericContainer redis = new GenericContainer<>(DockerImageName.parse("redis:5.0.3-alpine")) + .withExposedPorts(6379); + redis.start(); + System.setProperty("spring.redis.host", redis.getHost()); + System.setProperty("spring.redis.port", redis.getMappedPort(6379).toString()); + } + + @Autowired + private ProductService productService; + + @Test + void givenProductCreated_whenGettingProductById_thenProductExistsAndHasSameProperties() { + Product product = new Product("1", "Test Product", 10.0); + productService.createProduct(product); + Product productFromDb = productService.getProduct("1"); + assertEquals("1", productFromDb.getId()); + assertEquals("Test Product", productFromDb.getName()); + assertEquals(10.0, productFromDb.getPrice()); + } + + @Test + void givenProductCreatedAndUpdated_whenGettingTheProduct_thenUpdatedProductReturned() { + Product product = new Product("1", "Test Product", 10.0); + productService.createProduct(product); + Product productFromDb = productService.getProduct("1"); + assertEquals("1", productFromDb.getId()); + assertEquals("Test Product", productFromDb.getName()); + assertEquals(10.0, productFromDb.getPrice()); + productFromDb.setName("Updated Product"); + productFromDb.setPrice(20.0); + productService.updateProduct(productFromDb); + Product updatedProductFromDb = productService.getProduct("1"); + assertEquals("Updated Product", updatedProductFromDb.getName()); + assertEquals(20.0, updatedProductFromDb.getPrice()); + } + + @Test + void givenProductCreatedAndDeleted_whenGettingTheProduct_thenNoProductReturned() { + Product product = new Product("1", "Test Product", 10.0); + productService.createProduct(product); + Product productFromDb = productService.getProduct("1"); + assertEquals("1", productFromDb.getId()); + assertEquals("Test Product", productFromDb.getName()); + assertEquals(10.0, productFromDb.getPrice()); + productService.deleteProduct("1"); + Product deletedProductFromDb = productService.getProduct("1"); + assertNull(deletedProductFromDb); + } + + @Test + void givenProductCreated_whenGettingProductById_thenSameProductReturned() { + Product product = new Product("1", "Test Product", 10.0); + productService.createProduct(product); + Product productFromDb = productService.getProduct("1"); + assertEquals("1", productFromDb.getId()); + assertEquals("Test Product", productFromDb.getName()); + assertEquals(10.0, productFromDb.getPrice()); + } +} \ No newline at end of file From e80218d1e0eeca014c625db16bc7a872b52b1125 Mon Sep 17 00:00:00 2001 From: panagiotiskakos Date: Thu, 14 Jul 2022 08:23:11 +0300 Subject: [PATCH 51/53] [JAVA-12943] Improvement --- .../src/main/java/com/baeldung/javalin/User/User.java | 2 +- .../java/com/baeldung/javalin/User/UserController.java | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libraries-http/src/main/java/com/baeldung/javalin/User/User.java b/libraries-http/src/main/java/com/baeldung/javalin/User/User.java index 288c027c8b..ac96ece03e 100644 --- a/libraries-http/src/main/java/com/baeldung/javalin/User/User.java +++ b/libraries-http/src/main/java/com/baeldung/javalin/User/User.java @@ -1,5 +1,5 @@ package com.baeldung.javalin.User; -import com.fasterxml.jackson.annotation.JsonProperty; + public class User { public int id; diff --git a/libraries-http/src/main/java/com/baeldung/javalin/User/UserController.java b/libraries-http/src/main/java/com/baeldung/javalin/User/UserController.java index 685890c6d7..1b3cc950e8 100644 --- a/libraries-http/src/main/java/com/baeldung/javalin/User/UserController.java +++ b/libraries-http/src/main/java/com/baeldung/javalin/User/UserController.java @@ -3,6 +3,7 @@ package com.baeldung.javalin.User; import io.javalin.Handler; import java.util.Objects; +import java.util.Optional; public class UserController { public static Handler fetchAllUsernames = ctx -> { @@ -14,11 +15,11 @@ public class UserController { public static Handler fetchById = ctx -> { int id = Integer.parseInt(Objects.requireNonNull(ctx.param("id"))); UserDao dao = UserDao.instance(); - User user = dao.getUserById(id).get(); - if (user == null) { - ctx.html("Not Found"); - } else { + Optional user = dao.getUserById(id); + if(user.isPresent()){ ctx.json(user); + } else { + ctx.html("User Not Found"); } }; } From 8bf83f0fe6350129187b8d2040fc0cd88fe400ef Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Thu, 14 Jul 2022 10:50:07 +0100 Subject: [PATCH 52/53] [JAVA-13290] Update record name --- .../baeldung/java_16_features/groupingby/BlogPost.java | 6 +++--- .../groupingby/JavaGroupingByCollectorUnitTest.java | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core-java-modules/core-java-16/src/main/java/com/baeldung/java_16_features/groupingby/BlogPost.java b/core-java-modules/core-java-16/src/main/java/com/baeldung/java_16_features/groupingby/BlogPost.java index 960a75a58e..314fbeeeb5 100644 --- a/core-java-modules/core-java-16/src/main/java/com/baeldung/java_16_features/groupingby/BlogPost.java +++ b/core-java-modules/core-java-16/src/main/java/com/baeldung/java_16_features/groupingby/BlogPost.java @@ -4,15 +4,15 @@ import java.util.IntSummaryStatistics; public class BlogPost { - + private String title; private String author; private BlogPostType type; private int likes; record AuthPostTypesLikes(String author, BlogPostType type, int likes) {}; - record PostcountTitlesLikesStats(long postCount, String titles, IntSummaryStatistics likesStats){}; + record PostCountTitlesLikesStats(long postCount, String titles, IntSummaryStatistics likesStats){}; record TitlesBoundedSumOfLikes(String titles, int boundedSumOfLikes) {}; - + public BlogPost(String title, String author, BlogPostType type, int likes) { this.title = title; this.author = author; diff --git a/core-java-modules/core-java-16/src/test/java/com/baeldung/java_16_features/groupingby/JavaGroupingByCollectorUnitTest.java b/core-java-modules/core-java-16/src/test/java/com/baeldung/java_16_features/groupingby/JavaGroupingByCollectorUnitTest.java index 0dea142658..603bebb7c5 100644 --- a/core-java-modules/core-java-16/src/test/java/com/baeldung/java_16_features/groupingby/JavaGroupingByCollectorUnitTest.java +++ b/core-java-modules/core-java-16/src/test/java/com/baeldung/java_16_features/groupingby/JavaGroupingByCollectorUnitTest.java @@ -257,7 +257,7 @@ public class JavaGroupingByCollectorUnitTest { @Test public void givenListOfPosts_whenGroupedByAuthor_thenGetAMapUsingCollectingAndThen() { - Map postsPerAuthor = posts.stream() + Map postsPerAuthor = posts.stream() .collect(groupingBy(BlogPost::getAuthor, collectingAndThen(toList(), list -> { long count = list.stream() .map(BlogPost::getTitle) @@ -267,10 +267,10 @@ public class JavaGroupingByCollectorUnitTest { .collect(joining(" : ")); IntSummaryStatistics summary = list.stream() .collect(summarizingInt(BlogPost::getLikes)); - return new BlogPost.PostcountTitlesLikesStats(count, titles, summary); + return new BlogPost.PostCountTitlesLikesStats(count, titles, summary); }))); - BlogPost.PostcountTitlesLikesStats result = postsPerAuthor.get("Author 1"); + BlogPost.PostCountTitlesLikesStats result = postsPerAuthor.get("Author 1"); assertThat(result.postCount()).isEqualTo(3L); assertThat(result.titles()).isEqualTo("News item 1 : Programming guide : Tech review 2"); assertThat(result.likesStats().getMax()).isEqualTo(20); @@ -294,7 +294,7 @@ public class JavaGroupingByCollectorUnitTest { .toUpperCase(), u1.boundedSumOfLikes() + likes); })); - + BlogPost.TitlesBoundedSumOfLikes result = postsPerAuthor.get("Author 1"); assertThat(result.titles()).isEqualTo("NEWS ITEM 1 : PROGRAMMING GUIDE : TECH REVIEW 2"); assertThat(result.boundedSumOfLikes()).isEqualTo(47); From c252786fa90e829eb21892fa7a3e5b945b48b55b Mon Sep 17 00:00:00 2001 From: Avin Buricha Date: Fri, 15 Jul 2022 00:08:20 +0530 Subject: [PATCH 53/53] Updated article code (#12493) --- .../baeldung/mongo/find/FindWithObjectId.java | 2 +- .../mongo/find/FindWithObjectIdLiveTest.java | 28 +++++++++---------- .../src/test/resources/vehicle.json | 3 ++ 3 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 persistence-modules/java-mongodb-3/src/test/resources/vehicle.json diff --git a/persistence-modules/java-mongodb-3/src/main/java/com/baeldung/mongo/find/FindWithObjectId.java b/persistence-modules/java-mongodb-3/src/main/java/com/baeldung/mongo/find/FindWithObjectId.java index b82dcb6c5b..4e7dce2d72 100644 --- a/persistence-modules/java-mongodb-3/src/main/java/com/baeldung/mongo/find/FindWithObjectId.java +++ b/persistence-modules/java-mongodb-3/src/main/java/com/baeldung/mongo/find/FindWithObjectId.java @@ -25,7 +25,7 @@ public class FindWithObjectId { mongoClient = new MongoClient("localhost", 27017); databaseName = "baeldung"; - collectionName = "employee"; + collectionName = "vehicle"; database = mongoClient.getDatabase(databaseName); collection = database.getCollection(collectionName); diff --git a/persistence-modules/java-mongodb-3/src/test/java/com/baeldung/mongo/find/FindWithObjectIdLiveTest.java b/persistence-modules/java-mongodb-3/src/test/java/com/baeldung/mongo/find/FindWithObjectIdLiveTest.java index 590758855c..b8a34c809b 100644 --- a/persistence-modules/java-mongodb-3/src/test/java/com/baeldung/mongo/find/FindWithObjectIdLiveTest.java +++ b/persistence-modules/java-mongodb-3/src/test/java/com/baeldung/mongo/find/FindWithObjectIdLiveTest.java @@ -26,7 +26,7 @@ public class FindWithObjectIdLiveTest { private static MongoClient mongoClient; private static MongoDatabase database; private static MongoCollection collection; - private static final String DATASET_JSON = "/employee.json"; + private static final String DATASET_JSON = "/vehicle.json"; @BeforeClass public static void setUp() throws IOException { @@ -34,7 +34,7 @@ public class FindWithObjectIdLiveTest { mongoClient = new MongoClient("localhost", 27017); database = mongoClient.getDatabase("baeldung"); - collection = database.getCollection("employee"); + collection = database.getCollection("vehicle"); collection.drop(); @@ -47,10 +47,10 @@ public class FindWithObjectIdLiveTest { } @Test - public void givenEmployeeCollection_whenFetchingDocumentsUsingObjectId_thenCheckingForDocuments() { - Document employee = collection.find() + public void givenVehicleCollection_whenFetchingDocumentsUsingObjectId_thenCheckingForDocuments() { + Document vehicle = collection.find() .first(); - ObjectId objectId = (ObjectId) employee.get(OBJECT_ID_FIELD); + ObjectId objectId = (ObjectId) vehicle.get(OBJECT_ID_FIELD); FindIterable documents = collection.find(eq(OBJECT_ID_FIELD, objectId)); MongoCursor cursor = documents.iterator(); @@ -60,24 +60,24 @@ public class FindWithObjectIdLiveTest { } @Test - public void givenEmployeeCollection_whenFetchingFirstDocumentUsingObjectId_thenCheckingForDocument() { - Document employee = collection.find() + public void givenVehicleCollection_whenFetchingFirstDocumentUsingObjectId_thenCheckingForDocument() { + Document vehicle = collection.find() .first(); - ObjectId objectId = (ObjectId) employee.get(OBJECT_ID_FIELD); + ObjectId objectId = (ObjectId) vehicle.get(OBJECT_ID_FIELD); - Document queriedEmployee = collection.find(eq(OBJECT_ID_FIELD, objectId)) + Document queriedVehicle = collection.find(eq(OBJECT_ID_FIELD, objectId)) .first(); - assertNotNull(queriedEmployee); - assertEquals(employee.get(OBJECT_ID_FIELD), queriedEmployee.get(OBJECT_ID_FIELD)); + assertNotNull(queriedVehicle); + assertEquals(vehicle.get(OBJECT_ID_FIELD), queriedVehicle.get(OBJECT_ID_FIELD)); } @Test - public void givenEmployeeCollection_whenFetchingUsingRandomObjectId_thenCheckingForDocument() { - Document employee = collection.find(eq(OBJECT_ID_FIELD, new ObjectId())) + public void givenVehicleCollection_whenFetchingUsingRandomObjectId_thenCheckingForDocument() { + Document vehicle = collection.find(eq(OBJECT_ID_FIELD, new ObjectId())) .first(); - assertNull(employee); + assertNull(vehicle); } @AfterClass diff --git a/persistence-modules/java-mongodb-3/src/test/resources/vehicle.json b/persistence-modules/java-mongodb-3/src/test/resources/vehicle.json new file mode 100644 index 0000000000..567aba647f --- /dev/null +++ b/persistence-modules/java-mongodb-3/src/test/resources/vehicle.json @@ -0,0 +1,3 @@ +{"companyName":"Skoda","modelName":"Octavia","launchYear":2016,"type":"Sports","registeredNo":"SKO 1134"} +{"companyName":"BMW","modelName":"X5","launchYear":2020,"type":"SUV","registeredNo":"BMW 3325"} +{"companyName":"Mercedes","modelName":"Maybach","launchYear":2021,"type":"Luxury","registeredNo":"MER 9754"} \ No newline at end of file