Date: Sat, 28 Mar 2020 16:48:04 +0530
Subject: [PATCH 28/87] JAVA-623: Moved 3 articles from core-java-security to
security-2
---
.../core-java-security/README.md | 5 +-
core-java-modules/core-java-security/pom.xml | 15 --
.../baeldung/hashing/DigestAlgorithms.java | 9 --
.../baeldung/hashing/Keccak256Hashing.java | 30 ----
.../com/baeldung/hashing/SHA256Hashing.java | 39 -----
.../com/baeldung/hashing/SHA3Hashing.java | 45 ------
.../com/baeldung/hashing/SHACommonUtils.java | 16 --
.../passwordhashing/PBKDF2Hasher.java | 149 ------------------
.../passwordhashing/SHA512Hasher.java | 35 ----
.../passwordhashing/SimplePBKDF2Hasher.java | 18 ---
.../hashing/Keccak256HashingUnitTest.java | 22 ---
.../hashing/SHA256HashingUnitTest.java | 35 ----
.../baeldung/hashing/SHA3HashingUnitTest.java | 38 -----
.../baeldung/java/md5/JavaMD5UnitTest.java | 75 ---------
.../passwordhashing/PBKDF2HasherUnitTest.java | 41 -----
.../passwordhashing/SHA512HasherUnitTest.java | 70 --------
.../src/test/resources/test_md5.txt | 1 -
17 files changed, 2 insertions(+), 641 deletions(-)
delete mode 100644 core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/DigestAlgorithms.java
delete mode 100644 core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/Keccak256Hashing.java
delete mode 100644 core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHA256Hashing.java
delete mode 100644 core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHA3Hashing.java
delete mode 100644 core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHACommonUtils.java
delete mode 100644 core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/PBKDF2Hasher.java
delete mode 100644 core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/SHA512Hasher.java
delete mode 100644 core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/SimplePBKDF2Hasher.java
delete mode 100644 core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/Keccak256HashingUnitTest.java
delete mode 100644 core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/SHA256HashingUnitTest.java
delete mode 100644 core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/SHA3HashingUnitTest.java
delete mode 100644 core-java-modules/core-java-security/src/test/java/com/baeldung/java/md5/JavaMD5UnitTest.java
delete mode 100644 core-java-modules/core-java-security/src/test/java/com/baeldung/passwordhashing/PBKDF2HasherUnitTest.java
delete mode 100644 core-java-modules/core-java-security/src/test/java/com/baeldung/passwordhashing/SHA512HasherUnitTest.java
delete mode 100644 core-java-modules/core-java-security/src/test/resources/test_md5.txt
diff --git a/core-java-modules/core-java-security/README.md b/core-java-modules/core-java-security/README.md
index ff9b1eef14..83b12793b5 100644
--- a/core-java-modules/core-java-security/README.md
+++ b/core-java-modules/core-java-security/README.md
@@ -3,17 +3,16 @@
This module contains articles about core Java Security
### Relevant Articles:
-- [MD5 Hashing in Java](http://www.baeldung.com/java-md5)
+
- [Guide to the Cipher Class](http://www.baeldung.com/java-cipher-class)
- [Introduction to SSL in Java](http://www.baeldung.com/java-ssl)
- [Java KeyStore API](http://www.baeldung.com/java-keystore)
- [Encrypting and Decrypting Files in Java](http://www.baeldung.com/java-cipher-input-output-stream)
-- [Hashing a Password in Java](https://www.baeldung.com/java-password-hashing)
- [SSL Handshake Failures](https://www.baeldung.com/java-ssl-handshake-failures)
-- [SHA-256 and SHA3-256 Hashing in Java](https://www.baeldung.com/sha-256-hashing-java)
- [Enabling TLS v1.2 in Java 7](https://www.baeldung.com/java-7-tls-v12)
- [The Java SecureRandom Class](https://www.baeldung.com/java-secure-random)
- [An Introduction to Java SASL](https://www.baeldung.com/java-sasl)
- [A Guide to Java GSS API](https://www.baeldung.com/java-gss)
- [Intro to the Java SecurityManager](https://www.baeldung.com/java-security-manager)
+- More articles: [[next -->]](/core-java-modules/core-java-security-2)
diff --git a/core-java-modules/core-java-security/pom.xml b/core-java-modules/core-java-security/pom.xml
index a46c2e2d40..96024a73a1 100644
--- a/core-java-modules/core-java-security/pom.xml
+++ b/core-java-modules/core-java-security/pom.xml
@@ -24,24 +24,9 @@
${assertj-core.version}
test
-
-
- commons-codec
- commons-codec
- ${commons-codec.version}
-
-
- org.bouncycastle
- bcprov-jdk15on
- ${bouncycastle.version}
-
-
- 1.60
- 1.11
-
3.10.0
diff --git a/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/DigestAlgorithms.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/DigestAlgorithms.java
deleted file mode 100644
index 94dd22ff4b..0000000000
--- a/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/DigestAlgorithms.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.baeldung.hashing;
-
-public class DigestAlgorithms {
-
- public static final String SHA3_256 = "SHA3-256";
- public static final String SHA_256 = "SHA-256";
- public static final String KECCAK_256 = "Keccak-256";
-
-}
diff --git a/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/Keccak256Hashing.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/Keccak256Hashing.java
deleted file mode 100644
index 19fc4cf059..0000000000
--- a/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/Keccak256Hashing.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.baeldung.hashing;
-
-import org.bouncycastle.jcajce.provider.digest.Keccak;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.bouncycastle.util.encoders.Hex;
-
-import java.nio.charset.StandardCharsets;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.Security;
-
-import static com.baeldung.hashing.DigestAlgorithms.KECCAK_256;
-import static com.baeldung.hashing.SHACommonUtils.bytesToHex;
-
-public class Keccak256Hashing {
-
- public static String hashWithJavaMessageDigest(final String originalString) throws NoSuchAlgorithmException {
- Security.addProvider(new BouncyCastleProvider());
- final MessageDigest digest = MessageDigest.getInstance(KECCAK_256);
- final byte[] encodedhash = digest.digest(originalString.getBytes(StandardCharsets.UTF_8));
- return bytesToHex(encodedhash);
- }
-
- public static String hashWithBouncyCastle(final String originalString) {
- Keccak.Digest256 digest256 = new Keccak.Digest256();
- byte[] hashbytes = digest256.digest(originalString.getBytes(StandardCharsets.UTF_8));
- return new String(Hex.encode(hashbytes));
- }
-
-}
diff --git a/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHA256Hashing.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHA256Hashing.java
deleted file mode 100644
index ec008cebab..0000000000
--- a/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHA256Hashing.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.baeldung.hashing;
-
-import com.google.common.hash.Hashing;
-import org.apache.commons.codec.digest.DigestUtils;
-import org.bouncycastle.util.encoders.Hex;
-
-import java.nio.charset.StandardCharsets;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-import static com.baeldung.hashing.DigestAlgorithms.SHA_256;
-import static com.baeldung.hashing.SHACommonUtils.bytesToHex;
-
-public class SHA256Hashing {
-
- public static String HashWithJavaMessageDigest(final String originalString) throws NoSuchAlgorithmException {
- final MessageDigest digest = MessageDigest.getInstance(SHA_256);
- final byte[] encodedhash = digest.digest(originalString.getBytes(StandardCharsets.UTF_8));
- return bytesToHex(encodedhash);
- }
-
- public static String hashWithGuava(final String originalString) {
- final String sha256hex = Hashing.sha256().hashString(originalString, StandardCharsets.UTF_8).toString();
- return sha256hex;
- }
-
- public static String HashWithApacheCommons(final String originalString) {
- final String sha256hex = DigestUtils.sha256Hex(originalString);
- return sha256hex;
- }
-
- public static String HashWithBouncyCastle(final String originalString) throws NoSuchAlgorithmException {
- final MessageDigest digest = MessageDigest.getInstance(SHA_256);
- final byte[] hash = digest.digest(originalString.getBytes(StandardCharsets.UTF_8));
- final String sha256hex = new String(Hex.encode(hash));
- return sha256hex;
- }
-
-}
diff --git a/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHA3Hashing.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHA3Hashing.java
deleted file mode 100644
index eb363205b1..0000000000
--- a/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHA3Hashing.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.baeldung.hashing;
-
-import com.google.common.hash.Hashing;
-import org.apache.commons.codec.digest.DigestUtils;
-import org.bouncycastle.crypto.digests.SHA3Digest;
-import org.bouncycastle.jcajce.provider.digest.SHA3;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.bouncycastle.util.encoders.Hex;
-
-import java.nio.charset.StandardCharsets;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.Security;
-
-import static com.baeldung.hashing.DigestAlgorithms.SHA3_256;
-import static com.baeldung.hashing.SHACommonUtils.bytesToHex;
-
-public class SHA3Hashing {
-
- /* works with JDK9+ only */
- public static String hashWithJavaMessageDigestJDK9(final String originalString) throws NoSuchAlgorithmException {
- final MessageDigest digest = MessageDigest.getInstance(SHA3_256);
- final byte[] hashbytes = digest.digest(originalString.getBytes(StandardCharsets.UTF_8));
- return bytesToHex(hashbytes);
- }
-
- public static String hashWithJavaMessageDigest(final String originalString) throws NoSuchAlgorithmException {
- Security.addProvider(new BouncyCastleProvider());
- final MessageDigest digest = MessageDigest.getInstance(SHA3_256);
- final byte[] hashbytes = digest.digest(originalString.getBytes(StandardCharsets.UTF_8));
- return bytesToHex(hashbytes);
- }
-
- /* works with JDK9+ only */
- public static String hashWithApacheCommonsJDK9(final String originalString) {
- return new DigestUtils(SHA3_256).digestAsHex(originalString);
- }
-
- public static String hashWithBouncyCastle(final String originalString) {
- SHA3.Digest256 digest256 = new SHA3.Digest256();
- byte[] hashbytes = digest256.digest(originalString.getBytes(StandardCharsets.UTF_8));
- return new String(Hex.encode(hashbytes));
- }
-
-}
diff --git a/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHACommonUtils.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHACommonUtils.java
deleted file mode 100644
index 0f28408083..0000000000
--- a/core-java-modules/core-java-security/src/main/java/com/baeldung/hashing/SHACommonUtils.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.baeldung.hashing;
-
-class SHACommonUtils {
-
- public static String bytesToHex(byte[] hash) {
- StringBuffer hexString = new StringBuffer();
- for (byte h : hash) {
- String hex = Integer.toHexString(0xff & h);
- if (hex.length() == 1)
- hexString.append('0');
- hexString.append(hex);
- }
- return hexString.toString();
- }
-
-}
diff --git a/core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/PBKDF2Hasher.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/PBKDF2Hasher.java
deleted file mode 100644
index e2259e4249..0000000000
--- a/core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/PBKDF2Hasher.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package com.baeldung.passwordhashing;
-
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.KeySpec;
-import java.util.Arrays;
-import java.util.Base64;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.crypto.SecretKeyFactory;
-import javax.crypto.spec.PBEKeySpec;
-
-/**
- * Hash passwords for storage, and test passwords against password tokens.
- *
- * Instances of this class can be used concurrently by multiple threads.
- *
- * @author erickson
- * @see StackOverflow
- */
-public final class PBKDF2Hasher
-{
-
- /**
- * Each token produced by this class uses this identifier as a prefix.
- */
- public static final String ID = "$31$";
-
- /**
- * The minimum recommended cost, used by default
- */
- public static final int DEFAULT_COST = 16;
-
- private static final String ALGORITHM = "PBKDF2WithHmacSHA1";
-
- private static final int SIZE = 128;
-
- private static final Pattern layout = Pattern.compile("\\$31\\$(\\d\\d?)\\$(.{43})");
-
- private final SecureRandom random;
-
- private final int cost;
-
- public PBKDF2Hasher()
- {
- this(DEFAULT_COST);
- }
-
- /**
- * Create a password manager with a specified cost
- *
- * @param cost the exponential computational cost of hashing a password, 0 to 30
- */
- public PBKDF2Hasher(int cost)
- {
- iterations(cost); /* Validate cost */
- this.cost = cost;
- this.random = new SecureRandom();
- }
-
- private static int iterations(int cost)
- {
- if ((cost < 0) || (cost > 30))
- throw new IllegalArgumentException("cost: " + cost);
- return 1 << cost;
- }
-
- /**
- * Hash a password for storage.
- *
- * @return a secure authentication token to be stored for later authentication
- */
- public String hash(char[] password)
- {
- byte[] salt = new byte[SIZE / 8];
- random.nextBytes(salt);
- byte[] dk = pbkdf2(password, salt, 1 << cost);
- byte[] hash = new byte[salt.length + dk.length];
- System.arraycopy(salt, 0, hash, 0, salt.length);
- System.arraycopy(dk, 0, hash, salt.length, dk.length);
- Base64.Encoder enc = Base64.getUrlEncoder().withoutPadding();
- return ID + cost + '$' + enc.encodeToString(hash);
- }
-
- /**
- * Authenticate with a password and a stored password token.
- *
- * @return true if the password and token match
- */
- public boolean checkPassword(char[] password, String token)
- {
- Matcher m = layout.matcher(token);
- if (!m.matches())
- throw new IllegalArgumentException("Invalid token format");
- int iterations = iterations(Integer.parseInt(m.group(1)));
- byte[] hash = Base64.getUrlDecoder().decode(m.group(2));
- byte[] salt = Arrays.copyOfRange(hash, 0, SIZE / 8);
- byte[] check = pbkdf2(password, salt, iterations);
- int zero = 0;
- for (int idx = 0; idx < check.length; ++idx)
- zero |= hash[salt.length + idx] ^ check[idx];
- return zero == 0;
- }
-
- private static byte[] pbkdf2(char[] password, byte[] salt, int iterations)
- {
- KeySpec spec = new PBEKeySpec(password, salt, iterations, SIZE);
- try {
- SecretKeyFactory f = SecretKeyFactory.getInstance(ALGORITHM);
- return f.generateSecret(spec).getEncoded();
- }
- catch (NoSuchAlgorithmException ex) {
- throw new IllegalStateException("Missing algorithm: " + ALGORITHM, ex);
- }
- catch (InvalidKeySpecException ex) {
- throw new IllegalStateException("Invalid SecretKeyFactory", ex);
- }
- }
-
- /**
- * Hash a password in an immutable {@code String}.
- *
- * Passwords should be stored in a {@code char[]} so that it can be filled
- * with zeros after use instead of lingering on the heap and elsewhere.
- *
- * @deprecated Use {@link #hash(char[])} instead
- */
- @Deprecated
- public String hash(String password)
- {
- return hash(password.toCharArray());
- }
-
- /**
- * Authenticate with a password in an immutable {@code String} and a stored
- * password token.
- *
- * @deprecated Use {@link #checkPassword(char[],String)} instead.
- * @see #hash(String)
- */
- @Deprecated
- public boolean checkPassword(String password, String token)
- {
- return checkPassword(password.toCharArray(), token);
- }
-
-}
diff --git a/core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/SHA512Hasher.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/SHA512Hasher.java
deleted file mode 100644
index 4f5337f963..0000000000
--- a/core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/SHA512Hasher.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.baeldung.passwordhashing;
-
-import java.nio.charset.StandardCharsets;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-
-/** A really simple SHA_512 Encryption example.
- *
- */
-public class SHA512Hasher {
-
- public String hash(String passwordToHash, byte[] salt){
- String generatedPassword = null;
- try {
- MessageDigest md = MessageDigest.getInstance("SHA-512");
- md.update(salt);
- byte[] bytes = md.digest(passwordToHash.getBytes(StandardCharsets.UTF_8));
- StringBuilder sb = new StringBuilder();
- for(int i=0; i< bytes.length ;i++){
- sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));
- }
- generatedPassword = sb.toString();
- }
- catch (NoSuchAlgorithmException e){
- e.printStackTrace();
- }
- return generatedPassword;
- }
-
- public boolean checkPassword(String hash, String attempt, byte[] salt){
- String generatedHash = hash(attempt, salt);
- return hash.equals(generatedHash);
- }
-}
diff --git a/core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/SimplePBKDF2Hasher.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/SimplePBKDF2Hasher.java
deleted file mode 100644
index 36c9b65070..0000000000
--- a/core-java-modules/core-java-security/src/main/java/com/baeldung/passwordhashing/SimplePBKDF2Hasher.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.baeldung.passwordhashing;
-
-import javax.crypto.SecretKeyFactory;
-import javax.crypto.spec.PBEKeySpec;
-import java.security.spec.KeySpec;
-
-/** A really simple SimplePBKDF2 Encryption example.
- *
- */
-public class SimplePBKDF2Hasher {
-
- public static String hashSimple(String password, byte[] salt) throws Exception{
- KeySpec spec = new PBEKeySpec(password.toCharArray(), salt, 65536, 128);
- SecretKeyFactory f = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
- byte[] hash = f.generateSecret(spec).getEncoded();
- return String.valueOf(hash);
- }
-}
diff --git a/core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/Keccak256HashingUnitTest.java b/core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/Keccak256HashingUnitTest.java
deleted file mode 100644
index 9ed35c8834..0000000000
--- a/core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/Keccak256HashingUnitTest.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.baeldung.hashing;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class Keccak256HashingUnitTest {
-
- private static String originalValue = "abc123";
- private static String hashedValue = "719accc61a9cc126830e5906f9d672d06eab6f8597287095a2c55a8b775e7016";
-
- @Test public void testHashWithJavaMessageDigest() throws Exception {
- final String currentHashedValue = Keccak256Hashing.hashWithJavaMessageDigest(originalValue);
- assertEquals(hashedValue, currentHashedValue);
- }
-
- @Test public void testHashWithBouncyCastle() {
- final String currentHashedValue = Keccak256Hashing.hashWithBouncyCastle(originalValue);
- assertEquals(hashedValue, currentHashedValue);
- }
-
-}
diff --git a/core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/SHA256HashingUnitTest.java b/core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/SHA256HashingUnitTest.java
deleted file mode 100644
index 6bc9ad2cc6..0000000000
--- a/core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/SHA256HashingUnitTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.baeldung.hashing;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class SHA256HashingUnitTest {
-
- private static String originalValue = "abc123";
- private static String hashedValue = "6ca13d52ca70c883e0f0bb101e425a89e8624de51db2d2392593af6a84118090";
-
- @Test
- public void testHashWithJavaMessageDigest() throws Exception {
- final String currentHashedValue = SHA256Hashing.HashWithJavaMessageDigest(originalValue);
- assertEquals(hashedValue, currentHashedValue);
- }
-
- @Test
- public void testHashWithGuava() throws Exception {
- final String currentHashedValue = SHA256Hashing.hashWithGuava(originalValue);
- assertEquals(hashedValue, currentHashedValue);
- }
-
- @Test
- public void testHashWithApacheCommans() throws Exception {
- final String currentHashedValue = SHA256Hashing.HashWithApacheCommons(originalValue);
- assertEquals(hashedValue, currentHashedValue);
- }
-
- @Test
- public void testHashWithBouncyCastle() throws Exception {
- final String currentHashedValue = SHA256Hashing.HashWithBouncyCastle(originalValue);
- assertEquals(hashedValue, currentHashedValue);
- }
-}
\ No newline at end of file
diff --git a/core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/SHA3HashingUnitTest.java b/core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/SHA3HashingUnitTest.java
deleted file mode 100644
index fffab96405..0000000000
--- a/core-java-modules/core-java-security/src/test/java/com/baeldung/hashing/SHA3HashingUnitTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.baeldung.hashing;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class SHA3HashingUnitTest {
-
- private static String originalValue = "abc123";
- private static String hashedValue = "f58fa3df820114f56e1544354379820cff464c9c41cb3ca0ad0b0843c9bb67ee";
-
- /* works with JDK9+ only */
- //@Test
- public void testHashWithJavaMessageDigestJDK9() throws Exception {
- final String currentHashedValue = SHA3Hashing.hashWithJavaMessageDigestJDK9(originalValue);
- assertEquals(hashedValue, currentHashedValue);
- }
-
- @Test
- public void testHashWithJavaMessageDigest() throws Exception {
- final String currentHashedValue = SHA3Hashing.hashWithJavaMessageDigest(originalValue);
- assertEquals(hashedValue, currentHashedValue);
- }
-
- /* works with JDK9+ only */
- //@Test
- public void testHashWithApacheCommonsJDK9() {
- final String currentHashedValue = SHA3Hashing.hashWithApacheCommonsJDK9(originalValue);
- assertEquals(hashedValue, currentHashedValue);
- }
-
- @Test
- public void testHashWithBouncyCastle() {
- final String currentHashedValue = SHA3Hashing.hashWithBouncyCastle(originalValue);
- assertEquals(hashedValue, currentHashedValue);
- }
-
-}
diff --git a/core-java-modules/core-java-security/src/test/java/com/baeldung/java/md5/JavaMD5UnitTest.java b/core-java-modules/core-java-security/src/test/java/com/baeldung/java/md5/JavaMD5UnitTest.java
deleted file mode 100644
index 67d6918c09..0000000000
--- a/core-java-modules/core-java-security/src/test/java/com/baeldung/java/md5/JavaMD5UnitTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package com.baeldung.java.md5;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-import javax.xml.bind.DatatypeConverter;
-
-import org.apache.commons.codec.digest.DigestUtils;
-import org.junit.Test;
-
-import com.google.common.hash.HashCode;
-import com.google.common.hash.Hashing;
-
-public class JavaMD5UnitTest {
-
- String filename = "src/test/resources/test_md5.txt";
- String checksum = "5EB63BBBE01EEED093CB22BB8F5ACDC3";
-
- String hash = "35454B055CC325EA1AF2126E27707052";
- String password = "ILoveJava";
-
- @Test
- public void givenPassword_whenHashing_thenVerifying() throws NoSuchAlgorithmException {
- String hash = "35454B055CC325EA1AF2126E27707052";
- String password = "ILoveJava";
-
- MessageDigest md = MessageDigest.getInstance("MD5");
- md.update(password.getBytes());
- byte[] digest = md.digest();
- String myHash = DatatypeConverter.printHexBinary(digest).toUpperCase();
-
- assertThat(myHash.equals(hash)).isTrue();
- }
-
- @Test
- public void givenFile_generatingChecksum_thenVerifying() throws NoSuchAlgorithmException, IOException {
- String filename = "src/test/resources/test_md5.txt";
- String checksum = "5EB63BBBE01EEED093CB22BB8F5ACDC3";
-
- MessageDigest md = MessageDigest.getInstance("MD5");
- md.update(Files.readAllBytes(Paths.get(filename)));
- byte[] digest = md.digest();
- String myChecksum = DatatypeConverter.printHexBinary(digest).toUpperCase();
-
- assertThat(myChecksum.equals(checksum)).isTrue();
- }
-
- @Test
- public void givenPassword_whenHashingUsingCommons_thenVerifying() {
- String hash = "35454B055CC325EA1AF2126E27707052";
- String password = "ILoveJava";
-
- String md5Hex = DigestUtils.md5Hex(password).toUpperCase();
-
- assertThat(md5Hex.equals(hash)).isTrue();
- }
-
- @Test
- public void givenFile_whenChecksumUsingGuava_thenVerifying() throws IOException {
- String filename = "src/test/resources/test_md5.txt";
- String checksum = "5EB63BBBE01EEED093CB22BB8F5ACDC3";
-
- HashCode hash = com.google.common.io.Files.hash(new File(filename), Hashing.md5());
- String myChecksum = hash.toString().toUpperCase();
-
- assertThat(myChecksum.equals(checksum)).isTrue();
- }
-
-}
diff --git a/core-java-modules/core-java-security/src/test/java/com/baeldung/passwordhashing/PBKDF2HasherUnitTest.java b/core-java-modules/core-java-security/src/test/java/com/baeldung/passwordhashing/PBKDF2HasherUnitTest.java
deleted file mode 100644
index 8e90725c77..0000000000
--- a/core-java-modules/core-java-security/src/test/java/com/baeldung/passwordhashing/PBKDF2HasherUnitTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.baeldung.passwordhashing;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-
-public class PBKDF2HasherUnitTest {
-
- private PBKDF2Hasher mPBKDF2Hasher;
-
- @Before
- public void setUp() throws Exception {
- mPBKDF2Hasher = new PBKDF2Hasher();
- }
-
- @Test
- public void givenCorrectMessageAndHash_whenAuthenticated_checkAuthenticationSucceeds() throws Exception {
- String message1 = "password123";
-
- String hash1 = mPBKDF2Hasher.hash(message1.toCharArray());
-
- assertTrue(mPBKDF2Hasher.checkPassword(message1.toCharArray(), hash1));
-
- }
-
- @Test
- public void givenWrongMessage_whenAuthenticated_checkAuthenticationFails() throws Exception {
- String message1 = "password123";
-
- String hash1 = mPBKDF2Hasher.hash(message1.toCharArray());
-
- String wrongPasswordAttempt = "IamWrong";
-
- assertFalse(mPBKDF2Hasher.checkPassword(wrongPasswordAttempt.toCharArray(), hash1));
-
- }
-
-
-}
\ No newline at end of file
diff --git a/core-java-modules/core-java-security/src/test/java/com/baeldung/passwordhashing/SHA512HasherUnitTest.java b/core-java-modules/core-java-security/src/test/java/com/baeldung/passwordhashing/SHA512HasherUnitTest.java
deleted file mode 100644
index 3acfb0ba9d..0000000000
--- a/core-java-modules/core-java-security/src/test/java/com/baeldung/passwordhashing/SHA512HasherUnitTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package com.baeldung.passwordhashing;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import java.security.SecureRandom;
-
-import static org.junit.Assert.*;
-
-/**
- * Created by PhysicsSam on 06-Sep-18.
- */
-public class SHA512HasherUnitTest {
-
- private SHA512Hasher hasher;
- private SecureRandom secureRandom;
-
- @Before
- public void setUp() throws Exception {
- hasher = new SHA512Hasher();
- secureRandom = new SecureRandom();
- }
-
- @Test
- public void givenSamePasswordAndSalt_whenHashed_checkResultingHashesAreEqual() throws Exception {
-
- byte[] salt = new byte[16];
- secureRandom.nextBytes(salt);
-
- String hash1 = hasher.hash("password", salt);
- String hash2 = hasher.hash("password", salt);
-
- assertEquals(hash1, hash2);
-
- }
-
- @Test
- public void givenSamePasswordAndDifferentSalt_whenHashed_checkResultingHashesNotEqual() throws Exception {
-
- byte[] salt = new byte[16];
- secureRandom.nextBytes(salt);
- String hash1 = hasher.hash("password", salt);
- //generate a second salt
- byte[] secondSalt = new byte[16];
- String hash2 = hasher.hash("password", secondSalt);
-
- assertNotEquals(hash1, hash2);
-
- }
-
- @Test
- public void givenPredefinedHash_whenCorrectAttemptGiven_checkAuthenticationSucceeds() throws Exception {
- byte[] salt = new byte[16];
- secureRandom.nextBytes(salt);
-
- String originalHash = hasher.hash("password123", salt);
-
- assertTrue(hasher.checkPassword(originalHash, "password123", salt));
- }
-
- @Test
- public void givenPredefinedHash_whenIncorrectAttemptGiven_checkAuthenticationFails() throws Exception {
- byte[] salt = new byte[16];
- secureRandom.nextBytes(salt);
-
- String originalHash = hasher.hash("password123", salt);
-
- assertFalse(hasher.checkPassword(originalHash, "password124", salt));
- }
-}
\ No newline at end of file
diff --git a/core-java-modules/core-java-security/src/test/resources/test_md5.txt b/core-java-modules/core-java-security/src/test/resources/test_md5.txt
deleted file mode 100644
index 95d09f2b10..0000000000
--- a/core-java-modules/core-java-security/src/test/resources/test_md5.txt
+++ /dev/null
@@ -1 +0,0 @@
-hello world
\ No newline at end of file
From a4c37bd9dd2011fd608f802f2083d27e9d730490 Mon Sep 17 00:00:00 2001
From: sampadawagde
Date: Sat, 28 Mar 2020 16:48:43 +0530
Subject: [PATCH 29/87] JAVA-623: Moved 3 articles to core-java-security-2
---
.../core-java-security-2/README.md | 8 +
.../core-java-security-2/pom.xml | 30 ++++
.../baeldung/hashing/DigestAlgorithms.java | 9 ++
.../baeldung/hashing/Keccak256Hashing.java | 30 ++++
.../com/baeldung/hashing/SHA256Hashing.java | 39 +++++
.../com/baeldung/hashing/SHA3Hashing.java | 45 ++++++
.../com/baeldung/hashing/SHACommonUtils.java | 16 ++
.../passwordhashing/PBKDF2Hasher.java | 149 ++++++++++++++++++
.../passwordhashing/SHA512Hasher.java | 35 ++++
.../passwordhashing/SimplePBKDF2Hasher.java | 18 +++
.../hashing/Keccak256HashingUnitTest.java | 22 +++
.../hashing/SHA256HashingUnitTest.java | 35 ++++
.../baeldung/hashing/SHA3HashingUnitTest.java | 38 +++++
.../baeldung/java/md5/JavaMD5UnitTest.java | 75 +++++++++
.../passwordhashing/PBKDF2HasherUnitTest.java | 41 +++++
.../passwordhashing/SHA512HasherUnitTest.java | 70 ++++++++
.../src/test/resources/test_md5.txt | 1 +
17 files changed, 661 insertions(+)
create mode 100644 core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/DigestAlgorithms.java
create mode 100644 core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/Keccak256Hashing.java
create mode 100644 core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/SHA256Hashing.java
create mode 100644 core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/SHA3Hashing.java
create mode 100644 core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/SHACommonUtils.java
create mode 100644 core-java-modules/core-java-security-2/src/main/java/com/baeldung/passwordhashing/PBKDF2Hasher.java
create mode 100644 core-java-modules/core-java-security-2/src/main/java/com/baeldung/passwordhashing/SHA512Hasher.java
create mode 100644 core-java-modules/core-java-security-2/src/main/java/com/baeldung/passwordhashing/SimplePBKDF2Hasher.java
create mode 100644 core-java-modules/core-java-security-2/src/test/java/com/baeldung/hashing/Keccak256HashingUnitTest.java
create mode 100644 core-java-modules/core-java-security-2/src/test/java/com/baeldung/hashing/SHA256HashingUnitTest.java
create mode 100644 core-java-modules/core-java-security-2/src/test/java/com/baeldung/hashing/SHA3HashingUnitTest.java
create mode 100644 core-java-modules/core-java-security-2/src/test/java/com/baeldung/java/md5/JavaMD5UnitTest.java
create mode 100644 core-java-modules/core-java-security-2/src/test/java/com/baeldung/passwordhashing/PBKDF2HasherUnitTest.java
create mode 100644 core-java-modules/core-java-security-2/src/test/java/com/baeldung/passwordhashing/SHA512HasherUnitTest.java
create mode 100644 core-java-modules/core-java-security-2/src/test/resources/test_md5.txt
diff --git a/core-java-modules/core-java-security-2/README.md b/core-java-modules/core-java-security-2/README.md
index c250e24078..2eb21fb77e 100644
--- a/core-java-modules/core-java-security-2/README.md
+++ b/core-java-modules/core-java-security-2/README.md
@@ -1,3 +1,11 @@
+## Core Java Security
+
+This module contains articles about core Java Security
+
### Relevant Articles:
- [Guide To The Java Authentication And Authorization Service (JAAS)](https://www.baeldung.com/java-authentication-authorization-service)
+- [MD5 Hashing in Java](http://www.baeldung.com/java-md5)
+- [Hashing a Password in Java](https://www.baeldung.com/java-password-hashing)
+- [SHA-256 and SHA3-256 Hashing in Java](https://www.baeldung.com/sha-256-hashing-java)
+- More articles: [[<-- prev]](/core-java-modules/core-java-security)
diff --git a/core-java-modules/core-java-security-2/pom.xml b/core-java-modules/core-java-security-2/pom.xml
index 23f0c5aab9..9315ab4af2 100644
--- a/core-java-modules/core-java-security-2/pom.xml
+++ b/core-java-modules/core-java-security-2/pom.xml
@@ -16,4 +16,34 @@
../../parent-java
+
+
+ commons-codec
+ commons-codec
+ ${commons-codec.version}
+
+
+
+ org.bouncycastle
+ bcprov-jdk15on
+ ${bouncycastle.version}
+
+
+
+
+ org.assertj
+ assertj-core
+ ${assertj-core.version}
+ test
+
+
+
+
+
+ 1.60
+ 1.11
+
+
+ 3.10.0
+
diff --git a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/DigestAlgorithms.java b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/DigestAlgorithms.java
new file mode 100644
index 0000000000..94dd22ff4b
--- /dev/null
+++ b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/DigestAlgorithms.java
@@ -0,0 +1,9 @@
+package com.baeldung.hashing;
+
+public class DigestAlgorithms {
+
+ public static final String SHA3_256 = "SHA3-256";
+ public static final String SHA_256 = "SHA-256";
+ public static final String KECCAK_256 = "Keccak-256";
+
+}
diff --git a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/Keccak256Hashing.java b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/Keccak256Hashing.java
new file mode 100644
index 0000000000..19fc4cf059
--- /dev/null
+++ b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/Keccak256Hashing.java
@@ -0,0 +1,30 @@
+package com.baeldung.hashing;
+
+import org.bouncycastle.jcajce.provider.digest.Keccak;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.bouncycastle.util.encoders.Hex;
+
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.Security;
+
+import static com.baeldung.hashing.DigestAlgorithms.KECCAK_256;
+import static com.baeldung.hashing.SHACommonUtils.bytesToHex;
+
+public class Keccak256Hashing {
+
+ public static String hashWithJavaMessageDigest(final String originalString) throws NoSuchAlgorithmException {
+ Security.addProvider(new BouncyCastleProvider());
+ final MessageDigest digest = MessageDigest.getInstance(KECCAK_256);
+ final byte[] encodedhash = digest.digest(originalString.getBytes(StandardCharsets.UTF_8));
+ return bytesToHex(encodedhash);
+ }
+
+ public static String hashWithBouncyCastle(final String originalString) {
+ Keccak.Digest256 digest256 = new Keccak.Digest256();
+ byte[] hashbytes = digest256.digest(originalString.getBytes(StandardCharsets.UTF_8));
+ return new String(Hex.encode(hashbytes));
+ }
+
+}
diff --git a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/SHA256Hashing.java b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/SHA256Hashing.java
new file mode 100644
index 0000000000..ec008cebab
--- /dev/null
+++ b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/SHA256Hashing.java
@@ -0,0 +1,39 @@
+package com.baeldung.hashing;
+
+import com.google.common.hash.Hashing;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.bouncycastle.util.encoders.Hex;
+
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+import static com.baeldung.hashing.DigestAlgorithms.SHA_256;
+import static com.baeldung.hashing.SHACommonUtils.bytesToHex;
+
+public class SHA256Hashing {
+
+ public static String HashWithJavaMessageDigest(final String originalString) throws NoSuchAlgorithmException {
+ final MessageDigest digest = MessageDigest.getInstance(SHA_256);
+ final byte[] encodedhash = digest.digest(originalString.getBytes(StandardCharsets.UTF_8));
+ return bytesToHex(encodedhash);
+ }
+
+ public static String hashWithGuava(final String originalString) {
+ final String sha256hex = Hashing.sha256().hashString(originalString, StandardCharsets.UTF_8).toString();
+ return sha256hex;
+ }
+
+ public static String HashWithApacheCommons(final String originalString) {
+ final String sha256hex = DigestUtils.sha256Hex(originalString);
+ return sha256hex;
+ }
+
+ public static String HashWithBouncyCastle(final String originalString) throws NoSuchAlgorithmException {
+ final MessageDigest digest = MessageDigest.getInstance(SHA_256);
+ final byte[] hash = digest.digest(originalString.getBytes(StandardCharsets.UTF_8));
+ final String sha256hex = new String(Hex.encode(hash));
+ return sha256hex;
+ }
+
+}
diff --git a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/SHA3Hashing.java b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/SHA3Hashing.java
new file mode 100644
index 0000000000..eb363205b1
--- /dev/null
+++ b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/SHA3Hashing.java
@@ -0,0 +1,45 @@
+package com.baeldung.hashing;
+
+import com.google.common.hash.Hashing;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.bouncycastle.crypto.digests.SHA3Digest;
+import org.bouncycastle.jcajce.provider.digest.SHA3;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.bouncycastle.util.encoders.Hex;
+
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.Security;
+
+import static com.baeldung.hashing.DigestAlgorithms.SHA3_256;
+import static com.baeldung.hashing.SHACommonUtils.bytesToHex;
+
+public class SHA3Hashing {
+
+ /* works with JDK9+ only */
+ public static String hashWithJavaMessageDigestJDK9(final String originalString) throws NoSuchAlgorithmException {
+ final MessageDigest digest = MessageDigest.getInstance(SHA3_256);
+ final byte[] hashbytes = digest.digest(originalString.getBytes(StandardCharsets.UTF_8));
+ return bytesToHex(hashbytes);
+ }
+
+ public static String hashWithJavaMessageDigest(final String originalString) throws NoSuchAlgorithmException {
+ Security.addProvider(new BouncyCastleProvider());
+ final MessageDigest digest = MessageDigest.getInstance(SHA3_256);
+ final byte[] hashbytes = digest.digest(originalString.getBytes(StandardCharsets.UTF_8));
+ return bytesToHex(hashbytes);
+ }
+
+ /* works with JDK9+ only */
+ public static String hashWithApacheCommonsJDK9(final String originalString) {
+ return new DigestUtils(SHA3_256).digestAsHex(originalString);
+ }
+
+ public static String hashWithBouncyCastle(final String originalString) {
+ SHA3.Digest256 digest256 = new SHA3.Digest256();
+ byte[] hashbytes = digest256.digest(originalString.getBytes(StandardCharsets.UTF_8));
+ return new String(Hex.encode(hashbytes));
+ }
+
+}
diff --git a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/SHACommonUtils.java b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/SHACommonUtils.java
new file mode 100644
index 0000000000..0f28408083
--- /dev/null
+++ b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/hashing/SHACommonUtils.java
@@ -0,0 +1,16 @@
+package com.baeldung.hashing;
+
+class SHACommonUtils {
+
+ public static String bytesToHex(byte[] hash) {
+ StringBuffer hexString = new StringBuffer();
+ for (byte h : hash) {
+ String hex = Integer.toHexString(0xff & h);
+ if (hex.length() == 1)
+ hexString.append('0');
+ hexString.append(hex);
+ }
+ return hexString.toString();
+ }
+
+}
diff --git a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/passwordhashing/PBKDF2Hasher.java b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/passwordhashing/PBKDF2Hasher.java
new file mode 100644
index 0000000000..e2259e4249
--- /dev/null
+++ b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/passwordhashing/PBKDF2Hasher.java
@@ -0,0 +1,149 @@
+package com.baeldung.passwordhashing;
+
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.KeySpec;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+
+/**
+ * Hash passwords for storage, and test passwords against password tokens.
+ *
+ * Instances of this class can be used concurrently by multiple threads.
+ *
+ * @author erickson
+ * @see StackOverflow
+ */
+public final class PBKDF2Hasher
+{
+
+ /**
+ * Each token produced by this class uses this identifier as a prefix.
+ */
+ public static final String ID = "$31$";
+
+ /**
+ * The minimum recommended cost, used by default
+ */
+ public static final int DEFAULT_COST = 16;
+
+ private static final String ALGORITHM = "PBKDF2WithHmacSHA1";
+
+ private static final int SIZE = 128;
+
+ private static final Pattern layout = Pattern.compile("\\$31\\$(\\d\\d?)\\$(.{43})");
+
+ private final SecureRandom random;
+
+ private final int cost;
+
+ public PBKDF2Hasher()
+ {
+ this(DEFAULT_COST);
+ }
+
+ /**
+ * Create a password manager with a specified cost
+ *
+ * @param cost the exponential computational cost of hashing a password, 0 to 30
+ */
+ public PBKDF2Hasher(int cost)
+ {
+ iterations(cost); /* Validate cost */
+ this.cost = cost;
+ this.random = new SecureRandom();
+ }
+
+ private static int iterations(int cost)
+ {
+ if ((cost < 0) || (cost > 30))
+ throw new IllegalArgumentException("cost: " + cost);
+ return 1 << cost;
+ }
+
+ /**
+ * Hash a password for storage.
+ *
+ * @return a secure authentication token to be stored for later authentication
+ */
+ public String hash(char[] password)
+ {
+ byte[] salt = new byte[SIZE / 8];
+ random.nextBytes(salt);
+ byte[] dk = pbkdf2(password, salt, 1 << cost);
+ byte[] hash = new byte[salt.length + dk.length];
+ System.arraycopy(salt, 0, hash, 0, salt.length);
+ System.arraycopy(dk, 0, hash, salt.length, dk.length);
+ Base64.Encoder enc = Base64.getUrlEncoder().withoutPadding();
+ return ID + cost + '$' + enc.encodeToString(hash);
+ }
+
+ /**
+ * Authenticate with a password and a stored password token.
+ *
+ * @return true if the password and token match
+ */
+ public boolean checkPassword(char[] password, String token)
+ {
+ Matcher m = layout.matcher(token);
+ if (!m.matches())
+ throw new IllegalArgumentException("Invalid token format");
+ int iterations = iterations(Integer.parseInt(m.group(1)));
+ byte[] hash = Base64.getUrlDecoder().decode(m.group(2));
+ byte[] salt = Arrays.copyOfRange(hash, 0, SIZE / 8);
+ byte[] check = pbkdf2(password, salt, iterations);
+ int zero = 0;
+ for (int idx = 0; idx < check.length; ++idx)
+ zero |= hash[salt.length + idx] ^ check[idx];
+ return zero == 0;
+ }
+
+ private static byte[] pbkdf2(char[] password, byte[] salt, int iterations)
+ {
+ KeySpec spec = new PBEKeySpec(password, salt, iterations, SIZE);
+ try {
+ SecretKeyFactory f = SecretKeyFactory.getInstance(ALGORITHM);
+ return f.generateSecret(spec).getEncoded();
+ }
+ catch (NoSuchAlgorithmException ex) {
+ throw new IllegalStateException("Missing algorithm: " + ALGORITHM, ex);
+ }
+ catch (InvalidKeySpecException ex) {
+ throw new IllegalStateException("Invalid SecretKeyFactory", ex);
+ }
+ }
+
+ /**
+ * Hash a password in an immutable {@code String}.
+ *
+ * Passwords should be stored in a {@code char[]} so that it can be filled
+ * with zeros after use instead of lingering on the heap and elsewhere.
+ *
+ * @deprecated Use {@link #hash(char[])} instead
+ */
+ @Deprecated
+ public String hash(String password)
+ {
+ return hash(password.toCharArray());
+ }
+
+ /**
+ * Authenticate with a password in an immutable {@code String} and a stored
+ * password token.
+ *
+ * @deprecated Use {@link #checkPassword(char[],String)} instead.
+ * @see #hash(String)
+ */
+ @Deprecated
+ public boolean checkPassword(String password, String token)
+ {
+ return checkPassword(password.toCharArray(), token);
+ }
+
+}
diff --git a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/passwordhashing/SHA512Hasher.java b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/passwordhashing/SHA512Hasher.java
new file mode 100644
index 0000000000..4f5337f963
--- /dev/null
+++ b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/passwordhashing/SHA512Hasher.java
@@ -0,0 +1,35 @@
+package com.baeldung.passwordhashing;
+
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+
+/** A really simple SHA_512 Encryption example.
+ *
+ */
+public class SHA512Hasher {
+
+ public String hash(String passwordToHash, byte[] salt){
+ String generatedPassword = null;
+ try {
+ MessageDigest md = MessageDigest.getInstance("SHA-512");
+ md.update(salt);
+ byte[] bytes = md.digest(passwordToHash.getBytes(StandardCharsets.UTF_8));
+ StringBuilder sb = new StringBuilder();
+ for(int i=0; i< bytes.length ;i++){
+ sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));
+ }
+ generatedPassword = sb.toString();
+ }
+ catch (NoSuchAlgorithmException e){
+ e.printStackTrace();
+ }
+ return generatedPassword;
+ }
+
+ public boolean checkPassword(String hash, String attempt, byte[] salt){
+ String generatedHash = hash(attempt, salt);
+ return hash.equals(generatedHash);
+ }
+}
diff --git a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/passwordhashing/SimplePBKDF2Hasher.java b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/passwordhashing/SimplePBKDF2Hasher.java
new file mode 100644
index 0000000000..36c9b65070
--- /dev/null
+++ b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/passwordhashing/SimplePBKDF2Hasher.java
@@ -0,0 +1,18 @@
+package com.baeldung.passwordhashing;
+
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+import java.security.spec.KeySpec;
+
+/** A really simple SimplePBKDF2 Encryption example.
+ *
+ */
+public class SimplePBKDF2Hasher {
+
+ public static String hashSimple(String password, byte[] salt) throws Exception{
+ KeySpec spec = new PBEKeySpec(password.toCharArray(), salt, 65536, 128);
+ SecretKeyFactory f = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
+ byte[] hash = f.generateSecret(spec).getEncoded();
+ return String.valueOf(hash);
+ }
+}
diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/hashing/Keccak256HashingUnitTest.java b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/hashing/Keccak256HashingUnitTest.java
new file mode 100644
index 0000000000..9ed35c8834
--- /dev/null
+++ b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/hashing/Keccak256HashingUnitTest.java
@@ -0,0 +1,22 @@
+package com.baeldung.hashing;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class Keccak256HashingUnitTest {
+
+ private static String originalValue = "abc123";
+ private static String hashedValue = "719accc61a9cc126830e5906f9d672d06eab6f8597287095a2c55a8b775e7016";
+
+ @Test public void testHashWithJavaMessageDigest() throws Exception {
+ final String currentHashedValue = Keccak256Hashing.hashWithJavaMessageDigest(originalValue);
+ assertEquals(hashedValue, currentHashedValue);
+ }
+
+ @Test public void testHashWithBouncyCastle() {
+ final String currentHashedValue = Keccak256Hashing.hashWithBouncyCastle(originalValue);
+ assertEquals(hashedValue, currentHashedValue);
+ }
+
+}
diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/hashing/SHA256HashingUnitTest.java b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/hashing/SHA256HashingUnitTest.java
new file mode 100644
index 0000000000..6bc9ad2cc6
--- /dev/null
+++ b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/hashing/SHA256HashingUnitTest.java
@@ -0,0 +1,35 @@
+package com.baeldung.hashing;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class SHA256HashingUnitTest {
+
+ private static String originalValue = "abc123";
+ private static String hashedValue = "6ca13d52ca70c883e0f0bb101e425a89e8624de51db2d2392593af6a84118090";
+
+ @Test
+ public void testHashWithJavaMessageDigest() throws Exception {
+ final String currentHashedValue = SHA256Hashing.HashWithJavaMessageDigest(originalValue);
+ assertEquals(hashedValue, currentHashedValue);
+ }
+
+ @Test
+ public void testHashWithGuava() throws Exception {
+ final String currentHashedValue = SHA256Hashing.hashWithGuava(originalValue);
+ assertEquals(hashedValue, currentHashedValue);
+ }
+
+ @Test
+ public void testHashWithApacheCommans() throws Exception {
+ final String currentHashedValue = SHA256Hashing.HashWithApacheCommons(originalValue);
+ assertEquals(hashedValue, currentHashedValue);
+ }
+
+ @Test
+ public void testHashWithBouncyCastle() throws Exception {
+ final String currentHashedValue = SHA256Hashing.HashWithBouncyCastle(originalValue);
+ assertEquals(hashedValue, currentHashedValue);
+ }
+}
\ No newline at end of file
diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/hashing/SHA3HashingUnitTest.java b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/hashing/SHA3HashingUnitTest.java
new file mode 100644
index 0000000000..fffab96405
--- /dev/null
+++ b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/hashing/SHA3HashingUnitTest.java
@@ -0,0 +1,38 @@
+package com.baeldung.hashing;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class SHA3HashingUnitTest {
+
+ private static String originalValue = "abc123";
+ private static String hashedValue = "f58fa3df820114f56e1544354379820cff464c9c41cb3ca0ad0b0843c9bb67ee";
+
+ /* works with JDK9+ only */
+ //@Test
+ public void testHashWithJavaMessageDigestJDK9() throws Exception {
+ final String currentHashedValue = SHA3Hashing.hashWithJavaMessageDigestJDK9(originalValue);
+ assertEquals(hashedValue, currentHashedValue);
+ }
+
+ @Test
+ public void testHashWithJavaMessageDigest() throws Exception {
+ final String currentHashedValue = SHA3Hashing.hashWithJavaMessageDigest(originalValue);
+ assertEquals(hashedValue, currentHashedValue);
+ }
+
+ /* works with JDK9+ only */
+ //@Test
+ public void testHashWithApacheCommonsJDK9() {
+ final String currentHashedValue = SHA3Hashing.hashWithApacheCommonsJDK9(originalValue);
+ assertEquals(hashedValue, currentHashedValue);
+ }
+
+ @Test
+ public void testHashWithBouncyCastle() {
+ final String currentHashedValue = SHA3Hashing.hashWithBouncyCastle(originalValue);
+ assertEquals(hashedValue, currentHashedValue);
+ }
+
+}
diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/java/md5/JavaMD5UnitTest.java b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/java/md5/JavaMD5UnitTest.java
new file mode 100644
index 0000000000..67d6918c09
--- /dev/null
+++ b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/java/md5/JavaMD5UnitTest.java
@@ -0,0 +1,75 @@
+package com.baeldung.java.md5;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+import javax.xml.bind.DatatypeConverter;
+
+import org.apache.commons.codec.digest.DigestUtils;
+import org.junit.Test;
+
+import com.google.common.hash.HashCode;
+import com.google.common.hash.Hashing;
+
+public class JavaMD5UnitTest {
+
+ String filename = "src/test/resources/test_md5.txt";
+ String checksum = "5EB63BBBE01EEED093CB22BB8F5ACDC3";
+
+ String hash = "35454B055CC325EA1AF2126E27707052";
+ String password = "ILoveJava";
+
+ @Test
+ public void givenPassword_whenHashing_thenVerifying() throws NoSuchAlgorithmException {
+ String hash = "35454B055CC325EA1AF2126E27707052";
+ String password = "ILoveJava";
+
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ md.update(password.getBytes());
+ byte[] digest = md.digest();
+ String myHash = DatatypeConverter.printHexBinary(digest).toUpperCase();
+
+ assertThat(myHash.equals(hash)).isTrue();
+ }
+
+ @Test
+ public void givenFile_generatingChecksum_thenVerifying() throws NoSuchAlgorithmException, IOException {
+ String filename = "src/test/resources/test_md5.txt";
+ String checksum = "5EB63BBBE01EEED093CB22BB8F5ACDC3";
+
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ md.update(Files.readAllBytes(Paths.get(filename)));
+ byte[] digest = md.digest();
+ String myChecksum = DatatypeConverter.printHexBinary(digest).toUpperCase();
+
+ assertThat(myChecksum.equals(checksum)).isTrue();
+ }
+
+ @Test
+ public void givenPassword_whenHashingUsingCommons_thenVerifying() {
+ String hash = "35454B055CC325EA1AF2126E27707052";
+ String password = "ILoveJava";
+
+ String md5Hex = DigestUtils.md5Hex(password).toUpperCase();
+
+ assertThat(md5Hex.equals(hash)).isTrue();
+ }
+
+ @Test
+ public void givenFile_whenChecksumUsingGuava_thenVerifying() throws IOException {
+ String filename = "src/test/resources/test_md5.txt";
+ String checksum = "5EB63BBBE01EEED093CB22BB8F5ACDC3";
+
+ HashCode hash = com.google.common.io.Files.hash(new File(filename), Hashing.md5());
+ String myChecksum = hash.toString().toUpperCase();
+
+ assertThat(myChecksum.equals(checksum)).isTrue();
+ }
+
+}
diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/passwordhashing/PBKDF2HasherUnitTest.java b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/passwordhashing/PBKDF2HasherUnitTest.java
new file mode 100644
index 0000000000..8e90725c77
--- /dev/null
+++ b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/passwordhashing/PBKDF2HasherUnitTest.java
@@ -0,0 +1,41 @@
+package com.baeldung.passwordhashing;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+public class PBKDF2HasherUnitTest {
+
+ private PBKDF2Hasher mPBKDF2Hasher;
+
+ @Before
+ public void setUp() throws Exception {
+ mPBKDF2Hasher = new PBKDF2Hasher();
+ }
+
+ @Test
+ public void givenCorrectMessageAndHash_whenAuthenticated_checkAuthenticationSucceeds() throws Exception {
+ String message1 = "password123";
+
+ String hash1 = mPBKDF2Hasher.hash(message1.toCharArray());
+
+ assertTrue(mPBKDF2Hasher.checkPassword(message1.toCharArray(), hash1));
+
+ }
+
+ @Test
+ public void givenWrongMessage_whenAuthenticated_checkAuthenticationFails() throws Exception {
+ String message1 = "password123";
+
+ String hash1 = mPBKDF2Hasher.hash(message1.toCharArray());
+
+ String wrongPasswordAttempt = "IamWrong";
+
+ assertFalse(mPBKDF2Hasher.checkPassword(wrongPasswordAttempt.toCharArray(), hash1));
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/passwordhashing/SHA512HasherUnitTest.java b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/passwordhashing/SHA512HasherUnitTest.java
new file mode 100644
index 0000000000..3acfb0ba9d
--- /dev/null
+++ b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/passwordhashing/SHA512HasherUnitTest.java
@@ -0,0 +1,70 @@
+package com.baeldung.passwordhashing;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.security.SecureRandom;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by PhysicsSam on 06-Sep-18.
+ */
+public class SHA512HasherUnitTest {
+
+ private SHA512Hasher hasher;
+ private SecureRandom secureRandom;
+
+ @Before
+ public void setUp() throws Exception {
+ hasher = new SHA512Hasher();
+ secureRandom = new SecureRandom();
+ }
+
+ @Test
+ public void givenSamePasswordAndSalt_whenHashed_checkResultingHashesAreEqual() throws Exception {
+
+ byte[] salt = new byte[16];
+ secureRandom.nextBytes(salt);
+
+ String hash1 = hasher.hash("password", salt);
+ String hash2 = hasher.hash("password", salt);
+
+ assertEquals(hash1, hash2);
+
+ }
+
+ @Test
+ public void givenSamePasswordAndDifferentSalt_whenHashed_checkResultingHashesNotEqual() throws Exception {
+
+ byte[] salt = new byte[16];
+ secureRandom.nextBytes(salt);
+ String hash1 = hasher.hash("password", salt);
+ //generate a second salt
+ byte[] secondSalt = new byte[16];
+ String hash2 = hasher.hash("password", secondSalt);
+
+ assertNotEquals(hash1, hash2);
+
+ }
+
+ @Test
+ public void givenPredefinedHash_whenCorrectAttemptGiven_checkAuthenticationSucceeds() throws Exception {
+ byte[] salt = new byte[16];
+ secureRandom.nextBytes(salt);
+
+ String originalHash = hasher.hash("password123", salt);
+
+ assertTrue(hasher.checkPassword(originalHash, "password123", salt));
+ }
+
+ @Test
+ public void givenPredefinedHash_whenIncorrectAttemptGiven_checkAuthenticationFails() throws Exception {
+ byte[] salt = new byte[16];
+ secureRandom.nextBytes(salt);
+
+ String originalHash = hasher.hash("password123", salt);
+
+ assertFalse(hasher.checkPassword(originalHash, "password124", salt));
+ }
+}
\ No newline at end of file
diff --git a/core-java-modules/core-java-security-2/src/test/resources/test_md5.txt b/core-java-modules/core-java-security-2/src/test/resources/test_md5.txt
new file mode 100644
index 0000000000..95d09f2b10
--- /dev/null
+++ b/core-java-modules/core-java-security-2/src/test/resources/test_md5.txt
@@ -0,0 +1 @@
+hello world
\ No newline at end of file
From d3dfce4d4415fe26f5d7372c9f344bf95a008b06 Mon Sep 17 00:00:00 2001
From: Krzysiek
Date: Sun, 29 Mar 2020 19:00:40 +0200
Subject: [PATCH 30/87] JAVA-43: Upgrade spring-security-modules to Spring Boot
2
---
spring-security-modules/spring-security-acl/pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/spring-security-modules/spring-security-acl/pom.xml b/spring-security-modules/spring-security-acl/pom.xml
index 3c613f9d92..5c04aaa9ca 100644
--- a/spring-security-modules/spring-security-acl/pom.xml
+++ b/spring-security-modules/spring-security-acl/pom.xml
@@ -10,9 +10,9 @@
com.baeldung
- parent-boot-1
+ parent-boot-2
0.0.1-SNAPSHOT
- ../../parent-boot-1
+ ../../parent-boot-2
From 313a2e05c40191274acfe85372e074eebc7d6dd3 Mon Sep 17 00:00:00 2001
From: Ali Dehghani
Date: Mon, 30 Mar 2020 01:29:02 +0430
Subject: [PATCH 31/87] Borrowing one Example from JCIP
---
.../volatilekeyword/TaskRunner.java | 25 +++++++++++++++++++
1 file changed, 25 insertions(+)
create mode 100644 core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/volatilekeyword/TaskRunner.java
diff --git a/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/volatilekeyword/TaskRunner.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/volatilekeyword/TaskRunner.java
new file mode 100644
index 0000000000..f0493d4911
--- /dev/null
+++ b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/volatilekeyword/TaskRunner.java
@@ -0,0 +1,25 @@
+package com.baeldung.concurrent.volatilekeyword;
+
+public class TaskRunner {
+
+ private static int number;
+ private volatile static boolean ready;
+
+ private static class Reader extends Thread {
+
+ @Override
+ public void run() {
+ while (!ready) {
+ Thread.yield();
+ }
+
+ System.out.println(number);
+ }
+ }
+
+ public static void main(String[] args) {
+ new Reader().start();
+ number = 42;
+ ready = true;
+ }
+}
From e9062fcedd25b9beef7e63a4cfd1c500920de09d Mon Sep 17 00:00:00 2001
From: Krzysiek
Date: Sun, 29 Mar 2020 23:54:31 +0200
Subject: [PATCH 32/87] JAVA-42: Upgrade spring-security-ldap to Spring Boot 2
---
.../spring-security-ldap/pom.xml | 8 +++++--
.../com/baeldung/SampleLDAPApplication.java | 13 +-----------
.../{security => config}/SecurityConfig.java | 21 +++++++++++++++----
.../java/com/baeldung/config/WebConfig.java | 16 ++++++++++++++
.../src/main/resources/application.properties | 1 +
.../src/main/resources/webSecurityConfig.xml | 1 +
6 files changed, 42 insertions(+), 18 deletions(-)
rename spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/{security => config}/SecurityConfig.java (53%)
create mode 100644 spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/config/WebConfig.java
create mode 100644 spring-security-modules/spring-security-ldap/src/main/resources/application.properties
diff --git a/spring-security-modules/spring-security-ldap/pom.xml b/spring-security-modules/spring-security-ldap/pom.xml
index f5e8856648..baed682186 100644
--- a/spring-security-modules/spring-security-ldap/pom.xml
+++ b/spring-security-modules/spring-security-ldap/pom.xml
@@ -9,9 +9,9 @@
com.baeldung
- parent-boot-1
+ parent-boot-2
0.0.1-SNAPSHOT
- ../../parent-boot-1
+ ../../parent-boot-2
@@ -21,6 +21,10 @@
org.springframework.boot
spring-boot-starter-security
+
+ org.springframework.boot
+ spring-boot-starter-web
+
org.springframework.boot
spring-boot-starter-thymeleaf
diff --git a/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/SampleLDAPApplication.java b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/SampleLDAPApplication.java
index ec585f2387..2d619cccfa 100644
--- a/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/SampleLDAPApplication.java
+++ b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/SampleLDAPApplication.java
@@ -2,7 +2,7 @@ package com.baeldung;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.web.support.SpringBootServletInitializer;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@@ -19,15 +19,4 @@ public class SampleLDAPApplication extends SpringBootServletInitializer {
SpringApplication.run(SampleLDAPApplication.class, args);
}
- @Bean
- public WebMvcConfigurerAdapter adapter() {
- return new WebMvcConfigurerAdapter() {
- @Override
- public void addViewControllers(ViewControllerRegistry registry) {
- registry.addViewController("/login")
- .setViewName("login");
- }
- };
- }
-
}
\ No newline at end of file
diff --git a/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/security/SecurityConfig.java b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/config/SecurityConfig.java
similarity index 53%
rename from spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/security/SecurityConfig.java
rename to spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/config/SecurityConfig.java
index a00cb02459..69f90d9de9 100644
--- a/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/security/SecurityConfig.java
+++ b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/config/SecurityConfig.java
@@ -1,4 +1,4 @@
-package com.baeldung.security;
+package com.baeldung.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
@@ -14,13 +14,26 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
- auth.ldapAuthentication().userSearchBase("ou=people").userSearchFilter("(uid={0})").groupSearchBase("ou=groups").groupSearchFilter("(member={0})").contextSource().root("dc=baeldung,dc=com").ldif("classpath:users.ldif");
+ auth.ldapAuthentication()
+ .userSearchBase("ou=people")
+ .userSearchFilter("(uid={0})")
+ .groupSearchBase("ou=groups")
+ .groupSearchFilter("(member={0})")
+ .contextSource()
+ .root("dc=baeldung,dc=com")
+ .ldif("classpath:users.ldif");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
- http.authorizeRequests().antMatchers("/", "/home").permitAll().anyRequest().authenticated();
- http.formLogin().loginPage("/login").permitAll().and().logout().logoutSuccessUrl("/");
+ http
+ .authorizeRequests()
+ .antMatchers("/", "/home", "/css/**")
+ .permitAll()
+ .anyRequest()
+ .authenticated()
+ .and().formLogin().loginPage("/login").permitAll()
+ .and().logout().logoutSuccessUrl("/");
}
}
diff --git a/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/config/WebConfig.java b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/config/WebConfig.java
new file mode 100644
index 0000000000..9809be1844
--- /dev/null
+++ b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/config/WebConfig.java
@@ -0,0 +1,16 @@
+package com.baeldung.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@Configuration
+public class WebConfig implements WebMvcConfigurer {
+
+ @Override
+ public void addViewControllers(ViewControllerRegistry registry) {
+ registry.addViewController("/login")
+ .setViewName("login");
+ }
+}
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
new file mode 100644
index 0000000000..3d0221bb7b
--- /dev/null
+++ b/spring-security-modules/spring-security-ldap/src/main/resources/application.properties
@@ -0,0 +1 @@
+management.health.ldap.enabled=false
\ No newline at end of file
diff --git a/spring-security-modules/spring-security-ldap/src/main/resources/webSecurityConfig.xml b/spring-security-modules/spring-security-ldap/src/main/resources/webSecurityConfig.xml
index c13f65de5e..adfd603e54 100644
--- a/spring-security-modules/spring-security-ldap/src/main/resources/webSecurityConfig.xml
+++ b/spring-security-modules/spring-security-ldap/src/main/resources/webSecurityConfig.xml
@@ -10,6 +10,7 @@
+
From 35d06c8c383b18313026fb6e37b1b552633e3d63 Mon Sep 17 00:00:00 2001
From: Krzysiek
Date: Mon, 30 Mar 2020 23:27:11 +0200
Subject: [PATCH 33/87] JAVA-42: Upgrade spring-security-kerberos to Spring
Boot 2
---
spring-security-modules/spring-security-kerberos/pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/spring-security-modules/spring-security-kerberos/pom.xml b/spring-security-modules/spring-security-kerberos/pom.xml
index 6846bdf063..51a48a78c6 100644
--- a/spring-security-modules/spring-security-kerberos/pom.xml
+++ b/spring-security-modules/spring-security-kerberos/pom.xml
@@ -10,9 +10,9 @@
com.baeldung
- parent-boot-1
+ parent-boot-2
0.0.1-SNAPSHOT
- ../../parent-boot-1
+ ../../parent-boot-2
From 9454f19f700a60151a157699dad34012bdb195da Mon Sep 17 00:00:00 2001
From: Krzysiek
Date: Mon, 30 Mar 2020 23:45:37 +0200
Subject: [PATCH 34/87] JAVA-42: Upgrade spring-security-cache-control to
Spring Boot 2
---
.../spring-security-cache-control/pom.xml | 38 +++----------------
.../ResourceEndpointIntegrationTest.java | 2 +-
2 files changed, 7 insertions(+), 33 deletions(-)
diff --git a/spring-security-modules/spring-security-cache-control/pom.xml b/spring-security-modules/spring-security-cache-control/pom.xml
index acc37b41ef..743b3c291d 100644
--- a/spring-security-modules/spring-security-cache-control/pom.xml
+++ b/spring-security-modules/spring-security-cache-control/pom.xml
@@ -8,9 +8,9 @@
com.baeldung
- parent-boot-1
+ parent-boot-2
0.0.1-SNAPSHOT
- ../../parent-boot-1
+ ../../parent-boot-2
@@ -23,41 +23,15 @@
spring-boot-starter-web
- org.springframework.security
- spring-security-core
-
-
- org.springframework.security
- spring-security-config
-
-
- org.springframework.security
- spring-security-web
-
-
- javax.servlet
- javax.servlet-api
- ${javax.servlet-api.version}
+ org.springframework.boot
+ spring-boot-starter-security
- org.hamcrest
- hamcrest
- ${hamcrest.version}
+ org.springframework.boot
+ spring-boot-starter-test
test
-
-
- org.mockito
- mockito-core
- test
-
-
-
- org.springframework
- spring-test
-
-
\ No newline at end of file
diff --git a/spring-security-modules/spring-security-cache-control/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java b/spring-security-modules/spring-security-cache-control/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java
index d6a1a97773..d4d24a4986 100644
--- a/spring-security-modules/spring-security-cache-control/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java
+++ b/spring-security-modules/spring-security-cache-control/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java
@@ -4,8 +4,8 @@ import static io.restassured.RestAssured.given;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.test.context.junit4.SpringRunner;
import io.restassured.http.ContentType;
From 405a0a88a96d94b722e87034714dd4093445076d Mon Sep 17 00:00:00 2001
From: ramkumarvenkat
Date: Tue, 31 Mar 2020 12:09:13 +0530
Subject: [PATCH 35/87] Fix code after article changes
---
.../com/baeldung/guava/entity/Profile.java | 20 ++++++++
.../com/baeldung/guava/entity/Session.java | 13 ++++++
.../java/com/baeldung/guava/entity/User.java | 20 ++++++++
.../guava/mapmaker/GuavaMapMakerUnitTest.java | 46 +++++++++++++------
4 files changed, 84 insertions(+), 15 deletions(-)
create mode 100644 guava-collections-map/src/main/java/com/baeldung/guava/entity/Profile.java
create mode 100644 guava-collections-map/src/main/java/com/baeldung/guava/entity/Session.java
create mode 100644 guava-collections-map/src/main/java/com/baeldung/guava/entity/User.java
diff --git a/guava-collections-map/src/main/java/com/baeldung/guava/entity/Profile.java b/guava-collections-map/src/main/java/com/baeldung/guava/entity/Profile.java
new file mode 100644
index 0000000000..17a6502f39
--- /dev/null
+++ b/guava-collections-map/src/main/java/com/baeldung/guava/entity/Profile.java
@@ -0,0 +1,20 @@
+package com.baeldung.guava.entity;
+
+public class Profile {
+ private long id;
+ private String type;
+
+ public Profile(long id, String type) {
+ this.id = id;
+ this.type = type;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public String getName() {
+ return type;
+ }
+
+}
diff --git a/guava-collections-map/src/main/java/com/baeldung/guava/entity/Session.java b/guava-collections-map/src/main/java/com/baeldung/guava/entity/Session.java
new file mode 100644
index 0000000000..b834c23df1
--- /dev/null
+++ b/guava-collections-map/src/main/java/com/baeldung/guava/entity/Session.java
@@ -0,0 +1,13 @@
+package com.baeldung.guava.entity;
+
+public class Session {
+ private long id;
+
+ public Session(long id) {
+ this.id = id;
+ }
+
+ public long getId() {
+ return id;
+ }
+}
diff --git a/guava-collections-map/src/main/java/com/baeldung/guava/entity/User.java b/guava-collections-map/src/main/java/com/baeldung/guava/entity/User.java
new file mode 100644
index 0000000000..613045ec23
--- /dev/null
+++ b/guava-collections-map/src/main/java/com/baeldung/guava/entity/User.java
@@ -0,0 +1,20 @@
+package com.baeldung.guava.entity;
+
+public class User {
+ private long id;
+ private String name;
+
+ public User(long id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+}
diff --git a/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java b/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java
index 8da459f22e..e2bc1349c6 100644
--- a/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java
+++ b/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java
@@ -1,40 +1,56 @@
package com.baeldung.guava.mapmaker;
+import com.baeldung.guava.entity.Profile;
+import com.baeldung.guava.entity.Session;
+import com.baeldung.guava.entity.User;
import com.google.common.collect.MapMaker;
+import org.junit.Assert;
import org.junit.Test;
import java.util.concurrent.ConcurrentMap;
+import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertNotNull;
public class GuavaMapMakerUnitTest {
@Test
- public void whenMakeMap_thenCreated() {
- ConcurrentMap concurrentMap = new MapMaker().makeMap();
- assertNotNull(concurrentMap);
+ public void whenCreateCaches_thenCreated() {
+ ConcurrentMap sessionCache = new MapMaker().makeMap();
+ assertNotNull(sessionCache);
+
+ ConcurrentMap profileCache = new MapMaker().makeMap();
+ assertNotNull(profileCache);
+
+ User userA = new User(1, "UserA");
+
+ sessionCache.put(userA, new Session(100));
+ Assert.assertThat(sessionCache.size(), equalTo(1));
+
+ profileCache.put(userA, new Profile(1000, "Personal"));
+ Assert.assertThat(profileCache.size(), equalTo(1));
}
@Test
- public void whenMakeMapWithWeakKeys_thenCreated() {
- ConcurrentMap concurrentMap = new MapMaker().weakKeys().makeMap();
- assertNotNull(concurrentMap);
+ public void whenCreateCacheWithInitialCapacity_thenCreated() {
+ ConcurrentMap profileCache = new MapMaker().initialCapacity(100).makeMap();
+ assertNotNull(profileCache);
}
@Test
- public void whenMakeMapWithWeakValues_thenCreated() {
- ConcurrentMap concurrentMap = new MapMaker().weakValues().makeMap();
- assertNotNull(concurrentMap);
+ public void whenCreateCacheWithConcurrencyLevel_thenCreated() {
+ ConcurrentMap sessionCache = new MapMaker().concurrencyLevel(10).makeMap();
+ assertNotNull(sessionCache);
}
@Test
- public void whenMakeMapWithInitialCapacity_thenCreated() {
- ConcurrentMap concurrentMap = new MapMaker().initialCapacity(10).makeMap();
- assertNotNull(concurrentMap);
+ public void whenCreateCacheWithWeakKeys_thenCreated() {
+ ConcurrentMap sessionCache = new MapMaker().weakKeys().makeMap();
+ assertNotNull(sessionCache);
}
@Test
- public void whenMakeMapWithConcurrencyLevel_thenCreated() {
- ConcurrentMap concurrentMap = new MapMaker().concurrencyLevel(10).makeMap();
- assertNotNull(concurrentMap);
+ public void whenCreateCacheWithWeakValues_thenCreated() {
+ ConcurrentMap profileCache = new MapMaker().weakValues().makeMap();
+ assertNotNull(profileCache);
}
}
From bd4b7f81b5805f8453ab94a722a9d819cd068f80 Mon Sep 17 00:00:00 2001
From: Krzysiek
Date: Tue, 31 Mar 2020 22:55:19 +0200
Subject: [PATCH 36/87] JAVA-42: Upgrade spring-security-x509 to Spring Boot 2
---
spring-security-modules/spring-security-x509/pom.xml | 4 ++--
.../src/main/resources/application.properties | 6 +++---
.../src/main/resources/application.properties | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/spring-security-modules/spring-security-x509/pom.xml b/spring-security-modules/spring-security-x509/pom.xml
index a4ff908eed..d4132f058d 100644
--- a/spring-security-modules/spring-security-x509/pom.xml
+++ b/spring-security-modules/spring-security-x509/pom.xml
@@ -9,9 +9,9 @@
com.baeldung
- parent-boot-1
+ parent-boot-2
0.0.1-SNAPSHOT
- ../../parent-boot-1
+ ../../parent-boot-2
diff --git a/spring-security-modules/spring-security-x509/spring-security-x509-basic-auth/src/main/resources/application.properties b/spring-security-modules/spring-security-x509/spring-security-x509-basic-auth/src/main/resources/application.properties
index f293d6712d..53dfe9976a 100644
--- a/spring-security-modules/spring-security-x509/spring-security-x509-basic-auth/src/main/resources/application.properties
+++ b/spring-security-modules/spring-security-x509/spring-security-x509-basic-auth/src/main/resources/application.properties
@@ -1,8 +1,8 @@
-server.ssl.key-store=../keystore/keystore.jks
+server.ssl.key-store=keystore/keystore.jks
server.ssl.key-store-password=changeit
server.ssl.key-alias=localhost
server.ssl.key-password=changeit
server.ssl.enabled=true
server.port=8443
-security.user.name=Admin
-security.user.password=admin
\ No newline at end of file
+spring.security.user.name=Admin
+spring.security.user.password=admin
\ No newline at end of file
diff --git a/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/application.properties b/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/application.properties
index 174eba9f98..743c9c4582 100644
--- a/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/application.properties
+++ b/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/application.properties
@@ -4,8 +4,8 @@ server.ssl.key-alias=localhost
server.ssl.key-password=changeit
server.ssl.enabled=true
server.port=8443
-security.user.name=Admin
-security.user.password=admin
+spring.security.user.name=Admin
+spring.security.user.password=admin
server.ssl.trust-store=../keystore/truststore.jks
server.ssl.trust-store-password=changeit
server.ssl.client-auth=need
\ No newline at end of file
From a014c8655c171238e1018feb8c385ad579ab4d52 Mon Sep 17 00:00:00 2001
From: Waldemar
Date: Wed, 1 Apr 2020 20:29:34 +0200
Subject: [PATCH 37/87] BAEL-2398 rename package
---
coroutines-java/pom.xml | 4 ++--
.../main/java/com/baeldung/{introduction => quasar}/App.java | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
rename coroutines-java/src/main/java/com/baeldung/{introduction => quasar}/App.java (86%)
diff --git a/coroutines-java/pom.xml b/coroutines-java/pom.xml
index 3546aa5673..caee769a78 100644
--- a/coroutines-java/pom.xml
+++ b/coroutines-java/pom.xml
@@ -53,7 +53,7 @@
exec-maven-plugin
1.6.0
- com.baeldung.introduction.App
+ com.baeldung.quasar.App
target/classes
java
@@ -68,7 +68,7 @@
- com.baeldung.introduction.App
+ com.baeldung.quasar.App
diff --git a/coroutines-java/src/main/java/com/baeldung/introduction/App.java b/coroutines-java/src/main/java/com/baeldung/quasar/App.java
similarity index 86%
rename from coroutines-java/src/main/java/com/baeldung/introduction/App.java
rename to coroutines-java/src/main/java/com/baeldung/quasar/App.java
index f915464973..510877d1be 100644
--- a/coroutines-java/src/main/java/com/baeldung/introduction/App.java
+++ b/coroutines-java/src/main/java/com/baeldung/quasar/App.java
@@ -1,4 +1,4 @@
-package com.baeldung.introduction;
+package com.baeldung.quasar;
import co.paralleluniverse.fibers.Fiber;
From b2629b630ebd5b80a021ba2ba7ea8c5e2b6f72f0 Mon Sep 17 00:00:00 2001
From: ramkumarvenkat
Date: Thu, 2 Apr 2020 07:13:19 +0530
Subject: [PATCH 38/87] Change package name
---
.../java/com/baeldung/guava/{entity => mapmaker}/Profile.java | 2 +-
.../java/com/baeldung/guava/{entity => mapmaker}/Session.java | 2 +-
.../java/com/baeldung/guava/{entity => mapmaker}/User.java | 2 +-
.../com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java | 3 ---
4 files changed, 3 insertions(+), 6 deletions(-)
rename guava-collections-map/src/main/java/com/baeldung/guava/{entity => mapmaker}/Profile.java (88%)
rename guava-collections-map/src/main/java/com/baeldung/guava/{entity => mapmaker}/Session.java (81%)
rename guava-collections-map/src/main/java/com/baeldung/guava/{entity => mapmaker}/User.java (88%)
diff --git a/guava-collections-map/src/main/java/com/baeldung/guava/entity/Profile.java b/guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/Profile.java
similarity index 88%
rename from guava-collections-map/src/main/java/com/baeldung/guava/entity/Profile.java
rename to guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/Profile.java
index 17a6502f39..165c5a9f8f 100644
--- a/guava-collections-map/src/main/java/com/baeldung/guava/entity/Profile.java
+++ b/guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/Profile.java
@@ -1,4 +1,4 @@
-package com.baeldung.guava.entity;
+package com.baeldung.guava.mapmaker;
public class Profile {
private long id;
diff --git a/guava-collections-map/src/main/java/com/baeldung/guava/entity/Session.java b/guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/Session.java
similarity index 81%
rename from guava-collections-map/src/main/java/com/baeldung/guava/entity/Session.java
rename to guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/Session.java
index b834c23df1..a614f431f8 100644
--- a/guava-collections-map/src/main/java/com/baeldung/guava/entity/Session.java
+++ b/guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/Session.java
@@ -1,4 +1,4 @@
-package com.baeldung.guava.entity;
+package com.baeldung.guava.mapmaker;
public class Session {
private long id;
diff --git a/guava-collections-map/src/main/java/com/baeldung/guava/entity/User.java b/guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/User.java
similarity index 88%
rename from guava-collections-map/src/main/java/com/baeldung/guava/entity/User.java
rename to guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/User.java
index 613045ec23..a7f0435049 100644
--- a/guava-collections-map/src/main/java/com/baeldung/guava/entity/User.java
+++ b/guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/User.java
@@ -1,4 +1,4 @@
-package com.baeldung.guava.entity;
+package com.baeldung.guava.mapmaker;
public class User {
private long id;
diff --git a/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java b/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java
index e2bc1349c6..754e3ac099 100644
--- a/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java
+++ b/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java
@@ -1,8 +1,5 @@
package com.baeldung.guava.mapmaker;
-import com.baeldung.guava.entity.Profile;
-import com.baeldung.guava.entity.Session;
-import com.baeldung.guava.entity.User;
import com.google.common.collect.MapMaker;
import org.junit.Assert;
import org.junit.Test;
From f92dde7c1df2c0a74a3ac5a4c5d4479f7f6a4521 Mon Sep 17 00:00:00 2001
From: Krzysztof Woyke
Date: Thu, 2 Apr 2020 16:10:53 +0200
Subject: [PATCH 39/87] JAVA-997: Upgrade Spring Core & Security to the latest
versions
---
parent-spring-5/pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/parent-spring-5/pom.xml b/parent-spring-5/pom.xml
index 27f355bfad..c75655ebc8 100644
--- a/parent-spring-5/pom.xml
+++ b/parent-spring-5/pom.xml
@@ -31,8 +31,8 @@
- 5.2.2.RELEASE
- 5.2.1.RELEASE
+ 5.2.5.RELEASE
+ 5.2.3.RELEASE
\ No newline at end of file
From 44d068ca811856e910d73991e879712c0e145133 Mon Sep 17 00:00:00 2001
From: sampadawagde
Date: Sat, 4 Apr 2020 12:55:27 +0530
Subject: [PATCH 40/87] JAVA-624: Updated READMEs for prev links
---
java-collections-maps-2/README.md | 2 +-
java-collections-maps-3/README.md | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/java-collections-maps-2/README.md b/java-collections-maps-2/README.md
index 71c6a3f32b..2188960543 100644
--- a/java-collections-maps-2/README.md
+++ b/java-collections-maps-2/README.md
@@ -13,4 +13,4 @@ This module contains articles about Map data structures in Java.
- [Sort a HashMap in Java](https://www.baeldung.com/java-hashmap-sort)
- [Finding the Highest Value in a Java Map](https://www.baeldung.com/java-find-map-max)
- [Initialize a HashMap in Java](https://www.baeldung.com/java-initialize-hashmap)
-- More articles: [[<-- prev>]](/java-collections-maps) [[next -->]](/java-collections-maps-3)
+- More articles: [[<-- prev]](/java-collections-maps) [[next -->]](/java-collections-maps-3)
diff --git a/java-collections-maps-3/README.md b/java-collections-maps-3/README.md
index 8f185f6ad4..886461a35c 100644
--- a/java-collections-maps-3/README.md
+++ b/java-collections-maps-3/README.md
@@ -5,4 +5,4 @@ This module contains articles about Map data structures in Java.
### Relevant Articles:
- [Java TreeMap vs HashMap](https://www.baeldung.com/java-treemap-vs-hashmap)
- [Comparing Two HashMaps in Java](https://www.baeldung.com/java-compare-hashmaps)
-- More articles: [[<-- prev>]](/java-collections-maps-2)
+- More articles: [[<-- prev]](/java-collections-maps-2)
From 987c6b455236227c427ce2b6e142022a0cd2dd94 Mon Sep 17 00:00:00 2001
From: Waldemar
Date: Sat, 4 Apr 2020 11:38:24 +0200
Subject: [PATCH 41/87] BAEL-2398: add libraries-concurrency module
---
libraries-concurrency/pom.xml | 15 +++++++++++++++
pom.xml | 1 +
2 files changed, 16 insertions(+)
create mode 100644 libraries-concurrency/pom.xml
diff --git a/libraries-concurrency/pom.xml b/libraries-concurrency/pom.xml
new file mode 100644
index 0000000000..0dc546e63a
--- /dev/null
+++ b/libraries-concurrency/pom.xml
@@ -0,0 +1,15 @@
+
+
+
+ parent-modules
+ com.baeldung
+ 1.0.0-SNAPSHOT
+
+ 4.0.0
+
+ libraries-concurrency
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index a295439951..9694941645 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1259,6 +1259,7 @@
wildfly
xml
xstream
+ libraries-concurrency
From e77514b67d06c3f86d729f0ad5fd7c54fa1d80b6 Mon Sep 17 00:00:00 2001
From: Waldemar
Date: Sat, 4 Apr 2020 11:48:18 +0200
Subject: [PATCH 42/87] BAEL-2398: move coroutines-java module into
libraries-concurrency module
---
.../coroutines-java}/pom.xml | 15 +++++----------
.../src/main/java/com/baeldung/quasar/App.java | 0
libraries-concurrency/pom.xml | 11 ++++++++---
3 files changed, 13 insertions(+), 13 deletions(-)
rename {coroutines-java => libraries-concurrency/coroutines-java}/pom.xml (89%)
rename {coroutines-java => libraries-concurrency/coroutines-java}/src/main/java/com/baeldung/quasar/App.java (100%)
diff --git a/coroutines-java/pom.xml b/libraries-concurrency/coroutines-java/pom.xml
similarity index 89%
rename from coroutines-java/pom.xml
rename to libraries-concurrency/coroutines-java/pom.xml
index caee769a78..72356738d4 100644
--- a/coroutines-java/pom.xml
+++ b/libraries-concurrency/coroutines-java/pom.xml
@@ -2,19 +2,14 @@
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
-
- com.baeldung
coroutines-java
- 1.0-SNAPSHOT
-
coroutines-java
- http://baeldung.com
-
- UTF-8
- 1.8
- 1.8
-
+
+ com.baeldung
+ libraries-concurrency
+ 1.0.0-SNAPSHOT
+
diff --git a/coroutines-java/src/main/java/com/baeldung/quasar/App.java b/libraries-concurrency/coroutines-java/src/main/java/com/baeldung/quasar/App.java
similarity index 100%
rename from coroutines-java/src/main/java/com/baeldung/quasar/App.java
rename to libraries-concurrency/coroutines-java/src/main/java/com/baeldung/quasar/App.java
diff --git a/libraries-concurrency/pom.xml b/libraries-concurrency/pom.xml
index 0dc546e63a..5ba722ae2e 100644
--- a/libraries-concurrency/pom.xml
+++ b/libraries-concurrency/pom.xml
@@ -2,14 +2,19 @@
+ 4.0.0
+ libraries-concurrency
+ libraries-concurrency
+ pom
+
parent-modules
com.baeldung
1.0.0-SNAPSHOT
- 4.0.0
-
- libraries-concurrency
+
+ coroutines-java
+
\ No newline at end of file
From 4a2aee6aa38e4187f41710520c7763994a5674eb Mon Sep 17 00:00:00 2001
From: Waldemar
Date: Sat, 4 Apr 2020 11:50:20 +0200
Subject: [PATCH 43/87] BAEL-2398: rename coroutines-java to
coroutines-with-quasar
---
.../{coroutines-java => coroutines-with-quasar}/pom.xml | 4 ++--
.../src/main/java/com/baeldung/quasar/App.java | 0
libraries-concurrency/pom.xml | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
rename libraries-concurrency/{coroutines-java => coroutines-with-quasar}/pom.xml (97%)
rename libraries-concurrency/{coroutines-java => coroutines-with-quasar}/src/main/java/com/baeldung/quasar/App.java (100%)
diff --git a/libraries-concurrency/coroutines-java/pom.xml b/libraries-concurrency/coroutines-with-quasar/pom.xml
similarity index 97%
rename from libraries-concurrency/coroutines-java/pom.xml
rename to libraries-concurrency/coroutines-with-quasar/pom.xml
index 72356738d4..59241272e7 100644
--- a/libraries-concurrency/coroutines-java/pom.xml
+++ b/libraries-concurrency/coroutines-with-quasar/pom.xml
@@ -2,8 +2,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
- coroutines-java
- coroutines-java
+ coroutines-with-quasar
+ coroutines-with-quasar
com.baeldung
diff --git a/libraries-concurrency/coroutines-java/src/main/java/com/baeldung/quasar/App.java b/libraries-concurrency/coroutines-with-quasar/src/main/java/com/baeldung/quasar/App.java
similarity index 100%
rename from libraries-concurrency/coroutines-java/src/main/java/com/baeldung/quasar/App.java
rename to libraries-concurrency/coroutines-with-quasar/src/main/java/com/baeldung/quasar/App.java
diff --git a/libraries-concurrency/pom.xml b/libraries-concurrency/pom.xml
index 5ba722ae2e..7ae834025f 100644
--- a/libraries-concurrency/pom.xml
+++ b/libraries-concurrency/pom.xml
@@ -14,7 +14,7 @@
- coroutines-java
+ coroutines-with-quasar
\ No newline at end of file
From c0d2e94267429437dea74437a90f18f8feca340e Mon Sep 17 00:00:00 2001
From: Fabricio Pautasso
Date: Sat, 4 Apr 2020 11:55:13 -0300
Subject: [PATCH 44/87] BAEL-3918 - Adding BigDecimal numbers using the Stream
API (#8900)
* BAEL-3918 - Adding BigDecimal numbers using the Stream API
* BAEL-3918 - Adding BigDecimal numbers using the Stream API
* BAEL-3918 - Adding BigDecimal numbers using the Stream API
* BAEL-3918 - Updating test methods names to be compliant with Baeldung standards
* Minor name change
Co-authored-by: ashleyfrieze
---
.../bigdecimals/AddNumbersUnitTest.java | 42 +++++++++++++++++++
1 file changed, 42 insertions(+)
create mode 100644 core-java-modules/core-java-streams-3/src/test/java/com/baeldung/streams/bigdecimals/AddNumbersUnitTest.java
diff --git a/core-java-modules/core-java-streams-3/src/test/java/com/baeldung/streams/bigdecimals/AddNumbersUnitTest.java b/core-java-modules/core-java-streams-3/src/test/java/com/baeldung/streams/bigdecimals/AddNumbersUnitTest.java
new file mode 100644
index 0000000000..9399908b30
--- /dev/null
+++ b/core-java-modules/core-java-streams-3/src/test/java/com/baeldung/streams/bigdecimals/AddNumbersUnitTest.java
@@ -0,0 +1,42 @@
+package com.baeldung.streams.bigdecimals;
+
+import static org.junit.Assert.assertEquals;
+
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+
+import org.junit.Test;
+
+public class AddNumbersUnitTest {
+
+ @Test
+ public void givenIntStream_whenSum_thenResultIsCorrect() {
+ IntStream intNumbers = IntStream.range(0, 3);
+ assertEquals(3, intNumbers.sum());
+ }
+
+ @Test
+ public void givenCollectionOfDouble_whenUsingMapToDoubleToSum_thenResultIsCorrect() {
+ List doubleNumbers = Arrays.asList(23.48, 52.26, 13.5);
+ double result = doubleNumbers.stream()
+ .mapToDouble(Double::doubleValue)
+ .sum();
+ assertEquals(89.24, result, .1);
+ }
+
+ public void givenStreamOfIntegers_whenUsingReduceToSum_thenResultIsCorrect() {
+ Stream intNumbers = Stream.of(0, 1, 2);
+ int result = intNumbers.reduce(0, Integer::sum);
+ assertEquals(106, result);
+ }
+
+ public void givenStreamOfBigDecimals_whenUsingReduceToSum_thenResultIsCorrect() {
+ Stream bigDecimalNumber = Stream.of(BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN);
+ BigDecimal result = bigDecimalNumber.reduce(BigDecimal.ZERO, BigDecimal::add);
+ assertEquals(11, result);
+ }
+
+}
From cc11987f59f088a195512dfb096f33f908da87f9 Mon Sep 17 00:00:00 2001
From: mikr
Date: Sat, 4 Apr 2020 20:24:48 +0200
Subject: [PATCH 45/87] JAVA-117 Standardize spring-boot-modules/spring-boot
---
.../java/{org => com}/baeldung/boot/Application.java | 2 +-
.../baeldung/boot/config/H2JpaConfig.java | 6 +++---
.../{org => com}/baeldung/boot/config/WebConfig.java | 8 ++++----
.../boot/controller/servlet/HelloWorldServlet.java | 2 +-
.../controller/servlet/SpringHelloWorldServlet.java | 2 +-
.../boot/converter/GenericBigDecimalConverter.java | 2 +-
.../boot/converter/StringToEmployeeConverter.java | 2 +-
.../boot/converter/StringToEnumConverterFactory.java | 2 +-
.../StringToEmployeeConverterController.java | 2 +-
.../{org => com}/baeldung/boot/domain/Modes.java | 2 +-
.../common/error/MyCustomErrorController.java | 2 +-
.../error/SpringHelloServletRegistrationBean.java | 2 +-
.../common/error/controller/ErrorController.java | 2 +-
.../MyServletContainerCustomizationBean.java | 2 +-
.../resources/ExecutorServiceExitCodeGenerator.java | 2 +-
.../{org => com}/baeldung/demo/DemoApplication.java | 2 +-
.../baeldung/demo/boottest/Employee.java | 2 +-
.../baeldung/demo/boottest/EmployeeRepository.java | 2 +-
.../demo/boottest/EmployeeRestController.java | 2 +-
.../baeldung/demo/boottest/EmployeeService.java | 2 +-
.../baeldung/demo/boottest/EmployeeServiceImpl.java | 2 +-
.../baeldung/demo/components/FooService.java | 6 +++---
.../baeldung/demo/exceptions/CommonException.java | 2 +-
.../demo/exceptions/FooNotFoundException.java | 2 +-
.../java/{org => com}/baeldung/demo/model/Foo.java | 2 +-
.../baeldung/demo/repository/FooRepository.java | 4 ++--
.../baeldung/demo/service/FooController.java | 6 +++---
.../endpoints/info/TotalUsersInfoContributor.java | 4 ++--
.../baeldung/main/SpringBootApplication.java | 12 ++++++------
.../main/java/{org => com}/baeldung/model/User.java | 2 +-
.../baeldung/repository/UserRepository.java | 4 ++--
.../baeldung/session/exception/Application.java | 4 ++--
.../session/exception/repository/FooRepository.java | 4 ++--
.../exception/repository/FooRepositoryImpl.java | 4 ++--
.../baeldung/startup/AppStartupRunner.java | 2 +-
.../startup/CommandLineAppStartupRunner.java | 2 +-
.../baeldung/boot/ApplicationIntegrationTest.java | 4 ++--
.../boot/DemoApplicationIntegrationTest.java | 4 ++--
.../repository/FooRepositoryIntegrationTest.java | 8 ++++----
.../repository/HibernateSessionIntegrationTest.java | 8 ++++----
.../NoHibernateSessionIntegrationTest.java | 8 ++++----
.../converter/CustomConverterIntegrationTest.java | 6 +++---
...ToEmployeeConverterControllerIntegrationTest.java | 4 ++--
.../boottest/EmployeeControllerIntegrationTest.java | 5 +----
.../boottest/EmployeeRepositoryIntegrationTest.java | 6 +++---
.../EmployeeRestControllerIntegrationTest.java | 4 ++--
.../boottest/EmployeeServiceImplIntegrationTest.java | 6 +++++-
.../baeldung/demo/boottest/JsonUtil.java | 2 +-
.../repository/UserRepositoryIntegrationTest.java | 7 ++++---
49 files changed, 93 insertions(+), 91 deletions(-)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/Application.java (93%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/config/H2JpaConfig.java (89%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/config/WebConfig.java (71%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/controller/servlet/HelloWorldServlet.java (96%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java (96%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/converter/GenericBigDecimalConverter.java (96%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/converter/StringToEmployeeConverter.java (90%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/converter/StringToEnumConverterFactory.java (95%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/converter/controller/StringToEmployeeConverterController.java (91%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/domain/Modes.java (54%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/common/error/MyCustomErrorController.java (93%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/common/error/SpringHelloServletRegistrationBean.java (91%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/common/error/controller/ErrorController.java (90%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/common/properties/MyServletContainerCustomizationBean.java (95%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java (94%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/DemoApplication.java (94%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/boottest/Employee.java (95%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/boottest/EmployeeRepository.java (91%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/boottest/EmployeeRestController.java (96%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/boottest/EmployeeService.java (89%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/boottest/EmployeeServiceImpl.java (96%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/components/FooService.java (77%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/exceptions/CommonException.java (85%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/exceptions/FooNotFoundException.java (86%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/model/Foo.java (95%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/repository/FooRepository.java (70%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/service/FooController.java (85%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/endpoints/info/TotalUsersInfoContributor.java (89%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/main/SpringBootApplication.java (78%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/model/User.java (96%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/repository/UserRepository.java (98%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/session/exception/Application.java (87%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/session/exception/repository/FooRepository.java (50%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/session/exception/repository/FooRepositoryImpl.java (88%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/startup/AppStartupRunner.java (95%)
rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/startup/CommandLineAppStartupRunner.java (94%)
rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/boot/ApplicationIntegrationTest.java (85%)
rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/boot/DemoApplicationIntegrationTest.java (87%)
rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/boot/repository/FooRepositoryIntegrationTest.java (82%)
rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/boot/repository/HibernateSessionIntegrationTest.java (81%)
rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java (78%)
rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/converter/CustomConverterIntegrationTest.java (94%)
rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java (94%)
rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java (93%)
rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java (94%)
rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java (97%)
rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java (94%)
rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/demo/boottest/JsonUtil.java (91%)
rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/repository/UserRepositoryIntegrationTest.java (92%)
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/Application.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/Application.java
similarity index 93%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/Application.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/Application.java
index c1b6558b26..cb0d0c1532 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/Application.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/Application.java
@@ -1,4 +1,4 @@
-package org.baeldung.boot;
+package com.baeldung.boot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/config/H2JpaConfig.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/config/H2JpaConfig.java
similarity index 89%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/config/H2JpaConfig.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/config/H2JpaConfig.java
index 92a6ed7ab0..928928c9a5 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/config/H2JpaConfig.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/config/H2JpaConfig.java
@@ -1,4 +1,4 @@
-package org.baeldung.boot.config;
+package com.baeldung.boot.config;
import java.util.Properties;
@@ -18,7 +18,7 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
-@EnableJpaRepositories(basePackages = { "org.baeldung.boot.repository", "org.baeldung.boot.boottest", "org.baeldung.repository" })
+@EnableJpaRepositories(basePackages = { "com.baeldung.boot.repository", "com.baeldung.boot.boottest", "com.baeldung.repository" })
@PropertySource("classpath:persistence-generic-entity.properties")
@EnableTransactionManagement
public class H2JpaConfig {
@@ -41,7 +41,7 @@ public class H2JpaConfig {
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
- em.setPackagesToScan(new String[] { "org.baeldung.boot.domain", "org.baeldung.boot.model", "org.baeldung.boot.boottest", "org.baeldung.model" });
+ em.setPackagesToScan(new String[] { "com.baeldung.boot.domain", "com.baeldung.boot.model", "com.baeldung.boot.boottest", "com.baeldung.model" });
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
em.setJpaProperties(additionalProperties());
return em;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/config/WebConfig.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/config/WebConfig.java
similarity index 71%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/config/WebConfig.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/config/WebConfig.java
index 9554facb12..b23c910a04 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/config/WebConfig.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/config/WebConfig.java
@@ -1,8 +1,8 @@
-package org.baeldung.boot.config;
+package com.baeldung.boot.config;
-import org.baeldung.boot.converter.StringToEmployeeConverter;
-import org.baeldung.boot.converter.StringToEnumConverterFactory;
-import org.baeldung.boot.converter.GenericBigDecimalConverter;
+import com.baeldung.boot.converter.StringToEmployeeConverter;
+import com.baeldung.boot.converter.StringToEnumConverterFactory;
+import com.baeldung.boot.converter.GenericBigDecimalConverter;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/HelloWorldServlet.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/controller/servlet/HelloWorldServlet.java
similarity index 96%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/HelloWorldServlet.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/controller/servlet/HelloWorldServlet.java
index 34ad11254c..80c75aa8b5 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/HelloWorldServlet.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/controller/servlet/HelloWorldServlet.java
@@ -1,4 +1,4 @@
-package org.baeldung.boot.controller.servlet;
+package com.baeldung.boot.controller.servlet;
import java.io.IOException;
import java.io.PrintWriter;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java
similarity index 96%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java
index 91547683c6..f276f94b7c 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java
@@ -1,4 +1,4 @@
-package org.baeldung.boot.controller.servlet;
+package com.baeldung.boot.controller.servlet;
import java.io.IOException;
import java.io.PrintWriter;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/GenericBigDecimalConverter.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/GenericBigDecimalConverter.java
similarity index 96%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/GenericBigDecimalConverter.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/GenericBigDecimalConverter.java
index 8add28fc2d..fc73cfee5f 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/GenericBigDecimalConverter.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/GenericBigDecimalConverter.java
@@ -1,4 +1,4 @@
-package org.baeldung.boot.converter;
+package com.baeldung.boot.converter;
import com.google.common.collect.ImmutableSet;
import org.springframework.core.convert.TypeDescriptor;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEmployeeConverter.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/StringToEmployeeConverter.java
similarity index 90%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEmployeeConverter.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/StringToEmployeeConverter.java
index 1bf75b38f0..ac635532ea 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEmployeeConverter.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/StringToEmployeeConverter.java
@@ -1,4 +1,4 @@
-package org.baeldung.boot.converter;
+package com.baeldung.boot.converter;
import org.springframework.core.convert.converter.Converter;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEnumConverterFactory.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/StringToEnumConverterFactory.java
similarity index 95%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEnumConverterFactory.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/StringToEnumConverterFactory.java
index ddb2cd2b08..a2dce11a6a 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEnumConverterFactory.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/StringToEnumConverterFactory.java
@@ -1,4 +1,4 @@
-package org.baeldung.boot.converter;
+package com.baeldung.boot.converter;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.ConverterFactory;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/controller/StringToEmployeeConverterController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/controller/StringToEmployeeConverterController.java
similarity index 91%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/controller/StringToEmployeeConverterController.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/controller/StringToEmployeeConverterController.java
index 27bad4c387..260b1c734b 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/controller/StringToEmployeeConverterController.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/controller/StringToEmployeeConverterController.java
@@ -1,4 +1,4 @@
-package org.baeldung.boot.converter.controller;
+package com.baeldung.boot.converter.controller;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/domain/Modes.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/domain/Modes.java
similarity index 54%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/domain/Modes.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/domain/Modes.java
index dcba064e8c..7717294996 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/domain/Modes.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/domain/Modes.java
@@ -1,4 +1,4 @@
-package org.baeldung.boot.domain;
+package com.baeldung.boot.domain;
public enum Modes {
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/MyCustomErrorController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/MyCustomErrorController.java
similarity index 93%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/MyCustomErrorController.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/MyCustomErrorController.java
index df0e3ec0b2..373ae8f745 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/MyCustomErrorController.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/MyCustomErrorController.java
@@ -1,4 +1,4 @@
-package org.baeldung.common.error;
+package com.baeldung.common.error;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.web.bind.annotation.GetMapping;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/SpringHelloServletRegistrationBean.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/SpringHelloServletRegistrationBean.java
similarity index 91%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/SpringHelloServletRegistrationBean.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/SpringHelloServletRegistrationBean.java
index 774cf1b970..3f51a4ab69 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/SpringHelloServletRegistrationBean.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/SpringHelloServletRegistrationBean.java
@@ -1,4 +1,4 @@
-package org.baeldung.common.error;
+package com.baeldung.common.error;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/controller/ErrorController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/controller/ErrorController.java
similarity index 90%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/controller/ErrorController.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/controller/ErrorController.java
index ac5f92e9c9..1e5fbf3ac4 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/controller/ErrorController.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/controller/ErrorController.java
@@ -1,4 +1,4 @@
-package org.baeldung.common.error.controller;
+package com.baeldung.common.error.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/properties/MyServletContainerCustomizationBean.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/properties/MyServletContainerCustomizationBean.java
similarity index 95%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/properties/MyServletContainerCustomizationBean.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/properties/MyServletContainerCustomizationBean.java
index d553d44769..be503b1b6c 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/properties/MyServletContainerCustomizationBean.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/properties/MyServletContainerCustomizationBean.java
@@ -1,4 +1,4 @@
-package org.baeldung.common.properties;
+package com.baeldung.common.properties;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java
similarity index 94%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java
index 64853a9941..1db7054f85 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java
@@ -1,4 +1,4 @@
-package org.baeldung.common.resources;
+package com.baeldung.common.resources;
import org.springframework.boot.ExitCodeGenerator;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/DemoApplication.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/DemoApplication.java
similarity index 94%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/DemoApplication.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/DemoApplication.java
index 4a88fcea07..eb091b4695 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/DemoApplication.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/DemoApplication.java
@@ -1,4 +1,4 @@
-package org.baeldung.demo;
+package com.baeldung.demo;
import com.baeldung.graphql.GraphqlConfiguration;
import org.springframework.boot.SpringApplication;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/Employee.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/Employee.java
similarity index 95%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/Employee.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/Employee.java
index 645ce2838a..fa3c1dc809 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/Employee.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/Employee.java
@@ -1,4 +1,4 @@
-package org.baeldung.demo.boottest;
+package com.baeldung.demo.boottest;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRepository.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeRepository.java
similarity index 91%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRepository.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeRepository.java
index 00fdbfaae4..b6850d587e 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRepository.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeRepository.java
@@ -1,4 +1,4 @@
-package org.baeldung.demo.boottest;
+package com.baeldung.demo.boottest;
import java.util.List;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRestController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeRestController.java
similarity index 96%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRestController.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeRestController.java
index 516bff0e8c..7d2e06d4a0 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRestController.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeRestController.java
@@ -1,4 +1,4 @@
-package org.baeldung.demo.boottest;
+package com.baeldung.demo.boottest;
import java.util.List;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeService.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeService.java
similarity index 89%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeService.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeService.java
index 07765a511c..ff1976cad1 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeService.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeService.java
@@ -1,4 +1,4 @@
-package org.baeldung.demo.boottest;
+package com.baeldung.demo.boottest;
import java.util.List;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeServiceImpl.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeServiceImpl.java
similarity index 96%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeServiceImpl.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeServiceImpl.java
index a1639b29cc..156fc571f3 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeServiceImpl.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeServiceImpl.java
@@ -1,4 +1,4 @@
-package org.baeldung.demo.boottest;
+package com.baeldung.demo.boottest;
import java.util.List;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/components/FooService.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/components/FooService.java
similarity index 77%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/components/FooService.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/components/FooService.java
index 66943f6461..98a0db67ef 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/components/FooService.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/components/FooService.java
@@ -1,7 +1,7 @@
-package org.baeldung.demo.components;
+package com.baeldung.demo.components;
-import org.baeldung.demo.model.Foo;
-import org.baeldung.demo.repository.FooRepository;
+import com.baeldung.demo.model.Foo;
+import com.baeldung.demo.repository.FooRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/exceptions/CommonException.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/exceptions/CommonException.java
similarity index 85%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/exceptions/CommonException.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/exceptions/CommonException.java
index 51dd7bbd44..276802d0b9 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/exceptions/CommonException.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/exceptions/CommonException.java
@@ -1,4 +1,4 @@
-package org.baeldung.demo.exceptions;
+package com.baeldung.demo.exceptions;
public class CommonException extends RuntimeException {
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/exceptions/FooNotFoundException.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/exceptions/FooNotFoundException.java
similarity index 86%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/exceptions/FooNotFoundException.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/exceptions/FooNotFoundException.java
index 59796c58f0..8c425d078e 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/exceptions/FooNotFoundException.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/exceptions/FooNotFoundException.java
@@ -1,4 +1,4 @@
-package org.baeldung.demo.exceptions;
+package com.baeldung.demo.exceptions;
public class FooNotFoundException extends RuntimeException {
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/model/Foo.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/model/Foo.java
similarity index 95%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/model/Foo.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/model/Foo.java
index e5638cfd3d..796bcca11b 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/model/Foo.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/model/Foo.java
@@ -1,4 +1,4 @@
-package org.baeldung.demo.model;
+package com.baeldung.demo.model;
import java.io.Serializable;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/repository/FooRepository.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/repository/FooRepository.java
similarity index 70%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/repository/FooRepository.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/repository/FooRepository.java
index c04e0c7438..ed27ac23bc 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/repository/FooRepository.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/repository/FooRepository.java
@@ -1,6 +1,6 @@
-package org.baeldung.demo.repository;
+package com.baeldung.demo.repository;
-import org.baeldung.demo.model.Foo;
+import com.baeldung.demo.model.Foo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface FooRepository extends JpaRepository {
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/service/FooController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/service/FooController.java
similarity index 85%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/service/FooController.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/service/FooController.java
index c28dcde1a7..c72c52fa3e 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/service/FooController.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/service/FooController.java
@@ -1,7 +1,7 @@
-package org.baeldung.demo.service;
+package com.baeldung.demo.service;
-import org.baeldung.demo.components.FooService;
-import org.baeldung.demo.model.Foo;
+import com.baeldung.demo.model.Foo;
+import com.baeldung.demo.components.FooService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/endpoints/info/TotalUsersInfoContributor.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/endpoints/info/TotalUsersInfoContributor.java
similarity index 89%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/endpoints/info/TotalUsersInfoContributor.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/endpoints/info/TotalUsersInfoContributor.java
index 34b50a2c0a..c316cabda5 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/endpoints/info/TotalUsersInfoContributor.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/endpoints/info/TotalUsersInfoContributor.java
@@ -1,9 +1,9 @@
-package org.baeldung.endpoints.info;
+package com.baeldung.endpoints.info;
import java.util.HashMap;
import java.util.Map;
-import org.baeldung.repository.UserRepository;
+import com.baeldung.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.info.Info;
import org.springframework.boot.actuate.info.InfoContributor;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/main/SpringBootApplication.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/main/SpringBootApplication.java
similarity index 78%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/main/SpringBootApplication.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/main/SpringBootApplication.java
index a203659d63..c8cfb50f1c 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/main/SpringBootApplication.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/main/SpringBootApplication.java
@@ -1,9 +1,9 @@
-package org.baeldung.main;
+package com.baeldung.main;
-import org.baeldung.boot.controller.servlet.HelloWorldServlet;
-import org.baeldung.boot.controller.servlet.SpringHelloWorldServlet;
-import org.baeldung.common.error.SpringHelloServletRegistrationBean;
-import org.baeldung.common.resources.ExecutorServiceExitCodeGenerator;
+import com.baeldung.boot.controller.servlet.HelloWorldServlet;
+import com.baeldung.boot.controller.servlet.SpringHelloWorldServlet;
+import com.baeldung.common.error.SpringHelloServletRegistrationBean;
+import com.baeldung.common.resources.ExecutorServiceExitCodeGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -18,7 +18,7 @@ import java.util.concurrent.Executors;
@RestController
@EnableAutoConfiguration
-@ComponentScan({ "org.baeldung.common.error", "org.baeldung.common.error.controller", "org.baeldung.common.properties", "org.baeldung.common.resources", "org.baeldung.endpoints", "org.baeldung.service", "org.baeldung.monitor.jmx", "org.baeldung.boot.config" })
+@ComponentScan({ "org.baeldung.common.error", "com.baeldung.common.error.controller", "com.baeldung.common.properties", "com.baeldung.common.resources", "com.baeldung.endpoints", "com.baeldung.service", "com.baeldung.monitor.jmx", "com.baeldung.boot.config" })
public class SpringBootApplication {
private static ApplicationContext applicationContext;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/model/User.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/model/User.java
similarity index 96%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/model/User.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/model/User.java
index eb886338a0..cc5f27f38c 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/model/User.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/model/User.java
@@ -1,4 +1,4 @@
-package org.baeldung.model;
+package com.baeldung.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/repository/UserRepository.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/repository/UserRepository.java
similarity index 98%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/repository/UserRepository.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/repository/UserRepository.java
index 752664cd5d..4dd863fb17 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/repository/UserRepository.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/repository/UserRepository.java
@@ -1,6 +1,6 @@
-package org.baeldung.repository;
+package com.baeldung.repository;
-import org.baeldung.model.User;
+import com.baeldung.model.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/Application.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/Application.java
similarity index 87%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/Application.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/Application.java
index 354c64c258..de4ca5998e 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/Application.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/Application.java
@@ -1,6 +1,6 @@
-package org.baeldung.session.exception;
+package com.baeldung.session.exception;
-import org.baeldung.demo.model.Foo;
+import com.baeldung.demo.model.Foo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepository.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/repository/FooRepository.java
similarity index 50%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepository.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/repository/FooRepository.java
index ce7bbfe57b..5e748973ed 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepository.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/repository/FooRepository.java
@@ -1,6 +1,6 @@
-package org.baeldung.session.exception.repository;
+package com.baeldung.session.exception.repository;
-import org.baeldung.demo.model.Foo;
+import com.baeldung.demo.model.Foo;
public interface FooRepository {
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepositoryImpl.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/repository/FooRepositoryImpl.java
similarity index 88%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepositoryImpl.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/repository/FooRepositoryImpl.java
index 607bae83ba..a304373d6c 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepositoryImpl.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/repository/FooRepositoryImpl.java
@@ -1,8 +1,8 @@
-package org.baeldung.session.exception.repository;
+package com.baeldung.session.exception.repository;
import javax.persistence.EntityManagerFactory;
-import org.baeldung.demo.model.Foo;
+import com.baeldung.demo.model.Foo;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/startup/AppStartupRunner.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/startup/AppStartupRunner.java
similarity index 95%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/startup/AppStartupRunner.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/startup/AppStartupRunner.java
index d491bdb42c..0495473704 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/startup/AppStartupRunner.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/startup/AppStartupRunner.java
@@ -1,4 +1,4 @@
-package org.baeldung.startup;
+package com.baeldung.startup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/startup/CommandLineAppStartupRunner.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/startup/CommandLineAppStartupRunner.java
similarity index 94%
rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/startup/CommandLineAppStartupRunner.java
rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/startup/CommandLineAppStartupRunner.java
index 6a7be59c21..48c5225cf1 100644
--- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/startup/CommandLineAppStartupRunner.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/startup/CommandLineAppStartupRunner.java
@@ -1,4 +1,4 @@
-package org.baeldung.startup;
+package com.baeldung.startup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/ApplicationIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/ApplicationIntegrationTest.java
similarity index 85%
rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/ApplicationIntegrationTest.java
rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/ApplicationIntegrationTest.java
index 5e351157c8..462291e0ac 100644
--- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/ApplicationIntegrationTest.java
+++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/ApplicationIntegrationTest.java
@@ -1,6 +1,6 @@
-package org.baeldung.boot;
+package com.baeldung.boot;
-import org.baeldung.session.exception.Application;
+import com.baeldung.session.exception.Application;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/DemoApplicationIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/DemoApplicationIntegrationTest.java
similarity index 87%
rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/DemoApplicationIntegrationTest.java
rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/DemoApplicationIntegrationTest.java
index 0541da3199..aaf4f1f780 100644
--- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/DemoApplicationIntegrationTest.java
+++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/DemoApplicationIntegrationTest.java
@@ -1,6 +1,6 @@
-package org.baeldung.boot;
+package com.baeldung.boot;
-import org.baeldung.demo.DemoApplication;
+import com.baeldung.demo.DemoApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/FooRepositoryIntegrationTest.java
similarity index 82%
rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryIntegrationTest.java
rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/FooRepositoryIntegrationTest.java
index c32e36d7e3..1772739d20 100644
--- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryIntegrationTest.java
+++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/FooRepositoryIntegrationTest.java
@@ -1,8 +1,8 @@
-package org.baeldung.boot.repository;
+package com.baeldung.boot.repository;
-import org.baeldung.boot.DemoApplicationIntegrationTest;
-import org.baeldung.demo.model.Foo;
-import org.baeldung.demo.repository.FooRepository;
+import com.baeldung.boot.DemoApplicationIntegrationTest;
+import com.baeldung.demo.model.Foo;
+import com.baeldung.demo.repository.FooRepository;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/HibernateSessionIntegrationTest.java
similarity index 81%
rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionIntegrationTest.java
rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/HibernateSessionIntegrationTest.java
index b22282e896..2fe072bb67 100644
--- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionIntegrationTest.java
+++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/HibernateSessionIntegrationTest.java
@@ -1,8 +1,8 @@
-package org.baeldung.boot.repository;
+package com.baeldung.boot.repository;
-import org.baeldung.boot.DemoApplicationIntegrationTest;
-import org.baeldung.demo.model.Foo;
-import org.baeldung.demo.repository.FooRepository;
+import com.baeldung.boot.DemoApplicationIntegrationTest;
+import com.baeldung.demo.model.Foo;
+import com.baeldung.demo.repository.FooRepository;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java
similarity index 78%
rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java
rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java
index 5c8d10223b..2e3326e6b1 100644
--- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java
+++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java
@@ -1,8 +1,8 @@
-package org.baeldung.boot.repository;
+package com.baeldung.boot.repository;
-import org.baeldung.boot.ApplicationIntegrationTest;
-import org.baeldung.demo.model.Foo;
-import org.baeldung.session.exception.repository.FooRepository;
+import com.baeldung.boot.ApplicationIntegrationTest;
+import com.baeldung.demo.model.Foo;
+import com.baeldung.session.exception.repository.FooRepository;
import org.hibernate.HibernateException;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/converter/CustomConverterIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/converter/CustomConverterIntegrationTest.java
similarity index 94%
rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/converter/CustomConverterIntegrationTest.java
rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/converter/CustomConverterIntegrationTest.java
index bd1ae2c8fa..4619964783 100644
--- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/converter/CustomConverterIntegrationTest.java
+++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/converter/CustomConverterIntegrationTest.java
@@ -1,9 +1,9 @@
-package org.baeldung.converter;
+package com.baeldung.converter;
import com.baeldung.toggle.Employee;
-import org.baeldung.boot.Application;
-import org.baeldung.boot.domain.Modes;
+import com.baeldung.boot.Application;
+import com.baeldung.boot.domain.Modes;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java
similarity index 94%
rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java
rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java
index 2afda7565a..52dc542ebf 100644
--- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java
+++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java
@@ -1,4 +1,4 @@
-package org.baeldung.converter.controller;
+package com.baeldung.converter.controller;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -14,7 +14,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import org.baeldung.boot.Application;
+import com.baeldung.boot.Application;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = Application.class)
diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java
similarity index 93%
rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java
rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java
index 2d70583a54..962abf0fa3 100644
--- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java
+++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java
@@ -1,8 +1,5 @@
-package org.baeldung.demo.boottest;
+package com.baeldung.demo.boottest;
-import org.baeldung.demo.boottest.Employee;
-import org.baeldung.demo.boottest.EmployeeRestController;
-import org.baeldung.demo.boottest.EmployeeService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java
similarity index 94%
rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java
rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java
index 3042f95a46..164887886b 100644
--- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java
+++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java
@@ -1,7 +1,7 @@
-package org.baeldung.demo.boottest;
+package com.baeldung.demo.boottest;
-import org.baeldung.demo.boottest.Employee;
-import org.baeldung.demo.boottest.EmployeeRepository;
+import com.baeldung.demo.boottest.Employee;
+import com.baeldung.demo.boottest.EmployeeRepository;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java
similarity index 97%
rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java
rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java
index a4b35889d6..327e9f9d56 100644
--- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java
+++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java
@@ -1,4 +1,4 @@
-package org.baeldung.demo.boottest;
+package com.baeldung.demo.boottest;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.is;
@@ -14,7 +14,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.io.IOException;
import java.util.List;
-import org.baeldung.demo.DemoApplication;
+import com.baeldung.demo.DemoApplication;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java
similarity index 94%
rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java
rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java
index df28111a57..88f2830a2b 100644
--- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java
+++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java
@@ -1,4 +1,4 @@
-package org.baeldung.demo.boottest;
+package com.baeldung.demo.boottest;
import static org.assertj.core.api.Assertions.assertThat;
@@ -6,6 +6,10 @@ import java.util.Arrays;
import java.util.List;
import java.util.Optional;
+import com.baeldung.demo.boottest.Employee;
+import com.baeldung.demo.boottest.EmployeeRepository;
+import com.baeldung.demo.boottest.EmployeeService;
+import com.baeldung.demo.boottest.EmployeeServiceImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/JsonUtil.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/JsonUtil.java
similarity index 91%
rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/JsonUtil.java
rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/JsonUtil.java
index 7e04f47696..3fcd709f7c 100644
--- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/JsonUtil.java
+++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/JsonUtil.java
@@ -1,4 +1,4 @@
-package org.baeldung.demo.boottest;
+package com.baeldung.demo.boottest;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/repository/UserRepositoryIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/repository/UserRepositoryIntegrationTest.java
similarity index 92%
rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/repository/UserRepositoryIntegrationTest.java
rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/repository/UserRepositoryIntegrationTest.java
index ea7f118967..a1318949f3 100644
--- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/repository/UserRepositoryIntegrationTest.java
+++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/repository/UserRepositoryIntegrationTest.java
@@ -1,7 +1,8 @@
-package org.baeldung.repository;
+package com.baeldung.repository;
-import org.baeldung.boot.config.H2JpaConfig;
-import org.baeldung.model.User;
+import com.baeldung.boot.config.H2JpaConfig;
+import com.baeldung.model.User;
+import com.baeldung.repository.UserRepository;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
From 87b22be5fda1517164e1dd7a37042472eb828523 Mon Sep 17 00:00:00 2001
From: mikr
Date: Sat, 4 Apr 2020 20:40:09 +0200
Subject: [PATCH 46/87] JAVA-117 Standardize
spring-boot-modules/spring-boot-client
---
.../main/java/{org => com}/baeldung/boot/Application.java | 2 +-
.../java/{org => com}/baeldung/boot/client/Details.java | 2 +-
.../baeldung/boot/client/DetailsServiceClient.java | 2 +-
.../{org => com}/baeldung/websocket/client/Message.java | 2 +-
.../baeldung/websocket/client/MyStompSessionHandler.java | 2 +-
.../{org => com}/baeldung/websocket/client/StompClient.java | 2 +-
.../test/java/{org => com}/baeldung/SpringContextTest.java | 4 ++--
.../boot/client/DetailsServiceClientIntegrationTest.java | 6 ++++--
.../client/MyStompSessionHandlerIntegrationTest.java | 1 -
9 files changed, 12 insertions(+), 11 deletions(-)
rename spring-boot-modules/spring-boot-client/src/main/java/{org => com}/baeldung/boot/Application.java (93%)
rename spring-boot-modules/spring-boot-client/src/main/java/{org => com}/baeldung/boot/client/Details.java (93%)
rename spring-boot-modules/spring-boot-client/src/main/java/{org => com}/baeldung/boot/client/DetailsServiceClient.java (93%)
rename spring-boot-modules/spring-boot-client/src/main/java/{org => com}/baeldung/websocket/client/Message.java (89%)
rename spring-boot-modules/spring-boot-client/src/main/java/{org => com}/baeldung/websocket/client/MyStompSessionHandler.java (98%)
rename spring-boot-modules/spring-boot-client/src/main/java/{org => com}/baeldung/websocket/client/StompClient.java (96%)
rename spring-boot-modules/spring-boot-client/src/test/java/{org => com}/baeldung/SpringContextTest.java (86%)
rename spring-boot-modules/spring-boot-client/src/test/java/{org => com}/baeldung/boot/client/DetailsServiceClientIntegrationTest.java (90%)
diff --git a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/Application.java b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/Application.java
similarity index 93%
rename from spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/Application.java
rename to spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/Application.java
index c1b6558b26..cb0d0c1532 100644
--- a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/Application.java
+++ b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/Application.java
@@ -1,4 +1,4 @@
-package org.baeldung.boot;
+package com.baeldung.boot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
diff --git a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/client/Details.java b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/client/Details.java
similarity index 93%
rename from spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/client/Details.java
rename to spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/client/Details.java
index 1e3ddf7b21..c806476634 100644
--- a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/client/Details.java
+++ b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/client/Details.java
@@ -1,4 +1,4 @@
-package org.baeldung.boot.client;
+package com.baeldung.boot.client;
public class Details {
diff --git a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/client/DetailsServiceClient.java b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/client/DetailsServiceClient.java
similarity index 93%
rename from spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/client/DetailsServiceClient.java
rename to spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/client/DetailsServiceClient.java
index f2b9d6d030..a9f1b08c97 100644
--- a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/client/DetailsServiceClient.java
+++ b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/client/DetailsServiceClient.java
@@ -1,4 +1,4 @@
-package org.baeldung.boot.client;
+package com.baeldung.boot.client;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.stereotype.Service;
diff --git a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/Message.java b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/Message.java
similarity index 89%
rename from spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/Message.java
rename to spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/Message.java
index 2744c49f62..19140f76a2 100644
--- a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/Message.java
+++ b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/Message.java
@@ -1,4 +1,4 @@
-package org.baeldung.websocket.client;
+package com.baeldung.websocket.client;
public class Message {
diff --git a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/MyStompSessionHandler.java b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/MyStompSessionHandler.java
similarity index 98%
rename from spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/MyStompSessionHandler.java
rename to spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/MyStompSessionHandler.java
index 92beab9430..8ccc42c58a 100644
--- a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/MyStompSessionHandler.java
+++ b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/MyStompSessionHandler.java
@@ -1,4 +1,4 @@
-package org.baeldung.websocket.client;
+package com.baeldung.websocket.client;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
diff --git a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/StompClient.java b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/StompClient.java
similarity index 96%
rename from spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/StompClient.java
rename to spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/StompClient.java
index 2bff07186d..04d87dd2ed 100644
--- a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/StompClient.java
+++ b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/StompClient.java
@@ -1,4 +1,4 @@
-package org.baeldung.websocket.client;
+package com.baeldung.websocket.client;
import java.util.Scanner;
diff --git a/spring-boot-modules/spring-boot-client/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/SpringContextTest.java
similarity index 86%
rename from spring-boot-modules/spring-boot-client/src/test/java/org/baeldung/SpringContextTest.java
rename to spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/SpringContextTest.java
index 9c3b83ea79..1341f17eac 100644
--- a/spring-boot-modules/spring-boot-client/src/test/java/org/baeldung/SpringContextTest.java
+++ b/spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/SpringContextTest.java
@@ -1,6 +1,6 @@
-package org.baeldung;
+package com.baeldung;
-import org.baeldung.boot.Application;
+import com.baeldung.boot.Application;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
diff --git a/spring-boot-modules/spring-boot-client/src/test/java/org/baeldung/boot/client/DetailsServiceClientIntegrationTest.java b/spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/boot/client/DetailsServiceClientIntegrationTest.java
similarity index 90%
rename from spring-boot-modules/spring-boot-client/src/test/java/org/baeldung/boot/client/DetailsServiceClientIntegrationTest.java
rename to spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/boot/client/DetailsServiceClientIntegrationTest.java
index d423300b85..4af5370950 100644
--- a/spring-boot-modules/spring-boot-client/src/test/java/org/baeldung/boot/client/DetailsServiceClientIntegrationTest.java
+++ b/spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/boot/client/DetailsServiceClientIntegrationTest.java
@@ -1,10 +1,12 @@
-package org.baeldung.boot.client;
+package com.baeldung.boot.client;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
-import org.baeldung.boot.Application;
+import com.baeldung.boot.Application;
+import com.baeldung.boot.client.Details;
+import com.baeldung.boot.client.DetailsServiceClient;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/websocket/client/MyStompSessionHandlerIntegrationTest.java b/spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/websocket/client/MyStompSessionHandlerIntegrationTest.java
index bb1b5e254e..57eec935f6 100644
--- a/spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/websocket/client/MyStompSessionHandlerIntegrationTest.java
+++ b/spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/websocket/client/MyStompSessionHandlerIntegrationTest.java
@@ -1,6 +1,5 @@
package com.baeldung.websocket.client;
-import org.baeldung.websocket.client.MyStompSessionHandler;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.messaging.simp.stomp.StompHeaders;
From 2e2fa14b7ca32ff9ba9d188d8719a91b3cbb3cfc Mon Sep 17 00:00:00 2001
From: mikr
Date: Sat, 4 Apr 2020 21:16:51 +0200
Subject: [PATCH 47/87] JAVA-117 Standardize
spring-boot-modules/spring-boot-gradle
---
spring-boot-modules/spring-boot-gradle/build.gradle | 8 ++++----
.../main/java/{org => com}/baeldung/DemoApplication.java | 2 +-
.../java/{org => com}/baeldung/DemoApplicationTests.java | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
rename spring-boot-modules/spring-boot-gradle/src/main/java/{org => com}/baeldung/DemoApplication.java (92%)
rename spring-boot-modules/spring-boot-gradle/src/test/java/{org => com}/baeldung/DemoApplicationTests.java (93%)
diff --git a/spring-boot-modules/spring-boot-gradle/build.gradle b/spring-boot-modules/spring-boot-gradle/build.gradle
index 96055536c3..faae01a1a5 100644
--- a/spring-boot-modules/spring-boot-gradle/build.gradle
+++ b/spring-boot-modules/spring-boot-gradle/build.gradle
@@ -21,7 +21,7 @@ apply plugin: 'io.spring.dependency-management'
//add tasks thinJar and thinResolve for thin JAR deployments
apply plugin: 'org.springframework.boot.experimental.thin-launcher'
-group = 'org.baeldung'
+group = 'com.baeldung'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
@@ -35,16 +35,16 @@ dependencies {
}
springBoot {
- mainClassName = 'org.baeldung.DemoApplication'
+ mainClassName = 'com.baeldung.DemoApplication'
}
bootJar {
// This is overridden by the mainClassName in springBoot{} and added here for reference purposes.
- mainClassName = 'org.baeldung.DemoApplication'
+ mainClassName = 'com.baeldung.DemoApplication'
// This block serves the same purpose as the above thus commented out. Added here for reference purposes
// manifest {
-// attributes 'Start-Class': 'org.baeldung.DemoApplication'
+// attributes 'Start-Class': 'com.baeldung.DemoApplication'
// }
}
diff --git a/spring-boot-modules/spring-boot-gradle/src/main/java/org/baeldung/DemoApplication.java b/spring-boot-modules/spring-boot-gradle/src/main/java/com/baeldung/DemoApplication.java
similarity index 92%
rename from spring-boot-modules/spring-boot-gradle/src/main/java/org/baeldung/DemoApplication.java
rename to spring-boot-modules/spring-boot-gradle/src/main/java/com/baeldung/DemoApplication.java
index f8df823f25..64bac6936b 100644
--- a/spring-boot-modules/spring-boot-gradle/src/main/java/org/baeldung/DemoApplication.java
+++ b/spring-boot-modules/spring-boot-gradle/src/main/java/com/baeldung/DemoApplication.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
diff --git a/spring-boot-modules/spring-boot-gradle/src/test/java/org/baeldung/DemoApplicationTests.java b/spring-boot-modules/spring-boot-gradle/src/test/java/com/baeldung/DemoApplicationTests.java
similarity index 93%
rename from spring-boot-modules/spring-boot-gradle/src/test/java/org/baeldung/DemoApplicationTests.java
rename to spring-boot-modules/spring-boot-gradle/src/test/java/com/baeldung/DemoApplicationTests.java
index b24bfb2cb6..65395582cb 100644
--- a/spring-boot-modules/spring-boot-gradle/src/test/java/org/baeldung/DemoApplicationTests.java
+++ b/spring-boot-modules/spring-boot-gradle/src/test/java/com/baeldung/DemoApplicationTests.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
From 6e21afabdb0c5e03c04252f66fe1a58202681874 Mon Sep 17 00:00:00 2001
From: mikr
Date: Sat, 4 Apr 2020 21:47:45 +0200
Subject: [PATCH 48/87] JAVA-117 Standardize spring-boot-modules
---
.../src/test/java/org/baeldung/SpringContextTest.java | 2 +-
.../src/test/java/org/baeldung/SpringContextTest.java | 2 +-
.../src/test/java/org/baeldung/SpringContextTest.java | 2 +-
spring-boot-modules/spring-boot-artifacts/pom.xml | 2 +-
.../src/test/java/org/baeldung/SpringContextTest.java | 2 +-
.../src/test/java/org/baeldung/SpringContextTest.java | 2 +-
.../src/test/java/org/baeldung/SpringContextTest.java | 2 +-
.../src/test/java/org/baeldung/SpringContextTest.java | 2 +-
spring-boot-modules/spring-boot-deployment/pom.xml | 2 +-
.../src/test/java/org/baeldung/SpringContextTest.java | 2 +-
.../src/test/java/org/baeldung/SpringContextTest.java | 2 +-
.../src/test/java/org/baeldung/SpringContextTest.java | 2 +-
.../src/test/java/org/baeldung/SpringContextLiveTest.java | 2 +-
.../src/test/java/org/baeldung/SpringContextTest.java | 2 +-
.../properties/external/ExternalPropertiesWithJavaConfig.java | 2 +-
.../properties/external/ExternalPropertiesWithXmlConfig.java | 2 +-
.../properties/external/ExternalPropertiesWithXmlConfigOne.java | 2 +-
.../src/test/java/org/baeldung/SpringContextTest.java | 2 +-
.../src/test/java/org/baeldung/SpringContextTest.java | 2 +-
.../src/test/java/org/baeldung/SpringContextTest.java | 2 +-
.../src/main/java/com/baeldung/main/SpringBootApplication.java | 2 +-
21 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/test/java/org/baeldung/SpringContextTest.java
index 834f26dacf..78a1ab7a54 100644
--- a/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/test/java/org/baeldung/SpringContextTest.java
+++ b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/test/java/org/baeldung/SpringContextTest.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/org/baeldung/SpringContextTest.java
index c185456019..3322193134 100644
--- a/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/org/baeldung/SpringContextTest.java
+++ b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/org/baeldung/SpringContextTest.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot-angular/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-angular/src/test/java/org/baeldung/SpringContextTest.java
index 961d756a68..0f4fa757d6 100644
--- a/spring-boot-modules/spring-boot-angular/src/test/java/org/baeldung/SpringContextTest.java
+++ b/spring-boot-modules/spring-boot-angular/src/test/java/org/baeldung/SpringContextTest.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot-artifacts/pom.xml b/spring-boot-modules/spring-boot-artifacts/pom.xml
index f7c8636593..de9f6ab635 100644
--- a/spring-boot-modules/spring-boot-artifacts/pom.xml
+++ b/spring-boot-modules/spring-boot-artifacts/pom.xml
@@ -208,7 +208,7 @@
- org.baeldung.boot.Application
+ com.baeldung.boot.Application
3.1.1
3.3.7-1
2.2
diff --git a/spring-boot-modules/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java
index 8324fabfca..ce743e0f77 100644
--- a/spring-boot-modules/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java
+++ b/spring-boot-modules/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot-ctx-fluent/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-ctx-fluent/src/test/java/org/baeldung/SpringContextTest.java
index ff3e795778..ca8989724b 100644
--- a/spring-boot-modules/spring-boot-ctx-fluent/src/test/java/org/baeldung/SpringContextTest.java
+++ b/spring-boot-modules/spring-boot-ctx-fluent/src/test/java/org/baeldung/SpringContextTest.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java
index e6ce83fab5..b4668e7d2b 100644
--- a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java
+++ b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java
index b82b67df68..7103da97f3 100644
--- a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java
+++ b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot-deployment/pom.xml b/spring-boot-modules/spring-boot-deployment/pom.xml
index 64c0e698f6..b3fc3eabd1 100644
--- a/spring-boot-modules/spring-boot-deployment/pom.xml
+++ b/spring-boot-modules/spring-boot-deployment/pom.xml
@@ -190,7 +190,7 @@
- org.baeldung.boot.Application
+ com.baeldung.boot.Application
3.1.1
3.3.7-1
2.2
diff --git a/spring-boot-modules/spring-boot-jasypt/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-jasypt/src/test/java/org/baeldung/SpringContextTest.java
index ab6e4557d5..97810cf590 100644
--- a/spring-boot-modules/spring-boot-jasypt/src/test/java/org/baeldung/SpringContextTest.java
+++ b/spring-boot-modules/spring-boot-jasypt/src/test/java/org/baeldung/SpringContextTest.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot-keycloak/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-keycloak/src/test/java/org/baeldung/SpringContextTest.java
index 4effccc083..3f3ecd87d0 100644
--- a/spring-boot-modules/spring-boot-keycloak/src/test/java/org/baeldung/SpringContextTest.java
+++ b/spring-boot-modules/spring-boot-keycloak/src/test/java/org/baeldung/SpringContextTest.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java
index 9817522e68..d2660ad84e 100644
--- a/spring-boot-modules/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java
+++ b/spring-boot-modules/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextLiveTest.java b/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextLiveTest.java
index 069dd41b8d..209a93d94c 100644
--- a/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextLiveTest.java
+++ b/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextLiveTest.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextTest.java
index 16e0708fc9..e73f4e79f7 100644
--- a/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextTest.java
+++ b/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextTest.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithJavaConfig.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithJavaConfig.java
index d43f18f6a7..5b954f8941 100644
--- a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithJavaConfig.java
+++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithJavaConfig.java
@@ -7,7 +7,7 @@ import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@Configuration
-@ComponentScan("org.baeldung.properties.core")
+@ComponentScan("com.baeldung.properties.core")
@PropertySource("classpath:foo.properties")
public class ExternalPropertiesWithJavaConfig {
diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfig.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfig.java
index 6d105428d9..9080e3d0ba 100644
--- a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfig.java
+++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfig.java
@@ -6,7 +6,7 @@ import org.springframework.context.annotation.ImportResource;
@Configuration
@ImportResource("classpath:configForProperties.xml")
-@ComponentScan("org.baeldung.core")
+@ComponentScan("com.baeldung.core")
public class ExternalPropertiesWithXmlConfig {
public ExternalPropertiesWithXmlConfig() {
diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfigOne.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfigOne.java
index 6f1e4c8490..f45f5b6a03 100644
--- a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfigOne.java
+++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfigOne.java
@@ -6,7 +6,7 @@ import org.springframework.context.annotation.ImportResource;
@Configuration
@ImportResource("classpath:configForPropertiesOne.xml")
-@ComponentScan("org.baeldung.core")
+@ComponentScan("com.baeldung.core")
public class ExternalPropertiesWithXmlConfigOne {
public ExternalPropertiesWithXmlConfigOne() {
diff --git a/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java
index 874c4f582f..2e1a17199d 100644
--- a/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java
+++ b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java
index 874c4f582f..2e1a17199d 100644
--- a/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java
+++ b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot-vue/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-vue/src/test/java/org/baeldung/SpringContextTest.java
index 16e0708fc9..e73f4e79f7 100644
--- a/spring-boot-modules/spring-boot-vue/src/test/java/org/baeldung/SpringContextTest.java
+++ b/spring-boot-modules/spring-boot-vue/src/test/java/org/baeldung/SpringContextTest.java
@@ -1,4 +1,4 @@
-package org.baeldung;
+package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/main/SpringBootApplication.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/main/SpringBootApplication.java
index c8cfb50f1c..383932524f 100644
--- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/main/SpringBootApplication.java
+++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/main/SpringBootApplication.java
@@ -18,7 +18,7 @@ import java.util.concurrent.Executors;
@RestController
@EnableAutoConfiguration
-@ComponentScan({ "org.baeldung.common.error", "com.baeldung.common.error.controller", "com.baeldung.common.properties", "com.baeldung.common.resources", "com.baeldung.endpoints", "com.baeldung.service", "com.baeldung.monitor.jmx", "com.baeldung.boot.config" })
+@ComponentScan({ "com.baeldung.common.error", "com.baeldung.common.error.controller", "com.baeldung.common.properties", "com.baeldung.common.resources", "com.baeldung.endpoints", "com.baeldung.service", "com.baeldung.monitor.jmx", "com.baeldung.boot.config" })
public class SpringBootApplication {
private static ApplicationContext applicationContext;
From f9a6ef176faec736ffe699134a2727bf959b2fe1 Mon Sep 17 00:00:00 2001
From: kwoyke
Date: Sun, 5 Apr 2020 07:52:47 +0200
Subject: [PATCH 49/87] BAEL-3978: Add code samples for Objects.equals()
(#9033)
---
.../comparelong/CompareLongUnitTest.java | 31 +++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/comparelong/CompareLongUnitTest.java b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/comparelong/CompareLongUnitTest.java
index ab4ea2b657..a26b0a74b0 100644
--- a/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/comparelong/CompareLongUnitTest.java
+++ b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/comparelong/CompareLongUnitTest.java
@@ -1,8 +1,12 @@
package com.baeldung.comparelong;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+
import org.junit.Test;
+import java.util.Objects;
+
public class CompareLongUnitTest {
@Test
@@ -32,6 +36,33 @@ public class CompareLongUnitTest {
assertThat(l1.equals(l2)).isTrue();
}
+ @Test
+ public void givenLongValuesLessThan128_whenUsingObjectsEquals_thenSuccess() {
+
+ Long l1 = 127L;
+ Long l2 = 127L;
+
+ assertThat(Objects.equals(l1, l2)).isTrue();
+ }
+
+ @Test
+ public void givenLongValuesGreaterOrEqualsThan128_whenUsingObjectsEquals_thenSuccess() {
+
+ Long l1 = 128L;
+ Long l2 = 128L;
+
+ assertThat(Objects.equals(l1, l2)).isTrue();
+ }
+
+ @Test
+ public void givenNullReference_whenUsingObjectsEquals_thenNoException() {
+
+ Long l1 = null;
+ Long l2 = 128L;
+
+ assertThatCode(() -> Objects.equals(l1, l2)).doesNotThrowAnyException();
+ }
+
@Test
public void givenLongValuesGreaterOrEqualsThan128_whenUsingComparisonOperator_andLongValue_thenSuccess() {
From 6c13633cac28b2e4fc1309903830e2ef42e539a5 Mon Sep 17 00:00:00 2001
From: Belma Jakupovic
Date: Mon, 6 Apr 2020 20:22:28 +0200
Subject: [PATCH 50/87] Belma Jakupovic - Mockito additional answers (#9041)
---
.../mockito/additionalanswers/Book.java | 58 ++++++++++++++++
.../additionalanswers/BookRepository.java | 17 +++++
.../additionalanswers/BookService.java | 22 ++++++
.../BookServiceUnitTest.java | 68 +++++++++++++++++++
4 files changed, 165 insertions(+)
create mode 100644 testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/Book.java
create mode 100644 testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookRepository.java
create mode 100644 testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookService.java
create mode 100644 testing-modules/mockito-2/src/test/java/com/baeldung/mockito/additionalanswers/BookServiceUnitTest.java
diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/Book.java b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/Book.java
new file mode 100644
index 0000000000..fa021f8cba
--- /dev/null
+++ b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/Book.java
@@ -0,0 +1,58 @@
+package com.baeldung.mockito.additionalanswers;
+
+public class Book {
+
+ private Long bookId;
+
+ private String title;
+
+ private String author;
+
+ private int numberOfPages;
+
+ public Book(String title, String author, int numberOfPages) {
+ this.title = title;
+ this.author = author;
+ this.numberOfPages = numberOfPages;
+ }
+
+ public Book(Long bookId, String title, String author, int numberOfPages) {
+ this.bookId = bookId;
+ this.title = title;
+ this.author = author;
+ this.numberOfPages = numberOfPages;
+ }
+
+ public Long getBookId() {
+ return bookId;
+ }
+
+ public void setBookId(Long bookId) {
+ this.bookId = bookId;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public int getNumberOfPages() {
+ return numberOfPages;
+ }
+
+ public void setNumberOfPages(int numberOfPages) {
+ this.numberOfPages = numberOfPages;
+ }
+}
+
diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookRepository.java b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookRepository.java
new file mode 100644
index 0000000000..78187e3f01
--- /dev/null
+++ b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookRepository.java
@@ -0,0 +1,17 @@
+package com.baeldung.mockito.additionalanswers;
+
+public class BookRepository {
+ public Book getByBookId(Long bookId) {
+ return new Book(bookId, "To Kill a Mocking Bird", "Harper Lee", 256);
+ }
+
+ public Book save(Book book) {
+ return new Book(book.getBookId(), book.getTitle(), book.getAuthor(), book.getNumberOfPages());
+ }
+
+ public Book checkIfEquals(Book bookOne, Book bookTwo, Book bookThree) {
+ if (bookOne.equals(bookTwo) && bookTwo.equals(bookThree) && bookThree.equals(bookOne)) {
+ return bookOne;
+ } else return bookTwo;
+ }
+}
diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookService.java b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookService.java
new file mode 100644
index 0000000000..92c01f8a70
--- /dev/null
+++ b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookService.java
@@ -0,0 +1,22 @@
+package com.baeldung.mockito.additionalanswers;
+
+public class BookService {
+ private final BookRepository bookRepository;
+
+ public BookService(BookRepository bookRepository) {
+ this.bookRepository = bookRepository;
+ }
+
+ public Book getByBookId(Long id) {
+ return bookRepository.getByBookId(id);
+ }
+
+ public Book save(Book book) {
+ return bookRepository.save(book);
+ }
+
+ public Book checkifEquals(Book book1, Book book2, Book book3) {
+ return bookRepository.checkIfEquals(book1, book2, book3);
+ }
+}
+
diff --git a/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/additionalanswers/BookServiceUnitTest.java b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/additionalanswers/BookServiceUnitTest.java
new file mode 100644
index 0000000000..c9527ec0ec
--- /dev/null
+++ b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/additionalanswers/BookServiceUnitTest.java
@@ -0,0 +1,68 @@
+package com.baeldung.mockito.additionalanswers;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.AdditionalAnswers;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+
+@RunWith(MockitoJUnitRunner.class)
+public class BookServiceUnitTest {
+ @InjectMocks
+ private BookService bookService;
+
+ @Mock
+ private BookRepository bookRepository;
+
+ @Test
+ public void givenSaveMethodMocked_whenSaveInvoked_ThenReturnFirstArgument_UnitTest() {
+ Book book = new Book("To Kill a Mocking Bird", "Harper Lee", 256);
+ Mockito.when(bookRepository.save(any(Book.class))).then(AdditionalAnswers.returnsFirstArg());
+
+ Book savedBook = bookService.save(book);
+
+ assertEquals(savedBook, book);
+ }
+
+ @Test
+ public void givenCheckifEqualsMethodMocked_whenCheckifEqualsInvoked_ThenReturnSecondArgument_UnitTest() {
+ Book book1 = new Book(1L, "The Stranger", "Albert Camus", 456);
+ Book book2 = new Book(2L, "Animal Farm", "George Orwell", 300);
+ Book book3 = new Book(3L, "Romeo and Juliet", "William Shakespeare", 200);
+
+ Mockito.when(bookRepository.checkIfEquals(any(Book.class), any(Book.class), any(Book.class))).then(AdditionalAnswers.returnsSecondArg());
+
+ Book secondBook = bookService.checkifEquals(book1, book2, book3);
+
+ assertEquals(secondBook, book2);
+ }
+
+ @Test
+ public void givenCheckifEqualsMethodMocked_whenCheckifEqualsInvoked_ThenReturnLastArgument_UnitTest() {
+ Book book1 = new Book(1L, "The Stranger", "Albert Camus", 456);
+ Book book2 = new Book(2L, "Animal Farm", "George Orwell", 300);
+ Book book3 = new Book(3L, "Romeo and Juliet", "William Shakespeare", 200);
+
+ Mockito.when(bookRepository.checkIfEquals(any(Book.class), any(Book.class), any(Book.class))).then(AdditionalAnswers.returnsLastArg());
+
+ Book lastBook = bookService.checkifEquals(book1, book2, book3);
+ assertEquals(lastBook, book3);
+ }
+
+ @Test
+ public void givenCheckifEqualsMethodMocked_whenCheckifEqualsInvoked_ThenReturnArgumentAtIndex_UnitTest() {
+ Book book1 = new Book(1L, "The Stranger", "Albert Camus", 456);
+ Book book2 = new Book(2L, "Animal Farm", "George Orwell", 300);
+ Book book3 = new Book(3L, "Romeo and Juliet", "William Shakespeare", 200);
+
+ Mockito.when(bookRepository.checkIfEquals(any(Book.class), any(Book.class), any(Book.class))).then(AdditionalAnswers.returnsArgAt(1));
+
+ Book bookOnIndex = bookService.checkifEquals(book1, book2, book3);
+
+ assertEquals(bookOnIndex, book2);
+ }
+}
From 817c5a012a9b00f419fa4e92eab61d56a64ebfb0 Mon Sep 17 00:00:00 2001
From: Jonathan Cook
Date: Mon, 6 Apr 2020 22:21:24 +0200
Subject: [PATCH 51/87] BAEL-3868 - Fix the integrations tests in mocks (#9039)
* BAEL-3491 - Check for null before calling parse in the
Double.parseDouble
* BAEL-3491 - Check for null before calling parse in the
Double.parseDouble
- Return to indentation with spaces.
* BAEL-3854 - Pattern Matching for instanceof in Java 14
* BAEL-3854 - Pattern Matching for instanceof in Java 14 - add unit test
* BAEL-3868 - Fix the integrations tests in mocks
Co-authored-by: Jonathan Cook
---
.../jmockit/ExpectationsCollaborator.java | 2 +-
.../jmockit/ExpectationsIntegrationTest.java | 35 ++++++++++---------
2 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/testing-modules/mocks/src/main/java/com/baeldung/jmockit/ExpectationsCollaborator.java b/testing-modules/mocks/src/main/java/com/baeldung/jmockit/ExpectationsCollaborator.java
index 799e7721e0..1aafa28a6a 100644
--- a/testing-modules/mocks/src/main/java/com/baeldung/jmockit/ExpectationsCollaborator.java
+++ b/testing-modules/mocks/src/main/java/com/baeldung/jmockit/ExpectationsCollaborator.java
@@ -15,5 +15,5 @@ public interface ExpectationsCollaborator {
void methodForArgThat(Object o);
String methodReturnsString();
int methodReturnsInt();
- Object methodForDelegate(int i);
+ int methodForDelegate(int i);
}
diff --git a/testing-modules/mocks/src/test/java/com/baeldung/jmockit/ExpectationsIntegrationTest.java b/testing-modules/mocks/src/test/java/com/baeldung/jmockit/ExpectationsIntegrationTest.java
index 8b0c3ab4ec..1ff90111d1 100644
--- a/testing-modules/mocks/src/test/java/com/baeldung/jmockit/ExpectationsIntegrationTest.java
+++ b/testing-modules/mocks/src/test/java/com/baeldung/jmockit/ExpectationsIntegrationTest.java
@@ -1,21 +1,21 @@
package com.baeldung.jmockit;
-import com.baeldung.jmockit.ExpectationsCollaborator;
-import com.baeldung.jmockit.Model;
-import mockit.Delegate;
-import mockit.Expectations;
-import mockit.Mocked;
-import mockit.Verifications;
-import mockit.integration.junit4.JMockit;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.junit.Test;
import org.junit.runner.RunWith;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
+import mockit.Delegate;
+import mockit.Expectations;
+import mockit.Mocked;
+import mockit.Verifications;
+import mockit.integration.junit4.JMockit;
@RunWith(JMockit.class)
@SuppressWarnings("unchecked")
@@ -112,17 +112,16 @@ public class ExpectationsIntegrationTest {
result = "foo";
result = new Exception();
result = "bar";
- mock.methodReturnsInt();
- result = new int[]{1, 2, 3};
- mock.methodReturnsString();
returns("foo", "bar");
mock.methodReturnsInt();
+ result = new int[]{1, 2, 3};
result = 1;
}};
assertEquals("Should return foo", "foo", mock.methodReturnsString());
try {
mock.methodReturnsString();
+ fail("Shouldn't reach here");
} catch (Exception e) {
// NOOP
}
@@ -134,13 +133,14 @@ public class ExpectationsIntegrationTest {
assertEquals("Should return bar", "bar", mock.methodReturnsString());
assertEquals("Should return 1", 1, mock.methodReturnsInt());
}
-
+
@Test
public void testDelegate(@Mocked ExpectationsCollaborator mock) {
new Expectations() {{
mock.methodForDelegate(anyInt);
- result = new Delegate() {
- public int delegate(int i) throws Exception {
+
+ result = new Delegate() {
+ int delegate(int i) throws Exception {
if (i < 3) {
return 5;
} else {
@@ -153,6 +153,7 @@ public class ExpectationsIntegrationTest {
assertEquals("Should return 5", 5, mock.methodForDelegate(1));
try {
mock.methodForDelegate(3);
+ fail("Shouldn't reach here");
} catch (Exception e) {
}
}
From 114048af945360ed1f8f8aeb534fd5cfcb4e4c32 Mon Sep 17 00:00:00 2001
From: Krzysiek
Date: Mon, 6 Apr 2020 22:28:19 +0200
Subject: [PATCH 52/87] JAVA-1201: Disable libraries-concurrency in the main
pom.xml
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index e21c13efc2..bc9b820766 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1263,7 +1263,7 @@
wildfly
xml
xstream
- libraries-concurrency
+
From 9d3eafd57efc3239b22dc6f38b271c39c089989d Mon Sep 17 00:00:00 2001
From: Krzysztof Woyke
Date: Tue, 7 Apr 2020 08:50:55 +0200
Subject: [PATCH 53/87] Revert "JAVA-1201: Disable libraries-concurrency in the
main pom.xml"
This reverts commit 114048af945360ed1f8f8aeb534fd5cfcb4e4c32.
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index bc9b820766..e21c13efc2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1263,7 +1263,7 @@
wildfly
xml
xstream
-
+ libraries-concurrency
From 5d3e1da1ce6fb6663a376ad709c59bede16a8b91 Mon Sep 17 00:00:00 2001
From: Krzysztof Woyke
Date: Tue, 7 Apr 2020 08:52:00 +0200
Subject: [PATCH 54/87] JAVA-1201: Disable coroutines-with-quasar as it needs
Java 12
---
libraries-concurrency/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libraries-concurrency/pom.xml b/libraries-concurrency/pom.xml
index 7ae834025f..cb59b17674 100644
--- a/libraries-concurrency/pom.xml
+++ b/libraries-concurrency/pom.xml
@@ -14,7 +14,7 @@
- coroutines-with-quasar
+
\ No newline at end of file
From 4cab4f6917d7e4ab277cbd7072800f63b8ebd82d Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Tue, 7 Apr 2020 15:02:49 +0800
Subject: [PATCH 55/87] Update README.md
---
cas/cas-server/README.md | 145 ---------------------------------------
1 file changed, 145 deletions(-)
diff --git a/cas/cas-server/README.md b/cas/cas-server/README.md
index b224738732..8b13789179 100644
--- a/cas/cas-server/README.md
+++ b/cas/cas-server/README.md
@@ -1,146 +1 @@
-CAS Overlay Template [](https://travis-ci.org/apereo/cas-overlay-template)
-=======================
-Generic CAS WAR overlay to exercise the latest versions of CAS. This overlay could be freely used as a starting template for local CAS war overlays.
-
-# Versions
-
-- CAS `6.1.x`
-- JDK `11`
-
-# Overview
-
-To build the project, use:
-
-```bash
-# Use --refresh-dependencies to force-update SNAPSHOT versions
-./gradlew[.bat] clean build
-```
-
-To see what commands are available to the build script, run:
-
-```bash
-./gradlew[.bat] tasks
-```
-
-To launch into the CAS command-line shell:
-
-```bash
-./gradlew[.bat] downloadShell runShell
-```
-
-To fetch and overlay a CAS resource or view, use:
-
-```bash
-./gradlew[.bat] getResource -PresourceName=[resource-name]
-```
-
-To list all available CAS views and templates:
-
-```bash
-./gradlew[.bat] listTemplateViews
-```
-
-To unzip and explode the CAS web application file and the internal resources jar:
-
-```bash
-./gradlew[.bat] explodeWar
-```
-
-# Configuration
-
-- The `etc` directory contains the configuration files and directories that need to be copied to `/etc/cas/config`.
-
-```bash
-./gradlew[.bat] copyCasConfiguration
-```
-
-- The specifics of the build are controlled using the `gradle.properties` file.
-
-## Adding Modules
-
-CAS modules may be specified under the `dependencies` block of the [Gradle build script](build.gradle):
-
-```gradle
-dependencies {
- compile "org.apereo.cas:cas-server-some-module:${project.casVersion}"
- ...
-}
-```
-
-To collect the list of all project modules and dependencies:
-
-```bash
-./gradlew[.bat] allDependencies
-```
-
-### Clear Gradle Cache
-
-If you need to, on Linux/Unix systems, you can delete all the existing artifacts (artifacts and metadata) Gradle has downloaded using:
-
-```bash
-# Only do this when absolutely necessary
-rm -rf $HOME/.gradle/caches/
-```
-
-Same strategy applies to Windows too, provided you switch `$HOME` to its equivalent in the above command.
-
-# Deployment
-
-- Create a keystore file `thekeystore` under `/etc/cas`. Use the password `changeit` for both the keystore and the key/certificate entries. This can either be done using the JDK's `keytool` utility or via the following command:
-
-```bash
-./gradlew[.bat] createKeystore
-```
-
-- Ensure the keystore is loaded up with keys and certificates of the server.
-
-On a successful deployment via the following methods, CAS will be available at:
-
-* `https://cas.server.name:8443/cas`
-
-## Executable WAR
-
-Run the CAS web application as an executable WAR:
-
-```bash
-./gradlew[.bat] run
-```
-
-Debug the CAS web application as an executable WAR:
-
-```bash
-./gradlew[.bat] debug
-```
-
-Run the CAS web application as a *standalone* executable WAR:
-
-```bash
-./gradlew[.bat] clean executable
-```
-
-## External
-
-Deploy the binary web application file `cas.war` after a successful build to a servlet container of choice.
-
-## Docker
-
-The following strategies outline how to build and deploy CAS Docker images.
-
-### Jib
-
-The overlay embraces the [Jib Gradle Plugin](https://github.com/GoogleContainerTools/jib) to provide easy-to-use out-of-the-box tooling for building CAS docker images. Jib is an open-source Java containerizer from Google that lets Java developers build containers using the tools they know. It is a container image builder that handles all the steps of packaging your application into a container image. It does not require you to write a Dockerfile or have Docker installed, and it is directly integrated into the overlay.
-
-```bash
-./gradlew build jibDockerBuild
-```
-
-### Dockerfile
-
-You can also use the native Docker tooling and the provided `Dockerfile` to build and run CAS.
-
-```bash
-chmod +x *.sh
-./docker-build.sh
-./docker-run.sh
-```
From d96430302da9a97b4c5e7479de5fd61afa2b176f Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Tue, 7 Apr 2020 15:02:57 +0800
Subject: [PATCH 56/87] Delete README.md
---
cas/cas-server/README.md | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 cas/cas-server/README.md
diff --git a/cas/cas-server/README.md b/cas/cas-server/README.md
deleted file mode 100644
index 8b13789179..0000000000
--- a/cas/cas-server/README.md
+++ /dev/null
@@ -1 +0,0 @@
-
From 84c7da874b49079d21a579cbd45d77db52b2529a Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Tue, 7 Apr 2020 16:24:27 +0800
Subject: [PATCH 57/87] Update README.md
---
libraries-3/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libraries-3/README.md b/libraries-3/README.md
index f3c3375098..62bd3b9f66 100644
--- a/libraries-3/README.md
+++ b/libraries-3/README.md
@@ -15,4 +15,4 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m
- [Introduction to the jcabi-aspects AOP Annotations Library](https://www.baeldung.com/java-jcabi-aspects)
- [Introduction to Takes](https://www.baeldung.com/java-takes)
- [Using NullAway to Avoid NullPointerExceptions](https://www.baeldung.com/java-nullaway)
-
+- [Introduction to Alibaba Arthas](https://www.baeldung.com/java-alibaba-arthas-intro)
From 6470be6c3d47413197d094d62a1c4ce87a9616a0 Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Tue, 7 Apr 2020 16:27:04 +0800
Subject: [PATCH 58/87] Update README.md
---
persistence-modules/spring-boot-persistence-h2/README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/persistence-modules/spring-boot-persistence-h2/README.md b/persistence-modules/spring-boot-persistence-h2/README.md
index a0f9c67a33..d11ec1f409 100644
--- a/persistence-modules/spring-boot-persistence-h2/README.md
+++ b/persistence-modules/spring-boot-persistence-h2/README.md
@@ -1,4 +1,5 @@
### Relevant Articles:
- [Access the Same In-Memory H2 Database in Multiple Spring Boot Applications](https://www.baeldung.com/spring-boot-access-h2-database-multiple-apps)
- [Spring Boot With H2 Database](https://www.baeldung.com/spring-boot-h2-database)
-- [Hibernate @NotNull vs @Column(nullable = false)](https://www.baeldung.com/hibernate-notnull-vs-nullable)
\ No newline at end of file
+- [Hibernate @NotNull vs @Column(nullable = false)](https://www.baeldung.com/hibernate-notnull-vs-nullable)
+- [Quick Guide to Hibernate enable_lazy_load_no_trans Property](https://www.baeldung.com/hibernate-lazy-loading-workaround)
From aacc987598ccf6fa79bf6481dad4dbbedc06a36b Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Tue, 7 Apr 2020 16:30:42 +0800
Subject: [PATCH 59/87] Update README.md
---
core-java-modules/core-java-io-2/README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/core-java-modules/core-java-io-2/README.md b/core-java-modules/core-java-io-2/README.md
index 62461be0ff..84cabc5992 100644
--- a/core-java-modules/core-java-io-2/README.md
+++ b/core-java-modules/core-java-io-2/README.md
@@ -12,4 +12,5 @@ This module contains articles about core Java input and output (IO)
- [Java – Append Data to a File](https://www.baeldung.com/java-append-to-file)
- [How to Copy a File with Java](https://www.baeldung.com/java-copy-file)
- [Create a Directory in Java](https://www.baeldung.com/java-create-directory)
+- [Java IO vs NIO](https://www.baeldung.com/java-io-vs-nio)
- [[<-- Prev]](/core-java-modules/core-java-io)
From 2cbdb26c8ca2ee5c18bd98e2fb214d9b9fbf8af8 Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Tue, 7 Apr 2020 16:37:03 +0800
Subject: [PATCH 60/87] Create README.md
---
linux-bash/functions/src/main/bash/README.md | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 linux-bash/functions/src/main/bash/README.md
diff --git a/linux-bash/functions/src/main/bash/README.md b/linux-bash/functions/src/main/bash/README.md
new file mode 100644
index 0000000000..5fb6958b9d
--- /dev/null
+++ b/linux-bash/functions/src/main/bash/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles
+
+- [Bash Functions in Linux](https://www.baeldung.com/linux/bash-functions)
From a112f50f050a9c802680f6420a9edd171f273280 Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Tue, 7 Apr 2020 16:39:13 +0800
Subject: [PATCH 61/87] Create README.md
---
lombok/src/main/README.md | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 lombok/src/main/README.md
diff --git a/lombok/src/main/README.md b/lombok/src/main/README.md
new file mode 100644
index 0000000000..4092d8ce99
--- /dev/null
+++ b/lombok/src/main/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles:
+
+- [Guide to the Linux wc Command](https://www.baeldung.com/linux/wc-command)
From bf973384e234a1a3c5313179297a58c7faee45db Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Tue, 7 Apr 2020 16:44:15 +0800
Subject: [PATCH 62/87] Create README.md
---
linux-bash/read/README.md | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 linux-bash/read/README.md
diff --git a/linux-bash/read/README.md b/linux-bash/read/README.md
new file mode 100644
index 0000000000..56c1dd5b24
--- /dev/null
+++ b/linux-bash/read/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles:
+
+- [Guide to the Linux read Command](https://www.baeldung.com/linux/read-command)
From 56162f373edf8a5b60ca60da4308cdb4ee543a79 Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Tue, 7 Apr 2020 16:48:21 +0800
Subject: [PATCH 63/87] Create README.md
---
linux-bash/command-line-arguments/src/main/bash/README.md | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 linux-bash/command-line-arguments/src/main/bash/README.md
diff --git a/linux-bash/command-line-arguments/src/main/bash/README.md b/linux-bash/command-line-arguments/src/main/bash/README.md
new file mode 100644
index 0000000000..27d89fff99
--- /dev/null
+++ b/linux-bash/command-line-arguments/src/main/bash/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles:
+
+- [How to Use Command Line Arguments in a Bash Script](https://www.baeldung.com/linux/use-command-line-arguments-in-bash-script)
From 36305bbb2fb3cc60c3a6761855288ece77cf2ca6 Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Tue, 7 Apr 2020 16:49:44 +0800
Subject: [PATCH 64/87] Update README.md
---
linux-bash/text/README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/linux-bash/text/README.md b/linux-bash/text/README.md
index de99c1962a..20df2a33ec 100644
--- a/linux-bash/text/README.md
+++ b/linux-bash/text/README.md
@@ -1,3 +1,4 @@
### Relevant Articles:
- [Linux Commands – Remove All Text After X](https://www.baeldung.com/linux/tr-manipulate-strings)
+- [Linux Commands for Appending Multiple Lines to a File](https://www.baeldung.com/linux/appending-multiple-lines-to-file2)
From 584cbd9aa73803181d491ec091afce6d25ef2b78 Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Tue, 7 Apr 2020 16:56:28 +0800
Subject: [PATCH 65/87] Create README.md
---
.../core-java-concurrency-collections-2/README.md | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 core-java-modules/core-java-concurrency-collections-2/README.md
diff --git a/core-java-modules/core-java-concurrency-collections-2/README.md b/core-java-modules/core-java-concurrency-collections-2/README.md
new file mode 100644
index 0000000000..91da6c623c
--- /dev/null
+++ b/core-java-modules/core-java-concurrency-collections-2/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles:
+
+- [Introduction to Lock Striping](https://www.baeldung.com/java-lock-stripping)
From e8e8fb2e3bd4f47a0b0a1558a052e90d56cacc5f Mon Sep 17 00:00:00 2001
From: johnA1331 <53036378+johnA1331@users.noreply.github.com>
Date: Tue, 7 Apr 2020 17:09:25 +0800
Subject: [PATCH 66/87] Create README.md
---
core-scala/README.md | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 core-scala/README.md
diff --git a/core-scala/README.md b/core-scala/README.md
new file mode 100644
index 0000000000..72b583c22b
--- /dev/null
+++ b/core-scala/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles:
+
+- [Pattern Matching in Scala](https://www.baeldung.com/scala/pattern-matching)
From a3d01425f7f52b88083d4604ec51eb4cf843e016 Mon Sep 17 00:00:00 2001
From: sampadawagde
Date: Tue, 7 Apr 2020 14:49:42 +0530
Subject: [PATCH 67/87] JAVA-1188: Moved modules to core-java-modules
---
java-collections-maps-2/README.md | 16 -
java-collections-maps-2/pom.xml | 79 ----
.../main/java/com/baeldung/map/Product.java | 133 -------
.../com/baeldung/map/convert/MapToString.java | 34 --
.../com/baeldung/map/convert/StringToMap.java | 21 --
.../baeldung/map/copyhashmap/CopyHashMap.java | 55 ---
.../map/initialize/MapInitializer.java | 80 -----
.../baeldung/map/iteration/MapIteration.java | 74 ----
.../java/com/baeldung/map/mapmax/MapMax.java | 92 -----
.../com/baeldung/map/mergemaps/Employee.java | 60 ----
.../com/baeldung/map/mergemaps/MergeMaps.java | 105 ------
.../map/primitives/PrimitiveMaps.java | 69 ----
.../com/baeldung/map/sort/SortHashMap.java | 104 ------
.../com/baeldung/map/ProductUnitTest.java | 174 ---------
.../map/convert/MapToStringUnitTest.java | 48 ---
.../map/convert/StringToMapUnitTest.java | 23 --
.../map/copyhashmap/CopyHashMapUnitTest.java | 76 ----
.../baeldung/map/copyhashmap/Employee.java | 28 --
.../initialize/MapInitializerUnitTest.java | 27 --
.../baeldung/map/mapmax/MapMaxUnitTest.java | 58 ---
.../map/weakhashmap/WeakHashMapUnitTest.java | 72 ----
java-collections-maps-3/README.md | 8 -
java-collections-maps-3/pom.xml | 26 --
.../compare/HashMapComparisonUnitTest.java | 225 ------------
.../TreeMapVsHashMapUnitTest.java | 58 ---
java-collections-maps/README.md | 16 -
java-collections-maps/pom.xml | 35 --
.../main/java/com/baeldung/map/MapUtil.java | 44 ---
.../src/main/java/com/baeldung/map/MyKey.java | 64 ----
.../com/baeldung/map/MyLinkedHashMap.java | 23 --
.../src/main/resources/logback.xml | 13 -
.../baeldung/guava/GuavaBiMapUnitTest.java | 120 -------
.../baeldung/map/ImmutableMapUnitTest.java | 84 -----
.../com/baeldung/map/KeyCheckUnitTest.java | 27 --
.../map/MapMultipleValuesUnitTest.java | 119 -------
.../java/com/baeldung/map/MapUnitTest.java | 336 ------------------
.../com/baeldung/map/MapUtilUnitTest.java | 103 ------
.../baeldung/map/MultiValuedMapUnitTest.java | 227 ------------
38 files changed, 2956 deletions(-)
delete mode 100644 java-collections-maps-2/README.md
delete mode 100644 java-collections-maps-2/pom.xml
delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/Product.java
delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/convert/MapToString.java
delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/convert/StringToMap.java
delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/copyhashmap/CopyHashMap.java
delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/initialize/MapInitializer.java
delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/iteration/MapIteration.java
delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/mapmax/MapMax.java
delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/Employee.java
delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/MergeMaps.java
delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/primitives/PrimitiveMaps.java
delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/sort/SortHashMap.java
delete mode 100644 java-collections-maps-2/src/test/java/com/baeldung/map/ProductUnitTest.java
delete mode 100644 java-collections-maps-2/src/test/java/com/baeldung/map/convert/MapToStringUnitTest.java
delete mode 100644 java-collections-maps-2/src/test/java/com/baeldung/map/convert/StringToMapUnitTest.java
delete mode 100644 java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/CopyHashMapUnitTest.java
delete mode 100644 java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/Employee.java
delete mode 100644 java-collections-maps-2/src/test/java/com/baeldung/map/initialize/MapInitializerUnitTest.java
delete mode 100644 java-collections-maps-2/src/test/java/com/baeldung/map/mapmax/MapMaxUnitTest.java
delete mode 100644 java-collections-maps-2/src/test/java/com/baeldung/map/weakhashmap/WeakHashMapUnitTest.java
delete mode 100644 java-collections-maps-3/README.md
delete mode 100644 java-collections-maps-3/pom.xml
delete mode 100644 java-collections-maps-3/src/test/java/com/baeldung/map/compare/HashMapComparisonUnitTest.java
delete mode 100644 java-collections-maps-3/src/test/java/com/baeldung/map/treemaphashmap/TreeMapVsHashMapUnitTest.java
delete mode 100644 java-collections-maps/README.md
delete mode 100644 java-collections-maps/pom.xml
delete mode 100644 java-collections-maps/src/main/java/com/baeldung/map/MapUtil.java
delete mode 100644 java-collections-maps/src/main/java/com/baeldung/map/MyKey.java
delete mode 100644 java-collections-maps/src/main/java/com/baeldung/map/MyLinkedHashMap.java
delete mode 100644 java-collections-maps/src/main/resources/logback.xml
delete mode 100644 java-collections-maps/src/test/java/com/baeldung/guava/GuavaBiMapUnitTest.java
delete mode 100644 java-collections-maps/src/test/java/com/baeldung/map/ImmutableMapUnitTest.java
delete mode 100644 java-collections-maps/src/test/java/com/baeldung/map/KeyCheckUnitTest.java
delete mode 100644 java-collections-maps/src/test/java/com/baeldung/map/MapMultipleValuesUnitTest.java
delete mode 100644 java-collections-maps/src/test/java/com/baeldung/map/MapUnitTest.java
delete mode 100644 java-collections-maps/src/test/java/com/baeldung/map/MapUtilUnitTest.java
delete mode 100644 java-collections-maps/src/test/java/com/baeldung/map/MultiValuedMapUnitTest.java
diff --git a/java-collections-maps-2/README.md b/java-collections-maps-2/README.md
deleted file mode 100644
index 2188960543..0000000000
--- a/java-collections-maps-2/README.md
+++ /dev/null
@@ -1,16 +0,0 @@
-## Java Collections Cookbooks and Examples
-
-This module contains articles about Map data structures in Java.
-
-### Relevant Articles:
-- [Map of Primitives in Java](https://www.baeldung.com/java-map-primitives)
-- [Copying a HashMap in Java](https://www.baeldung.com/java-copy-hashmap)
-- [A Guide to Java HashMap](https://www.baeldung.com/java-hashmap)
-- [Guide to WeakHashMap in Java](https://www.baeldung.com/java-weakhashmap)
-- [Map to String Conversion in Java](https://www.baeldung.com/java-map-to-string-conversion)
-- [Iterate over a Map in Java](https://www.baeldung.com/java-iterate-map)
-- [Merging Two Maps with Java 8](https://www.baeldung.com/java-merge-maps)
-- [Sort a HashMap in Java](https://www.baeldung.com/java-hashmap-sort)
-- [Finding the Highest Value in a Java Map](https://www.baeldung.com/java-find-map-max)
-- [Initialize a HashMap in Java](https://www.baeldung.com/java-initialize-hashmap)
-- More articles: [[<-- prev]](/java-collections-maps) [[next -->]](/java-collections-maps-3)
diff --git a/java-collections-maps-2/pom.xml b/java-collections-maps-2/pom.xml
deleted file mode 100644
index a246559f61..0000000000
--- a/java-collections-maps-2/pom.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
- 4.0.0
- java-collections-maps-2
- 0.1.0-SNAPSHOT
- java-collections-maps-2
- jar
-
-
- com.baeldung
- parent-java
- 0.0.1-SNAPSHOT
- ../parent-java
-
-
-
-
- org.eclipse.collections
- eclipse-collections
- ${eclipse-collections.version}
-
-
- net.sf.trove4j
- trove4j
- ${trove4j.version}
-
-
- it.unimi.dsi
- fastutil
- ${fastutil.version}
-
-
- colt
- colt
- ${colt.version}
-
-
- org.apache.commons
- commons-lang3
- ${commons-lang3.version}
-
-
- org.apache.commons
- commons-collections4
- ${commons-collections4.version}
-
-
- one.util
- streamex
- ${streamex.version}
-
-
- com.jayway.awaitility
- awaitility
- ${avaitility.version}
- test
-
-
- org.assertj
- assertj-core
- ${assertj.version}
- test
-
-
-
-
- 0.6.5
- 4.1
- 1.7.0
- 8.2.0
- 3.0.2
- 8.1.0
- 1.2.0
- 3.11.1
-
-
-
\ No newline at end of file
diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/Product.java b/java-collections-maps-2/src/main/java/com/baeldung/map/Product.java
deleted file mode 100644
index 5559895730..0000000000
--- a/java-collections-maps-2/src/main/java/com/baeldung/map/Product.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package com.baeldung.map;
-
-import java.util.*;
-
-public class Product {
-
- private String name;
- private String description;
- private List tags;
-
- public Product(String name, String description) {
- this.name = name;
- this.description = description;
- this.tags = new ArrayList<>();
- }
-
- public String getName() {
- return name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public List getTags() {
- return tags;
- }
-
- public Product addTagsOfOtherProdcut(Product product) {
- this.tags.addAll(product.getTags());
- return this;
- }
-
- @Override
- public boolean equals(Object o) {
-
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- Product product = (Product) o;
- return Objects.equals(name, product.name) &&
- Objects.equals(description, product.description);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(name, description);
- }
-
- public static void forEach() {
-
- HashMap productsByName = new HashMap<>();
- productsByName.forEach( (key, product)
- -> System.out.println("Key: " + key + " Product:" + product.getDescription())
- //do something with the key and value
- );
-
- //Prior to Java 8:
- for(Map.Entry entry : productsByName.entrySet()) {
- Product product = entry.getValue();
- String key = entry.getKey();
- //do something with the key and value
- }
- }
-
- public static void getOrDefault() {
-
- HashMap productsByName = new HashMap<>();
- Product chocolate = new Product("chocolate", "something sweet");
- Product defaultProduct = productsByName.getOrDefault("horse carriage", chocolate);
- Product bike = productsByName.getOrDefault("E-Bike", chocolate);
-
- //Prior to Java 8:
- Product bike2 = productsByName.containsKey("E-Bike")
- ? productsByName.get("E-Bike")
- : chocolate;
- Product defaultProduct2 = productsByName.containsKey("horse carriage")
- ? productsByName.get("horse carriage")
- : chocolate;
- }
-
- public static void putIfAbsent() {
-
- HashMap productsByName = new HashMap<>();
- Product chocolate = new Product("chocolate", "something sweet");
- productsByName.putIfAbsent("E-Bike", chocolate);
-
- //Prior to Java 8:
- if(productsByName.containsKey("E-Bike")) {
- productsByName.put("E-Bike", chocolate);
- }
- }
-
- public static void merge() {
-
- HashMap productsByName = new HashMap<>();
- Product eBike2 = new Product("E-Bike", "A bike with a battery");
- eBike2.getTags().add("sport");
- productsByName.merge("E-Bike", eBike2, Product::addTagsOfOtherProdcut);
-
- //Prior to Java 8:
- if(productsByName.containsKey("E-Bike")) {
- productsByName.get("E-Bike").addTagsOfOtherProdcut(eBike2);
- } else {
- productsByName.put("E-Bike", eBike2);
- }
- }
-
- public static void compute() {
-
- HashMap productsByName = new HashMap<>();
- Product eBike2 = new Product("E-Bike", "A bike with a battery");
-
- productsByName.compute("E-Bike", (k,v) -> {
- if(v != null) {
- return v.addTagsOfOtherProdcut(eBike2);
- } else {
- return eBike2;
- }
- });
-
- //Prior to Java 8:
- if(productsByName.containsKey("E-Bike")) {
- productsByName.get("E-Bike").addTagsOfOtherProdcut(eBike2);
- } else {
- productsByName.put("E-Bike", eBike2);
- }
- }
-}
diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/convert/MapToString.java b/java-collections-maps-2/src/main/java/com/baeldung/map/convert/MapToString.java
deleted file mode 100644
index d13be924ff..0000000000
--- a/java-collections-maps-2/src/main/java/com/baeldung/map/convert/MapToString.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.baeldung.map.convert;
-
-import com.google.common.base.Joiner;
-import org.apache.commons.lang3.StringUtils;
-
-import java.util.Map;
-import java.util.stream.Collectors;
-
-public class MapToString {
-
- public static String convertWithIteration(Map map) {
- StringBuilder mapAsString = new StringBuilder("{");
- for (Integer key : map.keySet()) {
- mapAsString.append(key + "=" + map.get(key) + ", ");
- }
- mapAsString.delete(mapAsString.length()-2, mapAsString.length()).append("}");
- return mapAsString.toString();
- }
-
- public static String convertWithStream(Map map) {
- String mapAsString = map.keySet().stream()
- .map(key -> key + "=" + map.get(key))
- .collect(Collectors.joining(", ", "{", "}"));
- return mapAsString;
- }
-
- public static String convertWithGuava(Map map) {
- return Joiner.on(",").withKeyValueSeparator("=").join(map);
- }
-
- public static String convertWithApache(Map map) {
- return StringUtils.join(map);
- }
-}
diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/convert/StringToMap.java b/java-collections-maps-2/src/main/java/com/baeldung/map/convert/StringToMap.java
deleted file mode 100644
index 416ba4dd9a..0000000000
--- a/java-collections-maps-2/src/main/java/com/baeldung/map/convert/StringToMap.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.baeldung.map.convert;
-
-import com.google.common.base.Splitter;
-
-import java.util.Arrays;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-public class StringToMap {
-
- public static Map convertWithStream(String mapAsString) {
- Map map = Arrays.stream(mapAsString.split(","))
- .map(entry -> entry.split("="))
- .collect(Collectors.toMap(entry -> entry[0], entry -> entry[1]));
- return map;
- }
-
- public static Map convertWithGuava(String mapAsString) {
- return Splitter.on(',').withKeyValueSeparator('=').split(mapAsString);
- }
-}
diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/copyhashmap/CopyHashMap.java b/java-collections-maps-2/src/main/java/com/baeldung/map/copyhashmap/CopyHashMap.java
deleted file mode 100644
index cb18f3aa11..0000000000
--- a/java-collections-maps-2/src/main/java/com/baeldung/map/copyhashmap/CopyHashMap.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.baeldung.map.copyhashmap;
-
-import org.apache.commons.lang3.SerializationUtils;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-public class CopyHashMap {
-
- public static HashMap copyUsingConstructor(HashMap originalMap) {
- return new HashMap(originalMap);
- }
-
- public static HashMap copyUsingClone(HashMap originalMap) {
- return (HashMap) originalMap.clone();
- }
-
- public static HashMap copyUsingPut(HashMap originalMap) {
- HashMap shallowCopy = new HashMap();
- Set> entries = originalMap.entrySet();
- for(Map.Entry mapEntry: entries) {
- shallowCopy.put(mapEntry.getKey(), mapEntry.getValue());
- }
-
- return shallowCopy;
- }
-
- public static HashMap copyUsingPutAll(HashMap originalMap) {
- HashMap shallowCopy = new HashMap();
- shallowCopy.putAll(originalMap);
-
- return shallowCopy;
- }
-
- public static HashMap copyUsingJava8Stream(HashMap originalMap) {
- Set> entries = originalMap.entrySet();
- HashMap shallowCopy = (HashMap) entries
- .stream()
- .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
-
- return shallowCopy;
- }
-
- public static HashMap shallowCopy(HashMap originalMap) {
- return (HashMap) originalMap.clone();
- }
-
- public static HashMap deepCopy(HashMap originalMap) {
- return SerializationUtils.clone(originalMap);
- }
-
-}
diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/initialize/MapInitializer.java b/java-collections-maps-2/src/main/java/com/baeldung/map/initialize/MapInitializer.java
deleted file mode 100644
index 4d63abcfd0..0000000000
--- a/java-collections-maps-2/src/main/java/com/baeldung/map/initialize/MapInitializer.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package com.baeldung.map.initialize;
-
-import java.util.AbstractMap;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-public class MapInitializer {
-
- public static Map articleMapOne;
- static {
- articleMapOne = new HashMap<>();
- articleMapOne.put("ar01", "Intro to Map");
- articleMapOne.put("ar02", "Some article");
- }
-
- public static Map createSingletonMap() {
- Map passwordMap = Collections.singletonMap("username1", "password1");
- return passwordMap;
-
- }
-
- public Map createEmptyMap() {
- Map emptyMap = Collections.emptyMap();
- return emptyMap;
- }
-
- public Map createUsingDoubleBrace() {
- Map doubleBraceMap = new HashMap() {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- {
- put("key1", "value1");
- put("key2", "value2");
- }
- };
- return doubleBraceMap;
- }
-
- public Map createMapUsingStreamStringArray() {
- Map map = Stream.of(new String[][] { { "Hello", "World" }, { "John", "Doe" }, })
- .collect(Collectors.toMap(data -> data[0], data -> data[1]));
-
- return map;
- }
-
- public Map createMapUsingStreamObjectArray() {
- Map map = Stream.of(new Object[][] { { "data1", 1 }, { "data2", 2 }, })
- .collect(Collectors.toMap(data -> (String) data[0], data -> (Integer) data[1]));
-
- return map;
- }
-
- public Map createMapUsingStreamSimpleEntry() {
- Map map = Stream.of(new AbstractMap.SimpleEntry<>("idea", 1), new AbstractMap.SimpleEntry<>("mobile", 2))
- .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
-
- return map;
- }
-
- public Map createMapUsingStreamSimpleImmutableEntry() {
- Map map = Stream.of(new AbstractMap.SimpleImmutableEntry<>("idea", 1), new AbstractMap.SimpleImmutableEntry<>("mobile", 2))
- .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
-
- return map;
- }
-
- public Map createImmutableMapWithStreams() {
- Map map = Stream.of(new String[][] { { "Hello", "World" }, { "John", "Doe" }, })
- .collect(Collectors.collectingAndThen(Collectors.toMap(data -> data[0], data -> data[1]), Collections:: unmodifiableMap));
- return map;
-
- }
-}
diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/iteration/MapIteration.java b/java-collections-maps-2/src/main/java/com/baeldung/map/iteration/MapIteration.java
deleted file mode 100644
index b0c32e1487..0000000000
--- a/java-collections-maps-2/src/main/java/com/baeldung/map/iteration/MapIteration.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package com.baeldung.map.iteration;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-public class MapIteration {
-
- public static void main(String[] args) {
- MapIteration mapIteration = new MapIteration();
- Map map = new HashMap<>();
-
- map.put("One", 1);
- map.put("Three", 3);
- map.put("Two", 2);
-
- System.out.println("Iterating Keys of Map Using KeySet");
- mapIteration.iterateKeys(map);
-
- System.out.println("Iterating Map Using Entry Set");
- mapIteration.iterateUsingEntrySet(map);
-
- System.out.println("Iterating Using Iterator and Map Entry");
- mapIteration.iterateUsingIteratorAndEntry(map);
-
- System.out.println("Iterating Using KeySet and For Each");
- mapIteration.iterateUsingKeySetAndForeach(map);
-
- System.out.println("Iterating Map Using Lambda Expression");
- mapIteration.iterateUsingLambda(map);
-
- System.out.println("Iterating Using Stream API");
- mapIteration.iterateUsingStreamAPI(map);
- }
-
- public void iterateUsingEntrySet(Map map) {
- for (Map.Entry entry : map.entrySet()) {
- System.out.println(entry.getKey() + ":" + entry.getValue());
- }
- }
-
- public void iterateUsingLambda(Map map) {
- map.forEach((k, v) -> System.out.println((k + ":" + v)));
- }
-
- public void iterateUsingIteratorAndEntry(Map map) {
- Iterator> iterator = map.entrySet()
- .iterator();
- while (iterator.hasNext()) {
- Map.Entry pair = iterator.next();
- System.out.println(pair.getKey() + ":" + pair.getValue());
- }
- }
-
- public void iterateUsingKeySetAndForeach(Map map) {
- for (String key : map.keySet()) {
- System.out.println(key + ":" + map.get(key));
- }
- }
-
- public void iterateUsingStreamAPI(Map map) {
- map.entrySet()
- .stream()
- .forEach(e -> System.out.println(e.getKey() + ":" + e.getValue()));
- }
-
- public void iterateKeys(Map map) {
- for (String key : map.keySet()) {
- System.out.println(key);
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/mapmax/MapMax.java b/java-collections-maps-2/src/main/java/com/baeldung/map/mapmax/MapMax.java
deleted file mode 100644
index 8c33c857ee..0000000000
--- a/java-collections-maps-2/src/main/java/com/baeldung/map/mapmax/MapMax.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package com.baeldung.map.mapmax;
-
-import java.util.*;
-import java.util.Map.Entry;
-
-public class MapMax {
-
- public > V maxUsingIteration(Map map) {
-
- Map.Entry maxEntry = null;
-
- for (Map.Entry entry : map.entrySet()) {
-
- if (maxEntry == null || entry.getValue()
- .compareTo(maxEntry.getValue()) > 0) {
- maxEntry = entry;
- }
- }
-
- return maxEntry.getValue();
- }
-
- public > V maxUsingCollectionsMax(Map map) {
-
- Entry maxEntry = Collections.max(map.entrySet(), new Comparator>() {
- public int compare(Entry e1, Entry e2) {
- return e1.getValue()
- .compareTo(e2.getValue());
- }
- });
-
- return maxEntry.getValue();
- }
-
- public > V maxUsingCollectionsMaxAndLambda(Map map) {
-
- Entry maxEntry = Collections.max(map.entrySet(), (Entry e1, Entry e2) -> e1.getValue()
- .compareTo(e2.getValue()));
-
- return maxEntry.getValue();
- }
-
- public > V maxUsingCollectionsMaxAndMethodReference(Map map) {
-
- Entry maxEntry = Collections.max(map.entrySet(), Comparator.comparing(Map.Entry::getValue));
-
- return maxEntry.getValue();
- }
-
- public > V maxUsingStreamAndLambda(Map map) {
-
- Optional> maxEntry = map.entrySet()
- .stream()
- .max((Entry e1, Entry e2) -> e1.getValue()
- .compareTo(e2.getValue()));
-
- return maxEntry.get()
- .getValue();
- }
-
- public