diff --git a/algorithms-miscellaneous-3/pom.xml b/algorithms-miscellaneous-3/pom.xml index d5416e543d..19eca8eca7 100644 --- a/algorithms-miscellaneous-3/pom.xml +++ b/algorithms-miscellaneous-3/pom.xml @@ -20,19 +20,16 @@ ${org.assertj.core.version} test - org.apache.commons commons-collections4 ${commons-collections4.version} - com.google.guava guava ${guava.version} - com.squareup.retrofit2 retrofit @@ -43,13 +40,11 @@ converter-jackson ${retrofit.version} - org.apache.commons commons-lang3 ${commons.lang3.version} - pl.pragmatists JUnitParams diff --git a/algorithms-miscellaneous-5/pom.xml b/algorithms-miscellaneous-5/pom.xml index 8b7cfc7b25..1ba535dfbc 100644 --- a/algorithms-miscellaneous-5/pom.xml +++ b/algorithms-miscellaneous-5/pom.xml @@ -39,7 +39,6 @@ junit-platform-commons ${junit.platform.version} - org.assertj assertj-core diff --git a/apache-cxf/cxf-aegis/pom.xml b/apache-cxf/cxf-aegis/pom.xml index 43a6750475..996c6fc0cd 100644 --- a/apache-cxf/cxf-aegis/pom.xml +++ b/apache-cxf/cxf-aegis/pom.xml @@ -20,4 +20,4 @@ - + \ No newline at end of file diff --git a/apache-cxf/cxf-introduction/pom.xml b/apache-cxf/cxf-introduction/pom.xml index d56c7ecd81..12529e55c1 100644 --- a/apache-cxf/cxf-introduction/pom.xml +++ b/apache-cxf/cxf-introduction/pom.xml @@ -37,4 +37,4 @@ - + \ No newline at end of file diff --git a/apache-cxf/cxf-jaxrs-implementation/pom.xml b/apache-cxf/cxf-jaxrs-implementation/pom.xml index 04c94455e4..515f527a5b 100644 --- a/apache-cxf/cxf-jaxrs-implementation/pom.xml +++ b/apache-cxf/cxf-jaxrs-implementation/pom.xml @@ -52,4 +52,4 @@ 4.5.2 - + \ No newline at end of file diff --git a/apache-cxf/cxf-spring/pom.xml b/apache-cxf/cxf-spring/pom.xml index 340b3d486a..772ece81da 100644 --- a/apache-cxf/cxf-spring/pom.xml +++ b/apache-cxf/cxf-spring/pom.xml @@ -107,4 +107,4 @@ 1.6.1 - + \ No newline at end of file diff --git a/apache-cxf/pom.xml b/apache-cxf/pom.xml index 3f08c11db0..6b7e396b9e 100644 --- a/apache-cxf/pom.xml +++ b/apache-cxf/pom.xml @@ -38,4 +38,4 @@ 3.1.8 - + \ No newline at end of file diff --git a/apache-cxf/sse-jaxrs/pom.xml b/apache-cxf/sse-jaxrs/pom.xml index 737fc43dc2..1ac2948439 100644 --- a/apache-cxf/sse-jaxrs/pom.xml +++ b/apache-cxf/sse-jaxrs/pom.xml @@ -18,4 +18,4 @@ sse-jaxrs-client - + \ No newline at end of file diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml b/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml index 187f03a431..0467fd9e5d 100644 --- a/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml +++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml @@ -14,7 +14,6 @@ - javax.ws.rs javax.ws.rs-api @@ -33,7 +32,6 @@ ${bind-api.version} provided - @@ -85,4 +83,4 @@ 1.0 - + \ No newline at end of file diff --git a/apache-libraries/pom.xml b/apache-libraries/pom.xml index 856b01daa0..ded10b939f 100644 --- a/apache-libraries/pom.xml +++ b/apache-libraries/pom.xml @@ -183,7 +183,6 @@ - org.apache.meecrowave @@ -216,4 +215,4 @@ 6.4.0 - + \ No newline at end of file diff --git a/apache-rocketmq/pom.xml b/apache-rocketmq/pom.xml index a5f552d6f1..48399b6d51 100644 --- a/apache-rocketmq/pom.xml +++ b/apache-rocketmq/pom.xml @@ -25,4 +25,5 @@ 1.6.0 2.0.4 + \ No newline at end of file diff --git a/apache-spark/pom.xml b/apache-spark/pom.xml index 58b3a90b61..05c5088662 100644 --- a/apache-spark/pom.xml +++ b/apache-spark/pom.xml @@ -91,7 +91,7 @@ - + SparkPackagesRepo https://repos.spark-packages.org diff --git a/apache-tapestry/pom.xml b/apache-tapestry/pom.xml index c7cdc0bf3d..13ae49b0ba 100644 --- a/apache-tapestry/pom.xml +++ b/apache-tapestry/pom.xml @@ -77,7 +77,6 @@ true - org.apache.maven.plugins maven-surefire-plugin @@ -88,7 +87,6 @@ - org.mortbay.jetty @@ -119,7 +117,6 @@ jboss http://repository.jboss.org/nexus/content/groups/public/ - diff --git a/asciidoctor/pom.xml b/asciidoctor/pom.xml index ec998a67b8..e24917f2f4 100644 --- a/asciidoctor/pom.xml +++ b/asciidoctor/pom.xml @@ -68,4 +68,4 @@ 1.5.0-alpha.15 - + \ No newline at end of file diff --git a/atomix/pom.xml b/atomix/pom.xml index 2b9fc9be37..77e554852c 100644 --- a/atomix/pom.xml +++ b/atomix/pom.xml @@ -31,4 +31,4 @@ 1.0.0-rc9 - + \ No newline at end of file diff --git a/aws-lambda/pom.xml b/aws-lambda/pom.xml index 8014a87126..3264356977 100644 --- a/aws-lambda/pom.xml +++ b/aws-lambda/pom.xml @@ -20,4 +20,4 @@ todo-reminder/ToDoFunction - + \ No newline at end of file diff --git a/aws-lambda/todo-reminder/ToDoFunction/pom.xml b/aws-lambda/todo-reminder/ToDoFunction/pom.xml index d40ee51984..832cee841d 100644 --- a/aws-lambda/todo-reminder/ToDoFunction/pom.xml +++ b/aws-lambda/todo-reminder/ToDoFunction/pom.xml @@ -1,4 +1,5 @@ - 4.0.0 helloworld @@ -6,10 +7,6 @@ 1.0 jar ToDoFunction - - 1.8 - 1.8 - @@ -18,9 +15,9 @@ 1.2.1 - com.amazonaws - aws-lambda-java-events - 3.6.0 + com.amazonaws + aws-lambda-java-events + 3.6.0 uk.org.webcompere @@ -58,10 +55,10 @@ 5.0.1 - junit - junit - 4.13.1 - test + junit + junit + 4.13.1 + test uk.org.webcompere @@ -84,22 +81,28 @@ - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.4 - - - - - package - - shade - - - - - + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + + + package + + shade + + + + + - + + + 1.8 + 1.8 + + + \ No newline at end of file diff --git a/aws-reactive/pom.xml b/aws-reactive/pom.xml index 9f0144b15c..ea1e0c44a4 100644 --- a/aws-reactive/pom.xml +++ b/aws-reactive/pom.xml @@ -93,4 +93,5 @@ 2.2.1.RELEASE 2.10.27 + \ No newline at end of file diff --git a/blade/pom.xml b/blade/pom.xml index f4bc6d73be..6ab3a594f2 100644 --- a/blade/pom.xml +++ b/blade/pom.xml @@ -83,7 +83,6 @@ - maven-assembly-plugin ${assembly.plugin.version} diff --git a/bootique/pom.xml b/bootique/pom.xml index 5710259632..34fc75a5c0 100644 --- a/bootique/pom.xml +++ b/bootique/pom.xml @@ -48,13 +48,11 @@ - org.apache.maven.plugins maven-shade-plugin ${maven-shade-plugin.version} - diff --git a/cloud-foundry-uaa/pom.xml b/cloud-foundry-uaa/pom.xml index a8a46b921d..03a5b978d4 100644 --- a/cloud-foundry-uaa/pom.xml +++ b/cloud-foundry-uaa/pom.xml @@ -1,6 +1,5 @@ - 4.0.0 @@ -20,4 +19,4 @@ cf-uaa-oauth2-resource-server - + \ No newline at end of file diff --git a/core-groovy-2/pom.xml b/core-groovy-2/pom.xml index 859f9a2667..f8ef654293 100644 --- a/core-groovy-2/pom.xml +++ b/core-groovy-2/pom.xml @@ -173,4 +173,4 @@ 3.3.0-01 - + \ No newline at end of file diff --git a/core-java-modules/core-java-12/pom.xml b/core-java-modules/core-java-12/pom.xml index 8f6abdda5b..ce7ec72aeb 100644 --- a/core-java-modules/core-java-12/pom.xml +++ b/core-java-modules/core-java-12/pom.xml @@ -1,49 +1,60 @@ - 4.0.0 - core-java-12 - 0.1.0-SNAPSHOT - core-java-12 - jar - http://maven.apache.org + 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-12 + 0.1.0-SNAPSHOT + core-java-12 + jar + http://maven.apache.org - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - ../../ - + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../../ + - - - org.assertj - assertj-core - ${assertj.version} - test - - + + + org.assertj + assertj-core + ${assertj.version} + test + + + commons-io + commons-io + 2.11.0 + + - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${maven.compiler.source.version} - ${maven.compiler.target.version} - --enable-preview - - - - + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.source.version} + ${maven.compiler.target.version} + --enable-preview + + + + maven-surefire-plugin + + --enable-preview + + + + - - 12 - 12 - 3.6.1 - + + 12 + 12 + 3.6.1 + \ No newline at end of file diff --git a/core-java-modules/core-java-12/src/main/java/com/baeldung/file/content/comparison/CompareFileContents.java b/core-java-modules/core-java-12/src/main/java/com/baeldung/file/content/comparison/CompareFileContents.java new file mode 100644 index 0000000000..637ddb4a91 --- /dev/null +++ b/core-java-modules/core-java-12/src/main/java/com/baeldung/file/content/comparison/CompareFileContents.java @@ -0,0 +1,88 @@ +package com.baeldung.file.content.comparison; + +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.ByteBuffer; +import java.nio.MappedByteBuffer; +import java.nio.channels.FileChannel; +import java.nio.file.Files; +import java.nio.file.Path; + +public class CompareFileContents { + + public static long filesCompareByByte(Path path1, Path path2) throws IOException { + + if (path1.getFileSystem() + .provider() + .isSameFile(path1, path2)) { + return -1; + } + + try (BufferedInputStream fis1 = new BufferedInputStream(new FileInputStream(path1.toFile())); + BufferedInputStream fis2 = new BufferedInputStream(new FileInputStream(path2.toFile()))) { + int ch = 0; + long pos = 1; + while ((ch = fis1.read()) != -1) { + if (ch != fis2.read()) { + return pos; + } + pos++; + } + if (fis2.read() == -1) { + return -1; + } else { + return pos; + } + } + } + + public static long filesCompareByLine(Path path1, Path path2) throws IOException { + + if (path1.getFileSystem() + .provider() + .isSameFile(path1, path2)) { + return -1; + } + + try (BufferedReader bf1 = Files.newBufferedReader(path1); + BufferedReader bf2 = Files.newBufferedReader(path2)) { + + long lineNumber = 1; + String line1 = "", line2 = ""; + while ((line1 = bf1.readLine()) != null) { + line2 = bf2.readLine(); + if (line2 == null || !line1.equals(line2)) { + return lineNumber; + } + lineNumber++; + } + if (bf2.readLine() == null) { + return -1; + } else { + return lineNumber; + } + } + } + + public static boolean compareByMemoryMappedFiles(Path path1, Path path2) throws IOException { + + try (RandomAccessFile randomAccessFile1 = new RandomAccessFile(path1.toFile(), "r"); + RandomAccessFile randomAccessFile2 = new RandomAccessFile(path2.toFile(), "r")) { + + FileChannel ch1 = randomAccessFile1.getChannel(); + FileChannel ch2 = randomAccessFile2.getChannel(); + if (ch1.size() != ch2.size()) { + + return false; + } + long size = ch1.size(); + MappedByteBuffer m1 = ch1.map(FileChannel.MapMode.READ_ONLY, 0L, size); + MappedByteBuffer m2 = ch2.map(FileChannel.MapMode.READ_ONLY, 0L, size); + + return m1.equals(m2); + } + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-12/src/test/java/com/baeldung/file/content/comparison/CampareFileContentsApacheIOUnitTest.java b/core-java-modules/core-java-12/src/test/java/com/baeldung/file/content/comparison/CampareFileContentsApacheIOUnitTest.java new file mode 100644 index 0000000000..0d86abae11 --- /dev/null +++ b/core-java-modules/core-java-12/src/test/java/com/baeldung/file/content/comparison/CampareFileContentsApacheIOUnitTest.java @@ -0,0 +1,88 @@ +package com.baeldung.file.content.comparison; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.apache.commons.io.IOUtils; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +public class CampareFileContentsApacheIOUnitTest { + + public static Path path1 = null; + public static Path path2 = null; + + @BeforeAll + public static void setup() throws IOException { + + path1 = Files.createTempFile("file1Test", ".txt"); + path2 = Files.createTempFile("file2Test", ".txt"); + } + + @Test + public void whenFilesIdentical_thenReturnTrue() throws IOException { + + InputStream inputStream1 = new FileInputStream(path1.toFile()); + InputStream inputStream2 = new FileInputStream(path2.toFile()); + + Files.writeString(path1, "testing line 1" + System.lineSeparator() + "line 2"); + Files.writeString(path2, "testing line 1" + System.lineSeparator() + "line 2"); + + assertTrue(IOUtils.contentEquals(inputStream1, inputStream2)); + } + + @Test + public void whenFilesDifferent_thenReturnFalse() throws IOException { + + InputStream inputStream1 = new FileInputStream(path1.toFile()); + InputStream inputStream2 = new FileInputStream(path2.toFile()); + + Files.writeString(path1, "testing line " + System.lineSeparator() + "line 2"); + Files.writeString(path2, "testing line 1" + System.lineSeparator() + "line 2"); + + assertFalse(IOUtils.contentEquals(inputStream1, inputStream2)); + } + + @Test + public void whenFilesIdenticalIgnoreEOF_thenReturnTrue() throws IOException { + + Files.writeString(path1, "testing line 1 \n line 2"); + Files.writeString(path2, "testing line 1 \r\n line 2"); + + Reader reader1 = new BufferedReader(new FileReader(path1.toFile())); + Reader reader2 = new BufferedReader(new FileReader(path2.toFile())); + + assertTrue(IOUtils.contentEqualsIgnoreEOL(reader1, reader2)); + } + + @Test + public void whenFilesNotIdenticalIgnoreEOF_thenReturnFalse() throws IOException { + + Files.writeString(path1, "testing line \n line 2"); + Files.writeString(path2, "testing line 1 \r\n line 2"); + + Reader reader1 = new BufferedReader(new FileReader(path1.toFile())); + Reader reader2 = new BufferedReader(new FileReader(path2.toFile())); + + assertFalse(IOUtils.contentEqualsIgnoreEOL(reader1, reader2)); + } + + @AfterAll + public static void shutDown() { + + path1.toFile() + .deleteOnExit(); + path2.toFile() + .deleteOnExit(); + } +} diff --git a/core-java-modules/core-java-12/src/test/java/com/baeldung/file/content/comparison/CompareByMemoryMappedFilesUnitTest.java b/core-java-modules/core-java-12/src/test/java/com/baeldung/file/content/comparison/CompareByMemoryMappedFilesUnitTest.java new file mode 100644 index 0000000000..0405ac3b52 --- /dev/null +++ b/core-java-modules/core-java-12/src/test/java/com/baeldung/file/content/comparison/CompareByMemoryMappedFilesUnitTest.java @@ -0,0 +1,42 @@ +package com.baeldung.file.content.comparison; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +public class CompareByMemoryMappedFilesUnitTest { + + public static Path path1 = null; + public static Path path2 = null; + + @BeforeAll + public static void setup() throws IOException { + + path1 = Files.createTempFile("file1Test", ".txt"); + path2 = Files.createTempFile("file2Test", ".txt"); + } + + @Test + public void whenFilesIdentical_thenReturnTrue() throws IOException { + + Files.writeString(path1, "testing line 1" + System.lineSeparator() + "line 2"); + Files.writeString(path2, "testing line 1" + System.lineSeparator() + "line 2"); + + assertTrue(CompareFileContents.compareByMemoryMappedFiles(path1, path2)); + } + + @Test + public void whenFilesDifferent_thenReturnFalse() throws IOException { + + Files.writeString(path1, "testing line " + System.lineSeparator() + "line 2"); + Files.writeString(path2, "testing line 1" + System.lineSeparator() + "line 2"); + + assertFalse(CompareFileContents.compareByMemoryMappedFiles(path1, path2)); + } +} diff --git a/core-java-modules/core-java-12/src/test/java/com/baeldung/file/content/comparison/CompareFileContentsByBytesUnitTest.java b/core-java-modules/core-java-12/src/test/java/com/baeldung/file/content/comparison/CompareFileContentsByBytesUnitTest.java new file mode 100644 index 0000000000..15efc952c2 --- /dev/null +++ b/core-java-modules/core-java-12/src/test/java/com/baeldung/file/content/comparison/CompareFileContentsByBytesUnitTest.java @@ -0,0 +1,96 @@ +package com.baeldung.file.content.comparison; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +public class CompareFileContentsByBytesUnitTest { + + public static Path path1 = null; + public static Path path2 = null; + + @BeforeAll + public static void setup() throws IOException { + + path1 = Files.createTempFile("file1Test", ".txt"); + path2 = Files.createTempFile("file2Test", ".txt"); + } + + @Test + public void whenFirstFileShorter_thenPositionInSecondFile() throws IOException { + + Files.writeString(path1, "testing"); + Files.writeString(path2, "testing1"); + + assertEquals(8, CompareFileContents.filesCompareByByte(path1, path2)); + } + + @Test + public void whenSecondFileShorter_thenPositionInFirstFile() throws IOException { + + Files.writeString(path1, "testing1"); + Files.writeString(path2, "testing"); + + assertEquals(8, CompareFileContents.filesCompareByByte(path1, path2)); + + } + + @Test + public void whenFilesIdentical_thenSuccess() throws IOException { + + Files.writeString(path1, "testing"); + Files.writeString(path2, "testing"); + + assertEquals(-1, CompareFileContents.filesCompareByByte(path1, path2)); + + } + + @Test + public void whenFilesDifferent_thenPosition() throws IOException { + + Files.writeString(path1, "tesXing"); + Files.writeString(path2, "testing"); + + assertEquals(4, CompareFileContents.filesCompareByByte(path1, path2)); + } + + @Test + public void whenBothFilesEmpty_thenEqual() throws IOException { + + Files.writeString(path1, ""); + Files.writeString(path2, ""); + + assertEquals(-1, CompareFileContents.filesCompareByByte(path1, path2)); + } + + @Test + public void whenFirstEmpty_thenPositionFirst() throws IOException { + + Files.writeString(path1, ""); + Files.writeString(path2, "test"); + + assertEquals(1, CompareFileContents.filesCompareByByte(path1, path2)); + } + + @Test + public void whenSecondEmpty_thenPositionFirst() throws IOException { + + Files.writeString(path1, "test"); + Files.writeString(path2, ""); + + assertEquals(1, CompareFileContents.filesCompareByByte(path1, path2)); + } + + @AfterAll + public static void shutDown() { + + path1.toFile().deleteOnExit(); + path2.toFile().deleteOnExit(); + } +} diff --git a/core-java-modules/core-java-12/src/test/java/com/baeldung/file/content/comparison/CompareFileContentsByLinesUnitTest.java b/core-java-modules/core-java-12/src/test/java/com/baeldung/file/content/comparison/CompareFileContentsByLinesUnitTest.java new file mode 100644 index 0000000000..63170221d3 --- /dev/null +++ b/core-java-modules/core-java-12/src/test/java/com/baeldung/file/content/comparison/CompareFileContentsByLinesUnitTest.java @@ -0,0 +1,94 @@ +package com.baeldung.file.content.comparison; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +public class CompareFileContentsByLinesUnitTest { + + public static Path path1 = null; + public static Path path2 = null; + + @BeforeAll + public static void setup() throws IOException { + + path1 = Files.createTempFile("file1Test", ".txt"); + path2 = Files.createTempFile("file2Test", ".txt"); + } + + @Test + public void whenFirstFileShorter_thenLineNumbersFirstFile() throws IOException { + + Files.writeString(path1, "testing line 1"); + Files.writeString(path2, "testing1 line 1" + System.lineSeparator() + "line 2"); + + assertEquals(1, CompareFileContents.filesCompareByLine(path1, path2)); + } + + @Test + public void whenSecondFileShorter_thenLineNumbersSecondFile() throws IOException { + + Files.writeString(path1, "testing1 line 1" + System.lineSeparator() + "line 2"); + Files.writeString(path2, "testing line 1"); + + assertEquals(1, CompareFileContents.filesCompareByLine(path1, path2)); + } + + @Test + public void whenFileIdentical_thenLineSuccess() throws IOException { + + Files.writeString(path1, "testing1 line 1" + System.lineSeparator() + "line 2"); + Files.writeString(path2, "testing1 line 1" + System.lineSeparator() + "line 2"); + + assertEquals(-1, CompareFileContents.filesCompareByLine(path1, path2)); + } + + @Test + public void whenFilesDifferent_thenLineNumber() throws IOException { + + Files.writeString(path1, "testing1 line 1" + System.lineSeparator() + "line 2"); + Files.writeString(path2, "testing1 line 1" + System.lineSeparator() + "linX 2"); + + assertEquals(2, CompareFileContents.filesCompareByLine(path1, path2)); + } + + @Test + public void whenBothFilesEmpty_thenEqual() throws IOException { + + Files.writeString(path1, ""); + Files.writeString(path2, ""); + + assertEquals(-1, CompareFileContents.filesCompareByByte(path1, path2)); + } + + @Test + public void whenFirstEmpty_thenPositionFirst() throws IOException { + + Files.writeString(path1, ""); + Files.writeString(path2, "testing1 line 1" + System.lineSeparator() + "line 2"); + + assertEquals(1, CompareFileContents.filesCompareByByte(path1, path2)); + } + + @Test + public void whenSecondEmpty_thenPositionFirst() throws IOException { + + Files.writeString(path1, "testing1 line 1" + System.lineSeparator() + "line 2"); + Files.writeString(path2, ""); + + assertEquals(1, CompareFileContents.filesCompareByByte(path1, path2)); + } + + @AfterAll + public static void shutDown() { + + path1.toFile().deleteOnExit(); + path2.toFile().deleteOnExit(); + } +} diff --git a/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/CompactNumbersUnitTest.java b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/CompactNumbersUnitTest.java index 08a6d58d72..a557ce5545 100644 --- a/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/CompactNumbersUnitTest.java +++ b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/CompactNumbersUnitTest.java @@ -1,6 +1,6 @@ -package java.com.baeldung.newfeatures; +package com.baeldung.newfeatures; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.text.NumberFormat; import java.util.Locale; @@ -16,6 +16,6 @@ public class CompactNumbersUnitTest { assertEquals("2.59K", likesShort.format(2592)); NumberFormat likesLong = NumberFormat.getCompactNumberInstance(new Locale("en", "US"), NumberFormat.Style.LONG); likesLong.setMaximumFractionDigits(2); - assertEquals("2.59 thousand", likesShort.format(2592)); + assertEquals("2.59 thousand", likesLong.format(2592)); } } diff --git a/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/FileMismatchUnitTest.java b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/FileMismatchUnitTest.java index 7f081fe399..93fcfbda02 100644 --- a/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/FileMismatchUnitTest.java +++ b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/FileMismatchUnitTest.java @@ -1,6 +1,6 @@ -package java.com.baeldung.newfeatures; +package com.baeldung.newfeatures; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.nio.file.Files; diff --git a/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/StringUnitTest.java b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/StringUnitTest.java index 5ae51bd960..1651fe0ee6 100644 --- a/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/StringUnitTest.java +++ b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/StringUnitTest.java @@ -1,6 +1,6 @@ -package java.com.baeldung.newfeatures; +package com.baeldung.newfeatures; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.junit.Assert.assertEquals; diff --git a/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/TeeingCollectorUnitTest.java b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/TeeingCollectorUnitTest.java index 30a5cb40a7..a925e693ff 100644 --- a/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/TeeingCollectorUnitTest.java +++ b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/TeeingCollectorUnitTest.java @@ -1,6 +1,6 @@ -package java.com.baeldung.newfeatures; +package com.baeldung.newfeatures; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -13,6 +13,6 @@ public class TeeingCollectorUnitTest { public void givenSetOfNumbers_thenCalculateAverage() { double mean = Stream.of(1, 2, 3, 4, 5) .collect(Collectors.teeing(Collectors.summingDouble(i -> i), Collectors.counting(), (sum, count) -> sum / count)); - assertEquals(3.0, mean); + assertEquals(3.0, mean, 0); } } diff --git a/core-java-modules/core-java-concurrency-2/pom.xml b/core-java-modules/core-java-concurrency-2/pom.xml index 3a29101d0f..71c73f5dff 100644 --- a/core-java-modules/core-java-concurrency-2/pom.xml +++ b/core-java-modules/core-java-concurrency-2/pom.xml @@ -7,7 +7,7 @@ 0.1.0-SNAPSHOT core-java-concurrency-2 jar - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-concurrency-advanced-2/pom.xml b/core-java-modules/core-java-concurrency-advanced-2/pom.xml index 0571598684..f975dd41a4 100644 --- a/core-java-modules/core-java-concurrency-advanced-2/pom.xml +++ b/core-java-modules/core-java-concurrency-advanced-2/pom.xml @@ -31,7 +31,6 @@ jmh-generator-annprocess ${jmh-generator.version} - org.assertj assertj-core diff --git a/core-java-modules/core-java-concurrency-advanced/pom.xml b/core-java-modules/core-java-concurrency-advanced/pom.xml index 7dae0b17aa..52a2e67e70 100644 --- a/core-java-modules/core-java-concurrency-advanced/pom.xml +++ b/core-java-modules/core-java-concurrency-advanced/pom.xml @@ -7,7 +7,7 @@ 0.1.0-SNAPSHOT core-java-concurrency-advanced jar - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-concurrency-basic-2/pom.xml b/core-java-modules/core-java-concurrency-basic-2/pom.xml index 38c9c26c80..99c8cee0f2 100644 --- a/core-java-modules/core-java-concurrency-basic-2/pom.xml +++ b/core-java-modules/core-java-concurrency-basic-2/pom.xml @@ -7,7 +7,7 @@ 0.1.0-SNAPSHOT core-java-concurrency-basic-2 jar - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-concurrency-basic/pom.xml b/core-java-modules/core-java-concurrency-basic/pom.xml index 3f69d1a73b..5df379efb2 100644 --- a/core-java-modules/core-java-concurrency-basic/pom.xml +++ b/core-java-modules/core-java-concurrency-basic/pom.xml @@ -7,7 +7,7 @@ 0.1.0-SNAPSHOT core-java-concurrency-basic jar - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-concurrency-collections-2/pom.xml b/core-java-modules/core-java-concurrency-collections-2/pom.xml index 020586e892..0a31c64728 100644 --- a/core-java-modules/core-java-concurrency-collections-2/pom.xml +++ b/core-java-modules/core-java-concurrency-collections-2/pom.xml @@ -6,7 +6,7 @@ 0.1.0-SNAPSHOT core-java-concurrency-collections-2 jar - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-concurrency-collections/pom.xml b/core-java-modules/core-java-concurrency-collections/pom.xml index 8a7fc58bfd..edb5a71e39 100644 --- a/core-java-modules/core-java-concurrency-collections/pom.xml +++ b/core-java-modules/core-java-concurrency-collections/pom.xml @@ -7,7 +7,7 @@ 0.1.0-SNAPSHOT core-java-concurrency-collections jar - + com.baeldung.core-java-modules core-java-modules 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 ded6f062cf..955cd910e9 100644 --- a/core-java-modules/core-java-date-operations-1/pom.xml +++ b/core-java-modules/core-java-date-operations-1/pom.xml @@ -49,7 +49,6 @@ true - org.apache.maven.plugins diff --git a/core-java-modules/core-java-date-operations-2/pom.xml b/core-java-modules/core-java-date-operations-2/pom.xml index 5766f39739..bb0435a92a 100644 --- a/core-java-modules/core-java-date-operations-2/pom.xml +++ b/core-java-modules/core-java-date-operations-2/pom.xml @@ -7,7 +7,7 @@ ${project.parent.version} core-java-date-operations-2 jar - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-datetime-conversion/pom.xml b/core-java-modules/core-java-datetime-conversion/pom.xml index b494b307d0..8f082e2793 100644 --- a/core-java-modules/core-java-datetime-conversion/pom.xml +++ b/core-java-modules/core-java-datetime-conversion/pom.xml @@ -48,7 +48,6 @@ true - org.apache.maven.plugins diff --git a/core-java-modules/core-java-function/pom.xml b/core-java-modules/core-java-function/pom.xml index 5db73d8796..1cdcfe47db 100644 --- a/core-java-modules/core-java-function/pom.xml +++ b/core-java-modules/core-java-function/pom.xml @@ -7,7 +7,7 @@ 0.1.0-SNAPSHOT core-java-function jar - + com.baeldung.core-java-modules core-java-modules @@ -40,4 +40,4 @@ 3.6.1 - + \ No newline at end of file diff --git a/core-java-modules/core-java-functional/pom.xml b/core-java-modules/core-java-functional/pom.xml index 87a08e1e3f..3eeec71a5a 100644 --- a/core-java-modules/core-java-functional/pom.xml +++ b/core-java-modules/core-java-functional/pom.xml @@ -7,7 +7,7 @@ 0.1.0-SNAPSHOT core-java-functional jar - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-io-2/pom.xml b/core-java-modules/core-java-io-2/pom.xml index a4168a8f1f..19f34d6da1 100644 --- a/core-java-modules/core-java-io-2/pom.xml +++ b/core-java-modules/core-java-io-2/pom.xml @@ -7,7 +7,7 @@ 0.1.0-SNAPSHOT core-java-io-2 jar - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-io-apis/pom.xml b/core-java-modules/core-java-io-apis/pom.xml index 0984296ea1..9d0f3196ab 100644 --- a/core-java-modules/core-java-io-apis/pom.xml +++ b/core-java-modules/core-java-io-apis/pom.xml @@ -7,7 +7,7 @@ 0.1.0-SNAPSHOT core-java-io-apis jar - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-io-conversions/pom.xml b/core-java-modules/core-java-io-conversions/pom.xml index 14320f46b9..2dd21a80e8 100644 --- a/core-java-modules/core-java-io-conversions/pom.xml +++ b/core-java-modules/core-java-io-conversions/pom.xml @@ -7,6 +7,7 @@ 0.1.0-SNAPSHOT core-java-io-conversions jar + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-io/pom.xml b/core-java-modules/core-java-io/pom.xml index 67495f84f9..0cf6d6767e 100644 --- a/core-java-modules/core-java-io/pom.xml +++ b/core-java-modules/core-java-io/pom.xml @@ -7,7 +7,7 @@ 0.1.0-SNAPSHOT core-java-io jar - + com.baeldung.core-java-modules core-java-modules @@ -97,6 +97,7 @@ + integration diff --git a/core-java-modules/core-java-jar/pom.xml b/core-java-modules/core-java-jar/pom.xml index 4e4a7ee465..b638f81b0c 100644 --- a/core-java-modules/core-java-jar/pom.xml +++ b/core-java-modules/core-java-jar/pom.xml @@ -7,6 +7,7 @@ 0.1.0-SNAPSHOT core-java-jar jar + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-jpms/decoupling-pattern2/consumermodule2/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern2/consumermodule2/pom.xml index 774319a067..13d0b2d201 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern2/consumermodule2/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern2/consumermodule2/pom.xml @@ -45,4 +45,4 @@ 1.0 - + \ No newline at end of file diff --git a/core-java-modules/core-java-lang-4/pom.xml b/core-java-modules/core-java-lang-4/pom.xml index 46ad335568..824194cc07 100644 --- a/core-java-modules/core-java-lang-4/pom.xml +++ b/core-java-modules/core-java-lang-4/pom.xml @@ -48,4 +48,5 @@ + \ No newline at end of file diff --git a/core-java-modules/core-java-lang-math-2/pom.xml b/core-java-modules/core-java-lang-math-2/pom.xml index 098d77b59a..c825ecdef8 100644 --- a/core-java-modules/core-java-lang-math-2/pom.xml +++ b/core-java-modules/core-java-lang-math-2/pom.xml @@ -6,7 +6,7 @@ core-java-lang-math-2 0.0.1-SNAPSHOT core-java-lang-math-2 - + com.baeldung.core-java-modules core-java-modules diff --git a/core-java-modules/core-java-lang-math-3/pom.xml b/core-java-modules/core-java-lang-math-3/pom.xml index 6779d0ecc6..e1a650a18f 100644 --- a/core-java-modules/core-java-lang-math-3/pom.xml +++ b/core-java-modules/core-java-lang-math-3/pom.xml @@ -27,4 +27,4 @@ - + \ No newline at end of file diff --git a/core-java-modules/core-java-lang-syntax-2/pom.xml b/core-java-modules/core-java-lang-syntax-2/pom.xml index b725089351..9ca06e8fba 100644 --- a/core-java-modules/core-java-lang-syntax-2/pom.xml +++ b/core-java-modules/core-java-lang-syntax-2/pom.xml @@ -25,4 +25,4 @@ - + \ No newline at end of file diff --git a/core-java-modules/core-java-lang/pom.xml b/core-java-modules/core-java-lang/pom.xml index 2a1a7a05b8..6a14cab242 100644 --- a/core-java-modules/core-java-lang/pom.xml +++ b/core-java-modules/core-java-lang/pom.xml @@ -25,4 +25,4 @@ - + \ No newline at end of file diff --git a/core-java-modules/core-java-perf/pom.xml b/core-java-modules/core-java-perf/pom.xml index bc82e92e34..636de00d8f 100644 --- a/core-java-modules/core-java-perf/pom.xml +++ b/core-java-modules/core-java-perf/pom.xml @@ -15,4 +15,4 @@ ../ - + \ No newline at end of file diff --git a/core-java-modules/core-java-reflection-2/pom.xml b/core-java-modules/core-java-reflection-2/pom.xml index 347f986275..5b04b8e8db 100644 --- a/core-java-modules/core-java-reflection-2/pom.xml +++ b/core-java-modules/core-java-reflection-2/pom.xml @@ -62,4 +62,5 @@ 1.8 5.3.4 + \ No newline at end of file diff --git a/core-java-modules/core-java-regex-2/pom.xml b/core-java-modules/core-java-regex-2/pom.xml index 45e19ba5a5..9e081c2228 100644 --- a/core-java-modules/core-java-regex-2/pom.xml +++ b/core-java-modules/core-java-regex-2/pom.xml @@ -28,4 +28,4 @@ 3.15.0 - + \ No newline at end of file diff --git a/core-java-modules/core-java-streams-4/pom.xml b/core-java-modules/core-java-streams-4/pom.xml index a29fdb05a0..8cb3786776 100644 --- a/core-java-modules/core-java-streams-4/pom.xml +++ b/core-java-modules/core-java-streams-4/pom.xml @@ -38,7 +38,6 @@ true - org.apache.maven.plugins diff --git a/core-java-modules/core-java-streams/pom.xml b/core-java-modules/core-java-streams/pom.xml index f02ba1c69a..3d5de7cebe 100644 --- a/core-java-modules/core-java-streams/pom.xml +++ b/core-java-modules/core-java-streams/pom.xml @@ -91,7 +91,6 @@ true - org.apache.maven.plugins 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 1048b796bc..c8243258c1 100644 --- a/core-java-modules/core-java-string-algorithms-3/pom.xml +++ b/core-java-modules/core-java-string-algorithms-3/pom.xml @@ -27,7 +27,6 @@ guava ${guava.version} - org.junit.jupiter junit-jupiter diff --git a/core-java-modules/core-java-string-conversions-2/pom.xml b/core-java-modules/core-java-string-conversions-2/pom.xml index 584c808f56..700b4394c6 100644 --- a/core-java-modules/core-java-string-conversions-2/pom.xml +++ b/core-java-modules/core-java-string-conversions-2/pom.xml @@ -33,33 +33,29 @@ ${hamcrest.version} test - com.ibm.icu icu4j ${icu.version} - org.apache.commons commons-lang3 ${commons-lang3.version} - org.apache.commons commons-text ${commons-text.version} - org.assertj assertj-core ${assertj.version} test - + 64.2 3.12.2 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 00b37d2899..b73851f90c 100644 --- a/core-java-modules/core-java-string-operations-3/pom.xml +++ b/core-java-modules/core-java-string-operations-3/pom.xml @@ -5,7 +5,6 @@ 4.0.0 core-java-string-operations-3 0.1.0-SNAPSHOT - core-java-string-operations-3 jar @@ -58,6 +57,13 @@ + + + gradle-repo + https://repo.gradle.org/gradle/libs-releases-local/ + + + 11 11 @@ -68,10 +74,4 @@ 3.1.0 - - - gradle-repo - https://repo.gradle.org/gradle/libs-releases-local/ - - \ No newline at end of file diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index f727695036..13dd20b5da 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -137,4 +137,4 @@ 2.22.2 5.6.2 - + \ No newline at end of file diff --git a/ddd/pom.xml b/ddd/pom.xml index 77cf1f5341..cc5a173e85 100644 --- a/ddd/pom.xml +++ b/ddd/pom.xml @@ -101,4 +101,5 @@ 1.0.1 + \ No newline at end of file diff --git a/flyway-cdi-extension/pom.xml b/flyway-cdi-extension/pom.xml index 757d1e0a7f..dbd21374e2 100644 --- a/flyway-cdi-extension/pom.xml +++ b/flyway-cdi-extension/pom.xml @@ -56,4 +56,5 @@ 8.5.33 1.3.2 + \ No newline at end of file diff --git a/geotools/pom.xml b/geotools/pom.xml index 9abd479ebe..b9a6a7c91f 100644 --- a/geotools/pom.xml +++ b/geotools/pom.xml @@ -1,6 +1,5 @@ - 4.0.0 @@ -48,4 +47,4 @@ 15.2 - + \ No newline at end of file diff --git a/grpc/pom.xml b/grpc/pom.xml index c3e4996c29..915777f3bd 100644 --- a/grpc/pom.xml +++ b/grpc/pom.xml @@ -77,4 +77,5 @@ 1.6.1 0.6.1 + \ No newline at end of file diff --git a/guava-modules/guava-concurrency/pom.xml b/guava-modules/guava-concurrency/pom.xml index ef7f756596..a9ff19e6bd 100644 --- a/guava-modules/guava-concurrency/pom.xml +++ b/guava-modules/guava-concurrency/pom.xml @@ -1,14 +1,14 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + guava-concurrency + guava-modules com.baeldung 0.0.1-SNAPSHOT - 4.0.0 - - guava-concurrency \ No newline at end of file diff --git a/image-processing/pom.xml b/image-processing/pom.xml index b482aa30c1..3780ecfd33 100644 --- a/image-processing/pom.xml +++ b/image-processing/pom.xml @@ -92,7 +92,6 @@ webcam-capture ${webcam-capture.version} - diff --git a/java-collections-conversions-2/pom.xml b/java-collections-conversions-2/pom.xml index 74f955ebdd..a81b245b33 100644 --- a/java-collections-conversions-2/pom.xml +++ b/java-collections-conversions-2/pom.xml @@ -49,7 +49,6 @@ vavr 0.10.3 - diff --git a/java-collections-conversions/pom.xml b/java-collections-conversions/pom.xml index 92fc66b480..e76181c9af 100644 --- a/java-collections-conversions/pom.xml +++ b/java-collections-conversions/pom.xml @@ -41,5 +41,5 @@ 4.1 - + \ No newline at end of file diff --git a/java-collections-maps-3/pom.xml b/java-collections-maps-3/pom.xml index 37a0f617d0..0cdf24e31b 100644 --- a/java-collections-maps-3/pom.xml +++ b/java-collections-maps-3/pom.xml @@ -40,4 +40,5 @@ 3.6.1 5.2.5.RELEASE + \ No newline at end of file diff --git a/java-jdi/pom.xml b/java-jdi/pom.xml index 978ede604b..a8716de4ee 100644 --- a/java-jdi/pom.xml +++ b/java-jdi/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 java-jdi 0.1.0-SNAPSHOT @@ -39,4 +39,4 @@ 1.8 - + \ No newline at end of file diff --git a/java-lite/pom.xml b/java-lite/pom.xml index 7ff50a8fd3..c422e9a421 100644 --- a/java-lite/pom.xml +++ b/java-lite/pom.xml @@ -1,6 +1,7 @@ - + 4.0.0 org.baeldung java-lite diff --git a/jee-7/pom.xml b/jee-7/pom.xml index 2030a769b0..eb23a3e150 100644 --- a/jee-7/pom.xml +++ b/jee-7/pom.xml @@ -203,7 +203,7 @@ - org.eclipse.m2e @@ -518,4 +518,4 @@ 2.22.1 - + \ No newline at end of file diff --git a/jenkins/plugins/pom.xml b/jenkins/plugins/pom.xml index c4caf5567f..3662d59980 100644 --- a/jenkins/plugins/pom.xml +++ b/jenkins/plugins/pom.xml @@ -1,6 +1,7 @@ - + 4.0.0 plugins 1.0-SNAPSHOT @@ -12,7 +13,7 @@ org.jenkins-ci.plugins plugin 2.33 - + @@ -80,9 +81,9 @@ - + 2.7.3 - 1.7 2.12 2.39 @@ -93,4 +94,4 @@ 2.14 - + \ No newline at end of file diff --git a/json-2/pom.xml b/json-2/pom.xml index 26eab8fb4c..733fbc6668 100644 --- a/json-2/pom.xml +++ b/json-2/pom.xml @@ -51,7 +51,6 @@ commons-lang3 ${commons-lang3.version} - com.fasterxml.jackson.core jackson-annotations diff --git a/kubernetes/k8s-admission-controller/pom.xml b/kubernetes/k8s-admission-controller/pom.xml index fbee9ceba6..18bf98a830 100644 --- a/kubernetes/k8s-admission-controller/pom.xml +++ b/kubernetes/k8s-admission-controller/pom.xml @@ -3,6 +3,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + k8s-admission-controller + k8s-admission-controller + Demo project for Spring Boot com.baeldung @@ -11,16 +14,11 @@ ./../../parent-boot-2 - k8s-admission-controller - k8s-admission-controller - Demo project for Spring Boot - org.springframework.boot spring-boot-starter-webflux - org.projectlombok lombok @@ -31,13 +29,11 @@ spring-boot-starter-test test - io.projectreactor reactor-test test - org.springframework.boot spring-boot-starter-actuator @@ -54,7 +50,6 @@ - @@ -83,4 +78,4 @@ - + \ No newline at end of file diff --git a/kubernetes/pom.xml b/kubernetes/pom.xml index 57ae4fd596..2927d449d8 100644 --- a/kubernetes/pom.xml +++ b/kubernetes/pom.xml @@ -1,5 +1,7 @@ - + 4.0.0 kubernetes pom @@ -12,6 +14,7 @@ k8s-intro - k8s-admission-controller - + k8s-admission-controller + + \ No newline at end of file diff --git a/libraries-2/pom.xml b/libraries-2/pom.xml index 778f3246b8..104d3cbabc 100644 --- a/libraries-2/pom.xml +++ b/libraries-2/pom.xml @@ -135,4 +135,4 @@ 2.5.0 - + \ No newline at end of file diff --git a/libraries-3/pom.xml b/libraries-3/pom.xml index 079628ffaa..0ff89b046f 100644 --- a/libraries-3/pom.xml +++ b/libraries-3/pom.xml @@ -230,4 +230,5 @@ 2.8 2.1.3 + \ No newline at end of file diff --git a/libraries-4/pom.xml b/libraries-4/pom.xml index 212c733e59..b16d1f216f 100644 --- a/libraries-4/pom.xml +++ b/libraries-4/pom.xml @@ -126,4 +126,4 @@ 1.2.0 - + \ No newline at end of file diff --git a/libraries-http-2/README.md b/libraries-http-2/README.md index 3fa66de6e3..fdad2b3e0a 100644 --- a/libraries-http-2/README.md +++ b/libraries-http-2/README.md @@ -10,5 +10,6 @@ This module contains articles about HTTP libraries. - [Adding Interceptors in OkHTTP](https://www.baeldung.com/java-okhttp-interceptors) - [A Guide to Events in OkHTTP](https://www.baeldung.com/java-okhttp-events) - [Download a Binary File Using OkHttp](https://www.baeldung.com/java-okhttp-download-binary-file) +- [Trusting a Self-Signed Certificate in OkHttp](https://www.baeldung.com/okhttp-self-signed-cert) - More articles [[<-- prev]](/libraries-http) diff --git a/libraries-io/README.md b/libraries-io/README.md index 90095a2f23..6cfe978d91 100644 --- a/libraries-io/README.md +++ b/libraries-io/README.md @@ -2,4 +2,5 @@ ### Relevant Articles: - [Transferring a File Through SFTP in Java](https://www.baeldung.com/java-file-sftp) +- [How to Create Password-Protected Zip Files and Unzip Them in Java](https://www.baeldung.com/java-password-protected-zip-unzip) diff --git a/libraries-io/pom.xml b/libraries-io/pom.xml index 2f65fd989b..0cea9ae9ac 100644 --- a/libraries-io/pom.xml +++ b/libraries-io/pom.xml @@ -29,6 +29,11 @@ commons-vfs2 ${vfs.version} + + net.lingala.zip4j + zip4j + 2.9.0 + diff --git a/libraries-io/src/main/java/com/baeldung/java/io/zip4j/CreateSplitZipFile.java b/libraries-io/src/main/java/com/baeldung/java/io/zip4j/CreateSplitZipFile.java new file mode 100644 index 0000000000..cc39bc9dd2 --- /dev/null +++ b/libraries-io/src/main/java/com/baeldung/java/io/zip4j/CreateSplitZipFile.java @@ -0,0 +1,22 @@ +package com.baeldung.java.io.zip4j; + +import net.lingala.zip4j.ZipFile; +import net.lingala.zip4j.exception.ZipException; +import net.lingala.zip4j.model.ZipParameters; +import net.lingala.zip4j.model.enums.EncryptionMethod; + +import java.io.File; +import java.util.Arrays; + +public class CreateSplitZipFile { + + public static void main(String[] args) throws ZipException { + ZipParameters zipParameters = new ZipParameters(); + zipParameters.setEncryptFiles(true); + zipParameters.setEncryptionMethod(EncryptionMethod.AES); + ZipFile zipFile = new ZipFile("compressed.zip", "password".toCharArray()); + int splitLength = 1024 * 1024 * 10; //10MB + zipFile.createSplitZipFile(Arrays.asList(new File("aFile.txt")), zipParameters, true, splitLength); + zipFile.createSplitZipFileFromFolder(new File("/users/folder_to_add"), zipParameters, true, splitLength); + } +} diff --git a/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ExtractAllFile.java b/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ExtractAllFile.java new file mode 100644 index 0000000000..10e7ddd339 --- /dev/null +++ b/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ExtractAllFile.java @@ -0,0 +1,12 @@ +package com.baeldung.java.io.zip4j; + +import net.lingala.zip4j.ZipFile; +import net.lingala.zip4j.exception.ZipException; + +public class ExtractAllFile { + + public static void main(String[] args) throws ZipException { + ZipFile zipFile = new ZipFile("compressed.zip", "password".toCharArray()); + zipFile.extractAll("/destination_directory"); + } +} diff --git a/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ExtractSingleFile.java b/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ExtractSingleFile.java new file mode 100644 index 0000000000..4cf466d02b --- /dev/null +++ b/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ExtractSingleFile.java @@ -0,0 +1,12 @@ +package com.baeldung.java.io.zip4j; + +import net.lingala.zip4j.ZipFile; +import net.lingala.zip4j.exception.ZipException; + +public class ExtractSingleFile { + + public static void main(String[] args) throws ZipException { + ZipFile zipFile = new ZipFile("compressed.zip", "password".toCharArray()); + zipFile.extractFile("aFile.txt", "/destination_directory"); + } +} diff --git a/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ZipFolder.java b/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ZipFolder.java new file mode 100644 index 0000000000..4d89e8665f --- /dev/null +++ b/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ZipFolder.java @@ -0,0 +1,19 @@ +package com.baeldung.java.io.zip4j; + +import net.lingala.zip4j.ZipFile; +import net.lingala.zip4j.exception.ZipException; +import net.lingala.zip4j.model.ZipParameters; +import net.lingala.zip4j.model.enums.EncryptionMethod; + +import java.io.File; + +public class ZipFolder { + + public static void main(String[] args) throws ZipException { + ZipParameters zipParameters = new ZipParameters(); + zipParameters.setEncryptFiles(true); + zipParameters.setEncryptionMethod(EncryptionMethod.AES); + ZipFile zipFile = new ZipFile("compressed.zip", "password".toCharArray()); + zipFile.addFolder(new File("/users/folder_to_add"), zipParameters); + } +} diff --git a/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ZipMultiFile.java b/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ZipMultiFile.java new file mode 100644 index 0000000000..dcb860ef92 --- /dev/null +++ b/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ZipMultiFile.java @@ -0,0 +1,27 @@ +package com.baeldung.java.io.zip4j; + +import net.lingala.zip4j.ZipFile; +import net.lingala.zip4j.exception.ZipException; +import net.lingala.zip4j.model.ZipParameters; +import net.lingala.zip4j.model.enums.EncryptionMethod; + +import java.io.File; +import java.util.Arrays; +import java.util.List; + +public class ZipMultiFile { + + public static void main(String[] args) throws ZipException { + ZipParameters zipParameters = new ZipParameters(); + zipParameters.setEncryptFiles(true); + zipParameters.setEncryptionMethod(EncryptionMethod.AES); + + List filesToAdd = Arrays.asList( + new File("aFile.txt"), + new File("bFile.txt") + ); + + ZipFile zipFile = new ZipFile("compressed.zip", "password".toCharArray()); + zipFile.addFiles(filesToAdd, zipParameters); + } +} diff --git a/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ZipSingleFile.java b/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ZipSingleFile.java new file mode 100644 index 0000000000..a5f600df47 --- /dev/null +++ b/libraries-io/src/main/java/com/baeldung/java/io/zip4j/ZipSingleFile.java @@ -0,0 +1,21 @@ +package com.baeldung.java.io.zip4j; + +import net.lingala.zip4j.ZipFile; +import net.lingala.zip4j.exception.ZipException; +import net.lingala.zip4j.model.ZipParameters; +import net.lingala.zip4j.model.enums.CompressionLevel; +import net.lingala.zip4j.model.enums.EncryptionMethod; + +import java.io.File; + +public class ZipSingleFile { + + public static void main(String[] args) throws ZipException { + ZipParameters zipParameters = new ZipParameters(); + zipParameters.setEncryptFiles(true); + zipParameters.setCompressionLevel(CompressionLevel.HIGHER); + zipParameters.setEncryptionMethod(EncryptionMethod.AES); + ZipFile zipFile = new ZipFile("compressed.zip", "password".toCharArray()); + zipFile.addFile(new File("aFile.txt")); + } +} diff --git a/libraries-security/pom.xml b/libraries-security/pom.xml index 6ee6b7c358..0031b7bc06 100644 --- a/libraries-security/pom.xml +++ b/libraries-security/pom.xml @@ -1,6 +1,7 @@ - + 4.0.0 libraries-security libraries-security diff --git a/libraries-server/pom.xml b/libraries-server/pom.xml index e36ed88f8f..b283164daa 100644 --- a/libraries-server/pom.xml +++ b/libraries-server/pom.xml @@ -1,6 +1,7 @@ - + 4.0.0 libraries-server 0.0.1-SNAPSHOT @@ -99,7 +100,7 @@ ${nanohttpd.version} - + 3.6.2 4.5.3 diff --git a/logging-modules/pom.xml b/logging-modules/pom.xml index 6d036d5648..d7b820040a 100644 --- a/logging-modules/pom.xml +++ b/logging-modules/pom.xml @@ -26,4 +26,4 @@ 5.6.2 - + \ No newline at end of file diff --git a/lombok-custom/pom.xml b/lombok-custom/pom.xml index 220367bfe9..dc7f0dfec6 100644 --- a/lombok-custom/pom.xml +++ b/lombok-custom/pom.xml @@ -1,11 +1,11 @@ + 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 lombok-custom - lombok-custom 0.1-SNAPSHOT + lombok-custom com.baeldung @@ -20,13 +20,11 @@ ${lombok.version} provided - org.kohsuke.metainf-services metainf-services ${metainf-services.version} - org.eclipse.jdt core @@ -62,4 +60,4 @@ 3.3.0-v_771 - + \ No newline at end of file diff --git a/maven-modules/maven-builder-plugin/pom.xml b/maven-modules/maven-builder-plugin/pom.xml index 0eaa858db7..2fedee06cc 100644 --- a/maven-modules/maven-builder-plugin/pom.xml +++ b/maven-modules/maven-builder-plugin/pom.xml @@ -1,9 +1,8 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.example maven-builder-plugin 1.0-SNAPSHOT @@ -14,7 +13,6 @@ UTF-8 - @@ -38,4 +36,5 @@ - + + \ No newline at end of file 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 24a7c48499..e2f0d57e3a 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 @@ -1,20 +1,19 @@ - + 4.0.0 + org.baeldung + copy-rename-maven-plugin + 1.0-SNAPSHOT + copy-rename-maven-plugin + maven-copy-files com.baeldung 1.0-SNAPSHOT - org.baeldung - copy-rename-maven-plugin - 1.0-SNAPSHOT - copy-rename-maven-plugin - - UTF-8 - 1.7 - 1.7 - + junit @@ -23,6 +22,7 @@ test + @@ -89,4 +89,11 @@ - + + + UTF-8 + 1.7 + 1.7 + + + \ No newline at end of file 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 61017dd18a..97e714d9ff 100644 --- a/maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml +++ b/maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml @@ -1,20 +1,19 @@ - + 4.0.0 + org.baeldung + maven-antrun-plugin + 1.0-SNAPSHOT + maven-antrun-plugin + maven-copy-files com.baeldung 1.0-SNAPSHOT - org.baeldung - maven-antrun-plugin - 1.0-SNAPSHOT - maven-antrun-plugin - - UTF-8 - 1.7 - 1.7 - + junit @@ -23,6 +22,7 @@ test + @@ -35,7 +35,8 @@ - + @@ -91,4 +92,11 @@ - + + + UTF-8 + 1.7 + 1.7 + + + \ No newline at end of file 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 be151ae608..eed40565da 100644 --- a/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml +++ b/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml @@ -1,20 +1,19 @@ - + 4.0.0 + org.baeldung + maven-resources-plugin + 1.0-SNAPSHOT + maven-resoures-plugin + maven-copy-files com.baeldung 1.0-SNAPSHOT - org.baeldung - maven-resources-plugin - 1.0-SNAPSHOT - maven-resources-plugin - - UTF-8 - 1.7 - 1.7 - + junit @@ -23,6 +22,7 @@ test + @@ -89,4 +89,11 @@ - + + + UTF-8 + 1.7 + 1.7 + + + \ No newline at end of file diff --git a/maven-modules/maven-copy-files/pom.xml b/maven-modules/maven-copy-files/pom.xml index b7b67286bc..d2208d68eb 100644 --- a/maven-modules/maven-copy-files/pom.xml +++ b/maven-modules/maven-copy-files/pom.xml @@ -1,23 +1,28 @@ - + 4.0.0 + com.baeldung + maven-copy-files + 1.0-SNAPSHOT + maven-copy-files + pom + + http://www.example.com + maven-modules com.baeldung 0.0.1-SNAPSHOT - com.baeldung - maven-copy-files - 1.0-SNAPSHOT - pom - maven-copy-files - - http://www.example.com - - UTF-8 - 1.7 - 1.7 - + + + maven-resources-plugin + maven-antrun-plugin + copy-rename-maven-plugin + + junit @@ -26,6 +31,7 @@ test + @@ -72,9 +78,11 @@ - - maven-resources-plugin - maven-antrun-plugin - copy-rename-maven-plugin - - + + + UTF-8 + 1.7 + 1.7 + + + \ No newline at end of file diff --git a/maven-modules/maven-custom-plugin/counter-maven-plugin/pom.xml b/maven-modules/maven-custom-plugin/counter-maven-plugin/pom.xml index 369f771401..9648464102 100644 --- a/maven-modules/maven-custom-plugin/counter-maven-plugin/pom.xml +++ b/maven-modules/maven-custom-plugin/counter-maven-plugin/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/maven-v4_0_0.xsd"> 4.0.0 com.baeldung counter-maven-plugin diff --git a/maven-modules/maven-custom-plugin/usage-example/pom.xml b/maven-modules/maven-custom-plugin/usage-example/pom.xml index f512fc104d..bf5a69146b 100644 --- a/maven-modules/maven-custom-plugin/usage-example/pom.xml +++ b/maven-modules/maven-custom-plugin/usage-example/pom.xml @@ -1,6 +1,5 @@ - 4.0.0 @@ -48,4 +47,4 @@ 4.12 - + \ No newline at end of file diff --git a/maven-modules/maven-pom-types/pom.xml b/maven-modules/maven-pom-types/pom.xml index 98fbc828a0..8b174ea08e 100644 --- a/maven-modules/maven-pom-types/pom.xml +++ b/maven-modules/maven-pom-types/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 com.baeldung maven-pom-types diff --git a/maven-modules/maven-printing-plugins/pom.xml b/maven-modules/maven-printing-plugins/pom.xml index 805c3c1633..b68c88dbee 100644 --- a/maven-modules/maven-printing-plugins/pom.xml +++ b/maven-modules/maven-printing-plugins/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 maven-printing-plugins maven-printing-plugins @@ -27,11 +27,12 @@ - - - + + + + message="Save to file!" /> @@ -84,4 +85,5 @@ - + + \ No newline at end of file diff --git a/maven-modules/maven-properties/README.md b/maven-modules/maven-properties/README.md index 52ac8506b3..75ae24d215 100644 --- a/maven-modules/maven-properties/README.md +++ b/maven-modules/maven-properties/README.md @@ -6,3 +6,4 @@ have their own dedicated modules. ### Relevant Articles - [Accessing Maven Properties in Java](https://www.baeldung.com/java-accessing-maven-properties) +- [Default Values for Maven Properties](https://www.baeldung.com/maven-properties-defaults) diff --git a/maven-modules/plugin-management/pom.xml b/maven-modules/plugin-management/pom.xml index 4a999a1aae..cd75e5dbd0 100644 --- a/maven-modules/plugin-management/pom.xml +++ b/maven-modules/plugin-management/pom.xml @@ -1,16 +1,17 @@ + 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 + plugin-management 0.0.1-SNAPSHOT + pom + maven-modules com.baeldung 0.0.1-SNAPSHOT - plugin-management - pom submodule-1 diff --git a/maven-modules/plugin-management/submodule-1/pom.xml b/maven-modules/plugin-management/submodule-1/pom.xml index 915e4dfe60..c36e092254 100644 --- a/maven-modules/plugin-management/submodule-1/pom.xml +++ b/maven-modules/plugin-management/submodule-1/pom.xml @@ -20,4 +20,4 @@ - + \ No newline at end of file diff --git a/maven-modules/plugin-management/submodule-2/pom.xml b/maven-modules/plugin-management/submodule-2/pom.xml index 327bdcebb1..e50d3cc26d 100644 --- a/maven-modules/plugin-management/submodule-2/pom.xml +++ b/maven-modules/plugin-management/submodule-2/pom.xml @@ -11,4 +11,4 @@ 0.0.1-SNAPSHOT - + \ No newline at end of file diff --git a/maven-modules/pom.xml b/maven-modules/pom.xml index 9fc201f46d..5b4b567ae6 100644 --- a/maven-modules/pom.xml +++ b/maven-modules/pom.xml @@ -16,7 +16,7 @@ - maven-copy-files + maven-copy-files maven-custom-plugin maven-exec-plugin maven-integration-test @@ -32,9 +32,9 @@ version-overriding-plugins versions-maven-plugin maven-printing-plugins - maven-builder-plugin + maven-builder-plugin host-maven-repo-example plugin-management - + \ No newline at end of file diff --git a/netflix-modules/mantis/pom.xml b/netflix-modules/mantis/pom.xml index 1f8b377b94..0bab944b8a 100644 --- a/netflix-modules/mantis/pom.xml +++ b/netflix-modules/mantis/pom.xml @@ -55,9 +55,10 @@ test + - jcenter + jcenter https://jcenter.bintray.com/ diff --git a/open-liberty/pom.xml b/open-liberty/pom.xml index aff951cfd8..268b65c07e 100644 --- a/open-liberty/pom.xml +++ b/open-liberty/pom.xml @@ -111,4 +111,5 @@ 9443 7070 + \ No newline at end of file diff --git a/parent-boot-1/pom.xml b/parent-boot-1/pom.xml index 96f4b1cbe3..7029d96a7e 100644 --- a/parent-boot-1/pom.xml +++ b/parent-boot-1/pom.xml @@ -60,4 +60,4 @@ 1.5.22.RELEASE - + \ No newline at end of file diff --git a/parent-boot-2/pom.xml b/parent-boot-2/pom.xml index fcc4175369..accbc2df96 100644 --- a/parent-boot-2/pom.xml +++ b/parent-boot-2/pom.xml @@ -87,4 +87,4 @@ 3.4.0 - + \ No newline at end of file diff --git a/parent-java/pom.xml b/parent-java/pom.xml index c1abe79b2e..09d7f4c96d 100644 --- a/parent-java/pom.xml +++ b/parent-java/pom.xml @@ -46,4 +46,4 @@ 2.2 - + \ No newline at end of file diff --git a/patterns/design-patterns-architectural/README.md b/patterns/design-patterns-architectural/README.md index ae6781c66c..a8a5a98b88 100644 --- a/patterns/design-patterns-architectural/README.md +++ b/patterns/design-patterns-architectural/README.md @@ -2,3 +2,4 @@ - [Service Locator Pattern and Java Implementation](https://www.baeldung.com/java-service-locator-pattern) - [The DAO Pattern in Java](https://www.baeldung.com/java-dao-pattern) - [DAO vs Repository Patterns](https://www.baeldung.com/java-dao-vs-repository) +- [Difference Between MVC and MVP Patterns](https://www.baeldung.com/mvc-vs-mvp-pattern) diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/MvcMainClass.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/MvcMainClass.java new file mode 100644 index 0000000000..9ccd4ee74c --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/MvcMainClass.java @@ -0,0 +1,24 @@ +package com.baeldung.mvc_mvp.mvc; + +public class MvcMainClass { + + public static void main(String[] args) { + + Product model = retrieveProductFromDatabase(); + ProductView view = new ProductView(); + model.setView(view); + model.showProduct(); + + ProductController controller = new ProductController(model); + controller.setName("SmartPhone"); + model.showProduct(); + } + + private static Product retrieveProductFromDatabase() { + Product product = new Product(); + product.setName("Mobile"); + product.setDescription("New Brand"); + product.setPrice(1000.0); + return product; + } +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/Product.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/Product.java new file mode 100644 index 0000000000..5c44d4475a --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/Product.java @@ -0,0 +1,45 @@ +package com.baeldung.mvc_mvp.mvc; + +public class Product { + private String name; + private String description; + private Double price; + private ProductView view; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price; + } + + public ProductView getView() { + return view; + } + + public void setView(ProductView view) { + this.view = view; + } + + public void showProduct() { + view.printProductDetails(name, description, price); + } + +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductController.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductController.java new file mode 100644 index 0000000000..62cdb76f23 --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductController.java @@ -0,0 +1,34 @@ +package com.baeldung.mvc_mvp.mvc; + +public class ProductController { + private final Product product; + + public ProductController(Product product) { + this.product = product; + } + + public String getName() { + return product.getName(); + } + + public void setName(String name) { + product.setName(name); + } + + public String getDescription() { + return product.getDescription(); + } + + public void setDescription(String description) { + product.setDescription(description); + } + + public Double getPrice() { + return product.getPrice(); + } + + public void setPrice(Double price) { + product.setPrice(price); + } + +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductView.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductView.java new file mode 100644 index 0000000000..43f45b6df7 --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductView.java @@ -0,0 +1,15 @@ +package com.baeldung.mvc_mvp.mvc; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ProductView { + private static Logger log = LoggerFactory.getLogger(ProductView.class); + + public void printProductDetails(String name, String description, Double price) { + log.info("Product details:"); + log.info("product Name: " + name); + log.info("product Description: " + description); + log.info("product price: " + price); + } +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/MvpMainClass.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/MvpMainClass.java new file mode 100644 index 0000000000..7d12a0142c --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/MvpMainClass.java @@ -0,0 +1,22 @@ +package com.baeldung.mvc_mvp.mvp; + +public class MvpMainClass { + + public static void main(String[] args) { + + Product model = retrieveProductFromDatabase(); + ProductView view = new ProductView(); + ProductPresenter presenter = new ProductPresenter(model, view); + presenter.showProduct(); + presenter.setName("SmartPhone"); + presenter.showProduct(); + } + + private static Product retrieveProductFromDatabase() { + Product product = new Product(); + product.setName("Mobile"); + product.setDescription("New Brand"); + product.setPrice(1000.0); + return product; + } +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/Product.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/Product.java new file mode 100644 index 0000000000..315e6e69b6 --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/Product.java @@ -0,0 +1,32 @@ +package com.baeldung.mvc_mvp.mvp; + +public class Product { + private String name; + private String description; + private Double price; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price; + } + +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductPresenter.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductPresenter.java new file mode 100644 index 0000000000..2b87bdbbb5 --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductPresenter.java @@ -0,0 +1,40 @@ +package com.baeldung.mvc_mvp.mvp; + +public class ProductPresenter { + private final Product product; + private final ProductView view; + + public ProductPresenter(Product product, ProductView view) { + this.product = product; + this.view = view; + } + + public String getName() { + return product.getName(); + } + + public void setName(String name) { + product.setName(name); + } + + public String getDescription() { + return product.getDescription(); + } + + public void setDescription(String description) { + product.setDescription(description); + } + + public Double getProductPrice() { + return product.getPrice(); + } + + public void setPrice(Double price) { + product.setPrice(price); + } + + public void showProduct() { + view.printProductDetails(product.getName(), product.getDescription(), product.getPrice()); + } + +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductView.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductView.java new file mode 100644 index 0000000000..27ccc6743d --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductView.java @@ -0,0 +1,15 @@ +package com.baeldung.mvc_mvp.mvp; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ProductView { + private static Logger log = LoggerFactory.getLogger(ProductView.class); + + public void printProductDetails(String name, String description, Double price) { + log.info("Product details:"); + log.info("product Name: " + name); + log.info("product Description: " + description); + log.info("product price: " + price); + } +} diff --git a/patterns/enterprise-patterns/pom.xml b/patterns/enterprise-patterns/pom.xml index 21803e728e..5b952b9743 100644 --- a/patterns/enterprise-patterns/pom.xml +++ b/patterns/enterprise-patterns/pom.xml @@ -1,67 +1,67 @@ - 4.0.0 - - com.baeldung - patterns - 1.0.0-SNAPSHOT - + 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 + enterprise-patterns + pom - enterprise-patterns - pom + + com.baeldung + patterns + 1.0.0-SNAPSHOT + - - 3.7.4 - + + wire-tap + - - wire-tap - + + + org.apache.camel.springboot + camel-spring-boot-starter + + + org.apache.camel.springboot + camel-activemq-starter + + + + org.springframework.boot + spring-boot-starter-test + 2.2.2.RELEASE + test + + + org.apache.camel + camel-test-spring-junit5 + test + + - - - org.apache.camel.springboot - camel-spring-boot-starter - - - org.apache.camel.springboot - camel-activemq-starter - + + + + org.apache.camel.springboot + camel-spring-boot-dependencies + ${camel.version} + pom + import + + + - - - org.springframework.boot - spring-boot-starter-test - 2.2.2.RELEASE - test - - - org.apache.camel - camel-test-spring-junit5 - test - - + + + + org.springframework.boot + spring-boot-maven-plugin + + + - - - - org.apache.camel.springboot - camel-spring-boot-dependencies - ${camel.version} - pom - import - - - + + 3.7.4 + - - - - org.springframework.boot - spring-boot-maven-plugin - - - - + \ No newline at end of file diff --git a/patterns/enterprise-patterns/wire-tap/pom.xml b/patterns/enterprise-patterns/wire-tap/pom.xml index 1b1aa746d5..e7959e17f0 100644 --- a/patterns/enterprise-patterns/wire-tap/pom.xml +++ b/patterns/enterprise-patterns/wire-tap/pom.xml @@ -1,25 +1,25 @@ - 4.0.0 - wire-tap - 1.0 - 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 + wire-tap + 1.0 + jar - - enterprise-patterns - com.baeldung - 1.0.0-SNAPSHOT - + + enterprise-patterns + com.baeldung + 1.0.0-SNAPSHOT + - - - - org.springframework.boot - spring-boot-maven-plugin - - - + + + + org.springframework.boot + spring-boot-maven-plugin + + + - + \ No newline at end of file diff --git a/patterns/hexagonal-architecture/pom.xml b/patterns/hexagonal-architecture/pom.xml index f8d4524514..9dfc113d03 100644 --- a/patterns/hexagonal-architecture/pom.xml +++ b/patterns/hexagonal-architecture/pom.xml @@ -21,7 +21,6 @@ org.springframework.boot spring-boot-starter-web - org.springframework.boot spring-boot-starter-data-mongodb diff --git a/patterns/simplehexagonalexample/pom.xml b/patterns/simplehexagonalexample/pom.xml new file mode 100644 index 0000000000..b73e81be44 --- /dev/null +++ b/patterns/simplehexagonalexample/pom.xml @@ -0,0 +1,31 @@ + + 4.0.0 + 1.0.0-SNAPSHOT + simple-hexagonal-example + simpleHexagonalExample + + + 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 new file mode 100644 index 0000000000..de8b2f4793 --- /dev/null +++ b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/DailyQuoteMain.java @@ -0,0 +1,32 @@ +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 new file mode 100644 index 0000000000..9ecb2bf822 --- /dev/null +++ b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/controller/QuoteCliController.java @@ -0,0 +1,24 @@ +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 new file mode 100644 index 0000000000..061cff8cec --- /dev/null +++ b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/controller/QuoteRestController.java @@ -0,0 +1,24 @@ +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 new file mode 100644 index 0000000000..c74c224c70 --- /dev/null +++ b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/QuoteOfTheDay.java @@ -0,0 +1,56 @@ +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 new file mode 100644 index 0000000000..7e70cebd12 --- /dev/null +++ b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/repository/QuoteOfTheDayFromProvider.java @@ -0,0 +1,8 @@ +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 new file mode 100644 index 0000000000..16f7015ace --- /dev/null +++ b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/service/QuoteAggregator.java @@ -0,0 +1,22 @@ +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 new file mode 100644 index 0000000000..300387a41d --- /dev/null +++ b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/domain/service/QuoteService.java @@ -0,0 +1,8 @@ +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 new file mode 100644 index 0000000000..0cbbc60726 --- /dev/null +++ b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuote.java @@ -0,0 +1,109 @@ +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 new file mode 100644 index 0000000000..ded08f7b18 --- /dev/null +++ b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuoteAdapter.java @@ -0,0 +1,54 @@ +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 new file mode 100644 index 0000000000..611549f23d --- /dev/null +++ b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/repository/primary/quoteadapter/ProviderQuoteEnvelope.java @@ -0,0 +1,68 @@ +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 new file mode 100644 index 0000000000..54c28fc94e --- /dev/null +++ b/patterns/simplehexagonalexample/src/main/java/com/baeldung/simplehexagonalex/reposity/mock/quoteadapter/MockQuoteAdapter.java @@ -0,0 +1,20 @@ +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 new file mode 100644 index 0000000000..dd9413bfd5 --- /dev/null +++ b/patterns/simplehexagonalexample/src/main/resources/application.properties @@ -0,0 +1 @@ +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 new file mode 100644 index 0000000000..602f7ea5d4 --- /dev/null +++ b/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/MockAccessProviderUnitTest.java @@ -0,0 +1,22 @@ +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 new file mode 100644 index 0000000000..47e1dde136 --- /dev/null +++ b/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/PrimaryAccessProviderIntegrationTest.java @@ -0,0 +1,28 @@ +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 new file mode 100644 index 0000000000..552b5d51c2 --- /dev/null +++ b/patterns/simplehexagonalexample/src/test/java/com/baeldung/simplehexagonalex/repository/primaryQuoteProvider/QuoteRequestIntegrationTest.java @@ -0,0 +1,36 @@ +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 new file mode 100644 index 0000000000..dd9413bfd5 --- /dev/null +++ b/patterns/simplehexagonalexample/src/test/resources/application.properties @@ -0,0 +1 @@ +theysayso.quote.provider.url=https://quotes.rest/qod?language=en \ No newline at end of file diff --git a/persistence-modules/core-java-persistence-2/README.md b/persistence-modules/core-java-persistence-2/README.md index 365e9e7256..7b215bfef1 100644 --- a/persistence-modules/core-java-persistence-2/README.md +++ b/persistence-modules/core-java-persistence-2/README.md @@ -4,3 +4,4 @@ - [JDBC URL Format For Different Databases](https://www.baeldung.com/java-jdbc-url-format) - [How to Check if a Database Table Exists with JDBC](https://www.baeldung.com/jdbc-check-table-exists) - [Inserting Null Into an Integer Column Using JDBC](https://www.baeldung.com/jdbc-insert-null-into-integer-column) +- [A Guide to Auto-Commit in JDBC](https://www.baeldung.com/java-jdbc-auto-commit) diff --git a/persistence-modules/core-java-persistence-2/src/main/java/com/baeldung/jdbcautocommit/Person.java b/persistence-modules/core-java-persistence-2/src/main/java/com/baeldung/jdbcautocommit/Person.java new file mode 100644 index 0000000000..81c60a0db1 --- /dev/null +++ b/persistence-modules/core-java-persistence-2/src/main/java/com/baeldung/jdbcautocommit/Person.java @@ -0,0 +1,51 @@ +package com.baeldung.jdbcautocommit; + +public class Person { + + private Integer id; + private String name; + private String lastName; + private Integer age; + + public Person() { + } + + public Person(Integer id, String name, String lastName, Integer age) { + this.id = id; + this.name = name; + this.lastName = lastName; + this.age = age; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } +} diff --git a/persistence-modules/core-java-persistence-2/src/test/java/com/baeldung/jdbcautocommit/AutoCommitUnitTest.java b/persistence-modules/core-java-persistence-2/src/test/java/com/baeldung/jdbcautocommit/AutoCommitUnitTest.java new file mode 100644 index 0000000000..a3e3d8f34c --- /dev/null +++ b/persistence-modules/core-java-persistence-2/src/test/java/com/baeldung/jdbcautocommit/AutoCommitUnitTest.java @@ -0,0 +1,259 @@ +package com.baeldung.jdbcautocommit; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +public class AutoCommitUnitTest { + + private static final String INSERT_PERSON_SQL = "INSERT INTO Person VALUES (?,?,?,?)"; + private static final String SELECT_ALL_PEOPLE_SQL = "SELECT * FROM Person"; + private static final String UPDATE_PERSON_AGE_BY_ID_SQL = "UPDATE Person SET age = ? WHERE id = ?"; + private static final String DELETE_ALL_PEOPLE_SQL = "DELETE FROM Person"; + private static final String UPDATE_PERSON_AGE_BY_NAME_SQL + = "UPDATE Person SET age = ? WHERE id = (SELECT id FROM Person WHERE name = ?)"; + private static final String CREATE_PERSON_TABLE_SQL + = "CREATE TABLE Person (id INTEGER not null, name VARCHAR(50), lastName VARCHAR(50), age INTEGER, PRIMARY KEY (id))"; + + private static Connection connection1; + private static Connection connection2; + + @BeforeAll + static void setup() throws SQLException { + connection1 = DriverManager.getConnection("jdbc:h2:mem:autocommit", "sa", ""); + createPersonTable(connection1); + + connection2 = DriverManager.getConnection("jdbc:h2:mem:autocommit", "sa", ""); + } + + @Test + void givenAutoCommitTrue_whenInsertAndUpdateRecord_thenDataPersistedAfterEachWithoutCommit() throws SQLException { + + connection1.setAutoCommit(true); + + Person person = new Person(1, "John", "Doe", 45); + insertPerson(connection1, person); + + // no explicit commit needed here when auto-commit true + + // viewed from different connection, connection2 : assert person has been persisted into + // the database + List people = selectAllPeople(connection2); + assertThat("person record inserted OK into empty table", people.size(), is(equalTo(1))); + Person personInserted = people.iterator().next(); + assertThat("id correct", personInserted.getId(), is(equalTo(1))); + + // update age for person in database + updatePersonAgeById(connection1, 1, 65); + + // no explicit commit needed here + + // viewed from connection2 : assert person's age has been updated to database + people = selectAllPeople(connection2); + Person personUpdated = people.iterator().next(); + assertThat("updated age correct", personUpdated.getAge(), is(equalTo(65))); + } + + @Test + void givenAutoCommitFalse_whenInsertCommitAndUpdateCommit_thenDataViewableAfterEachCommit() throws SQLException { + + connection1.setAutoCommit(false); + + Person person = new Person(1, "John", "Doe", 45); + insertPerson(connection1, person); + + // viewed from different connection, connection2 : assert that person has not yet been + // persisted to database before issuing commit + List people = selectAllPeople(connection2); + assertThat("No people have been inserted into database yet", people.size(), is(equalTo(0))); + + connection1.commit(); + + // viewed from connection2 : assert that person has been persisted to database after + // issuing commit + people = selectAllPeople(connection2); + assertThat("Person has been inserted into empty table after commit", people.size(), is(equalTo(1))); + Person personInserted = people.iterator().next(); + assertThat("id correct", personInserted.getId(), is(equalTo(1))); + + updatePersonAgeById(connection1, 1, 65); + + // assert that person's age has not been updated before issuing commit + people = selectAllPeople(connection2); + Person personUpdated = people.iterator().next(); + assertThat("person's age still 45, not updated", personUpdated.getAge(), is(equalTo(45))); + + connection1.commit(); + + // viewed from connection2 : assert that person's age has been updated after issuing commit + people = selectAllPeople(connection2); + personUpdated = people.iterator().next(); + assertThat("person's age updated to 65", personUpdated.getAge(), is(equalTo(65))); + } + + @Test + void givenAutoCommitFalse_whenInsertAndUpdateWithCommitOnlyAtEnd_thenDataOnlyViewableAfterCommit() throws SQLException { + + connection1.setAutoCommit(false); + + Person person = new Person(1, "John", "Doe", 45); + insertPerson(connection1, person); + + // viewed from different connection, connection2 : assert that person has not yet been + // persisted to database before issuing commit + List people = selectAllPeople(connection2); + assertThat("No people have been inserted into database yet", people.size(), is(equalTo(0))); + + updatePersonAgeById(connection1, 1, 65); + + // viewed from connection2 : assert that person has still not yet been + // persisted to database before issuing commit + people = selectAllPeople(connection2); + assertThat("No people have been inserted into database yet", people.size(), is(equalTo(0))); + + connection1.commit(); + + // viewed from connection2 : assert that person record has been persisted to + // database and person's age has been updated after issuing commit + people = selectAllPeople(connection2); + Person personUpdated = people.iterator().next(); + assertThat("person's age updated to 65", personUpdated.getAge(), is(equalTo(65))); + } + + @Test + void givenAutoCommitTrue_whenUpdateWithNestedSelect_thenUpdatePersistedWithoutCommit() throws SQLException { + + connection1.setAutoCommit(true); + + Person person = new Person(1, "John", "Doe", 45); + insertPerson(connection1, person); + + updatePersonAgeByName(connection1, "John", 77); + + // viewed from connection2 : assert person's age has been updated correctly to database + // without issuing commit + List people = selectAllPeople(connection2); + Person personUpdated = people.iterator().next(); + assertThat("updated age correct", personUpdated.getAge(), is(equalTo(77))); + } + + @Test + void givenAutoCommitFalse_whenModeChangedToTrueAfterSQLUpdate_thenUpdatePersistedWithoutCommit() throws SQLException { + + connection1.setAutoCommit(false); + + Person person = new Person(1, "John", "Doe", 45); + insertPerson(connection1, person); + updatePersonAgeByName(connection1, "John", 77); + + connection1.setAutoCommit(true); + + // viewed from connection2 : assert record inserted and person's age has been updated + // correctly to database after auto-commit changed false -> true ... without explicit commit needed + List people = selectAllPeople(connection2); + Person personUpdated = people.iterator().next(); + assertThat("updated age correct", personUpdated.getAge(), is(equalTo(77))); + } + + @AfterEach + void deleteAllRecords() throws SQLException { + + if (connection1.getAutoCommit() == false) { + connection1.setAutoCommit(true); + } + + deleteAllPeople(connection1); + } + + @AfterAll + static void closeConnections() throws SQLException { + + connection1.close(); + connection2.close(); + } + + private static void createPersonTable(Connection connection) throws SQLException { + try(Statement statement = connection.createStatement()) { + statement.executeUpdate(CREATE_PERSON_TABLE_SQL); + } + } + + private static int insertPerson(Connection connection, Person person) throws SQLException { + + try (PreparedStatement preparedStatement = connection.prepareStatement(INSERT_PERSON_SQL)) { + + preparedStatement.setInt(1, person.getId()); + preparedStatement.setString(2, person.getName()); + preparedStatement.setString(3, person.getLastName()); + preparedStatement.setInt(4, person.getAge()); + + // execute statement and return the number of rows inserted + return preparedStatement.executeUpdate(); + } + } + + private static void deleteAllPeople(Connection connection) throws SQLException { + try (Statement statement = connection.createStatement()) { + statement.execute(DELETE_ALL_PEOPLE_SQL); + } + } + + private static List selectAllPeople(Connection connection) throws SQLException { + + List people = null; + + try (Statement statement = connection.createStatement()) { + + people = new ArrayList<>(); + ResultSet resultSet = statement.executeQuery(SELECT_ALL_PEOPLE_SQL); + + while (resultSet.next()) { + Person person = new Person(); + + person.setId(resultSet.getInt("id")); + person.setName(resultSet.getString("name")); + person.setLastName(resultSet.getString("lastName")); + person.setAge(resultSet.getInt("age")); + + people.add(person); + } + } + + return people; + } + + private static void updatePersonAgeById(Connection connection, int id, int newAge) throws SQLException { + + try (PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_PERSON_AGE_BY_ID_SQL)) { + + preparedStatement.setInt(1, newAge); + preparedStatement.setInt(2, id); + + preparedStatement.executeUpdate(); + } + } + + private static void updatePersonAgeByName(Connection connection, String name, int newAge) throws SQLException { + try (PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_PERSON_AGE_BY_NAME_SQL)) { + + preparedStatement.setInt(1, newAge); + preparedStatement.setString(2, name); + + preparedStatement.executeUpdate(); + } + } +} diff --git a/persistence-modules/hibernate-jpa/README.md b/persistence-modules/hibernate-jpa/README.md index 8379ad1626..bb079b1705 100644 --- a/persistence-modules/hibernate-jpa/README.md +++ b/persistence-modules/hibernate-jpa/README.md @@ -14,3 +14,4 @@ This module contains articles specific to use of Hibernate as a JPA implementati - [JPA/Hibernate Persistence Context](https://www.baeldung.com/jpa-hibernate-persistence-context) - [Quick Guide to EntityManager#getReference()](https://www.baeldung.com/jpa-entity-manager-get-reference) - [JPA Entities and the Serializable Interface](https://www.baeldung.com/jpa-entities-serializable) +- [EntityNotFoundException in Hibernate](https://www.baeldung.com/hibernate-entitynotfoundexception) diff --git a/persistence-modules/hibernate-jpa/pom.xml b/persistence-modules/hibernate-jpa/pom.xml index 11540b6d23..85bfdac07f 100644 --- a/persistence-modules/hibernate-jpa/pom.xml +++ b/persistence-modules/hibernate-jpa/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 hibernate-jpa 0.0.1-SNAPSHOT diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Item.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Item.java index ee6f677d7d..3abed00eb8 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Item.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Item.java @@ -15,7 +15,6 @@ public class Item implements Serializable { private String name; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "category_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) - @NotFound(action = NotFoundAction.IGNORE) private Category category; public long getId() { diff --git a/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml b/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml index 29cd4faf05..e895ac6ba9 100644 --- a/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml +++ b/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml @@ -114,7 +114,7 @@ - + @@ -132,7 +132,7 @@ - + diff --git a/persistence-modules/hibernate-mapping/pom.xml b/persistence-modules/hibernate-mapping/pom.xml index 4f76c16a3f..805402951e 100644 --- a/persistence-modules/hibernate-mapping/pom.xml +++ b/persistence-modules/hibernate-mapping/pom.xml @@ -1,7 +1,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 hibernate-mapping hibernate-mapping diff --git a/persistence-modules/hibernate-ogm/pom.xml b/persistence-modules/hibernate-ogm/pom.xml index 58098ebb65..9274186cd1 100644 --- a/persistence-modules/hibernate-ogm/pom.xml +++ b/persistence-modules/hibernate-ogm/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 hibernate-ogm 0.0.1-SNAPSHOT diff --git a/persistence-modules/hibernate-queries/pom.xml b/persistence-modules/hibernate-queries/pom.xml index 4a8c578aba..83b2ea4d00 100644 --- a/persistence-modules/hibernate-queries/pom.xml +++ b/persistence-modules/hibernate-queries/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 hibernate-queries 0.0.1-SNAPSHOT diff --git a/persistence-modules/hibernate5/pom.xml b/persistence-modules/hibernate5/pom.xml index 9b4ffff739..d46d2c16d4 100644 --- a/persistence-modules/hibernate5/pom.xml +++ b/persistence-modules/hibernate5/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 hibernate5 0.0.1-SNAPSHOT diff --git a/persistence-modules/redis/pom.xml b/persistence-modules/redis/pom.xml index c407482788..8079d56cbd 100644 --- a/persistence-modules/redis/pom.xml +++ b/persistence-modules/redis/pom.xml @@ -59,7 +59,6 @@ 3.13.1 3.3.0 4.1.50.Final - \ No newline at end of file diff --git a/persistence-modules/spring-data-cassandra-reactive/pom.xml b/persistence-modules/spring-data-cassandra-reactive/pom.xml index 630e13583b..5dd5ab4b69 100644 --- a/persistence-modules/spring-data-cassandra-reactive/pom.xml +++ b/persistence-modules/spring-data-cassandra-reactive/pom.xml @@ -54,7 +54,6 @@ 2.2.6.RELEASE 3.11.2.0 - \ 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 e43e3821ae..d21541abf8 100644 --- a/persistence-modules/spring-data-cassandra/pom.xml +++ b/persistence-modules/spring-data-cassandra/pom.xml @@ -105,7 +105,6 @@ 2.1.9.2 2.1.9.2 2.0-0 - \ No newline at end of file diff --git a/persistence-modules/spring-data-jdbc/pom.xml b/persistence-modules/spring-data-jdbc/pom.xml index 2672405dd6..2b4c6d21aa 100644 --- a/persistence-modules/spring-data-jdbc/pom.xml +++ b/persistence-modules/spring-data-jdbc/pom.xml @@ -2,14 +2,15 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + spring-data-jdbc + spring-data-jdbc + com.baeldung parent-boot-2 0.0.1-SNAPSHOT ../../parent-boot-2 - spring-data-jdbc - spring-data-jdbc diff --git a/persistence-modules/spring-data-jpa-enterprise/pom.xml b/persistence-modules/spring-data-jpa-enterprise/pom.xml index 4367a11222..a76bcb8b0a 100644 --- a/persistence-modules/spring-data-jpa-enterprise/pom.xml +++ b/persistence-modules/spring-data-jpa-enterprise/pom.xml @@ -2,7 +2,6 @@ - 4.0.0 spring-data-jpa-enterprise spring-data-jpa-enterprise diff --git a/persistence-modules/spring-data-jpa-repo-2/pom.xml b/persistence-modules/spring-data-jpa-repo-2/pom.xml index b382e35e28..12e178dd49 100644 --- a/persistence-modules/spring-data-jpa-repo-2/pom.xml +++ b/persistence-modules/spring-data-jpa-repo-2/pom.xml @@ -42,4 +42,5 @@ 29.0-jre + \ No newline at end of file diff --git a/persistence-modules/spring-data-keyvalue/pom.xml b/persistence-modules/spring-data-keyvalue/pom.xml index aa2696dd12..704be15b4a 100644 --- a/persistence-modules/spring-data-keyvalue/pom.xml +++ b/persistence-modules/spring-data-keyvalue/pom.xml @@ -26,4 +26,5 @@ spring-boot-starter-test + \ No newline at end of file diff --git a/quarkus-extension/quarkus-app/pom.xml b/quarkus-extension/quarkus-app/pom.xml index f609261c5a..041b6f1762 100644 --- a/quarkus-extension/quarkus-app/pom.xml +++ b/quarkus-extension/quarkus-app/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 com.baeldung.quarkus.app quarkus-app diff --git a/quarkus/pom.xml b/quarkus/pom.xml index 6e250a2858..e88fd4dc5a 100644 --- a/quarkus/pom.xml +++ b/quarkus/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 com.baeldung.quarkus quarkus diff --git a/rabbitmq/pom.xml b/rabbitmq/pom.xml index ae38d697f6..8befd36ab6 100644 --- a/rabbitmq/pom.xml +++ b/rabbitmq/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 rabbitmq 0.1-SNAPSHOT diff --git a/spark-java/pom.xml b/spark-java/pom.xml index b5538b4ec3..0ecdd02f6a 100644 --- a/spark-java/pom.xml +++ b/spark-java/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 spark-java 0.1.0-SNAPSHOT diff --git a/spf4j/spf4j-aspects-app/pom.xml b/spf4j/spf4j-aspects-app/pom.xml index 54bbdddddc..a44ee805fb 100644 --- a/spf4j/spf4j-aspects-app/pom.xml +++ b/spf4j/spf4j-aspects-app/pom.xml @@ -22,8 +22,8 @@ ${spf4j.version} - org.apache.avro - avro + org.apache.avro + avro @@ -33,8 +33,8 @@ ${spf4j.version} - org.apache.avro - avro + org.apache.avro + avro @@ -43,11 +43,11 @@ slf4j-api ${org.slf4j.version} - - org.apache.avro - avro - 1.10.2 - + + org.apache.avro + avro + 1.10.2 + diff --git a/spf4j/spf4j-core-app/pom.xml b/spf4j/spf4j-core-app/pom.xml index 92333ea2ec..1f9be97854 100644 --- a/spf4j/spf4j-core-app/pom.xml +++ b/spf4j/spf4j-core-app/pom.xml @@ -22,8 +22,8 @@ ${spf4j.version} - org.apache.avro - avro + org.apache.avro + avro @@ -33,8 +33,8 @@ ${spf4j.version} - org.apache.avro - avro + org.apache.avro + avro @@ -43,17 +43,17 @@ slf4j-api ${org.slf4j.version} - - org.apache.avro - avro - + + org.apache.avro + avro + - - org.apache.avro - avro - 1.10.2 - + + org.apache.avro + avro + 1.10.2 + diff --git a/spring-5/pom.xml b/spring-5/pom.xml index 2284177dc0..5799f3bc8f 100644 --- a/spring-5/pom.xml +++ b/spring-5/pom.xml @@ -96,11 +96,11 @@ spring-restdocs-restassured test - - com.zaxxer - HikariCP - ${hikaricp.version} - + + com.zaxxer + HikariCP + ${hikaricp.version} + diff --git a/spring-aop/pom.xml b/spring-aop/pom.xml index 464a830383..da981987fe 100644 --- a/spring-aop/pom.xml +++ b/spring-aop/pom.xml @@ -71,4 +71,5 @@ 1.11 + \ No newline at end of file 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 63bc286b45..a1daa3fa19 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 @@ -81,5 +81,5 @@ 1.5.7 2.0.4.RELEASE - + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-cassandre/pom.xml b/spring-boot-modules/spring-boot-cassandre/pom.xml index c4672c8887..14849e50d7 100644 --- a/spring-boot-modules/spring-boot-cassandre/pom.xml +++ b/spring-boot-modules/spring-boot-cassandre/pom.xml @@ -1,52 +1,50 @@ - 4.0.0 - spring-boot-cassandre - jar - spring-boot-cassandre - Cassandre trading bot tutorial + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + spring-boot-cassandre + jar + spring-boot-cassandre + Cassandre trading bot tutorial - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 - + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + - - - - tech.cassandre.trading.bot - cassandre-trading-bot-spring-boot-starter - ${cassandre.trading.bot.version} - - - org.knowm.xchange - xchange-kucoin - ${xchange-kucoin.version} - - - org.hsqldb - hsqldb - ${hsqldb.version} - + + + + tech.cassandre.trading.bot + cassandre-trading-bot-spring-boot-starter + ${cassandre.trading.bot.version} + + + org.knowm.xchange + xchange-kucoin + ${xchange-kucoin.version} + + + org.hsqldb + hsqldb + ${hsqldb.version} + + + tech.cassandre.trading.bot + cassandre-trading-bot-spring-boot-starter-test + ${cassandre.trading.bot.version} + test + + - - tech.cassandre.trading.bot - cassandre-trading-bot-spring-boot-starter-test - ${cassandre.trading.bot.version} - test - + + 11 + 4.2.1 + 5.0.7 + 2.5.1 + - - - - 11 - 4.2.1 - 5.0.7 - 2.5.1 - - - + \ No newline at end of file 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 184becb657..5633e4d260 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 @@ -39,4 +39,5 @@ 2.2.5.RELEASE + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-performance/pom.xml b/spring-boot-modules/spring-boot-performance/pom.xml index 02cef986d0..71dfb3c437 100644 --- a/spring-boot-modules/spring-boot-performance/pom.xml +++ b/spring-boot-modules/spring-boot-performance/pom.xml @@ -51,4 +51,5 @@ com.baeldung.lazyinitialization.Application 2.0.0 + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties-3/pom.xml b/spring-boot-modules/spring-boot-properties-3/pom.xml index 400229a662..b5e6ef8701 100644 --- a/spring-boot-modules/spring-boot-properties-3/pom.xml +++ b/spring-boot-modules/spring-boot-properties-3/pom.xml @@ -40,4 +40,5 @@ + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-runtime-2/pom.xml b/spring-boot-modules/spring-boot-runtime-2/pom.xml index 2c97f63746..c177529a41 100644 --- a/spring-boot-modules/spring-boot-runtime-2/pom.xml +++ b/spring-boot-modules/spring-boot-runtime-2/pom.xml @@ -60,4 +60,5 @@ + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-validation/pom.xml b/spring-boot-modules/spring-boot-validation/pom.xml index 1aba8efeac..795d506dc0 100644 --- a/spring-boot-modules/spring-boot-validation/pom.xml +++ b/spring-boot-modules/spring-boot-validation/pom.xml @@ -1,41 +1,37 @@ - - 4.0.0 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + com.baeldung + spring-boot-validation + 0.0.1-SNAPSHOT - com.baeldung - spring-boot-validation - 0.0.1-SNAPSHOT - - + com.baeldung parent-boot-2 0.0.1-SNAPSHOT ../../parent-boot-2 - - - org.springframework.boot - spring-boot-starter-web - + + + org.springframework.boot + spring-boot-starter-web + + + org.hibernate.validator + hibernate-validator + + - - org.hibernate.validator - hibernate-validator - - - - + + + + org.springframework.boot + spring-boot-maven-plugin + + + - - - - org.springframework.boot - spring-boot-maven-plugin - - - diff --git a/spring-cloud/spring-cloud-bootstrap/order-service/pom.xml b/spring-cloud/spring-cloud-bootstrap/order-service/pom.xml index 64be52f5f4..273017c386 100644 --- a/spring-cloud/spring-cloud-bootstrap/order-service/pom.xml +++ b/spring-cloud/spring-cloud-bootstrap/order-service/pom.xml @@ -117,6 +117,6 @@ 1.8 1.8 com.baeldung.orderservice.OrderApplication - + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-config/client/pom.xml b/spring-cloud/spring-cloud-config/client/pom.xml index 00b5ba2edc..55c6e77a72 100644 --- a/spring-cloud/spring-cloud-config/client/pom.xml +++ b/spring-cloud/spring-cloud-config/client/pom.xml @@ -47,4 +47,5 @@ + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-config/server/pom.xml b/spring-cloud/spring-cloud-config/server/pom.xml index c59b6583f2..36d1b5b3aa 100644 --- a/spring-cloud/spring-cloud-config/server/pom.xml +++ b/spring-cloud/spring-cloud-config/server/pom.xml @@ -51,4 +51,5 @@ + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-contract/pom.xml b/spring-cloud/spring-cloud-contract/pom.xml index 1d12656f98..8546e76586 100644 --- a/spring-cloud/spring-cloud-contract/pom.xml +++ b/spring-cloud/spring-cloud-contract/pom.xml @@ -31,7 +31,6 @@ spring-boot-starter-data-rest ${spring-boot.version} - org.springframework.cloud spring-cloud-contract-wiremock diff --git a/spring-cloud/spring-cloud-kubernetes/pom.xml b/spring-cloud/spring-cloud-kubernetes/pom.xml index ba57100804..d8894eb36f 100644 --- a/spring-cloud/spring-cloud-kubernetes/pom.xml +++ b/spring-cloud/spring-cloud-kubernetes/pom.xml @@ -40,4 +40,5 @@ 2020.0.3 + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-rest/spring-cloud-rest-books-api/pom.xml b/spring-cloud/spring-cloud-rest/spring-cloud-rest-books-api/pom.xml index 2fa003a634..c7ff472655 100644 --- a/spring-cloud/spring-cloud-rest/spring-cloud-rest-books-api/pom.xml +++ b/spring-cloud/spring-cloud-rest/spring-cloud-rest-books-api/pom.xml @@ -75,4 +75,4 @@ - + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-sentinel/pom.xml b/spring-cloud/spring-cloud-sentinel/pom.xml index a36dcc51bc..f26a13f6f8 100644 --- a/spring-cloud/spring-cloud-sentinel/pom.xml +++ b/spring-cloud/spring-cloud-sentinel/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 spring-cloud-sentinel spring-cloud-sentinel diff --git a/spring-ejb/ejb-beans/pom.xml b/spring-ejb/ejb-beans/pom.xml index cdc28ef5d7..d820819a78 100644 --- a/spring-ejb/ejb-beans/pom.xml +++ b/spring-ejb/ejb-beans/pom.xml @@ -94,7 +94,6 @@ test - diff --git a/spring-mobile/pom.xml b/spring-mobile/pom.xml index 1593de27a8..7f715c8735 100644 --- a/spring-mobile/pom.xml +++ b/spring-mobile/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 spring-mobile 1.0-SNAPSHOT diff --git a/spring-security-modules/pom.xml b/spring-security-modules/pom.xml index 5847d6f28d..9a0862a6b0 100644 --- a/spring-security-modules/pom.xml +++ b/spring-security-modules/pom.xml @@ -49,4 +49,4 @@ spring-social-login - + \ No newline at end of file diff --git a/spring-security-modules/spring-security-web-persistent-login/pom.xml b/spring-security-modules/spring-security-web-persistent-login/pom.xml index 3bbabe3738..2d931c416c 100644 --- a/spring-security-modules/spring-security-web-persistent-login/pom.xml +++ b/spring-security-modules/spring-security-web-persistent-login/pom.xml @@ -136,7 +136,7 @@ - spring-security-web-persistence + spring-security-web-persistent-login src/main/resources diff --git a/spring-security-modules/spring-security-web-sockets/pom.xml b/spring-security-modules/spring-security-web-sockets/pom.xml index e822b6beda..b1536e88ea 100644 --- a/spring-security-modules/spring-security-web-sockets/pom.xml +++ b/spring-security-modules/spring-security-web-sockets/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 com.baeldung.springsecuredsockets spring-security-web-sockets diff --git a/spring-vault/pom.xml b/spring-vault/pom.xml index 759de80a6b..68856de2fc 100644 --- a/spring-vault/pom.xml +++ b/spring-vault/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 spring-vault 0.0.1-SNAPSHOT diff --git a/spring-web-modules/spring-mvc-basics-4/README.md b/spring-web-modules/spring-mvc-basics-4/README.md index 211564a363..f003f7df01 100644 --- a/spring-web-modules/spring-mvc-basics-4/README.md +++ b/spring-web-modules/spring-mvc-basics-4/README.md @@ -9,4 +9,5 @@ The "REST With Spring" Classes: https://bit.ly/restwithspring - [Spring Web Contexts](https://www.baeldung.com/spring-web-contexts) - [Spring Optional Path variables](https://www.baeldung.com/spring-optional-path-variables) - [JSON Parameters with Spring MVC](https://www.baeldung.com/spring-mvc-send-json-parameters) +- [How to Set JSON Content Type In Spring MVC](https://www.baeldung.com/spring-mvc-set-json-content-type) - More articles: [[<-- prev]](/spring-mvc-basics-3) diff --git a/spring-web-modules/spring-mvc-forms-jsp/pom.xml b/spring-web-modules/spring-mvc-forms-jsp/pom.xml index 94eb51a32d..707c18fa19 100644 --- a/spring-web-modules/spring-mvc-forms-jsp/pom.xml +++ b/spring-web-modules/spring-mvc-forms-jsp/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 0.1-SNAPSHOT spring-mvc-forms-jsp diff --git a/spring-web-modules/spring-mvc-forms-thymeleaf/pom.xml b/spring-web-modules/spring-mvc-forms-thymeleaf/pom.xml index 37bcee0b8d..eb31723798 100644 --- a/spring-web-modules/spring-mvc-forms-thymeleaf/pom.xml +++ b/spring-web-modules/spring-mvc-forms-thymeleaf/pom.xml @@ -28,7 +28,6 @@ org.projectlombok lombok - org.springframework.boot diff --git a/spring-web-modules/spring-rest-angular/pom.xml b/spring-web-modules/spring-rest-angular/pom.xml index ef14e78198..e7cb5c8664 100644 --- a/spring-web-modules/spring-rest-angular/pom.xml +++ b/spring-web-modules/spring-rest-angular/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 spring-rest-angular 1.0 diff --git a/testing-modules/testing-libraries-2/pom.xml b/testing-modules/testing-libraries-2/pom.xml index d914fcfb86..dcbddd60b4 100644 --- a/testing-modules/testing-libraries-2/pom.xml +++ b/testing-modules/testing-libraries-2/pom.xml @@ -131,5 +131,5 @@ 5.6.2 3.16.1 - - + + \ No newline at end of file diff --git a/vertx/pom.xml b/vertx/pom.xml index 9a22e2dd72..7608b3e355 100644 --- a/vertx/pom.xml +++ b/vertx/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 vertx 1.0-SNAPSHOT diff --git a/wildfly/pom.xml b/wildfly/pom.xml index c5d9bce37a..eaec4d176c 100644 --- a/wildfly/pom.xml +++ b/wildfly/pom.xml @@ -60,7 +60,6 @@ - org.apache.maven.plugins maven-war-plugin