diff --git a/akka-http/pom.xml b/akka-http/pom.xml index 4b73fbc960..a64d7a80f6 100644 --- a/akka-http/pom.xml +++ b/akka-http/pom.xml @@ -41,4 +41,4 @@ 2.5.11 - + \ No newline at end of file diff --git a/aws-lambda/lambda/pom.xml b/aws-lambda/lambda/pom.xml index dea951d1b3..b2e5cc3b2d 100644 --- a/aws-lambda/lambda/pom.xml +++ b/aws-lambda/lambda/pom.xml @@ -63,7 +63,8 @@ json-simple ${json-simple.version} - + junit junit diff --git a/core-java-modules/core-java-10/pom.xml b/core-java-modules/core-java-10/pom.xml index b293110546..c3406751dc 100644 --- a/core-java-modules/core-java-10/pom.xml +++ b/core-java-modules/core-java-10/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-11-2/pom.xml b/core-java-modules/core-java-11-2/pom.xml index 3ab8e883b0..863c9b0717 100644 --- a/core-java-modules/core-java-11-2/pom.xml +++ b/core-java-modules/core-java-11-2/pom.xml @@ -12,7 +12,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - ../.. diff --git a/core-java-modules/core-java-11/pom.xml b/core-java-modules/core-java-11/pom.xml index def7ab43f7..d3ffb0a8f0 100644 --- a/core-java-modules/core-java-11/pom.xml +++ b/core-java-modules/core-java-11/pom.xml @@ -13,7 +13,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - ../.. diff --git a/core-java-modules/core-java-12/pom.xml b/core-java-modules/core-java-12/pom.xml index 931fce820b..26b7d0c14d 100644 --- a/core-java-modules/core-java-12/pom.xml +++ b/core-java-modules/core-java-12/pom.xml @@ -13,7 +13,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - ../../ diff --git a/core-java-modules/core-java-13/pom.xml b/core-java-modules/core-java-13/pom.xml index 6369976580..d28618a21a 100644 --- a/core-java-modules/core-java-13/pom.xml +++ b/core-java-modules/core-java-13/pom.xml @@ -14,7 +14,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - ../../ diff --git a/core-java-modules/core-java-14/pom.xml b/core-java-modules/core-java-14/pom.xml index de01d17b0d..3967ce3455 100644 --- a/core-java-modules/core-java-14/pom.xml +++ b/core-java-modules/core-java-14/pom.xml @@ -12,7 +12,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - ../../ diff --git a/core-java-modules/core-java-16/pom.xml b/core-java-modules/core-java-16/pom.xml index 790b7dd057..14f15cdd92 100644 --- a/core-java-modules/core-java-16/pom.xml +++ b/core-java-modules/core-java-16/pom.xml @@ -38,37 +38,37 @@ ${maven-compiler-plugin.version} ${maven.compiler.release} - --enable-preview + --enable-preview ${maven.compiler.source.version} ${maven.compiler.target.version} - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.plugin.version} - - --enable-preview - 1 - - - - org.apache.maven.surefire - surefire-api - ${surefire.plugin.version} - - - + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.plugin.version} + + --enable-preview + 1 + + + + org.apache.maven.surefire + surefire-api + ${surefire.plugin.version} + + + 16 16 - 16 - 3.8.1 - 3.0.0-M5 - 3.17.2 + 16 + 3.8.1 + 3.0.0-M5 + 3.17.2 \ No newline at end of file diff --git a/core-java-modules/core-java-17/pom.xml b/core-java-modules/core-java-17/pom.xml index b1811ecf7f..3cee27b276 100644 --- a/core-java-modules/core-java-17/pom.xml +++ b/core-java-modules/core-java-17/pom.xml @@ -42,13 +42,11 @@ org.apache.maven.plugins maven-surefire-plugin ${surefire.plugin.version} - --enable-preview --enable-native-access=core.java 1 - org.apache.maven.surefire diff --git a/core-java-modules/core-java-annotations/pom.xml b/core-java-modules/core-java-annotations/pom.xml index a87baa6204..19d02aa2ac 100644 --- a/core-java-modules/core-java-annotations/pom.xml +++ b/core-java-modules/core-java-annotations/pom.xml @@ -1,7 +1,7 @@ + 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 core-java-annotations 0.1.0-SNAPSHOT @@ -37,4 +37,4 @@ - + \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-operations-advanced/pom.xml b/core-java-modules/core-java-arrays-operations-advanced/pom.xml index 065f1930e2..d122e3330c 100644 --- a/core-java-modules/core-java-arrays-operations-advanced/pom.xml +++ b/core-java-modules/core-java-arrays-operations-advanced/pom.xml @@ -19,20 +19,17 @@ commons-lang3 ${commons-lang3.version} - org.assertj assertj-core ${assertj-core.version} test - org.openjdk.jmh jmh-core ${jmh.version} - org.openjdk.jmh jmh-generator-annprocess diff --git a/core-java-modules/core-java-collections-set/pom.xml b/core-java-modules/core-java-collections-set/pom.xml index b8940f4a68..359c0fc86f 100644 --- a/core-java-modules/core-java-collections-set/pom.xml +++ b/core-java-modules/core-java-collections-set/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-date-operations-1/pom.xml b/core-java-modules/core-java-date-operations-1/pom.xml index 7b7c68d1b6..854d6ed916 100644 --- a/core-java-modules/core-java-date-operations-1/pom.xml +++ b/core-java-modules/core-java-date-operations-1/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-datetime-string/pom.xml b/core-java-modules/core-java-datetime-string/pom.xml index f50eb2ae5e..8bc7b60126 100644 --- a/core-java-modules/core-java-datetime-string/pom.xml +++ b/core-java-modules/core-java-datetime-string/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-io-conversions-2/README.md b/core-java-modules/core-java-io-conversions-2/README.md index b2153b3669..9abb539066 100644 --- a/core-java-modules/core-java-io-conversions-2/README.md +++ b/core-java-modules/core-java-io-conversions-2/README.md @@ -4,6 +4,7 @@ This module contains articles about core Java input/output(IO) conversions. ### Relevant Articles: - [Java InputStream to String](https://www.baeldung.com/convert-input-stream-to-string) +- [Java String to InputStream](https://www.baeldung.com/convert-string-to-input-stream) - [Java – Write an InputStream to a File](https://www.baeldung.com/convert-input-stream-to-a-file) - [Converting a BufferedReader to a JSONObject](https://www.baeldung.com/java-bufferedreader-to-jsonobject) - [Reading a CSV File into an Array](https://www.baeldung.com/java-csv-file-array) diff --git a/core-java-modules/core-java-io-conversions-2/pom.xml b/core-java-modules/core-java-io-conversions-2/pom.xml index dcb9d494dc..24708ad967 100644 --- a/core-java-modules/core-java-io-conversions-2/pom.xml +++ b/core-java-modules/core-java-io-conversions-2/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/stringtoinputstream/JavaXToInputStreamUnitTest.java b/core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/stringtoinputstream/JavaXToInputStreamUnitTest.java new file mode 100644 index 0000000000..7e7c79f764 --- /dev/null +++ b/core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/stringtoinputstream/JavaXToInputStreamUnitTest.java @@ -0,0 +1,44 @@ +package com.baeldung.stringtoinputstream; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + +import org.apache.commons.io.IOUtils; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.io.CharSource; + +public class JavaXToInputStreamUnitTest { + protected final Logger logger = LoggerFactory.getLogger(getClass()); + + // tests - String - InputStream + + @Test + public final void givenUsingPlainJava_whenConvertingStringToInputStream_thenCorrect() throws IOException { + final String initialString = "text"; + final InputStream targetStream = new ByteArrayInputStream(initialString.getBytes()); + + IOUtils.closeQuietly(targetStream); + } + + @Test + public final void givenUsingGuava_whenConvertingStringToInputStream_thenCorrect() throws IOException { + final String initialString = "text"; + final InputStream targetStream = CharSource.wrap(initialString).asByteSource(StandardCharsets.UTF_8).openStream(); + + IOUtils.closeQuietly(targetStream); + } + + @Test + public final void givenUsingCommonsIO_whenConvertingStringToInputStream_thenCorrect() throws IOException { + final String initialString = "text"; + final InputStream targetStream = IOUtils.toInputStream(initialString); + + IOUtils.closeQuietly(targetStream); + } + +} diff --git a/core-java-modules/core-java-io-conversions/README.md b/core-java-modules/core-java-io-conversions/README.md index 52f5222040..1f12c87241 100644 --- a/core-java-modules/core-java-io-conversions/README.md +++ b/core-java-modules/core-java-io-conversions/README.md @@ -13,5 +13,4 @@ This module contains articles about core Java input/output(IO) conversions. - [Java – Write a Reader to File](https://www.baeldung.com/java-write-reader-to-file) - [Java – Reader to Byte Array](https://www.baeldung.com/java-convert-reader-to-byte-array) - [Java – Reader to InputStream](https://www.baeldung.com/java-convert-reader-to-inputstream) -- [Java String to InputStream](https://www.baeldung.com/convert-string-to-input-stream) - More articles: [[next -->]](/core-java-modules/core-java-io-conversions-2) diff --git a/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/filetoinputstream/JavaXToInputStreamUnitTest.java b/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/filetoinputstream/JavaXToInputStreamUnitTest.java index c20752639f..9d061307ce 100644 --- a/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/filetoinputstream/JavaXToInputStreamUnitTest.java +++ b/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/filetoinputstream/JavaXToInputStreamUnitTest.java @@ -1,46 +1,25 @@ package com.baeldung.filetoinputstream; -import com.google.common.io.ByteSource; -import com.google.common.io.CharSource; -import com.google.common.io.Files; +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.SequenceInputStream; + import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.*; -import java.nio.charset.StandardCharsets; +import com.google.common.io.ByteSource; +import com.google.common.io.Files; public class JavaXToInputStreamUnitTest { protected final Logger logger = LoggerFactory.getLogger(getClass()); - // tests - String - InputStream - - @Test - public final void givenUsingPlainJava_whenConvertingStringToInputStream_thenCorrect() throws IOException { - final String initialString = "text"; - final InputStream targetStream = new ByteArrayInputStream(initialString.getBytes()); - - IOUtils.closeQuietly(targetStream); - } - - @Test - public final void givenUsingGuava_whenConvertingStringToInputStream_thenCorrect() throws IOException { - final String initialString = "text"; - final InputStream targetStream = CharSource.wrap(initialString).asByteSource(StandardCharsets.UTF_8).openStream(); - - IOUtils.closeQuietly(targetStream); - } - - @Test - public final void givenUsingCommonsIO_whenConvertingStringToInputStream_thenCorrect() throws IOException { - final String initialString = "text"; - final InputStream targetStream = IOUtils.toInputStream(initialString); - - IOUtils.closeQuietly(targetStream); - } - // byte array - InputStream @Test diff --git a/core-java-modules/core-java-io/pom.xml b/core-java-modules/core-java-io/pom.xml index 0cf6d6767e..a036818226 100644 --- a/core-java-modules/core-java-io/pom.xml +++ b/core-java-modules/core-java-io/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-jvm/pom.xml b/core-java-modules/core-java-jvm/pom.xml index a8ab4d9f2e..38cb1a7825 100644 --- a/core-java-modules/core-java-jvm/pom.xml +++ b/core-java-modules/core-java-jvm/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-os/pom.xml b/core-java-modules/core-java-os/pom.xml index 34afbec210..c0eac46db8 100644 --- a/core-java-modules/core-java-os/pom.xml +++ b/core-java-modules/core-java-os/pom.xml @@ -1,19 +1,18 @@ - 4.0.0 - core-java-os - 0.1.0-SNAPSHOT - core-java-os - jar + 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 + core-java-os + 0.1.0-SNAPSHOT + core-java-os + jar - - com.baeldung.core-java-modules - core-java-modules - 0.0.1-SNAPSHOT - ../ - + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + @@ -55,39 +54,39 @@ - - core-java-os - - - src/main/resources - true - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${maven.compiler.source} - ${maven.compiler.target} - - - - + + core-java-os + + + src/main/resources + true + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.source} + ${maven.compiler.target} + + + + - - - 4.1 - 4.01 - - 3.6.1 - 1.8.9 - 1.9 - 1.9 - 25.1-jre - 0.4 - 1.8.7 - + + + 4.1 + 4.01 + + 3.6.1 + 1.8.9 + 1.9 + 1.9 + 25.1-jre + 0.4 + 1.8.7 + - \ No newline at end of file + diff --git a/core-java-modules/core-java-security-2/README.md b/core-java-modules/core-java-security-2/README.md index 680a7de925..31404d24a5 100644 --- a/core-java-modules/core-java-security-2/README.md +++ b/core-java-modules/core-java-security-2/README.md @@ -10,12 +10,7 @@ This module contains articles about core Java Security - [SHA-256 and SHA3-256 Hashing in Java](https://www.baeldung.com/sha-256-hashing-java) - [Checksums in Java](https://www.baeldung.com/java-checksums) - [How to Read PEM File to Get Public and Private Keys](https://www.baeldung.com/java-read-pem-file-keys) -- [Listing the Available Cipher Algorithms](https://www.baeldung.com/java-list-cipher-algorithms) - [Get a List of Trusted Certificates in Java](https://www.baeldung.com/java-list-trusted-certificates) - [Security Context Basics: User, Subject and Principal](https://www.baeldung.com/security-context-basics) -- [Java AES Encryption and Decryption](https://www.baeldung.com/java-aes-encryption-decryption) -- [InvalidAlgorithmParameterException: Wrong IV Length](https://www.baeldung.com/java-invalidalgorithmparameter-exception) - [The java.security.egd JVM Option](https://www.baeldung.com/java-security-egd) -- [RSA in Java](https://www.baeldung.com/java-rsa) -- [3DES in Java](https://www.baeldung.com/java-3des) - More articles: [[<-- prev]](/core-java-modules/core-java-security) diff --git a/core-java-modules/core-java-security-3/pom.xml b/core-java-modules/core-java-security-3/pom.xml index 69d0ffb917..a0e73a1e29 100644 --- a/core-java-modules/core-java-security-3/pom.xml +++ b/core-java-modules/core-java-security-3/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-security-algorithms/README.md b/core-java-modules/core-java-security-algorithms/README.md new file mode 100644 index 0000000000..a1ce244ab8 --- /dev/null +++ b/core-java-modules/core-java-security-algorithms/README.md @@ -0,0 +1,11 @@ +## Core Java Security Algorithms + +This module contains articles about core Java Security Algorithms such as AES, DES, RSA, etc + +### Relevant Articles: + +- [Listing the Available Cipher Algorithms](https://www.baeldung.com/java-list-cipher-algorithms) +- [Java AES Encryption and Decryption](https://www.baeldung.com/java-aes-encryption-decryption) +- [InvalidAlgorithmParameterException: Wrong IV Length](https://www.baeldung.com/java-invalidalgorithmparameter-exception) +- [RSA in Java](https://www.baeldung.com/java-rsa) +- [3DES in Java](https://www.baeldung.com/java-3des) diff --git a/core-java-modules/core-java-security-algorithms/pom.xml b/core-java-modules/core-java-security-algorithms/pom.xml new file mode 100644 index 0000000000..db1bf09ead --- /dev/null +++ b/core-java-modules/core-java-security-algorithms/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + core-java-security-algorithms + 0.1.0-SNAPSHOT + core-java-security-algorithms + jar + + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + + + + + commons-codec + commons-codec + ${commons-codec.version} + + + org.bouncycastle + bcprov-jdk15on + ${bouncycastle.version} + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + + javax.xml.bind + jaxb-api + ${jaxb-api.version} + + + + + + 1.60 + 1.11 + + 3.18.0 + 2.3.1 + + + \ No newline at end of file diff --git a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/aes/AESUtil.java b/core-java-modules/core-java-security-algorithms/src/main/java/com/baeldung/aes/AESUtil.java similarity index 100% rename from core-java-modules/core-java-security-2/src/main/java/com/baeldung/aes/AESUtil.java rename to core-java-modules/core-java-security-algorithms/src/main/java/com/baeldung/aes/AESUtil.java diff --git a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/aes/Student.java b/core-java-modules/core-java-security-algorithms/src/main/java/com/baeldung/aes/Student.java similarity index 100% rename from core-java-modules/core-java-security-2/src/main/java/com/baeldung/aes/Student.java rename to core-java-modules/core-java-security-algorithms/src/main/java/com/baeldung/aes/Student.java diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/aes/AESUtilUnitTest.java b/core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/aes/AESUtilUnitTest.java similarity index 100% rename from core-java-modules/core-java-security-2/src/test/java/com/baeldung/aes/AESUtilUnitTest.java rename to core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/aes/AESUtilUnitTest.java diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java b/core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java similarity index 100% rename from core-java-modules/core-java-security-2/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java rename to core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/cipher/AvailableCiphersUnitTest.java diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/des/TripleDESUnitTest.java b/core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/des/TripleDESUnitTest.java similarity index 100% rename from core-java-modules/core-java-security-2/src/test/java/com/baeldung/des/TripleDESUnitTest.java rename to core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/des/TripleDESUnitTest.java diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/rsa/RsaUnitTest.java b/core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/rsa/RsaUnitTest.java similarity index 99% rename from core-java-modules/core-java-security-2/src/test/java/com/baeldung/rsa/RsaUnitTest.java rename to core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/rsa/RsaUnitTest.java index ac93f71125..9659fd8871 100644 --- a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/rsa/RsaUnitTest.java +++ b/core-java-modules/core-java-security-algorithms/src/test/java/com/baeldung/rsa/RsaUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.cipher; +package com.baeldung.rsa; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/core-java-modules/core-java-security-2/src/test/resources/baeldung.txt b/core-java-modules/core-java-security-algorithms/src/test/resources/baeldung.txt similarity index 100% rename from core-java-modules/core-java-security-2/src/test/resources/baeldung.txt rename to core-java-modules/core-java-security-algorithms/src/test/resources/baeldung.txt diff --git a/core-java-modules/core-java-string-algorithms-3/pom.xml b/core-java-modules/core-java-string-algorithms-3/pom.xml index 4287696332..88a3029cf1 100644 --- a/core-java-modules/core-java-string-algorithms-3/pom.xml +++ b/core-java-modules/core-java-string-algorithms-3/pom.xml @@ -4,8 +4,8 @@ 4.0.0 core-java-string-algorithms-3 0.1.0-SNAPSHOT - jar core-java-string-algorithms-3 + jar com.baeldung.core-java-modules @@ -61,4 +61,4 @@ 1.7 - + \ No newline at end of file diff --git a/core-java-modules/core-java-string-operations-3/pom.xml b/core-java-modules/core-java-string-operations-3/pom.xml index 20e9bcb39a..2567f776b1 100644 --- a/core-java-modules/core-java-string-operations-3/pom.xml +++ b/core-java-modules/core-java-string-operations-3/pom.xml @@ -92,4 +92,4 @@ 3.1.0 - + \ No newline at end of file diff --git a/core-java-modules/core-java-sun/pom.xml b/core-java-modules/core-java-sun/pom.xml index 347020a736..4c26b59168 100644 --- a/core-java-modules/core-java-sun/pom.xml +++ b/core-java-modules/core-java-sun/pom.xml @@ -12,7 +12,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/core-java-time-measurements/pom.xml b/core-java-modules/core-java-time-measurements/pom.xml index 5a2a13290b..d3c351b385 100644 --- a/core-java-modules/core-java-time-measurements/pom.xml +++ b/core-java-modules/core-java-time-measurements/pom.xml @@ -13,7 +13,6 @@ com.baeldung.core-java-modules core-java-modules 0.0.1-SNAPSHOT - ../ diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index d8191e74d0..a57cd54191 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -101,6 +101,7 @@ core-java-security-2 core-java-security-3 core-java-serialization + core-java-security-algorithms core-java-streams core-java-streams-2 core-java-streams-3 diff --git a/drools/pom.xml b/drools/pom.xml index cc96d9d032..daaf1fa8a7 100644 --- a/drools/pom.xml +++ b/drools/pom.xml @@ -19,7 +19,6 @@ httpcore ${http-component-version} - org.kie kie-ci diff --git a/feign/pom.xml b/feign/pom.xml index 56059d2a77..cf28890868 100644 --- a/feign/pom.xml +++ b/feign/pom.xml @@ -11,7 +11,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - .. diff --git a/flyway-cdi-extension/pom.xml b/flyway-cdi-extension/pom.xml index dbd21374e2..3d52ff0e36 100644 --- a/flyway-cdi-extension/pom.xml +++ b/flyway-cdi-extension/pom.xml @@ -11,7 +11,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - .. diff --git a/guava-modules/guava-18/pom.xml b/guava-modules/guava-18/pom.xml index ed295db2f4..8f5108bff1 100644 --- a/guava-modules/guava-18/pom.xml +++ b/guava-modules/guava-18/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-19/pom.xml b/guava-modules/guava-19/pom.xml index 3c29a2a59c..ba85fe0ae8 100644 --- a/guava-modules/guava-19/pom.xml +++ b/guava-modules/guava-19/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-21/pom.xml b/guava-modules/guava-21/pom.xml index 8b7c3cdcfd..9e791bfe23 100644 --- a/guava-modules/guava-21/pom.xml +++ b/guava-modules/guava-21/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-collections-list/pom.xml b/guava-modules/guava-collections-list/pom.xml index 671cbea39d..30d684d673 100644 --- a/guava-modules/guava-collections-list/pom.xml +++ b/guava-modules/guava-collections-list/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-collections-map/pom.xml b/guava-modules/guava-collections-map/pom.xml index e4d33ce0cc..04beaa13a1 100644 --- a/guava-modules/guava-collections-map/pom.xml +++ b/guava-modules/guava-collections-map/pom.xml @@ -12,7 +12,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-collections-set/pom.xml b/guava-modules/guava-collections-set/pom.xml index 97e03155e7..bd58645adc 100644 --- a/guava-modules/guava-collections-set/pom.xml +++ b/guava-modules/guava-collections-set/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-collections/pom.xml b/guava-modules/guava-collections/pom.xml index f3356cf982..91e3efcd8c 100644 --- a/guava-modules/guava-collections/pom.xml +++ b/guava-modules/guava-collections/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-core/pom.xml b/guava-modules/guava-core/pom.xml index a15dfb5178..2540ac97a7 100644 --- a/guava-modules/guava-core/pom.xml +++ b/guava-modules/guava-core/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-io/pom.xml b/guava-modules/guava-io/pom.xml index f1f75b43a8..2ea91c5e4f 100644 --- a/guava-modules/guava-io/pom.xml +++ b/guava-modules/guava-io/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/guava-modules/guava-utilities/pom.xml b/guava-modules/guava-utilities/pom.xml index b33ea16c11..debf014ac7 100644 --- a/guava-modules/guava-utilities/pom.xml +++ b/guava-modules/guava-utilities/pom.xml @@ -11,7 +11,6 @@ com.baeldung guava-modules 0.0.1-SNAPSHOT - ../ diff --git a/libraries-2/pom.xml b/libraries-2/pom.xml index 700a0a02d4..0988ed454e 100644 --- a/libraries-2/pom.xml +++ b/libraries-2/pom.xml @@ -54,7 +54,8 @@ jbpm-test ${jbpm.version} - + junit junit diff --git a/libraries-6/pom.xml b/libraries-6/pom.xml index cecc9ca476..cf2c2c551d 100644 --- a/libraries-6/pom.xml +++ b/libraries-6/pom.xml @@ -157,4 +157,4 @@ 2.4.4 - + \ No newline at end of file diff --git a/logging-modules/flogger/pom.xml b/logging-modules/flogger/pom.xml index b96025f277..c814d31767 100644 --- a/logging-modules/flogger/pom.xml +++ b/logging-modules/flogger/pom.xml @@ -9,7 +9,6 @@ com.baeldung logging-modules 1.0.0-SNAPSHOT - ../pom.xml diff --git a/logging-modules/log4j/pom.xml b/logging-modules/log4j/pom.xml index 864e2253b5..d3c7f8287e 100644 --- a/logging-modules/log4j/pom.xml +++ b/logging-modules/log4j/pom.xml @@ -11,7 +11,6 @@ com.baeldung logging-modules 1.0.0-SNAPSHOT - ../pom.xml diff --git a/logging-modules/log4j2/pom.xml b/logging-modules/log4j2/pom.xml index aaf60a4216..0b6fa9b902 100644 --- a/logging-modules/log4j2/pom.xml +++ b/logging-modules/log4j2/pom.xml @@ -10,7 +10,6 @@ com.baeldung logging-modules 1.0.0-SNAPSHOT - ../pom.xml diff --git a/logging-modules/logback/pom.xml b/logging-modules/logback/pom.xml index 512dc9e5a3..48bb37b881 100644 --- a/logging-modules/logback/pom.xml +++ b/logging-modules/logback/pom.xml @@ -11,7 +11,6 @@ com.baeldung logging-modules 1.0.0-SNAPSHOT - ../pom.xml diff --git a/logging-modules/pom.xml b/logging-modules/pom.xml index 7e358ae490..c7a770891d 100644 --- a/logging-modules/pom.xml +++ b/logging-modules/pom.xml @@ -11,7 +11,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - ../pom.xml diff --git a/maven-archetype/pom.xml b/maven-archetype/pom.xml index 2eab8ac614..04247f622c 100644 --- a/maven-archetype/pom.xml +++ b/maven-archetype/pom.xml @@ -18,7 +18,6 @@ ${archetype-packaging.version} - diff --git a/maven-modules/maven-copy-files/copy-rename-maven-plugin/pom.xml b/maven-modules/maven-copy-files/copy-rename-maven-plugin/pom.xml index 6feb8284e6..06a44ed4fb 100644 --- a/maven-modules/maven-copy-files/copy-rename-maven-plugin/pom.xml +++ b/maven-modules/maven-copy-files/copy-rename-maven-plugin/pom.xml @@ -54,7 +54,7 @@ maven-surefire-plugin - 2.22.1 + 2.22.2 maven-jar-plugin diff --git a/maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml b/maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml index 5168e0e965..b005f4b125 100644 --- a/maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml +++ b/maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml @@ -57,7 +57,7 @@ maven-surefire-plugin - 2.22.1 + 2.22.2 maven-jar-plugin diff --git a/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml b/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml index 6829898b45..a49095f528 100644 --- a/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml +++ b/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml @@ -54,7 +54,7 @@ maven-surefire-plugin - 2.22.1 + 2.22.2 maven-jar-plugin diff --git a/maven-modules/maven-copy-files/pom.xml b/maven-modules/maven-copy-files/pom.xml index 94bf952361..57d0ddf647 100644 --- a/maven-modules/maven-copy-files/pom.xml +++ b/maven-modules/maven-copy-files/pom.xml @@ -51,7 +51,7 @@ maven-surefire-plugin - 2.22.1 + 2.22.2 maven-jar-plugin diff --git a/maven-modules/maven-generate-war/pom.xml b/maven-modules/maven-generate-war/pom.xml index e5b42f5090..56256f58ea 100644 --- a/maven-modules/maven-generate-war/pom.xml +++ b/maven-modules/maven-generate-war/pom.xml @@ -1,62 +1,68 @@ - -4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.5.4 - - - -com.baeldung -maven-generate-war -0.0.1-SNAPSHOT -war -maven-generate-war -Spring boot project to demonstrate war file generation - - 11 - - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-tomcat - provided - - - org.springframework.boot - spring-boot-starter-test - test - - - - maven-generate-war - - - maven-war-plugin - 3.3.1 - - - - additional_resources - - - - - true - - - - - - - + + 4.0.0 + com.baeldung + maven-generate-war + 0.0.1-SNAPSHOT + war + maven-generate-war + Spring boot project to demonstrate war file generation + + org.springframework.boot + spring-boot-starter-parent + 2.5.4 + + + + + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + org.springframework.boot + spring-boot-starter-test + test + + + + + maven-generate-war + + + maven-war-plugin + 3.3.1 + + + + additional_resources + + + + + true + + + + + + + + + 11 + + + \ No newline at end of file diff --git a/maven-modules/maven-integration-test/pom.xml b/maven-modules/maven-integration-test/pom.xml index 01be0ad1a4..56c243e3c5 100644 --- a/maven-modules/maven-integration-test/pom.xml +++ b/maven-modules/maven-integration-test/pom.xml @@ -86,8 +86,8 @@ + org.apache.maven.plugins maven-surefire-plugin - ${maven.surefire.version} DataTest.java @@ -171,8 +171,8 @@ + org.apache.maven.plugins maven-surefire-plugin - ${maven.surefire.version} DataTest.java @@ -217,8 +217,8 @@ + org.apache.maven.plugins maven-surefire-plugin - ${maven.surefire.version} integration-test @@ -269,7 +269,6 @@ 3.0.2 3.8.0 - 2.22.0 2.22.0 1.1 3.0.0 diff --git a/maven-modules/maven-multi-source/pom.xml b/maven-modules/maven-multi-source/pom.xml index 65e00419af..d9863b31a9 100644 --- a/maven-modules/maven-multi-source/pom.xml +++ b/maven-modules/maven-multi-source/pom.xml @@ -54,8 +54,8 @@ + org.apache.maven.plugins maven-surefire-plugin - ${maven.surefire.version} integration-test @@ -81,7 +81,6 @@ 3.0.2 3.8.0 - 2.22.0 2.22.0 1.1 3.0.0 diff --git a/maven-modules/maven-parent-pom-resolution/aggregator/module1/pom.xml b/maven-modules/maven-parent-pom-resolution/aggregator/module1/pom.xml index e1f411db2f..67e60fb386 100644 --- a/maven-modules/maven-parent-pom-resolution/aggregator/module1/pom.xml +++ b/maven-modules/maven-parent-pom-resolution/aggregator/module1/pom.xml @@ -13,4 +13,4 @@ - + \ No newline at end of file diff --git a/maven-modules/maven-parent-pom-resolution/aggregator/module2/module3/pom.xml b/maven-modules/maven-parent-pom-resolution/aggregator/module2/module3/pom.xml index d983f35e3e..f4e3e81e7d 100644 --- a/maven-modules/maven-parent-pom-resolution/aggregator/module2/module3/pom.xml +++ b/maven-modules/maven-parent-pom-resolution/aggregator/module2/module3/pom.xml @@ -15,4 +15,4 @@ ../../pom.xml - + \ No newline at end of file diff --git a/maven-modules/maven-parent-pom-resolution/aggregator/module2/pom.xml b/maven-modules/maven-parent-pom-resolution/aggregator/module2/pom.xml index 48c1ebab9d..9b36ef37fb 100644 --- a/maven-modules/maven-parent-pom-resolution/aggregator/module2/pom.xml +++ b/maven-modules/maven-parent-pom-resolution/aggregator/module2/pom.xml @@ -18,4 +18,4 @@ module3 - + \ No newline at end of file diff --git a/maven-modules/maven-parent-pom-resolution/aggregator/pom.xml b/maven-modules/maven-parent-pom-resolution/aggregator/pom.xml index 8f6e3453a5..dde2c46370 100644 --- a/maven-modules/maven-parent-pom-resolution/aggregator/pom.xml +++ b/maven-modules/maven-parent-pom-resolution/aggregator/pom.xml @@ -19,4 +19,4 @@ module2 - + \ No newline at end of file diff --git a/maven-modules/maven-plugins/pom.xml b/maven-modules/maven-plugins/pom.xml index 29b3b550ea..4aa295c8a8 100644 --- a/maven-modules/maven-plugins/pom.xml +++ b/maven-modules/maven-plugins/pom.xml @@ -84,8 +84,8 @@ + org.apache.maven.plugins maven-surefire-plugin - ${maven.surefire.version} DataTest.java @@ -105,8 +105,8 @@ + org.apache.maven.plugins maven-surefire-plugin - ${maven.surefire.version} integration-test @@ -132,7 +132,6 @@ 3.0.2 3.8.0 - 2.22.0 2.22.0 1.1 3.0.0 diff --git a/maven-modules/maven-surefire-plugin/pom.xml b/maven-modules/maven-surefire-plugin/pom.xml index 98decc69e1..840ffab077 100644 --- a/maven-modules/maven-surefire-plugin/pom.xml +++ b/maven-modules/maven-surefire-plugin/pom.xml @@ -14,4 +14,4 @@ 0.0.1-SNAPSHOT - + \ No newline at end of file diff --git a/maven-modules/pom.xml b/maven-modules/pom.xml index 0aadb873e5..e09283efb4 100644 --- a/maven-modules/pom.xml +++ b/maven-modules/pom.xml @@ -37,7 +37,7 @@ plugin-management maven-surefire-plugin maven-parent-pom-resolution - maven-dependency + maven-dependency @@ -57,8 +57,4 @@ - - 5.8.1 - - \ No newline at end of file diff --git a/patterns/clean-architecture/pom.xml b/patterns/clean-architecture/pom.xml index 4a1f512240..7b244e4a5e 100644 --- a/patterns/clean-architecture/pom.xml +++ b/patterns/clean-architecture/pom.xml @@ -58,7 +58,6 @@ - org.springframework.boot spring-boot-maven-plugin diff --git a/patterns/simplehexagonalexample/pom.xml b/patterns/simplehexagonalexample/pom.xml deleted file mode 100644 index 31e829b7dc..0000000000 --- a/patterns/simplehexagonalexample/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - 4.0.0 - 1.0.0-SNAPSHOT - simple-hexagonal-example - simple-hexagonal-example - - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 - - - - - org.springframework.boot - spring-boot-starter-web - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - \ No newline at end of file diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/DailyQuoteMain.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/DailyQuoteMain.java deleted file mode 100644 index de8b2f4793..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/DailyQuoteMain.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.simplehexagonalex; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import com.baeldung.simplehexagonalex.controller.QuoteCliController; -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; - -@SpringBootApplication -public class DailyQuoteMain implements CommandLineRunner { - - private static final Logger LOG = LoggerFactory.getLogger(DailyQuoteMain.class); - @Autowired - private QuoteCliController quoteCliController; - - public static void main(final String[] args) { - - SpringApplication.run(DailyQuoteMain.class, args); - } - - @Override - public void run(String... args) throws Exception { - - QuoteOfTheDay quoteOfTheDay = quoteCliController.getQuote("cliController"); - - LOG.info(quoteOfTheDay.toString()); - } -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/controller/QuoteCliController.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/controller/QuoteCliController.java deleted file mode 100644 index 9ecb2bf822..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/controller/QuoteCliController.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.simplehexagonalex.controller; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; -import com.baeldung.simplehexagonalex.domain.service.QuoteService; - -@Component -public class QuoteCliController { - - private static final Logger LOG = LoggerFactory.getLogger(QuoteCliController.class); - - @Autowired - private QuoteService quoteService; - - public QuoteOfTheDay getQuote(String userId) { - - LOG.info("Getting quote"); - return quoteService.getQuote(userId); - } -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/controller/QuoteRestController.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/controller/QuoteRestController.java deleted file mode 100644 index 061cff8cec..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/controller/QuoteRestController.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.simplehexagonalex.controller; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; -import com.baeldung.simplehexagonalex.domain.service.QuoteService; - -@RestController -@RequestMapping("/quote") -public class QuoteRestController { - - @Autowired - private QuoteService quoteService; - - @GetMapping(path = "/{userId}") - public QuoteOfTheDay getEmployee(@PathVariable("userId") String userId) { - return quoteService.getQuote(userId); - } - -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/QuoteOfTheDay.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/QuoteOfTheDay.java deleted file mode 100644 index c74c224c70..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/QuoteOfTheDay.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.baeldung.simplehexagonalex.domain; - -import java.util.Objects; - -public class QuoteOfTheDay { - - private String userName; - private String quote; - private String provider; - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getQuote() { - return quote; - } - - public void setQuote(String quote) { - this.quote = quote; - } - - public String getProvider() { - return provider; - } - - public void setProvider(String provider) { - this.provider = provider; - } - - @Override - public int hashCode() { - return Objects.hash(provider, quote, userName); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - QuoteOfTheDay other = (QuoteOfTheDay) obj; - return Objects.equals(provider, other.provider) && Objects.equals(quote, other.quote) && Objects.equals(userName, other.userName); - } - - @Override - public String toString() { - return "QuoteOfTheDay [userName=" + userName + ", quote=" + quote + ", provider=" + provider + "]"; - } -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/repository/QuoteOfTheDayFromProvider.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/repository/QuoteOfTheDayFromProvider.java deleted file mode 100644 index 7e70cebd12..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/repository/QuoteOfTheDayFromProvider.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.simplehexagonalex.domain.repository; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; - -public interface QuoteOfTheDayFromProvider { - - QuoteOfTheDay getQuote(); -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/service/QuoteAggregator.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/service/QuoteAggregator.java deleted file mode 100644 index 16f7015ace..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/service/QuoteAggregator.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.simplehexagonalex.domain.service; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; -import com.baeldung.simplehexagonalex.domain.repository.QuoteOfTheDayFromProvider; - -@Service -public class QuoteAggregator implements QuoteService { - - @Autowired - private QuoteOfTheDayFromProvider quoteOfTheDayFromProvider; - - @Override - public QuoteOfTheDay getQuote(String userName) { - - QuoteOfTheDay quoteOfTheDay = quoteOfTheDayFromProvider.getQuote(); - quoteOfTheDay.setUserName(userName); - return quoteOfTheDay; - } -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/service/QuoteService.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/service/QuoteService.java deleted file mode 100644 index 300387a41d..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/service/QuoteService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.simplehexagonalex.domain.service; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; - -public interface QuoteService { - - QuoteOfTheDay getQuote(String userName); -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuote.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuote.java deleted file mode 100644 index 0cbbc60726..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuote.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.baeldung.simplehexagonalex.repository.primary.quoteadapter; - -import java.util.List; -import java.util.Objects; - -public class ProviderQuote { - - private String quote; - private String length; - private String author; - private List tags; - private String category; - private String language; - private String date; - private String permalink; - private String id; - private String background; - private String title; - - public ProviderQuote() { - - } - - public ProviderQuote(String quote, String length, String author, List tags, String category, String language, String date, String permalink, String id, String background, String title) { - super(); - this.quote = quote; - this.length = length; - this.author = author; - this.tags = tags; - this.category = category; - this.language = language; - this.date = date; - this.permalink = permalink; - this.id = id; - this.background = background; - this.title = title; - } - - public String getQuote() { - return quote; - } - - public String getLength() { - return length; - } - - public String getAuthor() { - return author; - } - - public List getTags() { - return tags; - } - - public String getCategory() { - return category; - } - - public String getLanguage() { - return language; - } - - public String getDate() { - return date; - } - - public String getPermalink() { - return permalink; - } - - public String getId() { - return id; - } - - public String getBackground() { - return background; - } - - public String getTitle() { - return title; - } - - public void setId(String id) { - this.id = id; - } - - @Override - public int hashCode() { - return Objects.hash(id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ProviderQuote other = (ProviderQuote) obj; - return Objects.equals(id, other.id); - } - - @Override - public String toString() { - return "TheysaysoQuote [quote=" + quote + ", length=" + length + ", " + "author=" + author + ", tags=" + tags + ", category=" + category + ", language=" + language + ", date=" + date + ", permalink=" + permalink + ", id=" + id + ", background=" - + background + ", title=" + title + "]"; - } -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuoteAdapter.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuoteAdapter.java deleted file mode 100644 index ded08f7b18..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuoteAdapter.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.baeldung.simplehexagonalex.repository.primary.quoteadapter; - -import java.net.URI; - -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Primary; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Service; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; -import com.baeldung.simplehexagonalex.domain.repository.QuoteOfTheDayFromProvider; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Service("providerQuoteAdapter") -@Primary -public class ProviderQuoteAdapter implements QuoteOfTheDayFromProvider { - - @Autowired - private Environment env; - - @Override - public QuoteOfTheDay getQuote() { - - QuoteOfTheDay quoteOfTheDay = new QuoteOfTheDay(); - ProviderQuoteEnvelope providerQuote; - try { - providerQuote = getProviderQuote(); - quoteOfTheDay.setQuote(providerQuote.getContents() - .getQuotes() - .get(0) - .getQuote()); - quoteOfTheDay.setProvider(providerQuote.getCopyright() - .getUrl()); - } catch (Exception e) { - quoteOfTheDay.setQuote("Unable to get the quote"); - quoteOfTheDay.setProvider("none"); - } - return quoteOfTheDay; - } - - private ProviderQuoteEnvelope getProviderQuote() throws Exception { - - HttpGet request = new HttpGet(URI.create(env.getProperty("theysayso.quote.provider.url"))); - CloseableHttpClient client = HttpClients.createDefault(); - CloseableHttpResponse response = client.execute(request); - ProviderQuoteEnvelope providersQuote = new ObjectMapper().readValue(response.getEntity() - .getContent(), ProviderQuoteEnvelope.class); - return providersQuote; - } -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuoteEnvelope.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuoteEnvelope.java deleted file mode 100644 index 611549f23d..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuoteEnvelope.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.baeldung.simplehexagonalex.repository.primary.quoteadapter; - -import java.util.List; - -public class ProviderQuoteEnvelope { - - private Success success; - private Contents contents; - private String baseurl; - private Copyright copyright; - - public ProviderQuoteEnvelope() { - - } - - public ProviderQuoteEnvelope(Success success, Contents contents, String baseurl, Copyright copyright) { - super(); - this.success = success; - this.contents = contents; - this.baseurl = baseurl; - this.copyright = copyright; - } - - public Success getSuccess() { - return success; - } - - public Contents getContents() { - return contents; - } - - public String getBaseurl() { - return baseurl; - } - - public Copyright getCopyright() { - return copyright; - } - - public class Contents { - private List quotes; - - public List getQuotes() { - return quotes; - } - } - - public class Copyright { - private int year; - private String url; - - public int getYear() { - return year; - } - - public String getUrl() { - return url; - } - } - - public class Success { - private int total; - - public int getTotal() { - return total; - } - } -} diff --git a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/reposity/mock/quoteadapter/MockQuoteAdapter.java b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/reposity/mock/quoteadapter/MockQuoteAdapter.java deleted file mode 100644 index 54c28fc94e..0000000000 --- a/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/reposity/mock/quoteadapter/MockQuoteAdapter.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.simplehexagonalex.reposity.mock.quoteadapter; - -import org.springframework.stereotype.Service; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; -import com.baeldung.simplehexagonalex.domain.repository.QuoteOfTheDayFromProvider; - -@Service -public class MockQuoteAdapter implements QuoteOfTheDayFromProvider { - - @Override - public QuoteOfTheDay getQuote() { - - QuoteOfTheDay quoteOfTheDay = new QuoteOfTheDay(); - quoteOfTheDay.setQuote("Mock quote of the day"); - quoteOfTheDay.setProvider("Mock Provider"); - - return quoteOfTheDay; - } -} diff --git a/patterns/simplehexagonalexample/src/main/resources/application.properties b/patterns/simplehexagonalexample/src/main/resources/application.properties deleted file mode 100644 index dd9413bfd5..0000000000 --- a/patterns/simplehexagonalexample/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -theysayso.quote.provider.url=https://quotes.rest/qod?language=en \ No newline at end of file diff --git a/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/MockAccessProviderUnitTest.java b/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/MockAccessProviderUnitTest.java deleted file mode 100644 index 602f7ea5d4..0000000000 --- a/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/MockAccessProviderUnitTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.simplehexagonalex.repository.primaryQuoteProvider; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import org.junit.jupiter.api.Test; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; -import com.baeldung.simplehexagonalex.reposity.mock.quoteadapter.MockQuoteAdapter; - -public class MockAccessProviderUnitTest { - - @Test - public void givenProvider_whenConnect_thenResponse() throws Exception { - - MockQuoteAdapter provider = new MockQuoteAdapter(); - QuoteOfTheDay quote = provider.getQuote(); - assertNotNull(quote); - assertEquals("Mock quote of the day", quote.getQuote()); - assertEquals("Mock Provider", quote.getProvider()); - } -} diff --git a/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/PrimaryAccessProviderIntegrationTest.java b/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/PrimaryAccessProviderIntegrationTest.java deleted file mode 100644 index 47e1dde136..0000000000 --- a/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/PrimaryAccessProviderIntegrationTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.simplehexagonalex.repository.primaryQuoteProvider; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.test.context.SpringBootTest; - -import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay; -import com.baeldung.simplehexagonalex.domain.repository.QuoteOfTheDayFromProvider; - -@SpringBootTest -public class PrimaryAccessProviderIntegrationTest { - - @Autowired - @Qualifier("providerQuoteAdapter") - QuoteOfTheDayFromProvider provider; - - @Test - public void whenQuoteProvider_thenResponse() throws Exception { - - QuoteOfTheDay quote = provider.getQuote(); - assertNotNull(quote); - assertThat(quote.getProvider()).contains("theysaidso"); - } -} diff --git a/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/QuoteRequestIntegrationTest.java b/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/QuoteRequestIntegrationTest.java deleted file mode 100644 index 552b5d51c2..0000000000 --- a/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/QuoteRequestIntegrationTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.simplehexagonalex.repository.primaryQuoteProvider; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.MvcResult; - -@SpringBootTest -@AutoConfigureMockMvc -public class QuoteRequestIntegrationTest { - - @Autowired - private MockMvc mockMvc; - - @Test - public void whenRestQuoteRequest_thenResponse() throws Exception { - - MvcResult result = this.mockMvc.perform(get("/quote/tester")) - .andDo(print()) - .andExpect(status().isOk()) - .andReturn(); - - String content = result.getResponse() - .getContentAsString(); - - assertThat(content).contains("tester"); - assertThat(content).contains("theysaidso"); - } -} \ No newline at end of file diff --git a/patterns/simplehexagonalexample/src/test/resources/application.properties b/patterns/simplehexagonalexample/src/test/resources/application.properties deleted file mode 100644 index dd9413bfd5..0000000000 --- a/patterns/simplehexagonalexample/src/test/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -theysayso.quote.provider.url=https://quotes.rest/qod?language=en \ No newline at end of file diff --git a/persistence-modules/apache-derby/pom.xml b/persistence-modules/apache-derby/pom.xml index 7728bd4d8f..f7f5ca7503 100644 --- a/persistence-modules/apache-derby/pom.xml +++ b/persistence-modules/apache-derby/pom.xml @@ -1,15 +1,15 @@ + 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 + apache-derby + persistence-modules com.baeldung 1.0.0-SNAPSHOT - 4.0.0 - - apache-derby @@ -18,15 +18,12 @@ derby 10.13.1.1 - org.apache.derby derbyclient 10.13.1.1 - - \ No newline at end of file diff --git a/persistence-modules/deltaspike/pom.xml b/persistence-modules/deltaspike/pom.xml index 5003ef9daf..f151255948 100644 --- a/persistence-modules/deltaspike/pom.xml +++ b/persistence-modules/deltaspike/pom.xml @@ -18,8 +18,8 @@ - + junit junit diff --git a/persistence-modules/spring-data-cassandra-2/pom.xml b/persistence-modules/spring-data-cassandra-2/pom.xml index 0e09448d0f..8202471d19 100644 --- a/persistence-modules/spring-data-cassandra-2/pom.xml +++ b/persistence-modules/spring-data-cassandra-2/pom.xml @@ -1,72 +1,73 @@ - - 4.0.0 - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 - + + 4.0.0 + org.baeldung + spring-cassandra + 0.0.1-SNAPSHOT + spring-cassandra + Demo project for Spring Data Cassandra - org.baeldung - spring-cassandra - 0.0.1-SNAPSHOT - spring-cassandra - Demo project for Spring Data Cassandra + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + - - - org.springframework.boot - spring-boot-starter-data-cassandra - - - org.springframework.data - spring-data-cassandra - ${org.springframework.data.version} - - - uk.org.webcompere - system-stubs-core - ${system.stubs.version} - - - org.springframework.boot - spring-boot-starter-test - test - - - org.testcontainers - testcontainers - ${testcontainers.version} - test - - - org.testcontainers - cassandra - ${testcontainers.version} - test - - - org.testcontainers - junit-jupiter - ${testcontainers.version} - test - - - uk.org.webcompere - system-stubs-jupiter - ${system.stubs.version} - test - - + + + org.springframework.boot + spring-boot-starter-data-cassandra + + + org.springframework.data + spring-data-cassandra + ${org.springframework.data.version} + + + uk.org.webcompere + system-stubs-core + ${system.stubs.version} + + + org.springframework.boot + spring-boot-starter-test + test + + + org.testcontainers + testcontainers + ${testcontainers.version} + test + + + org.testcontainers + cassandra + ${testcontainers.version} + test + + + org.testcontainers + junit-jupiter + ${testcontainers.version} + test + + + uk.org.webcompere + system-stubs-jupiter + ${system.stubs.version} + test + + - - 11 - 3.1.11 - 1.15.3 - 1.1.0 - 5.6.2 - + + 11 + 3.1.11 + 1.15.3 + 1.1.0 + 5.6.2 + - + \ No newline at end of file diff --git a/persistence-modules/spring-data-cassandra/pom.xml b/persistence-modules/spring-data-cassandra/pom.xml index 8092c05a40..925031b141 100644 --- a/persistence-modules/spring-data-cassandra/pom.xml +++ b/persistence-modules/spring-data-cassandra/pom.xml @@ -49,7 +49,8 @@ ${cassandra-unit-shaded.version} test - + junit junit diff --git a/quarkus-vs-springboot/pom.xml b/quarkus-vs-springboot/pom.xml index cf1cbb5d85..1726d076da 100644 --- a/quarkus-vs-springboot/pom.xml +++ b/quarkus-vs-springboot/pom.xml @@ -1,19 +1,19 @@ + 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 + quarkus-vs-springboot + 1.0-SNAPSHOT + quarkus-vs-springboot + pom + parent-modules com.baeldung 1.0.0-SNAPSHOT - 1.0-SNAPSHOT - quarkus-vs-springboot - quarkus-vs-springboot - pom - 4.0.0 - quarkus-project spring-project diff --git a/quarkus-vs-springboot/quarkus-project/pom.xml b/quarkus-vs-springboot/quarkus-project/pom.xml index 58d547f3b0..eeeb9d3256 100644 --- a/quarkus-vs-springboot/quarkus-project/pom.xml +++ b/quarkus-vs-springboot/quarkus-project/pom.xml @@ -1,143 +1,150 @@ - - 4.0.0 - - com.baeldung - quarkus-vs-springboot - 1.0-SNAPSHOT - - quarkus-project - 0.1-SNAPSHOT - - 3.8.1 - true - 11 - 11 - UTF-8 - UTF-8 - quarkus-bom - io.quarkus.platform - 2.2.2.Final - 3.0.0-M4 - - + 4.0.0 + quarkus-project + 0.1-SNAPSHOT + + + com.baeldung + quarkus-vs-springboot + 1.0-SNAPSHOT + + + + + + ${quarkus.platform.group-id} + ${quarkus.platform.artifact-id} + ${quarkus.platform.version} + pom + import + + + + - - ${quarkus.platform.group-id} - ${quarkus.platform.artifact-id} - ${quarkus.platform.version} - pom - import - + + io.quarkus + quarkus-hibernate-reactive-panache + + + io.quarkus + quarkus-resteasy-reactive + + + io.quarkus + quarkus-resteasy-reactive-jackson + + + io.quarkus + quarkus-reactive-pg-client + + + io.quarkus + quarkus-arc + + + io.quarkus + quarkus-container-image-docker + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + - - - - io.quarkus - quarkus-hibernate-reactive-panache - - - io.quarkus - quarkus-resteasy-reactive - - - io.quarkus - quarkus-resteasy-reactive-jackson - - - io.quarkus - quarkus-reactive-pg-client - - - io.quarkus - quarkus-arc - - - io.quarkus - quarkus-container-image-docker - - - io.quarkus - quarkus-junit5 - test - - - io.rest-assured - rest-assured - test - - - - - - ${quarkus.platform.group-id} - quarkus-maven-plugin - ${quarkus.platform.version} - true - - - - build - generate-code - generate-code-tests - - - - - - maven-compiler-plugin - ${compiler-plugin.version} - - ${maven.compiler.parameters} - - - - maven-surefire-plugin - ${surefire-plugin.version} - - false - - org.jboss.logmanager.LogManager - - - - - - - - native - - - native - - - + + - - maven-failsafe-plugin - ${surefire-plugin.version} - - - - integration-test - verify - + + ${quarkus.platform.group-id} + quarkus-maven-plugin + ${quarkus.platform.version} + true + + + + build + generate-code + generate-code-tests + + + + + + maven-compiler-plugin + ${compiler-plugin.version} - - ${project.build.directory}/${project.build.finalName}-runner - org.jboss.logmanager.LogManager - + ${maven.compiler.parameters} - - - + + + maven-surefire-plugin + ${surefire-plugin.version} + + false + + org.jboss.logmanager.LogManager + + + - - - -H:+AllowVMInspection - native - - - - + + + + native + + + native + + + + + + maven-failsafe-plugin + ${surefire-plugin.version} + + + + integration-test + verify + + + + ${project.build.directory}/${project.build.finalName}-runner + org.jboss.logmanager.LogManager + + + + + + + + + -H:+AllowVMInspection + native + + + + + + 3.8.1 + true + 11 + 11 + UTF-8 + UTF-8 + quarkus-bom + io.quarkus.platform + 2.2.2.Final + 3.0.0-M4 + + + \ No newline at end of file diff --git a/quarkus-vs-springboot/spring-project/pom.xml b/quarkus-vs-springboot/spring-project/pom.xml index be5cc57765..128966c07e 100644 --- a/quarkus-vs-springboot/spring-project/pom.xml +++ b/quarkus-vs-springboot/spring-project/pom.xml @@ -1,25 +1,18 @@ - - - org.springframework.boot - spring-boot-starter-parent - 2.5.4 - - - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-project com.baeldung 0.1-SNAPSHOT - - 11 - - 0.10.3 - + + org.springframework.boot + spring-boot-starter-parent + 2.5.4 + + @@ -161,11 +154,19 @@ org.apache.maven.plugins maven-surefire-plugin - -DspringAot=true -agentlib:native-image-agent=access-filter-file=src/test/resources/access-filter.json,config-merge-dir=target/classes/META-INF/native-image + -DspringAot=true + -agentlib:native-image-agent=access-filter-file=src/test/resources/access-filter.json,config-merge-dir=target/classes/META-INF/native-image + + + 11 + + 0.10.3 + + \ No newline at end of file diff --git a/quarkus/pom.xml b/quarkus/pom.xml index d826729ad7..22f5e0e991 100644 --- a/quarkus/pom.xml +++ b/quarkus/pom.xml @@ -16,8 +16,8 @@ - + junit junit diff --git a/rule-engines/evrete/pom.xml b/rule-engines/evrete/pom.xml index 819a912c43..cfcadcb2ea 100644 --- a/rule-engines/evrete/pom.xml +++ b/rule-engines/evrete/pom.xml @@ -8,10 +8,6 @@ 1.0 evrete - - 2.1.04 - - com.baeldung rule-engines @@ -32,4 +28,9 @@ ${evrete.version} + + + 2.1.04 + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-admin/pom.xml b/spring-boot-modules/spring-boot-admin/pom.xml index b995b6f02e..509abfa013 100644 --- a/spring-boot-modules/spring-boot-admin/pom.xml +++ b/spring-boot-modules/spring-boot-admin/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml index eca92ff3a5..72f828b259 100644 --- a/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml +++ b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-admin 0.0.1-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml index a1daa3fa19..0ccd43e0b9 100644 --- a/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml +++ b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-admin 0.0.1-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-angular/pom.xml b/spring-boot-modules/spring-boot-angular/pom.xml index 89a8814d2f..d713510cff 100644 --- a/spring-boot-modules/spring-boot-angular/pom.xml +++ b/spring-boot-modules/spring-boot-angular/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-annotations/pom.xml b/spring-boot-modules/spring-boot-annotations/pom.xml index 22572e7492..618ae6024b 100644 --- a/spring-boot-modules/spring-boot-annotations/pom.xml +++ b/spring-boot-modules/spring-boot-annotations/pom.xml @@ -11,7 +11,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-artifacts-2/pom.xml b/spring-boot-modules/spring-boot-artifacts-2/pom.xml index 8cf78b79e0..3b9390e973 100644 --- a/spring-boot-modules/spring-boot-artifacts-2/pom.xml +++ b/spring-boot-modules/spring-boot-artifacts-2/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-artifacts/pom.xml b/spring-boot-modules/spring-boot-artifacts/pom.xml index 7ed91a6626..5b4f5a1dd1 100644 --- a/spring-boot-modules/spring-boot-artifacts/pom.xml +++ b/spring-boot-modules/spring-boot-artifacts/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-autoconfiguration/pom.xml b/spring-boot-modules/spring-boot-autoconfiguration/pom.xml index bf8bcc5a87..b5e85bad59 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/pom.xml +++ b/spring-boot-modules/spring-boot-autoconfiguration/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-basic-customization-2/pom.xml b/spring-boot-modules/spring-boot-basic-customization-2/pom.xml index 6f3cb48b81..7a086331ab 100644 --- a/spring-boot-modules/spring-boot-basic-customization-2/pom.xml +++ b/spring-boot-modules/spring-boot-basic-customization-2/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/AuthenticationFilter.java b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/AuthenticationFilter.java new file mode 100644 index 0000000000..7ddcde7dc8 --- /dev/null +++ b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/AuthenticationFilter.java @@ -0,0 +1,34 @@ +package com.baeldung.onceperrequestfilter; + +import org.springframework.stereotype.Component; +import org.springframework.web.filter.OncePerRequestFilter; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Component +public class AuthenticationFilter extends OncePerRequestFilter { + + @Override + protected void doFilterInternal( + HttpServletRequest request, + HttpServletResponse response, + FilterChain filterChain) throws + ServletException, IOException { + String usrName = request.getHeader("userName"); + logger.info("Successfully authenticated user " + + usrName); + filterChain.doFilter(request, response); + } + @Override + protected boolean shouldNotFilterAsyncDispatch() { + return false; + } + @Override + protected boolean shouldNotFilterErrorDispatch() { + return false; + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/HelloController.java b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/HelloController.java new file mode 100644 index 0000000000..0a354c91ac --- /dev/null +++ b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/HelloController.java @@ -0,0 +1,40 @@ +package com.baeldung.onceperrequestfilter; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.context.request.async.DeferredResult; + +import javax.servlet.http.HttpServletResponse; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +@Controller +public class HelloController implements AutoCloseable { + + private final ExecutorService executorService = Executors.newCachedThreadPool(); + + private Logger logger = LoggerFactory.getLogger(HelloController.class); + + @GetMapping(path = "/greeting") + public DeferredResult hello(HttpServletResponse response) throws Exception { + DeferredResult deferredResult = new DeferredResult<>(); + executorService.submit(() -> perform(deferredResult)); + return deferredResult; + } + + private void perform(DeferredResult dr) { + try { + Thread.sleep(10); + } catch (InterruptedException e) { + e.printStackTrace(); + } + dr.setResult("OK"); + } + + @Override + public void close() throws Exception { + executorService.shutdownNow(); + } +} diff --git a/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/MyOncePerRequestFilter.java b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/MyOncePerRequestFilter.java new file mode 100644 index 0000000000..3fd304f86b --- /dev/null +++ b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/MyOncePerRequestFilter.java @@ -0,0 +1,29 @@ +package com.baeldung.onceperrequestfilter; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.filter.OncePerRequestFilter; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Component +public class MyOncePerRequestFilter extends OncePerRequestFilter { + private Logger logger = LoggerFactory.getLogger(MyOncePerRequestFilter.class); + + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) + throws ServletException, IOException { + logger.info("Inside Once Per Request Filter originated by request {}", request.getRequestURI()); + filterChain.doFilter(request, response); + } + + @Override + protected boolean shouldNotFilterAsyncDispatch() { + return true; + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/OncePerRequestFilterApp.java b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/OncePerRequestFilterApp.java new file mode 100644 index 0000000000..ed7be518a3 --- /dev/null +++ b/spring-boot-modules/spring-boot-basic-customization-2/src/main/java/com/baeldung/onceperrequestfilter/OncePerRequestFilterApp.java @@ -0,0 +1,12 @@ +package com.baeldung.onceperrequestfilter; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +@SpringBootApplication(scanBasePackages = "com.baeldung.onceperrequestfilter") +public class OncePerRequestFilterApp { + public static void main(String[] args) { + SpringApplication.run(OncePerRequestFilterApp.class, args); + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-basic-customization/pom.xml b/spring-boot-modules/spring-boot-basic-customization/pom.xml index 5ab747cff1..2782c3320e 100644 --- a/spring-boot-modules/spring-boot-basic-customization/pom.xml +++ b/spring-boot-modules/spring-boot-basic-customization/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-bootstrap/pom.xml b/spring-boot-modules/spring-boot-bootstrap/pom.xml index f94ee9ca31..caa3f6c7fc 100644 --- a/spring-boot-modules/spring-boot-bootstrap/pom.xml +++ b/spring-boot-modules/spring-boot-bootstrap/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-ci-cd/pom.xml b/spring-boot-modules/spring-boot-ci-cd/pom.xml index fb1810c62e..68a9f21d20 100644 --- a/spring-boot-modules/spring-boot-ci-cd/pom.xml +++ b/spring-boot-modules/spring-boot-ci-cd/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-client/pom.xml b/spring-boot-modules/spring-boot-client/pom.xml index 7f54d0e541..8ae2cbee79 100644 --- a/spring-boot-modules/spring-boot-client/pom.xml +++ b/spring-boot-modules/spring-boot-client/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-config-jpa-error/pom.xml b/spring-boot-modules/spring-boot-config-jpa-error/pom.xml index b5207f8997..6291589e7a 100644 --- a/spring-boot-modules/spring-boot-config-jpa-error/pom.xml +++ b/spring-boot-modules/spring-boot-config-jpa-error/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-crud/pom.xml b/spring-boot-modules/spring-boot-crud/pom.xml index 79eccf2fba..0a8e57be17 100644 --- a/spring-boot-modules/spring-boot-crud/pom.xml +++ b/spring-boot-modules/spring-boot-crud/pom.xml @@ -10,7 +10,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-ctx-fluent/pom.xml b/spring-boot-modules/spring-boot-ctx-fluent/pom.xml index 8a7aca076e..deefefc87c 100644 --- a/spring-boot-modules/spring-boot-ctx-fluent/pom.xml +++ b/spring-boot-modules/spring-boot-ctx-fluent/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml index 815c3e8366..c4759af373 100644 --- a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml @@ -11,7 +11,6 @@ com.baeldung.spring-boot-modules spring-boot-custom-starter 0.0.1-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-custom-starter/pom.xml b/spring-boot-modules/spring-boot-custom-starter/pom.xml index 27e3a03153..aee98b125e 100644 --- a/spring-boot-modules/spring-boot-custom-starter/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-data-2/pom.xml b/spring-boot-modules/spring-boot-data-2/pom.xml index b7006782c8..a3c2430497 100644 --- a/spring-boot-modules/spring-boot-data-2/pom.xml +++ b/spring-boot-modules/spring-boot-data-2/pom.xml @@ -9,7 +9,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-data/pom.xml b/spring-boot-modules/spring-boot-data/pom.xml index 447b730c02..c57dad49f4 100644 --- a/spring-boot-modules/spring-boot-data/pom.xml +++ b/spring-boot-modules/spring-boot-data/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-deployment/pom.xml b/spring-boot-modules/spring-boot-deployment/pom.xml index 7c78d20afc..c4d9fa7059 100644 --- a/spring-boot-modules/spring-boot-deployment/pom.xml +++ b/spring-boot-modules/spring-boot-deployment/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-di/pom.xml b/spring-boot-modules/spring-boot-di/pom.xml index 0e9fb49a95..af0dd7e4de 100644 --- a/spring-boot-modules/spring-boot-di/pom.xml +++ b/spring-boot-modules/spring-boot-di/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-disable-logging/disabling-console-jul/pom.xml b/spring-boot-modules/spring-boot-disable-logging/disabling-console-jul/pom.xml index deee4e435f..ace21410ea 100644 --- a/spring-boot-modules/spring-boot-disable-logging/disabling-console-jul/pom.xml +++ b/spring-boot-modules/spring-boot-disable-logging/disabling-console-jul/pom.xml @@ -11,7 +11,6 @@ com.baeldung.spring-boot-modules spring-boot-disable-logging 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-disable-logging/disabling-console-log4j2/pom.xml b/spring-boot-modules/spring-boot-disable-logging/disabling-console-log4j2/pom.xml index 0524f9d401..b71e1066e7 100644 --- a/spring-boot-modules/spring-boot-disable-logging/disabling-console-log4j2/pom.xml +++ b/spring-boot-modules/spring-boot-disable-logging/disabling-console-log4j2/pom.xml @@ -11,7 +11,6 @@ com.baeldung.spring-boot-modules spring-boot-disable-logging 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-disable-logging/disabling-console-logback/pom.xml b/spring-boot-modules/spring-boot-disable-logging/disabling-console-logback/pom.xml index 0990209ff9..37fad3ec53 100644 --- a/spring-boot-modules/spring-boot-disable-logging/disabling-console-logback/pom.xml +++ b/spring-boot-modules/spring-boot-disable-logging/disabling-console-logback/pom.xml @@ -10,7 +10,6 @@ com.baeldung.spring-boot-modules spring-boot-disable-logging 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-disable-logging/pom.xml b/spring-boot-modules/spring-boot-disable-logging/pom.xml index 65de521c63..31b02009b6 100644 --- a/spring-boot-modules/spring-boot-disable-logging/pom.xml +++ b/spring-boot-modules/spring-boot-disable-logging/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-environment/pom.xml b/spring-boot-modules/spring-boot-environment/pom.xml index 9c852986a1..2cda396a9b 100644 --- a/spring-boot-modules/spring-boot-environment/pom.xml +++ b/spring-boot-modules/spring-boot-environment/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-exceptions/pom.xml b/spring-boot-modules/spring-boot-exceptions/pom.xml index cec1bab4ff..b1240957f6 100644 --- a/spring-boot-modules/spring-boot-exceptions/pom.xml +++ b/spring-boot-modules/spring-boot-exceptions/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-flowable/pom.xml b/spring-boot-modules/spring-boot-flowable/pom.xml index 7d89c665cd..50500c3de6 100644 --- a/spring-boot-modules/spring-boot-flowable/pom.xml +++ b/spring-boot-modules/spring-boot-flowable/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-jasypt/pom.xml b/spring-boot-modules/spring-boot-jasypt/pom.xml index 0a37c545ac..8595b9c639 100644 --- a/spring-boot-modules/spring-boot-jasypt/pom.xml +++ b/spring-boot-modules/spring-boot-jasypt/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-libraries/pom.xml b/spring-boot-modules/spring-boot-libraries/pom.xml index ad00629e14..eee469ea46 100644 --- a/spring-boot-modules/spring-boot-libraries/pom.xml +++ b/spring-boot-modules/spring-boot-libraries/pom.xml @@ -11,7 +11,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-logging-log4j2/pom.xml b/spring-boot-modules/spring-boot-logging-log4j2/pom.xml index dafbddb93f..8cf052deb3 100644 --- a/spring-boot-modules/spring-boot-logging-log4j2/pom.xml +++ b/spring-boot-modules/spring-boot-logging-log4j2/pom.xml @@ -18,8 +18,8 @@ - + junit junit diff --git a/spring-boot-modules/spring-boot-mvc-2/pom.xml b/spring-boot-modules/spring-boot-mvc-2/pom.xml index d347b36b3b..f303171df8 100644 --- a/spring-boot-modules/spring-boot-mvc-2/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-2/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-mvc-3/pom.xml b/spring-boot-modules/spring-boot-mvc-3/pom.xml index a46837e315..dee217862d 100644 --- a/spring-boot-modules/spring-boot-mvc-3/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-3/pom.xml @@ -4,15 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-boot-mvc-3 - jar spring-boot-mvc-3 + jar Module For Spring Boot MVC Web com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-mvc-jersey/pom.xml b/spring-boot-modules/spring-boot-mvc-jersey/pom.xml index b6e2c62663..34b459d1dc 100644 --- a/spring-boot-modules/spring-boot-mvc-jersey/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-jersey/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-mvc/pom.xml b/spring-boot-modules/spring-boot-mvc/pom.xml index 3e835691aa..6d3f722146 100644 --- a/spring-boot-modules/spring-boot-mvc/pom.xml +++ b/spring-boot-modules/spring-boot-mvc/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-nashorn/pom.xml b/spring-boot-modules/spring-boot-nashorn/pom.xml index 89b0b984bc..0ae108ffd0 100644 --- a/spring-boot-modules/spring-boot-nashorn/pom.xml +++ b/spring-boot-modules/spring-boot-nashorn/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-parent/pom.xml b/spring-boot-modules/spring-boot-parent/pom.xml index 28a940bcd0..d9c23b66ac 100644 --- a/spring-boot-modules/spring-boot-parent/pom.xml +++ b/spring-boot-modules/spring-boot-parent/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-parent/spring-boot-with-custom-parent/pom.xml b/spring-boot-modules/spring-boot-parent/spring-boot-with-custom-parent/pom.xml index a61a5fd057..18fa4c53d9 100644 --- a/spring-boot-modules/spring-boot-parent/spring-boot-with-custom-parent/pom.xml +++ b/spring-boot-modules/spring-boot-parent/spring-boot-with-custom-parent/pom.xml @@ -11,7 +11,6 @@ com.baeldung.spring-boot-modules spring-boot-parent 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-parent/spring-boot-with-starter-parent/pom.xml b/spring-boot-modules/spring-boot-parent/spring-boot-with-starter-parent/pom.xml index 2568714278..e65f590c9b 100644 --- a/spring-boot-modules/spring-boot-parent/spring-boot-with-starter-parent/pom.xml +++ b/spring-boot-modules/spring-boot-parent/spring-boot-with-starter-parent/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-parent 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-performance/pom.xml b/spring-boot-modules/spring-boot-performance/pom.xml index f1f9b52dc4..38f5758c1f 100644 --- a/spring-boot-modules/spring-boot-performance/pom.xml +++ b/spring-boot-modules/spring-boot-performance/pom.xml @@ -11,7 +11,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-properties-2/pom.xml b/spring-boot-modules/spring-boot-properties-2/pom.xml index 62f23da450..d5aaab54d3 100644 --- a/spring-boot-modules/spring-boot-properties-2/pom.xml +++ b/spring-boot-modules/spring-boot-properties-2/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-properties-3/pom.xml b/spring-boot-modules/spring-boot-properties-3/pom.xml index b5e6ef8701..d72c410d9b 100644 --- a/spring-boot-modules/spring-boot-properties-3/pom.xml +++ b/spring-boot-modules/spring-boot-properties-3/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-properties/pom.xml b/spring-boot-modules/spring-boot-properties/pom.xml index 0ef44e0546..8cbaccdac5 100644 --- a/spring-boot-modules/spring-boot-properties/pom.xml +++ b/spring-boot-modules/spring-boot-properties/pom.xml @@ -4,16 +4,15 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-boot-properties - jar 0.0.1-SNAPSHOT spring-boot-properties + jar Spring Boot Properties Module com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-runtime-2/pom.xml b/spring-boot-modules/spring-boot-runtime-2/pom.xml index c177529a41..e6483e9ec0 100644 --- a/spring-boot-modules/spring-boot-runtime-2/pom.xml +++ b/spring-boot-modules/spring-boot-runtime-2/pom.xml @@ -4,15 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-boot-runtime-2 - jar spring-boot-runtime-2 + jar Demo project for Spring Boot com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-runtime/pom.xml b/spring-boot-modules/spring-boot-runtime/pom.xml index 92b1458cf6..d42ae303a7 100644 --- a/spring-boot-modules/spring-boot-runtime/pom.xml +++ b/spring-boot-modules/spring-boot-runtime/pom.xml @@ -4,15 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-boot-runtime - jar spring-boot-runtime + jar Demo project for Spring Boot Runtime com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-security/pom.xml b/spring-boot-modules/spring-boot-security/pom.xml index 11e5a38eeb..41dbcff38d 100644 --- a/spring-boot-modules/spring-boot-security/pom.xml +++ b/spring-boot-modules/spring-boot-security/pom.xml @@ -4,15 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-boot-security - jar spring-boot-security + jar Spring Boot Security Auto-Configuration com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-springdoc/pom.xml b/spring-boot-modules/spring-boot-springdoc/pom.xml index 892fbfe4ca..10bd9a7534 100644 --- a/spring-boot-modules/spring-boot-springdoc/pom.xml +++ b/spring-boot-modules/spring-boot-springdoc/pom.xml @@ -5,15 +5,14 @@ 4.0.0 spring-boot-springdoc 0.0.1-SNAPSHOT - jar spring-boot-springdoc + jar Project for Springdoc integration com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-swagger-jwt/pom.xml b/spring-boot-modules/spring-boot-swagger-jwt/pom.xml index c296b06388..e0d96627cd 100644 --- a/spring-boot-modules/spring-boot-swagger-jwt/pom.xml +++ b/spring-boot-modules/spring-boot-swagger-jwt/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-swagger/pom.xml b/spring-boot-modules/spring-boot-swagger/pom.xml index a9d8a943e4..87ee5f04cb 100644 --- a/spring-boot-modules/spring-boot-swagger/pom.xml +++ b/spring-boot-modules/spring-boot-swagger/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-testing/pom.xml b/spring-boot-modules/spring-boot-testing/pom.xml index a846227290..658eb7728e 100644 --- a/spring-boot-modules/spring-boot-testing/pom.xml +++ b/spring-boot-modules/spring-boot-testing/pom.xml @@ -4,15 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-boot-testing - war spring-boot-testing + war This is simple boot application for demonstrating testing features. com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot-vue/pom.xml b/spring-boot-modules/spring-boot-vue/pom.xml index 3d3d51797c..c552a9583f 100644 --- a/spring-boot-modules/spring-boot-vue/pom.xml +++ b/spring-boot-modules/spring-boot-vue/pom.xml @@ -5,15 +5,14 @@ 4.0.0 spring-boot-vue 0.0.1-SNAPSHOT - jar spring-boot-vue + jar Demo project for Spring Boot Vue project com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-boot-modules/spring-boot/pom.xml b/spring-boot-modules/spring-boot/pom.xml index 026c48c148..49effa3700 100644 --- a/spring-boot-modules/spring-boot/pom.xml +++ b/spring-boot-modules/spring-boot/pom.xml @@ -13,7 +13,6 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - ../ diff --git a/spring-cloud-data-flow/pom.xml b/spring-cloud-data-flow/pom.xml index f81daeeabc..49a5accb90 100644 --- a/spring-cloud-data-flow/pom.xml +++ b/spring-cloud-data-flow/pom.xml @@ -7,7 +7,6 @@ 0.0.1-SNAPSHOT spring-cloud-data-flow pom - com.baeldung parent-boot-2 diff --git a/spring-cloud/spring-cloud-aws/pom.xml b/spring-cloud/spring-cloud-aws/pom.xml index c9cd56bea6..c313e2026a 100644 --- a/spring-cloud/spring-cloud-aws/pom.xml +++ b/spring-cloud/spring-cloud-aws/pom.xml @@ -18,8 +18,8 @@ - + junit junit diff --git a/spring-cloud/spring-cloud-bootstrap/order-service/order-client/pom.xml b/spring-cloud/spring-cloud-bootstrap/order-service/order-client/pom.xml index dc6e196325..5326e181e0 100644 --- a/spring-cloud/spring-cloud-bootstrap/order-service/order-client/pom.xml +++ b/spring-cloud/spring-cloud-bootstrap/order-service/order-client/pom.xml @@ -16,4 +16,4 @@ 1.0.0-SNAPSHOT - + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-connectors-heroku/pom.xml b/spring-cloud/spring-cloud-connectors-heroku/pom.xml index 967b1b3caf..b13c512cc0 100644 --- a/spring-cloud/spring-cloud-connectors-heroku/pom.xml +++ b/spring-cloud/spring-cloud-connectors-heroku/pom.xml @@ -28,7 +28,7 @@ - + org.springframework.boot spring-boot-starter-cloud-connectors ${spring-boot-starter-cloud-connectors.version} @@ -57,9 +57,9 @@ - 2.2.6.RELEASE + 2.2.6.RELEASE Hoxton.SR4 42.2.10 - + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-dapr/pom.xml b/spring-cloud/spring-cloud-dapr/pom.xml index c2e9edaedc..436666b08e 100644 --- a/spring-cloud/spring-cloud-dapr/pom.xml +++ b/spring-cloud/spring-cloud-dapr/pom.xml @@ -17,4 +17,4 @@ greeting - + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-docker/docker-product-server/pom.xml b/spring-cloud/spring-cloud-docker/docker-product-server/pom.xml index 9645dd3dff..ba4cf63ad8 100644 --- a/spring-cloud/spring-cloud-docker/docker-product-server/pom.xml +++ b/spring-cloud/spring-cloud-docker/docker-product-server/pom.xml @@ -4,8 +4,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 docker-product-server - docker-product-server 1.0.0 + docker-product-server com.baeldung.spring.cloud diff --git a/spring-cloud/spring-cloud-docker/pom.xml b/spring-cloud/spring-cloud-docker/pom.xml index 3e407df6a1..f0f6b84fb0 100644 --- a/spring-cloud/spring-cloud-docker/pom.xml +++ b/spring-cloud/spring-cloud-docker/pom.xml @@ -4,8 +4,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-cloud-docker - spring-cloud-docker 1.0.0-SNAPSHOT + spring-cloud-docker pom diff --git a/spring-cloud/spring-cloud-hystrix/rest-consumer/pom.xml b/spring-cloud/spring-cloud-hystrix/rest-consumer/pom.xml index 73a0859785..741457529c 100644 --- a/spring-cloud/spring-cloud-hystrix/rest-consumer/pom.xml +++ b/spring-cloud/spring-cloud-hystrix/rest-consumer/pom.xml @@ -12,7 +12,6 @@ com.baeldung.spring.cloud spring-cloud-hystrix 1.0.0-SNAPSHOT - ../ diff --git a/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/client-service/pom.xml b/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/client-service/pom.xml index e916f2bc3e..cedd46dfef 100644 --- a/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/client-service/pom.xml +++ b/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/client-service/pom.xml @@ -4,8 +4,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 client-service - client-service 1.0-SNAPSHOT + client-service com.baeldung.spring.cloud diff --git a/spring-cloud/spring-cloud-kubernetes/kubernetes-selfhealing/liveness-example/pom.xml b/spring-cloud/spring-cloud-kubernetes/kubernetes-selfhealing/liveness-example/pom.xml index 725aa9cd3d..928f401405 100644 --- a/spring-cloud/spring-cloud-kubernetes/kubernetes-selfhealing/liveness-example/pom.xml +++ b/spring-cloud/spring-cloud-kubernetes/kubernetes-selfhealing/liveness-example/pom.xml @@ -4,8 +4,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 liveness-example - liveness-example 1.0-SNAPSHOT + liveness-example com.baeldung.spring.cloud diff --git a/spring-cloud/spring-cloud-stream-starters/twitterhdfs/pom.xml b/spring-cloud/spring-cloud-stream-starters/twitterhdfs/pom.xml index ba6cee1fce..1c8fa4e694 100644 --- a/spring-cloud/spring-cloud-stream-starters/twitterhdfs/pom.xml +++ b/spring-cloud/spring-cloud-stream-starters/twitterhdfs/pom.xml @@ -18,8 +18,8 @@ - + junit junit diff --git a/spring-ejb/pom.xml b/spring-ejb/pom.xml index 0b52fa52b1..003b428ff9 100755 --- a/spring-ejb/pom.xml +++ b/spring-ejb/pom.xml @@ -14,7 +14,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - ../ @@ -26,8 +25,8 @@ - + junit junit diff --git a/spring-quartz/pom.xml b/spring-quartz/pom.xml index 19ea302a1d..53b6962a60 100644 --- a/spring-quartz/pom.xml +++ b/spring-quartz/pom.xml @@ -4,8 +4,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-quartz - spring-quartz 0.0.1-SNAPSHOT + spring-quartz jar Demo project for Scheduling in Spring with Quartz diff --git a/spring-security-modules/spring-5-security-oauth/pom.xml b/spring-security-modules/spring-5-security-oauth/pom.xml index 194ace35b0..aa4958ae47 100644 --- a/spring-security-modules/spring-5-security-oauth/pom.xml +++ b/spring-security-modules/spring-5-security-oauth/pom.xml @@ -68,7 +68,8 @@ - + 2.5.2 com.baeldung.oauth2.SpringOAuthApplication diff --git a/spring-security-modules/spring-security-web-boot-3/pom.xml b/spring-security-modules/spring-security-web-boot-3/pom.xml index 9d09d60611..b26ca094be 100644 --- a/spring-security-modules/spring-security-web-boot-3/pom.xml +++ b/spring-security-modules/spring-security-web-boot-3/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-security-web-boot-3 0.0.1-SNAPSHOT diff --git a/spring-security-modules/spring-security-web-thymeleaf/pom.xml b/spring-security-modules/spring-security-web-thymeleaf/pom.xml index 8e6e0856af..3a240f4129 100644 --- a/spring-security-modules/spring-security-web-thymeleaf/pom.xml +++ b/spring-security-modules/spring-security-web-thymeleaf/pom.xml @@ -29,7 +29,6 @@ org.springframework.boot spring-boot-starter-web - org.springframework.boot spring-boot-starter-test diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/README.md b/spring-swagger-codegen/custom-validations-opeanpi-codegen/README.md new file mode 100644 index 0000000000..83eec25c03 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/README.md @@ -0,0 +1 @@ +# This is a sample on how we can merge the OpenApi code generation with the a custom annotation using ConstraintValidator diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/pom.xml b/spring-swagger-codegen/custom-validations-opeanpi-codegen/pom.xml new file mode 100644 index 0000000000..53e5006bf4 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/pom.xml @@ -0,0 +1,103 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.5.4 + + + com.example + petstore + 0.0.1-SNAPSHOT + petstore + Demo project for Swagger Custom Validations Codegen + + 11 + 3.0.0 + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.hibernate + hibernate-validator + 6.0.10.Final + + + javax.validation + validation-api + 2.0.1.Final + + + org.openapitools + openapi-generator + 3.3.4 + + + io.springfox + springfox-oas + ${springfox-version} + + + io.springfox + springfox-swagger-ui + ${springfox-version} + + + com.fasterxml.jackson.core + jackson-databind + 2.10.0.pr3 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.openapitools + openapi-generator-maven-plugin + 5.1.0 + + + + generate + + + + ${project.basedir}/src/main/resources/petstore.yml + + spring + com.baeldung.openapi.api + com.baeldung.openapi.model + + ApiUtil.java + + + false + java8-localdatetime + + + src/main/resources/openapi/templates + + + + + + + + + + diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/PetstoreApplication.java b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/PetstoreApplication.java new file mode 100644 index 0000000000..5a6372ba22 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/PetstoreApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.openapi.petstore; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class PetstoreApplication { + + public static void main(String[] args) { + SpringApplication.run(PetstoreApplication.class, args); + } + +} diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/controller/PetController.java b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/controller/PetController.java new file mode 100644 index 0000000000..081d0cb6f9 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/controller/PetController.java @@ -0,0 +1,17 @@ +package com.baeldung.openapi.petstore.controller; + +import com.baeldung.openapi.api.PetsApi; +import com.baeldung.openapi.model.Pet; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; + +import java.util.Arrays; +import java.util.List; + +@Controller +public class PetController implements PetsApi { + + public ResponseEntity> findPetsByName(String name) { + return ResponseEntity.ok(Arrays.asList(new Pet().id(1L).name(name))); + } +} diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/controller/PetControllerAdvice.java b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/controller/PetControllerAdvice.java new file mode 100644 index 0000000000..cf243dbb46 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/controller/PetControllerAdvice.java @@ -0,0 +1,20 @@ +package com.baeldung.openapi.petstore.controller; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; + +import javax.validation.ConstraintViolationException; + +@ControllerAdvice +public class PetControllerAdvice { + + @ResponseBody + @ResponseStatus(HttpStatus.BAD_REQUEST) + @ExceptionHandler(ConstraintViolationException.class) + public void handleConstraintViolationException() { + + } +} diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/Camelcase.java b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/Camelcase.java new file mode 100644 index 0000000000..b0b0b739e2 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/Camelcase.java @@ -0,0 +1,22 @@ +package com.baeldung.openapi.petstore.validation; + +import javax.validation.Constraint; +import javax.validation.Payload; +import java.lang.annotation.*; + +@Documented +@Constraint(validatedBy = {CamelcaseValidator.class}) +@Target({ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Camelcase { + + String message() default "Name should be uppercase."; + + boolean required() default true; + + Class[] groups() default {}; + + Class[] payload() default {}; + + String[] values() default {}; +} \ No newline at end of file diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/CamelcaseValidator.java b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/CamelcaseValidator.java new file mode 100644 index 0000000000..2b08e3dd2a --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/java/com/baeldung/openapi/petstore/validation/CamelcaseValidator.java @@ -0,0 +1,35 @@ +package com.baeldung.openapi.petstore.validation; + +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; +import java.util.Objects; + +public class CamelcaseValidator implements ConstraintValidator { + + private Camelcase uppercaseAnnotation; + + public void initialize(Camelcase constraintAnnotation) { + this.uppercaseAnnotation = constraintAnnotation; + } + + @Override + public boolean isValid(String nameField, ConstraintValidatorContext context) { + String correctName = buildCorrectName(nameField); + if (uppercaseAnnotation.required() + && (Objects.isNull(nameField) || nameField.isBlank() + || !correctName.equals(nameField))) { + context = context + .buildConstraintViolationWithTemplate(this.uppercaseAnnotation.message()) + .addConstraintViolation(); + context.disableDefaultConstraintViolation(); + return false; + } + return true; + } + + private String buildCorrectName(String nameField) { + String upCase = String.valueOf(nameField.charAt(0)).toUpperCase(); + String lowCase = nameField.substring(1).toLowerCase(); + return upCase.concat(lowCase); + } +} \ No newline at end of file diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/application.properties b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/application.properties new file mode 100644 index 0000000000..d5e4d42eb8 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/application.properties @@ -0,0 +1 @@ +openapi.petStore.base-path=/ diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/api.mustache b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/api.mustache new file mode 100644 index 0000000000..a7a35d43b5 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/api.mustache @@ -0,0 +1,150 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://com.baeldung.openapi-generator.tech) ({{{generatorVersion}}}). + * https://com.baeldung.openapi-generator.tech + * Do not edit the class manually. + */ +package {{package}}; + +{{#imports}}import {{import}}; +{{/imports}} +import io.swagger.annotations.*; +import com.baeldung.openapi.petstore.validation.Camelcase; +{{#jdk8-no-delegate}} +{{#virtualService}} +import io.virtualan.annotation.ApiVirtual; +import io.virtualan.annotation.VirtualService; +{{/virtualService}} +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +{{/jdk8-no-delegate}} +import org.springframework.http.ResponseEntity; +{{#useBeanValidation}} +import org.springframework.validation.annotation.Validated; +{{/useBeanValidation}} +{{#vendorExtensions.x-spring-paginated}} +import org.springframework.data.domain.Pageable; +{{/vendorExtensions.x-spring-paginated}} +import org.springframework.web.bind.annotation.*; +{{#jdk8-no-delegate}} + {{^reactive}} +import org.springframework.web.context.request.NativeWebRequest; + {{/reactive}} +{{/jdk8-no-delegate}} +import org.springframework.web.multipart.MultipartFile; +{{#reactive}} +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import org.springframework.http.codec.multipart.Part; +{{/reactive}} +import springfox.documentation.annotations.ApiIgnore; + +{{#useBeanValidation}} +import javax.validation.Valid; +import javax.validation.constraints.*; +{{/useBeanValidation}} +import java.util.List; +import java.util.Map; +{{#jdk8-no-delegate}} +import java.util.Optional; +{{/jdk8-no-delegate}} +{{^jdk8-no-delegate}} + {{#useOptional}} +import java.util.Optional; + {{/useOptional}} +{{/jdk8-no-delegate}} +{{#async}} +import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}}; +{{/async}} +{{>generatedAnnotation}} +{{#useBeanValidation}} +@Validated +{{/useBeanValidation}} +@Api(value = "{{{baseName}}}", tags = "All") +{{#operations}} +{{#virtualService}} +@VirtualService +{{/virtualService}} +public interface {{classname}} { +{{#jdk8-default-interface}} + {{^isDelegate}} + {{^reactive}} + + default Optional getRequest() { + return Optional.empty(); + } + {{/reactive}} + {{/isDelegate}} + {{#isDelegate}} + + default {{classname}}Delegate getDelegate() { + return new {{classname}}Delegate() {}; + } + {{/isDelegate}} +{{/jdk8-default-interface}} +{{#operation}} + + /** + * {{httpMethod}} {{{path}}}{{#summary}} : {{.}}{{/summary}} + {{#notes}} + * {{.}} + {{/notes}} + * + {{#allParams}} + * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} + {{/allParams}} + * @return {{#responses}}{{message}} (status code {{code}}){{^-last}} + * or {{/-last}}{{/responses}} + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#virtualService}} + @ApiVirtual + {{/virtualService}} + @ApiOperation(value = "{{{summary}}}", nickname = "{{{operationId}}}", notes = "{{{notes}}}"{{#returnBaseType}}, response = {{{returnBaseType}}}.class{{/returnBaseType}}{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = { + {{#authMethods}}{{#isOAuth}}@Authorization(value = "{{name}}", scopes = { + {{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{^-last}}, + {{/-last}}{{/scopes}} }){{^-last}},{{/-last}}{{/isOAuth}} + {{^isOAuth}}@Authorization(value = "{{name}}"){{^-last}},{{/-last}} + {{/isOAuth}}{{/authMethods}} }{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}",{{/vendorExtensions.x-tags}} }) + @ApiResponses(value = { {{#responses}} + @ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{#baseType}}, response = {{{baseType}}}.class{{/baseType}}{{#containerType}}, responseContainer = "{{{containerType}}}"{{/containerType}}){{^-last}},{{/-last}}{{/responses}} }) + {{#implicitHeaders}} + @ApiImplicitParams({ + {{#headerParams}} + {{>implicitHeader}} + {{/headerParams}} + }) + {{/implicitHeaders}} + @RequestMapping( + method = RequestMethod.{{httpMethod}}, + value = "{{{path}}}"{{#singleContentTypes}}{{#hasProduces}}, + produces = "{{{vendorExtensions.x-accepts}}}"{{/hasProduces}}{{#hasConsumes}}, + consumes = "{{{vendorExtensions.x-contentType}}}"{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}}, + produces = { {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }{{/hasProduces}}{{#hasConsumes}}, + consumes = { {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }{{/hasConsumes}}{{/singleContentTypes}} + ) + {{#jdk8-default-interface}}default {{/jdk8-default-interface}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{^-last}},{{/-last}}{{#-last}}{{#reactive}}, {{/reactive}}{{/-last}}{{/allParams}}{{#reactive}}@ApiIgnore final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, @ApiIgnore final Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{^jdk8-default-interface}};{{/jdk8-default-interface}}{{#jdk8-default-interface}}{{#unhandledException}} throws Exception{{/unhandledException}} { + {{#delegate-method}} + return {{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, pageable{{/vendorExtensions.x-spring-paginated}}); + } + + // Override this method + {{#jdk8-default-interface}}default {{/jdk8-default-interface}} {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}{{#reactive}}Flux{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}@ApiIgnore final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, @ApiIgnore final Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{#unhandledException}} throws Exception{{/unhandledException}} { + {{/delegate-method}} + {{^isDelegate}} + {{>methodBody}} + {{/isDelegate}} + {{#isDelegate}} + return getDelegate().{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, pageable{{/vendorExtensions.x-spring-paginated}}); + {{/isDelegate}} + }{{/jdk8-default-interface}} + +{{/operation}} +} +{{/operations}} \ No newline at end of file diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/beanValidationCore.mustache b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/beanValidationCore.mustache new file mode 100644 index 0000000000..e3c19c6474 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/beanValidationCore.mustache @@ -0,0 +1,26 @@ +{{{ vendorExtensions.x-constraints }}} +{{#errorMessage}}@Mandatory(errorMessage="{{{pattern}}}") {{/errorMessage}} +{{#pattern}}@Pattern(regexp="{{{pattern}}}") {{/pattern}}{{! +minLength && maxLength set +}}{{#minLength}}{{#maxLength}}@Size(min={{minLength}},max={{maxLength}}) {{/maxLength}}{{/minLength}}{{! +minLength set, maxLength not +}}{{#minLength}}{{^maxLength}}@Size(min={{minLength}}) {{/maxLength}}{{/minLength}}{{! +minLength not set, maxLength set +}}{{^minLength}}{{#maxLength}}@Size(max={{maxLength}}) {{/maxLength}}{{/minLength}}{{! +@Size: minItems && maxItems set +}}{{#minItems}}{{#maxItems}}@Size(min={{minItems}},max={{maxItems}}) {{/maxItems}}{{/minItems}}{{! +@Size: minItems set, maxItems not +}}{{#minItems}}{{^maxItems}}@Size(min={{minItems}}) {{/maxItems}}{{/minItems}}{{! +@Size: minItems not set && maxItems set +}}{{^minItems}}{{#maxItems}}@Size(max={{maxItems}}) {{/maxItems}}{{/minItems}}{{! +@Email: useBeanValidation set && isEmail && java8 set +}}{{#useBeanValidation}}{{#isEmail}}{{#java8}}@javax.validation.constraints.Email{{/java8}}{{/isEmail}}{{/useBeanValidation}}{{! +@Email: performBeanValidation set && isEmail && not java8 set +}}{{#performBeanValidation}}{{#isEmail}}{{^java8}}@org.hibernate.validator.constraints.Email{{/java8}}{{/isEmail}}{{/performBeanValidation}}{{! +check for integer or long / all others=decimal type with @Decimal* +isInteger set +}}{{#isInteger}}{{#minimum}}@Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}) {{/maximum}}{{/isInteger}}{{! +isLong set +}}{{#isLong}}{{#minimum}}@Min({{minimum}}L){{/minimum}}{{#maximum}} @Max({{maximum}}L) {{/maximum}}{{/isLong}}{{! +Not Integer, not Long => we have a decimal value! +}}{{^isInteger}}{{^isLong}}{{#minimum}}@DecimalMin({{#exclusiveMinimum}}value={{/exclusiveMinimum}}"{{minimum}}"{{#exclusiveMinimum}},inclusive=false{{/exclusiveMinimum}}){{/minimum}}{{#maximum}} @DecimalMax({{#exclusiveMaximum}}value={{/exclusiveMaximum}}"{{maximum}}"{{#exclusiveMaximum}},inclusive=false{{/exclusiveMaximum}}) {{/maximum}}{{/isLong}}{{/isInteger}} \ No newline at end of file diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/cookieParams.mustache b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/cookieParams.mustache new file mode 100644 index 0000000000..e21bd9ff4b --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/cookieParams.mustache @@ -0,0 +1 @@ +{{#isCookieParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues = "{{#enumVars}}{{#lambdaEscapeDoubleQuote}}{{{value}}}{{/lambdaEscapeDoubleQuote}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}{{/isContainer}}) @CookieValue("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isCookieParam}} \ No newline at end of file diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/enum.mustache b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/enum.mustache new file mode 100644 index 0000000000..3cdae7f3cc --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/enum.mustache @@ -0,0 +1,31 @@ +class {{classname}} { + /// The underlying value of this enum member. + {{dataType}} value; + + {{classname}}._internal(this.value); + {{ vendorExtensions.x-enum-varnames }} + {{ vendorExtensions.x-enum-descriptions }} + {{#allowableValues}} + {{#enumVars}} + {{#description}} + /// {{description}} + {{/description}} + static {{classname}} {{name}} = {{classname}}._internal({{{value}}}); + {{/enumVars}} + {{/allowableValues}} + + {{classname}}.fromJson(dynamic data) { + switch (data) { + {{#allowableValues}} + {{#enumVars}} + case {{{value}}}: value = data; break; + {{/enumVars}} + {{/allowableValues}} + default: throw('Unknown enum value to decode: $data'); + } + } + + static dynamic encode({{classname}} data) { + return data.value; + } +} \ No newline at end of file diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/model.mustache b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/model.mustache new file mode 100644 index 0000000000..d9329b40d3 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/model.mustache @@ -0,0 +1,42 @@ +package {{package}}; + +{{#imports}}import {{import}}; +{{/imports}} +import com.fasterxml.jackson.databind.annotation.*; +import com.fasterxml.jackson.annotation.*; +import com.baeldung.openapi.petstore.validation.Camelcase; +{{^supportJava6}} +import java.util.Objects; +import java.util.Arrays; +{{/supportJava6}} +{{#supportJava6}} +import org.apache.commons.lang3.ObjectUtils; +{{/supportJava6}} +{{#imports}} +import {{import}}; +{{/imports}} +{{#serializableModel}} +import java.io.Serializable; +{{/serializableModel}} +{{#jackson}} +{{#withXml}} +import com.fasterxml.jackson.dataformat.xml.annotation.*; +{{/withXml}} +{{/jackson}} +{{#withXml}} +import javax.xml.bind.annotation.*; +{{/withXml}} +{{#parcelableModel}} +import android.os.Parcelable; +import android.os.Parcel; +{{/parcelableModel}} +{{#useBeanValidation}} +import javax.validation.constraints.*; +import javax.validation.Valid; +{{/useBeanValidation}} + +{{#models}} +{{#model}} +{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>pojo}}{{/isEnum}} +{{/model}} +{{/models}} \ No newline at end of file diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/modelEnum.mustache b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/modelEnum.mustache new file mode 100644 index 0000000000..29f27bd851 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/openapi/templates/modelEnum.mustache @@ -0,0 +1,68 @@ +{{#jackson}} +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +{{/jackson}} +{{#gson}} +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +{{/gson}} + +/** + * {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}} + */ +{{#gson}} +@JsonAdapter({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.Adapter.class) +{{/gson}} +public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} { + {{#allowableValues}}{{#enumVars}} + {{{name}}}({{{value}}}){{^-last}}, + {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} + + private {{{dataType}}} value; + + {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{{dataType}}} value) { + this.value = value; + } + +{{#jackson}} + @JsonValue +{{/jackson}} + public {{{dataType}}} getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + +{{#jackson}} + @JsonCreator +{{/jackson}} + public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue{{#jackson}}({{{dataType}}} value){{/jackson}}{{^jackson}}(String text){{/jackson}} { + for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { + if ({{#jackson}}b.value.equals(value){{/jackson}}{{^jackson}}String.valueOf(b.value).equals(text){{/jackson}}) { + return b; + } + } + throw new UlpValidationException(UlpBundleKey.{{vendorExtensions.x-enum-invalidtag}}); + } +{{#gson}} + + public static class Adapter extends TypeAdapter<{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}> { + @Override + public void write(final JsonWriter jsonWriter, final {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} read(final JsonReader jsonReader) throws IOException { + {{#isNumber}}BigDecimal value = new BigDecimal(jsonReader.nextDouble()){{/isNumber}}{{^isNumber}}{{#isInteger}}Integer value {{/isInteger}}{{^isInteger}}String value {{/isInteger}}= jsonReader.{{#isInteger}}nextInt(){{/isInteger}}{{^isInteger}}nextString(){{/isInteger}}{{/isNumber}}; + return {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.fromValue({{#jackson}}value{{/jackson}}{{^jackson}}String.valueOf(value){{/jackson}}); + } + } +{{/gson}} +} \ No newline at end of file diff --git a/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/petstore.yml b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/petstore.yml new file mode 100644 index 0000000000..c9884c01e8 --- /dev/null +++ b/spring-swagger-codegen/custom-validations-opeanpi-codegen/src/main/resources/petstore.yml @@ -0,0 +1,65 @@ +openapi: 3.0.1 +info: + version: "1.0" + title: PetStore +paths: + /pets: + post: + tags: + - pet + summary: Add a new pet to the store + description: Add a new pet to the store + operationId: addPet + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + responses: + '201': + description: default response, returning the new pet id + content: + application/json: + schema: + type: integer + '400': + description: Invalid input + get: + tags: + - pet + summary: Finds Pets by name + description: 'Find pets by name' + operationId: findPetsByName + parameters: + - name: name + in: query + schema: + type: string + description: Tags to filter by + x-constraints: "@Camelcase(required = true)" + responses: + '200': + description: default response + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid name value +components: + schemas: + Pet: + type: object + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + x-constraints: "@Camelcase(required = true)" \ No newline at end of file diff --git a/testing-modules/assertion-libraries/pom.xml b/testing-modules/assertion-libraries/pom.xml index 2c84549d20..42dead6ee2 100644 --- a/testing-modules/assertion-libraries/pom.xml +++ b/testing-modules/assertion-libraries/pom.xml @@ -20,7 +20,8 @@ truth ${truth.version} - + junit junit @@ -55,7 +56,8 @@ ${jgotesting.version} test - + junit junit diff --git a/testing-modules/selenium-junit-testng/pom.xml b/testing-modules/selenium-junit-testng/pom.xml index 860397f229..0bf6f0726d 100644 --- a/testing-modules/selenium-junit-testng/pom.xml +++ b/testing-modules/selenium-junit-testng/pom.xml @@ -1,7 +1,7 @@ + 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 selenium-junit-testng 0.0.1-SNAPSHOT diff --git a/testing-modules/testing-assertions/src/test/java/com/baeldung/optional/OptionalUnitTest.java b/testing-modules/testing-assertions/src/test/java/com/baeldung/optional/OptionalUnitTest.java new file mode 100644 index 0000000000..351b3dd3e0 --- /dev/null +++ b/testing-modules/testing-assertions/src/test/java/com/baeldung/optional/OptionalUnitTest.java @@ -0,0 +1,58 @@ +package com.baeldung.optional; + +import org.junit.jupiter.api.Test; + +import java.util.Optional; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class OptionalUnitTest { + + private static final String OPTIONAL_RETURN_VALUE = "optionalReturnValue"; + + @Test + public void givenOptionalWithValue_whenAssertThatIsNotEmpty_thenOk() { + assertThat(Optional.of(OPTIONAL_RETURN_VALUE)).isNotEmpty(); + } + + @Test + public void givenOptionalWithValue_whenAssertThatHasValue_thenOk() { + assertThat(Optional.of(OPTIONAL_RETURN_VALUE)).hasValue(OPTIONAL_RETURN_VALUE); + } + + @Test + public void givenOptionalWithValue_whenAssertEqualsOptionalObject_thenOk() { + Optional expected = Optional.of(OPTIONAL_RETURN_VALUE); + Optional actual = Optional.of(OPTIONAL_RETURN_VALUE); + assertEquals(expected, actual); + } + + @Test + public void givenOptionalWithValue_whenAssertEqualsGet_thenOk() { + Optional optional = Optional.of(OPTIONAL_RETURN_VALUE); + assertEquals(OPTIONAL_RETURN_VALUE, optional.get()); + } + + @Test + public void givenOptionalWithValue_whenIsPresentAndGetSplit_thenOk() { + Optional optional = Optional.of(OPTIONAL_RETURN_VALUE); + + assertTrue(optional.isPresent()); + assertEquals(OPTIONAL_RETURN_VALUE, optional.get()); + } + + @Test + public void givenEmptyOptional_whenAssertThatIsEmpty_thenOk() { + Optional emptyOptional = Optional.empty(); + assertThat(emptyOptional).isEmpty(); + } + + @Test + public void givenEmptyOptional_whenAssertIsNotPresent_thenOk() { + Optional emptyOptional = Optional.empty(); + assertFalse(emptyOptional.isPresent()); + } +} diff --git a/xml/pom.xml b/xml/pom.xml index f88f0f89b0..d05f2401e3 100644 --- a/xml/pom.xml +++ b/xml/pom.xml @@ -14,6 +14,22 @@ + + org.jsoup + jsoup + ${jsoup.version} + + + net.sourceforge.htmlcleaner + htmlcleaner + ${htmlcleaner.version} + + + net.htmlparser.jericho + jericho-html + ${jericho.version} + + org.dom4j @@ -178,8 +194,8 @@ ${maven-compiler-plugin.version} + org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} @@ -242,7 +258,6 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} CustomerTest.java @@ -362,6 +377,9 @@ 1.3.1 3.8.0 + 1.14.3 + 2.25 + 3.4 \ No newline at end of file diff --git a/xml/src/test/java/com/baeldung/xmlhtml/delhtmltags/RemoveHtmlTagsLiveTest.java b/xml/src/test/java/com/baeldung/xmlhtml/delhtmltags/RemoveHtmlTagsLiveTest.java new file mode 100644 index 0000000000..b05123cbdc --- /dev/null +++ b/xml/src/test/java/com/baeldung/xmlhtml/delhtmltags/RemoveHtmlTagsLiveTest.java @@ -0,0 +1,61 @@ +package com.baeldung.xmlhtml.delhtmltags; + +import net.htmlparser.jericho.Renderer; +import net.htmlparser.jericho.Segment; +import net.htmlparser.jericho.Source; +import org.htmlcleaner.CleanerProperties; +import org.htmlcleaner.HtmlCleaner; +import org.jsoup.Jsoup; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Paths; + +class RemoveHtmlTagsLiveTest { + + @Test + void givenHtml1_whenRemoveTagsByRegex_thenPrintText() throws IOException, URISyntaxException { + String html = new String(Files.readAllBytes( + (Paths.get(getClass().getResource("/xmlhtml/delhtmltags/example1.html").toURI())))); + String result = html.replaceAll("<[^>]*>", "") + .replaceAll("(?m)^\\s*$", ""); // remove empty and blank lines + System.out.println(result); + } + + @Test + void givenHtml2_whenRemoveTagsByRegex_thenPrintText() throws IOException, URISyntaxException { + String html = new String(Files.readAllBytes( + (Paths.get(getClass().getResource("/xmlhtml/delhtmltags/example2.html").toURI())))); + String result = html.replaceAll("<[^>]*>", ""); + System.out.println(result); + } + + @Test + void givenHtml2_whenRemoveTagsByJsoup_thenPrintText() throws IOException, URISyntaxException { + String html = new String(Files.readAllBytes( + (Paths.get(getClass().getResource("/xmlhtml/delhtmltags/example2.html").toURI())))); + System.out.println(Jsoup.parse(html).text()); + } + + @Test + void givenHtml2_whenRemoveTagsByHtmlCleaner_thenPrintText() throws IOException, URISyntaxException { + String html = new String(Files.readAllBytes( + (Paths.get(getClass().getResource("/xmlhtml/delhtmltags/example2.html").toURI())))); + CleanerProperties props = new CleanerProperties(); + props.setPruneTags("script"); + String result = new HtmlCleaner(props).clean(html).getText().toString(); + System.out.println(result); + } + + @Test + void givenHtml2_whenRemoveTagsByJericho_thenPrintText() throws IOException, URISyntaxException { + String html = new String(Files.readAllBytes( + (Paths.get(getClass().getResource("/xmlhtml/delhtmltags/example2.html").toURI())))); + Source htmlSource = new Source(html); + Segment segment = new Segment(htmlSource, 0, htmlSource.length()); + Renderer htmlRender = new Renderer(segment).setIncludeHyperlinkURLs(true); + System.out.println(htmlRender); + } +} diff --git a/xml/src/test/resources/xmlhtml/delhtmltags/example1.html b/xml/src/test/resources/xmlhtml/delhtmltags/example1.html new file mode 100644 index 0000000000..43f3a22ef4 --- /dev/null +++ b/xml/src/test/resources/xmlhtml/delhtmltags/example1.html @@ -0,0 +1,15 @@ + + + + This is the page title + + +

+ If the application X doesn't start, the possible causes could be:
+ 1. Maven is not installed.
+ 2. Not enough disk space.
+ 3. Not enough memory. +

+ + \ No newline at end of file diff --git a/xml/src/test/resources/xmlhtml/delhtmltags/example2.html b/xml/src/test/resources/xmlhtml/delhtmltags/example2.html new file mode 100644 index 0000000000..532eadc101 --- /dev/null +++ b/xml/src/test/resources/xmlhtml/delhtmltags/example2.html @@ -0,0 +1,22 @@ + + + + This is the page title + + + +

+ If the application X doesn't start, the possible causes could be:
+ 1. + Maven + is not installed.
+ 2. Not enough (<1G) disk space.
+ 3. Not enough (<64MB) memory.
+

+ + \ No newline at end of file