diff --git a/algorithms-miscellaneous-1/pom.xml b/algorithms-miscellaneous-1/pom.xml index a2183f7474..b7c32bda43 100644 --- a/algorithms-miscellaneous-1/pom.xml +++ b/algorithms-miscellaneous-1/pom.xml @@ -64,7 +64,7 @@ org.codehaus.mojo cobertura-maven-plugin - 2.7 + ${cobertura.plugin.version} @@ -85,6 +85,7 @@ 1.11 27.0.1-jre 3.3.0 + 2.7 \ No newline at end of file diff --git a/algorithms-miscellaneous-3/pom.xml b/algorithms-miscellaneous-3/pom.xml index a893f0a045..673ac0121d 100644 --- a/algorithms-miscellaneous-3/pom.xml +++ b/algorithms-miscellaneous-3/pom.xml @@ -46,13 +46,13 @@ org.apache.commons commons-lang3 - 3.8.1 + ${commons.lang3.version} pl.pragmatists JUnitParams - 1.1.0 + ${JUnitParams.version} test @@ -91,6 +91,8 @@ 2.6.0 1.19 1.19 + 3.8.1 + 1.1.0 \ No newline at end of file diff --git a/algorithms-miscellaneous-5/pom.xml b/algorithms-miscellaneous-5/pom.xml index 95036da775..4f9cc8b711 100644 --- a/algorithms-miscellaneous-5/pom.xml +++ b/algorithms-miscellaneous-5/pom.xml @@ -37,7 +37,7 @@ com.google.guava guava - 28.1-jre + ${guava.version} @@ -65,6 +65,7 @@ 3.9.0 1.11 3.6.1 + 28.1-jre \ No newline at end of file diff --git a/algorithms-sorting-2/.gitignore b/algorithms-sorting-2/.gitignore new file mode 100644 index 0000000000..30b2b7442c --- /dev/null +++ b/algorithms-sorting-2/.gitignore @@ -0,0 +1,4 @@ +/target/ +.settings/ +.classpath +.project \ No newline at end of file diff --git a/algorithms-sorting-2/pom.xml b/algorithms-sorting-2/pom.xml new file mode 100644 index 0000000000..d862c91430 --- /dev/null +++ b/algorithms-sorting-2/pom.xml @@ -0,0 +1,64 @@ + + 4.0.0 + algorithms-sorting-2 + 0.0.1-SNAPSHOT + algorithms-sorting-2 + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + org.apache.commons + commons-math3 + ${commons-math3.version} + + + commons-codec + commons-codec + ${commons-codec.version} + + + org.projectlombok + lombok + ${lombok.version} + provided + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter-api.version} + test + + + org.assertj + assertj-core + ${org.assertj.core.version} + test + + + + + + + + org.codehaus.mojo + exec-maven-plugin + ${exec-maven-plugin.version} + + + + + + + 3.6.1 + 3.9.0 + 1.11 + 5.3.1 + + + \ No newline at end of file diff --git a/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/BentleyMcIlroyPartioning.java b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/BentleyMcIlroyPartioning.java new file mode 100644 index 0000000000..d005f2654c --- /dev/null +++ b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/BentleyMcIlroyPartioning.java @@ -0,0 +1,66 @@ +package com.baeldung.algorithms.quicksort; + +import static com.baeldung.algorithms.quicksort.SortingUtils.swap; + +public class BentleyMcIlroyPartioning { + + public static Partition partition(int input[], int begin, int end) { + int left = begin, right = end; + int leftEqualKeysCount = 0, rightEqualKeysCount = 0; + + int partitioningValue = input[end]; + + while (true) { + while (input[left] < partitioningValue) + left++; + + while (input[right] > partitioningValue) { + if (right == begin) + break; + right--; + } + + if (left == right && input[left] == partitioningValue) { + swap(input, begin + leftEqualKeysCount, left); + leftEqualKeysCount++; + left++; + } + + if (left >= right) { + break; + } + + swap(input, left, right); + + if (input[left] == partitioningValue) { + swap(input, begin + leftEqualKeysCount, left); + leftEqualKeysCount++; + } + + if (input[right] == partitioningValue) { + swap(input, right, end - rightEqualKeysCount); + rightEqualKeysCount++; + } + left++; right--; + } + right = left - 1; + for (int k = begin; k < begin + leftEqualKeysCount; k++, right--) { + if (right >= begin + leftEqualKeysCount) + swap(input, k, right); + } + for (int k = end; k > end - rightEqualKeysCount; k--, left++) { + if (left <= end - rightEqualKeysCount) + swap(input, left, k); + } + return new Partition(right + 1, left - 1); + } + + public static void quicksort(int input[], int begin, int end) { + if (end <= begin) + return; + Partition middlePartition = partition(input, begin, end); + quicksort(input, begin, middlePartition.getLeft() - 1); + quicksort(input, middlePartition.getRight() + 1, end); + } + +} diff --git a/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/DutchNationalFlagPartioning.java b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/DutchNationalFlagPartioning.java new file mode 100644 index 0000000000..e868cf0e2e --- /dev/null +++ b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/DutchNationalFlagPartioning.java @@ -0,0 +1,38 @@ +package com.baeldung.algorithms.quicksort; + +import static com.baeldung.algorithms.quicksort.SortingUtils.compare; +import static com.baeldung.algorithms.quicksort.SortingUtils.swap; + +public class DutchNationalFlagPartioning { + + public static Partition partition(int[] a, int begin, int end) { + int lt = begin, current = begin, gt = end; + int partitioningValue = a[begin]; + + while (current <= gt) { + int compareCurrent = compare(a[current], partitioningValue); + switch (compareCurrent) { + case -1: + swap(a, current++, lt++); + break; + case 0: + current++; + break; + case 1: + swap(a, current, gt--); + break; + } + } + return new Partition(lt, gt); + } + + public static void quicksort(int[] input, int begin, int end) { + if (end <= begin) + return; + + Partition middlePartition = partition(input, begin, end); + + quicksort(input, begin, middlePartition.getLeft() - 1); + quicksort(input, middlePartition.getRight() + 1, end); + } +} diff --git a/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/Partition.java b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/Partition.java new file mode 100644 index 0000000000..29812f2720 --- /dev/null +++ b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/Partition.java @@ -0,0 +1,29 @@ +package com.baeldung.algorithms.quicksort; + +public class Partition { + private int left; + private int right; + + public Partition(int left, int right) { + super(); + this.left = left; + this.right = right; + } + + public int getLeft() { + return left; + } + + public void setLeft(int left) { + this.left = left; + } + + public int getRight() { + return right; + } + + public void setRight(int right) { + this.right = right; + } + +} diff --git a/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/SortingUtils.java b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/SortingUtils.java new file mode 100644 index 0000000000..ac1aa5e8ee --- /dev/null +++ b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/SortingUtils.java @@ -0,0 +1,32 @@ +package com.baeldung.algorithms.quicksort; + +public class SortingUtils { + + public static void swap(int[] array, int position1, int position2) { + if (position1 != position2) { + int temp = array[position1]; + array[position1] = array[position2]; + array[position2] = temp; + } + } + + public static int compare(int num1, int num2) { + if (num1 > num2) + return 1; + else if (num1 < num2) + return -1; + else + return 0; + } + + public static void printArray(int[] array) { + if (array == null) { + return; + } + for (int e : array) { + System.out.print(e + " "); + } + System.out.println(); + } + +} diff --git a/algorithms-sorting-2/src/main/resources/logback.xml b/algorithms-sorting-2/src/main/resources/logback.xml new file mode 100644 index 0000000000..26beb6d5b4 --- /dev/null +++ b/algorithms-sorting-2/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/algorithms-sorting-2/src/test/java/com/baeldung/algorithms/quicksort/BentleyMcilroyPartitioningUnitTest.java b/algorithms-sorting-2/src/test/java/com/baeldung/algorithms/quicksort/BentleyMcilroyPartitioningUnitTest.java new file mode 100644 index 0000000000..847f7f8acb --- /dev/null +++ b/algorithms-sorting-2/src/test/java/com/baeldung/algorithms/quicksort/BentleyMcilroyPartitioningUnitTest.java @@ -0,0 +1,16 @@ +package com.baeldung.algorithms.quicksort; + +import org.junit.Assert; +import org.junit.Test; + +public class BentleyMcilroyPartitioningUnitTest { + + @Test + public void given_IntegerArray_whenSortedWithBentleyMcilroyPartitioning_thenGetSortedArray() { + int[] actual = {3, 2, 2, 2, 3, 7, 7, 3, 2, 2, 7, 3, 3}; + int[] expected = {2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 7, 7, 7}; + BentleyMcIlroyPartioning.quicksort(actual, 0, actual.length - 1); + Assert.assertArrayEquals(expected, actual); + } + +} diff --git a/algorithms-sorting-2/src/test/java/com/baeldung/algorithms/quicksort/DNFThreeWayQuickSortUnitTest.java b/algorithms-sorting-2/src/test/java/com/baeldung/algorithms/quicksort/DNFThreeWayQuickSortUnitTest.java new file mode 100644 index 0000000000..a8e27253cc --- /dev/null +++ b/algorithms-sorting-2/src/test/java/com/baeldung/algorithms/quicksort/DNFThreeWayQuickSortUnitTest.java @@ -0,0 +1,15 @@ +package com.baeldung.algorithms.quicksort; + +import org.junit.Assert; +import org.junit.Test; + +public class DNFThreeWayQuickSortUnitTest { + + @Test + public void givenIntegerArray_whenSortedWithThreeWayQuickSort_thenGetSortedArray() { + int[] actual = {3, 5, 5, 5, 3, 7, 7, 3, 5, 5, 7, 3, 3}; + int[] expected = {3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 7, 7, 7}; + DutchNationalFlagPartioning.quicksort(actual, 0, actual.length - 1); + Assert.assertArrayEquals(expected, actual); + } +} diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml b/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml index 43bbcf1ef4..1d7ecdb58f 100644 --- a/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml +++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml @@ -18,19 +18,19 @@ javax.ws.rs javax.ws.rs-api - 2.1 + ${rs-api.version} provided javax.enterprise cdi-api - 2.0 + ${cdi-api.version} provided javax.json.bind javax.json.bind-api - 1.0 + ${bind-api.version} provided @@ -80,6 +80,9 @@ 2.4.2 false 18.0.0.2 + 2.1 + 2.0 + 1.0 diff --git a/apache-rocketmq/pom.xml b/apache-rocketmq/pom.xml index 59c204dddf..f15dd0e61c 100644 --- a/apache-rocketmq/pom.xml +++ b/apache-rocketmq/pom.xml @@ -17,11 +17,12 @@ org.apache.rocketmq rocketmq-spring-boot-starter - 2.0.4 + ${rocketmq.version} 1.6.0 + 2.0.4 diff --git a/apache-tapestry/pom.xml b/apache-tapestry/pom.xml index e306b56b4a..a4124b07df 100644 --- a/apache-tapestry/pom.xml +++ b/apache-tapestry/pom.xml @@ -81,10 +81,10 @@ of testing facilities designed for use with TestNG (http://testng.org/), so it's org.apache.maven.plugins maven-compiler-plugin - 2.3.2 + ${compiler.plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} true @@ -92,7 +92,7 @@ of testing facilities designed for use with TestNG (http://testng.org/), so it's org.apache.maven.plugins maven-surefire-plugin - 2.7.2 + ${compiler.surefire.version} Qa @@ -104,7 +104,7 @@ of testing facilities designed for use with TestNG (http://testng.org/), so it's org.mortbay.jetty maven-jetty-plugin - 6.1.16 + ${compiler.jetty.version} @@ -140,6 +140,11 @@ of testing facilities designed for use with TestNG (http://testng.org/), so it's + 6.1.16 + 2.7.2 + 2.3.2 + 1.8 + 1.8 5.4.5 2.5 6.8.21 diff --git a/aws-reactive/pom.xml b/aws-reactive/pom.xml index b3fcb24902..046825130a 100644 --- a/aws-reactive/pom.xml +++ b/aws-reactive/pom.xml @@ -17,6 +17,8 @@ 1.8 + 2.2.1.RELEASE + 2.10.27 @@ -26,7 +28,7 @@ org.springframework.boot spring-boot-dependencies - 2.2.1.RELEASE + ${spring.version} pom import @@ -34,7 +36,7 @@ software.amazon.awssdk bom - 2.10.27 + ${awssdk.version} pom import diff --git a/blade/pom.xml b/blade/pom.xml index e302f33c51..6d73913e25 100644 --- a/blade/pom.xml +++ b/blade/pom.xml @@ -124,7 +124,7 @@ maven-assembly-plugin - 3.1.0 + ${assembly.plugin.version} ${project.build.finalName} false @@ -161,6 +161,7 @@ 3.11.1 3.0.0-M3 0.7 + 3.1.0 diff --git a/core-groovy-2/pom.xml b/core-groovy-2/pom.xml index e0987de4b3..752b6945b3 100644 --- a/core-groovy-2/pom.xml +++ b/core-groovy-2/pom.xml @@ -62,12 +62,12 @@ org.codehaus.groovy groovy-eclipse-compiler - 3.3.0-01 + ${groovy.compiler.version} true maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} groovy-eclipse-compiler ${java.version} @@ -113,7 +113,7 @@ maven-surefire-plugin - 2.20.1 + ${surefire.plugin.version} false @@ -126,7 +126,7 @@ org.apache.maven.plugins maven-assembly-plugin - 3.1.0 + ${assembly.plugin.version} @@ -183,6 +183,10 @@ 1.1.3 1.2.3 2.5.7 + 3.1.0 + 2.20.1 + 3.8.0 + 3.3.0-01 diff --git a/core-groovy-collections/pom.xml b/core-groovy-collections/pom.xml index 423be5e977..4e591970b0 100644 --- a/core-groovy-collections/pom.xml +++ b/core-groovy-collections/pom.xml @@ -99,7 +99,7 @@ maven-surefire-plugin - 2.20.1 + ${surefire.plugin.version} false @@ -126,6 +126,7 @@ 2.4.0 1.1-groovy-2.4 1.6 + 2.20.1 diff --git a/core-java-modules/core-java-11/pom.xml b/core-java-modules/core-java-11/pom.xml index 5bebaae00d..32bc68fa66 100644 --- a/core-java-modules/core-java-11/pom.xml +++ b/core-java-modules/core-java-11/pom.xml @@ -42,12 +42,12 @@ org.eclipse.collections eclipse-collections - 10.0.0 + ${eclipse.collections.version} org.eclipse.collections eclipse-collections-api - 10.0.0 + ${eclipse.collections.version} @@ -108,6 +108,7 @@ 3.11.1 benchmarks 1.22 + 10.0.0 diff --git a/core-java-modules/core-java-13/pom.xml b/core-java-modules/core-java-13/pom.xml index 1f215ae6b0..9469f49411 100644 --- a/core-java-modules/core-java-13/pom.xml +++ b/core-java-modules/core-java-13/pom.xml @@ -41,7 +41,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M3 + ${surefire.plugin.version} --enable-preview @@ -53,6 +53,7 @@ 13 13 3.6.1 + 3.0.0-M3 \ No newline at end of file diff --git a/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/SwitchExpressionsWithYieldUnitTest.java b/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/SwitchExpressionsWithYieldUnitTest.java new file mode 100644 index 0000000000..be1fcfd167 --- /dev/null +++ b/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/SwitchExpressionsWithYieldUnitTest.java @@ -0,0 +1,27 @@ +package com.baeldung.newfeatures; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class SwitchExpressionsWithYieldUnitTest { + + @Test + @SuppressWarnings("preview") + public void whenSwitchingOnOperationSquareMe_thenWillReturnSquare() { + var me = 4; + var operation = "squareMe"; + var result = switch (operation) { + case "doubleMe" -> { + yield me * 2; + } + case "squareMe" -> { + yield me * me; + } + default -> me; + }; + + assertEquals(16, result); + } + +} diff --git a/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/TextBlocksUnitTest.java b/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/TextBlocksUnitTest.java new file mode 100644 index 0000000000..1f8ddcbfb4 --- /dev/null +++ b/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/TextBlocksUnitTest.java @@ -0,0 +1,39 @@ +package com.baeldung.newfeatures; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +public class TextBlocksUnitTest { + + private static final String JSON_STRING = "{\r\n" + "\"name\" : \"Baeldung\",\r\n" + "\"website\" : \"https://www.%s.com/\"\r\n" + "}"; + + @SuppressWarnings("preview") + private static final String TEXT_BLOCK_JSON = """ + { + "name" : "Baeldung", + "website" : "https://www.%s.com/" + } + """; + + @Test + public void whenTextBlocks_thenStringOperationsWork() { + + assertThat(TEXT_BLOCK_JSON.contains("Baeldung")).isTrue(); + assertThat(TEXT_BLOCK_JSON.indexOf("www")).isGreaterThan(0); + assertThat(TEXT_BLOCK_JSON.length()).isGreaterThan(0); + + } + + @SuppressWarnings("removal") + @Test + public void whenTextBlocks_thenFormattedWorksAsFormat() { + assertThat(TEXT_BLOCK_JSON.formatted("baeldung") + .contains("www.baeldung.com")).isTrue(); + + assertThat(String.format(JSON_STRING, "baeldung") + .contains("www.baeldung.com")).isTrue(); + + } + +} diff --git a/core-java-modules/core-java-14/pom.xml b/core-java-modules/core-java-14/pom.xml index 48ec627416..b985ada5e6 100644 --- a/core-java-modules/core-java-14/pom.xml +++ b/core-java-modules/core-java-14/pom.xml @@ -36,7 +36,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M3 + ${surefire.plugin.version} --enable-preview @@ -47,6 +47,7 @@ 14 14 + 3.0.0-M3 \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-2/pom.xml b/core-java-modules/core-java-arrays-2/pom.xml index 532f0a6144..b300de511a 100644 --- a/core-java-modules/core-java-arrays-2/pom.xml +++ b/core-java-modules/core-java-arrays-2/pom.xml @@ -51,7 +51,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.2.0 + ${shade.plugin.version} package @@ -79,6 +79,7 @@ 3.9 3.10.0 + 3.2.0 diff --git a/core-java-modules/core-java-arrays/pom.xml b/core-java-modules/core-java-arrays/pom.xml index 20a835594f..02d82e4af6 100644 --- a/core-java-modules/core-java-arrays/pom.xml +++ b/core-java-modules/core-java-arrays/pom.xml @@ -183,8 +183,8 @@ maven-javadoc-plugin ${maven-javadoc-plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} @@ -373,6 +373,8 @@ 3.1.1 2.0.3.RELEASE 1.6.0 + 1.8 + 1.8 diff --git a/core-java-modules/core-java-concurrency-advanced-3/pom.xml b/core-java-modules/core-java-concurrency-advanced-3/pom.xml index df9834181f..8f275f4043 100644 --- a/core-java-modules/core-java-concurrency-advanced-3/pom.xml +++ b/core-java-modules/core-java-concurrency-advanced-3/pom.xml @@ -23,6 +23,37 @@ ${assertj.version} test + + + com.jcabi + jcabi-aspects + ${jcabi-aspects.version} + + + + org.aspectj + aspectjrt + ${aspectjrt.version} + runtime + + + + com.google.guava + guava + ${guava.version} + + + + org.cactoos + cactoos + ${cactoos.version} + + + + com.ea.async + ea-async + ${ea-async.version} + @@ -36,6 +67,30 @@ ${maven.compiler.target} + + com.jcabi + jcabi-maven-plugin + ${jcabi-maven-plugin.version} + + + + ajc + + + + + + org.aspectj + aspectjtools + ${aspectjtools.version} + + + org.aspectj + aspectjweaver + ${aspectjweaver.version} + + + @@ -49,6 +104,14 @@ 3.14.0 1.8 1.8 + 0.22.6 + 1.9.5 + 28.2-jre + 0.43 + 1.2.3 + 0.14.1 + 1.9.1 + 1.9.1 diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/async/EAAsyncExample.java b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/async/EAAsyncExample.java new file mode 100644 index 0000000000..c7c893e731 --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/async/EAAsyncExample.java @@ -0,0 +1,57 @@ +package com.baeldung.async; + +import static com.ea.async.Async.await; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +import com.ea.async.Async; + +public class EAAsyncExample { + + static { + Async.init(); + } + + public static void main(String[] args) throws Exception { + usingCompletableFuture(); + usingAsyncAwait(); + } + + public static void usingCompletableFuture() throws InterruptedException, ExecutionException, Exception { + CompletableFuture completableFuture = hello() + .thenComposeAsync(hello -> mergeWorld(hello)) + .thenAcceptAsync(helloWorld -> print(helloWorld)) + .exceptionally( throwable -> { + System.out.println(throwable.getCause()); + return null; + }); + completableFuture.get(); + } + + public static CompletableFuture hello() { + CompletableFuture completableFuture = CompletableFuture.supplyAsync(() -> "Hello"); + return completableFuture; + } + + public static CompletableFuture mergeWorld(String s) { + CompletableFuture completableFuture = CompletableFuture.supplyAsync(() -> { + return s + " World!"; + }); + return completableFuture; + } + + public static void print(String str) { + CompletableFuture.runAsync(() -> System.out.println(str)); + } + + private static void usingAsyncAwait() { + try { + String hello = await(hello()); + String helloWorld = await(mergeWorld(hello)); + await(CompletableFuture.runAsync(() -> print(helloWorld))); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/async/JavaAsync.java b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/async/JavaAsync.java new file mode 100644 index 0000000000..6f36f46154 --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/async/JavaAsync.java @@ -0,0 +1,183 @@ +package com.baeldung.async; + +import static com.ea.async.Async.await; + +import java.util.concurrent.Callable; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import com.google.common.util.concurrent.AsyncCallable; +import com.google.common.util.concurrent.Callables; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.common.util.concurrent.MoreExecutors; +import com.jcabi.aspects.Async; +import com.jcabi.aspects.Loggable; + +public class JavaAsync { + + static { + com.ea.async.Async.init(); + } + + private static final ExecutorService threadpool = Executors.newCachedThreadPool(); + + public static void main (String[] args) throws InterruptedException, ExecutionException { + int number = 20; + + //Thread Example + factorialUsingThread(number).start(); + + //FutureTask Example + Future futureTask = factorialUsingFutureTask(number); + System.out.println("Factorial of " + number + " is: " + futureTask.get()); + + // CompletableFuture Example + Future completableFuture = factorialUsingCompletableFuture(number); + System.out.println("Factorial of " + number + " is: " + completableFuture.get()); + + // EA Async example + System.out.println("Factorial of " + number + " is: " + factorialUsingEAAsync(number)); + + // cactoos async example + Future asyncFuture = factorialUsingCactoos(number); + System.out.println("Factorial of " + number + " is: " + asyncFuture.get()); + + // Guava example + ListenableFuture guavaFuture = factorialUsingGuavaServiceSubmit(number); + System.out.println("Factorial of " + number + " is: " + guavaFuture.get()); + + ListenableFuture guavaFutures = factorialUsingGuavaFutures(number); + System.out.println("Factorial of " + number + " is: " + guavaFutures.get()); + + // @async jcabi-aspect example + Future aspectFuture = factorialUsingJcabiAspect(number); + System.out.println("Factorial of " + number + " is: " + aspectFuture.get()); + + } + + /** + * Finds factorial of a number + * @param number + * @return + */ + public static long factorial(int number) { + long result = 1; + for(int i=number;i>0;i--) { + result *= i; + } + return result; + } + + /** + * Finds factorial of a number using Thread + * @param number + * @return + */ + @Loggable + public static Thread factorialUsingThread(int number) { + Thread newThread = new Thread(() -> { + System.out.println("Factorial of " + number + " is: " + factorial(number)); + }); + + return newThread; + } + + /** + * Finds factorial of a number using FutureTask + * @param number + * @return + */ + @Loggable + public static Future factorialUsingFutureTask(int number) { + Future futureTask = threadpool.submit(() -> factorial(number)); + + while (!futureTask.isDone()) { + System.out.println("FutureTask is not finished yet..."); + } + + return futureTask; + } + + /** + * Finds factorial of a number using CompletableFuture + * @param number + * @return + */ + @Loggable + public static Future factorialUsingCompletableFuture(int number) { + CompletableFuture completableFuture = CompletableFuture.supplyAsync(() -> factorial(number)); + return completableFuture; + } + + /** + * Finds factorial of a number using EA Async + * @param number + * @return + */ + @Loggable + public static long factorialUsingEAAsync(int number) { + CompletableFuture completableFuture = CompletableFuture.supplyAsync(() -> factorial(number)); + long result = await(completableFuture); + return result; + } + + /** + * Finds factorial of a number using Async of Cactoos + * @param number + * @return + * @throws InterruptedException + * @throws ExecutionException + */ + @Loggable + public static Future factorialUsingCactoos(int number) throws InterruptedException, ExecutionException { + org.cactoos.func.Async asyncFunction = new org.cactoos.func.Async(input -> factorial(input)); + Future asyncFuture = asyncFunction.apply(number); + return asyncFuture; + } + + /** + * Finds factorial of a number using Guava's ListeningExecutorService.submit() + * @param number + * @return + */ + @Loggable + public static ListenableFuture factorialUsingGuavaServiceSubmit(int number) { + ListeningExecutorService service = MoreExecutors.listeningDecorator(threadpool); + ListenableFuture factorialFuture = (ListenableFuture) service.submit(()-> factorial(number)); + return factorialFuture; + } + + /** + * Finds factorial of a number using Guava's Futures.submitAsync() + * @param number + * @return + */ + @Loggable + public static ListenableFuture factorialUsingGuavaFutures(int number) { + ListeningExecutorService service = MoreExecutors.listeningDecorator(threadpool); + AsyncCallable asyncCallable = Callables.asAsyncCallable(new Callable() { + public Long call() { + return factorial(number); + } + }, service); + return Futures.submitAsync(asyncCallable, service); + } + + /** + * Finds factorial of a number using @Async of jcabi-aspects + * @param number + * @return + */ + @Async + @Loggable + public static Future factorialUsingJcabiAspect(int number) { + Future factorialFuture = CompletableFuture.supplyAsync(() -> factorial(number)); + return factorialFuture; + } + +} diff --git a/core-java-modules/core-java-jar/pom.xml b/core-java-modules/core-java-jar/pom.xml index a3e8941622..fe94a6d8a8 100644 --- a/core-java-modules/core-java-jar/pom.xml +++ b/core-java-modules/core-java-jar/pom.xml @@ -207,8 +207,8 @@ maven-javadoc-plugin ${maven-javadoc-plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} @@ -397,6 +397,8 @@ 3.1.1 2.0.3.RELEASE 1.6.0 + 1.8 + 1.8 diff --git a/core-java-modules/core-java-jndi/pom.xml b/core-java-modules/core-java-jndi/pom.xml index 13504886d6..5f1d01a9f5 100644 --- a/core-java-modules/core-java-jndi/pom.xml +++ b/core-java-modules/core-java-jndi/pom.xml @@ -19,34 +19,34 @@ org.junit.jupiter junit-jupiter - 5.5.1 + ${jupiter.version} test org.springframework spring-core - 5.0.9.RELEASE + ${spring.version} org.springframework spring-context - 5.0.9.RELEASE + ${spring.version} org.springframework spring-jdbc - 5.0.9.RELEASE + ${spring.version} org.springframework spring-test - 5.0.9.RELEASE + ${spring.version} test com.h2database h2 - 1.4.199 + ${h2.version} @@ -56,11 +56,19 @@ org.apache.maven.plugins maven-compiler-plugin - 1.8 - 1.8 + ${source.version} + ${target.version} + + + 5.0.9.RELEASE + 1.4.199 + 5.5.1 + 1.8 + 1.8 + diff --git a/core-java-modules/core-java-jpms/decoupling-pattern1/consumermodule/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern1/consumermodule/pom.xml index ddf52d8fef..e708502dee 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern1/consumermodule/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern1/consumermodule/pom.xml @@ -16,7 +16,7 @@ com.baeldung.servicemodule servicemodule - 1.0 + ${servicemodule.version} @@ -29,4 +29,8 @@ + + 1.0 + + diff --git a/core-java-modules/core-java-jpms/decoupling-pattern1/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern1/pom.xml index 78a9d1eaad..3c03643a2c 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern1/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern1/pom.xml @@ -19,10 +19,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 11 - 11 + ${source.version} + ${target.version} @@ -31,6 +31,9 @@ UTF-8 + 3.8.0 + 11 + 11 \ No newline at end of file diff --git a/core-java-modules/core-java-jpms/decoupling-pattern2/consumermodule/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern2/consumermodule/pom.xml index 734774af0e..6f1038767d 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern2/consumermodule/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern2/consumermodule/pom.xml @@ -17,12 +17,12 @@ com.baeldung.servicemodule servicemodule - 1.0 + ${servicemodule.version} com.baeldung.providermodule providermodule - 1.0 + ${providermodule.version} @@ -34,5 +34,10 @@ + + + 1.0 + 1.0 + \ No newline at end of file diff --git a/core-java-modules/core-java-jpms/decoupling-pattern2/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern2/pom.xml index 2f84c69fd6..f6b4e5b0df 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern2/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern2/pom.xml @@ -20,14 +20,20 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 11 - 11 + ${source.version} + ${target.version} + + + 3.8.0 + 11 + 11 + \ No newline at end of file diff --git a/core-java-modules/core-java-jpms/decoupling-pattern2/providermodule/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern2/providermodule/pom.xml index 5ec36c581e..64766b9aff 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern2/providermodule/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern2/providermodule/pom.xml @@ -17,7 +17,7 @@ com.baeldung.servicemodule servicemodule - 1.0 + ${servicemodule.version} @@ -30,4 +30,9 @@ + + 1.0 + + + \ No newline at end of file diff --git a/core-java-modules/core-java-lang-2/pom.xml b/core-java-modules/core-java-lang-2/pom.xml index 5657e64b17..4702b7350b 100644 --- a/core-java-modules/core-java-lang-2/pom.xml +++ b/core-java-modules/core-java-lang-2/pom.xml @@ -18,7 +18,7 @@ commons-beanutils commons-beanutils - 1.9.4 + ${commons.beanutils.version} org.openjdk.jmh @@ -57,6 +57,7 @@ 1.19 1.19 3.12.2 + 1.9.4 diff --git a/core-java-modules/core-java-reflection/pom.xml b/core-java-modules/core-java-reflection/pom.xml index b3c3390df8..64086ef5b8 100644 --- a/core-java-modules/core-java-reflection/pom.xml +++ b/core-java-modules/core-java-reflection/pom.xml @@ -37,8 +37,8 @@ maven-compiler-plugin ${maven-compiler-plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} -parameters @@ -48,5 +48,7 @@ 3.8.0 3.10.0 + 1.8 + 1.8 \ No newline at end of file diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetExample.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetExample.java new file mode 100644 index 0000000000..a20ee527f8 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetExample.java @@ -0,0 +1,7 @@ +package com.baeldung.reflection.exception.invocationtarget; + +public class InvocationTargetExample { + public int divideByZeroExample() { + return 1 / 0; + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java new file mode 100644 index 0000000000..b4cabebcef --- /dev/null +++ b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java @@ -0,0 +1,23 @@ +package com.baeldung.reflection.exception.invocationtarget; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.junit.jupiter.api.Test; + +public class InvocationTargetUnitTest { + + @Test + public void whenCallingMethodThrowsException_thenAssertCauseOfInvocationTargetException() throws Exception { + + InvocationTargetExample targetExample = new InvocationTargetExample(); + Method method = InvocationTargetExample.class.getMethod("divideByZeroExample"); + + Exception exception = assertThrows(InvocationTargetException.class, () -> method.invoke(targetExample)); + + assertEquals(ArithmeticException.class, exception.getCause().getClass()); + } +} 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 a5dd31c762..43dc040591 100644 --- a/core-java-modules/core-java-string-algorithms-3/pom.xml +++ b/core-java-modules/core-java-string-algorithms-3/pom.xml @@ -25,7 +25,7 @@ com.google.guava guava - 28.1-jre + ${guava.version} @@ -62,7 +62,7 @@ 3.8.1 3.6.1 - 27.0.1-jre + 28.1-jre 5.3.1 diff --git a/core-java-modules/core-java-text/src/test/java/com/baeldung/regex/matcher/MatcherUnitTest.java b/core-java-modules/core-java-text/src/test/java/com/baeldung/regex/matcher/MatcherUnitTest.java new file mode 100644 index 0000000000..304b9f2f1d --- /dev/null +++ b/core-java-modules/core-java-text/src/test/java/com/baeldung/regex/matcher/MatcherUnitTest.java @@ -0,0 +1,63 @@ +package com.baeldung.regex.matcher; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.junit.jupiter.api.Test; + +public class MatcherUnitTest { + + @Test + public void whenFindFourDigitWorks_thenCorrect() { + Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d"); + Matcher m = stringPattern.matcher("goodbye 2019 and welcome 2020"); + + assertTrue(m.find()); + assertEquals(8, m.start()); + assertEquals("2019", m.group()); + assertEquals(12, m.end()); + + assertTrue(m.find()); + assertEquals(25, m.start()); + assertEquals("2020", m.group()); + assertEquals(29, m.end()); + + assertFalse(m.find()); + } + + @Test + public void givenStartIndex_whenFindFourDigitWorks_thenCorrect() { + Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d"); + Matcher m = stringPattern.matcher("goodbye 2019 and welcome 2020"); + + assertTrue(m.find(20)); + assertEquals(25, m.start()); + assertEquals("2020", m.group()); + assertEquals(29, m.end()); + } + + @Test + public void whenMatchFourDigitWorks_thenFail() { + Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d"); + Matcher m = stringPattern.matcher("goodbye 2019 and welcome 2020"); + assertFalse(m.matches()); + } + + @Test + public void whenMatchFourDigitWorks_thenCorrect() { + Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d"); + Matcher m = stringPattern.matcher("2019"); + + assertTrue(m.matches()); + assertEquals(0, m.start()); + assertEquals("2019", m.group()); + assertEquals(4, m.end()); + + assertTrue(m.matches());// matches will always return the same return + } + +} diff --git a/core-java-modules/core-java/pom.xml b/core-java-modules/core-java/pom.xml index 341363f8ed..2442d81559 100644 --- a/core-java-modules/core-java/pom.xml +++ b/core-java-modules/core-java/pom.xml @@ -207,8 +207,8 @@ maven-javadoc-plugin ${maven-javadoc-plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} @@ -397,6 +397,8 @@ 3.1.1 2.0.3.RELEASE 1.6.0 + 1.8 + 1.8 diff --git a/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml b/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml index fa2d92d67f..e8a8203f33 100644 --- a/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml +++ b/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml @@ -17,17 +17,17 @@ com.baeldung.entitymodule entitymodule - 1.0 + ${entitymodule.version} com.baeldung.daomodule daomodule - 1.0 + ${daomodule.version} com.baeldung.userdaomodule userdaomodule - 1.0 + ${userdaomodule.version} @@ -43,6 +43,9 @@ 9 9 + 1.0 + 1.0 + 1.0 \ No newline at end of file diff --git a/core-java-modules/multimodulemavenproject/pom.xml b/core-java-modules/multimodulemavenproject/pom.xml index 1d4aebf32e..dcf9f7311e 100644 --- a/core-java-modules/multimodulemavenproject/pom.xml +++ b/core-java-modules/multimodulemavenproject/pom.xml @@ -45,10 +45,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 1.9 - 1.9 + ${source.version} + ${target.version} @@ -56,6 +56,9 @@ + 3.8.0 + 1.9 + 1.9 UTF-8 3.12.2 diff --git a/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml b/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml index 19012708cf..8f4cc3d945 100644 --- a/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml +++ b/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml @@ -17,12 +17,12 @@ com.baeldung.entitymodule entitymodule - 1.0 + ${entitymodule.version} com.baeldung.daomodule daomodule - 1.0 + ${daomodule.version} @@ -38,6 +38,8 @@ 9 9 + 1.0 + 1.0 \ No newline at end of file diff --git a/core-java-modules/pre-jpms/pom.xml b/core-java-modules/pre-jpms/pom.xml index cb23427138..9833dc2ff7 100644 --- a/core-java-modules/pre-jpms/pom.xml +++ b/core-java-modules/pre-jpms/pom.xml @@ -29,16 +29,16 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} org.apache.maven.plugins maven-dependency-plugin - 3.1.1 + ${dependency.plugin.version} copy-dependencies @@ -69,5 +69,12 @@ + + + 3.1.1 + 3.8.0 + 1.8 + 1.8 + diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/sequences/SequencesTest.kt b/core-kotlin-2/src/test/kotlin/com/baeldung/sequences/SequencesTest.kt new file mode 100644 index 0000000000..a41e213c44 --- /dev/null +++ b/core-kotlin-2/src/test/kotlin/com/baeldung/sequences/SequencesTest.kt @@ -0,0 +1,54 @@ +package com.baeldung.sequeces + +import org.junit.Test +import kotlin.test.assertEquals +import java.time.Instant + +class SequencesTest { + + @Test + fun shouldBuildSequenceWhenUsingFromElements() { + val seqOfElements = sequenceOf("first" ,"second", "third") + .toList() + assertEquals(3, seqOfElements.count()) + } + + @Test + fun shouldBuildSequenceWhenUsingFromFunction() { + val seqFromFunction = generateSequence(Instant.now()) {it.plusSeconds(1)} + .take(3) + .toList() + assertEquals(3, seqFromFunction.count()) + } + + @Test + fun shouldBuildSequenceWhenUsingFromChunks() { + val seqFromChunks = sequence { + yield(1) + yieldAll((2..5).toList()) + }.toList() + assertEquals(5, seqFromChunks.count()) + } + + @Test + fun shouldBuildSequenceWhenUsingFromCollection() { + val seqFromIterable = (1..10) + .asSequence() + .toList() + assertEquals(10, seqFromIterable.count()) + } + + @Test + fun shouldShowNoCountDiffWhenUsingWithAndWithoutSequence() { + val withSequence = (1..10).asSequence() + .filter{it % 2 == 1} + .map { it * 2 } + .toList() + val withoutSequence = (1..10) + .filter{it % 2 == 1} + .map { it * 2 } + .toList() + assertEquals(withSequence.count(), withoutSequence.count()) + } + +} \ No newline at end of file diff --git a/core-scala/pom.xml b/core-scala/pom.xml index d6793cf4c6..d72727dd39 100644 --- a/core-scala/pom.xml +++ b/core-scala/pom.xml @@ -28,7 +28,7 @@ net.alchim31.maven scala-maven-plugin - 3.3.2 + ${scala.plugin.version} @@ -49,6 +49,7 @@ 2.12.7 + 3.3.2 diff --git a/data-structures/pom.xml b/data-structures/pom.xml index e8f4628062..f4a8ea3a14 100644 --- a/data-structures/pom.xml +++ b/data-structures/pom.xml @@ -12,6 +12,21 @@ 1.0.0-SNAPSHOT + + + github.release.repo + https://raw.github.com/bulldog2011/bulldog-repo/master/repo/releases/ + + + + + + com.leansoft + bigqueue + 0.7.0 + + + diff --git a/data-structures/src/test/java/com/baeldung/bigqueue/BigQueueLiveTest.java b/data-structures/src/test/java/com/baeldung/bigqueue/BigQueueLiveTest.java new file mode 100644 index 0000000000..c0305a7ca3 --- /dev/null +++ b/data-structures/src/test/java/com/baeldung/bigqueue/BigQueueLiveTest.java @@ -0,0 +1,82 @@ +package com.baeldung.bigqueue; + +import com.leansoft.bigqueue.BigQueueImpl; +import com.leansoft.bigqueue.IBigQueue; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@RunWith(JUnit4.class) +public class BigQueueLiveTest { + + private IBigQueue bigQueue; + + @Before + public void setup() throws IOException { + String queueDir = System.getProperty("user.home"); + String queueName = "baeldung-queue"; + bigQueue = new BigQueueImpl(queueDir, queueName); + } + + @After + public void emptyQueue() throws IOException { + bigQueue.removeAll(); + bigQueue.gc(); + bigQueue.close(); + } + + @Test + public void whenAddingRecords_ThenTheSizeIsCorrect() throws IOException { + for (int i = 1; i <= 100; i++) { + bigQueue.enqueue(String.valueOf(i).getBytes()); + } + + assertEquals(100, bigQueue.size()); + } + + @Test + public void whenAddingRecords_ThenTheyCanBeRetrieved() throws IOException { + bigQueue.enqueue(String.valueOf("new_record").getBytes()); + + String record = new String(bigQueue.dequeue()); + assertEquals("new_record", record); + } + + @Test + public void whenDequeueingRecords_ThenTheyAreConsumed() throws IOException { + for (int i = 1; i <= 100; i++) { + bigQueue.enqueue(String.valueOf(i).getBytes()); + } + bigQueue.dequeue(); + + assertEquals(99, bigQueue.size()); + } + + @Test + public void whenPeekingRecords_ThenSizeDoesntChange() throws IOException { + for (int i = 1; i <= 100; i++) { + bigQueue.enqueue(String.valueOf(i).getBytes()); + } + String firstRecord = new String(bigQueue.peek()); + + assertEquals("1", firstRecord); + assertEquals(100, bigQueue.size()); + } + + @Test + public void whenEmptyingTheQueue_ThenItSizeIs0() throws IOException { + for (int i = 1; i <= 100; i++) { + bigQueue.enqueue(String.valueOf(i).getBytes()); + } + bigQueue.removeAll(); + + assertEquals(0, bigQueue.size()); + } + +} diff --git a/deeplearning4j/pom.xml b/deeplearning4j/pom.xml index 0e84fa1516..c143b86ff8 100644 --- a/deeplearning4j/pom.xml +++ b/deeplearning4j/pom.xml @@ -44,12 +44,13 @@ org.apache.httpcomponents httpclient - 4.3.5 + ${httpclient.version} 0.9.1 + 4.3.5 diff --git a/ethereum/pom.xml b/ethereum/pom.xml index 6fc31208d2..da0a7ebda8 100644 --- a/ethereum/pom.xml +++ b/ethereum/pom.xml @@ -175,10 +175,10 @@ maven-compiler-plugin - 3.1 + ${compiler.plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} @@ -215,5 +215,8 @@ 1.2.3 1.7.25 2.0.4.RELEASE + 3.1 + 1.8 + 1.8 diff --git a/google-web-toolkit/pom.xml b/google-web-toolkit/pom.xml index e79b43c5e5..37e423b3af 100644 --- a/google-web-toolkit/pom.xml +++ b/google-web-toolkit/pom.xml @@ -63,7 +63,7 @@ net.ltgt.gwt.maven gwt-maven-plugin - 1.0-rc-8 + ${gwt.plugin.version} @@ -78,7 +78,7 @@ true - 1.8 + ${maven.compiler.source} @@ -98,7 +98,7 @@ maven-surefire-plugin - 2.17 + ${surefire.plugin.version} true @@ -119,6 +119,8 @@ UTF-8 UTF-8 2.8.2 + 1.0-rc-8 + 2.17 diff --git a/guest/core-kotlin/pom.xml b/guest/core-kotlin/pom.xml index 2d4a0c6144..ad0368c6ab 100644 --- a/guest/core-kotlin/pom.xml +++ b/guest/core-kotlin/pom.xml @@ -46,19 +46,19 @@ org.jetbrains.spek spek-api - 1.1.5 + ${spek.api.version} test org.jetbrains.spek spek-subject-extension - 1.1.5 + ${spek.subject.version} test org.jetbrains.spek spek-junit-platform-engine - 1.1.5 + ${spek.junit.version} test @@ -195,6 +195,9 @@ 5.2.0 3.10.0 3.7.0 + 1.1.5 + 1.1.5 + 1.1.5 diff --git a/intelliJ/remote-debugging/pom.xml b/intelliJ/remote-debugging/pom.xml index d18625e8f6..43b9a44d13 100644 --- a/intelliJ/remote-debugging/pom.xml +++ b/intelliJ/remote-debugging/pom.xml @@ -16,6 +16,7 @@ 1.8 + 3.1.2 @@ -31,7 +32,7 @@ org.awaitility awaitility - 3.1.2 + ${awaitility.version} test diff --git a/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml b/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml index 912a2cabac..a2d9443d67 100644 --- a/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml +++ b/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml @@ -12,12 +12,16 @@ java-ee-8-security-api 1.0-SNAPSHOT + + + 4.0.4 + com.unboundid unboundid-ldapsdk - 4.0.4 + ${unboundid.ldapsdk.version} diff --git a/java-numbers-2/pom.xml b/java-numbers-2/pom.xml index ba40ef0a38..5c81b00756 100644 --- a/java-numbers-2/pom.xml +++ b/java-numbers-2/pom.xml @@ -21,6 +21,11 @@ jmh-generator-annprocess ${jmh-generator.version} + + it.unimi.dsi + dsiutils + ${dsiutils.version} + @@ -33,4 +38,8 @@ + + 2.6.0 + + diff --git a/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/BruteForcePrimeChecker.java b/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/BruteForcePrimeChecker.java index 68382c26ea..7af8c5d58d 100644 --- a/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/BruteForcePrimeChecker.java +++ b/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/BruteForcePrimeChecker.java @@ -7,7 +7,7 @@ public class BruteForcePrimeChecker implements PrimeChecker { @Override public boolean isPrime(Integer number) { - return number > 2 ? IntStream.range(2, number) + return number > 1 ? IntStream.range(2, number) .noneMatch(n -> (number % n == 0)) : false; } diff --git a/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/OptimisedPrimeChecker.java b/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/OptimisedPrimeChecker.java index 3dc372ad22..3019c76eb4 100644 --- a/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/OptimisedPrimeChecker.java +++ b/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/OptimisedPrimeChecker.java @@ -6,7 +6,7 @@ public class OptimisedPrimeChecker implements PrimeChecker { @Override public boolean isPrime(Integer number) { - return number > 2 ? IntStream.rangeClosed(2, (int) Math.sqrt(number)) + return number > 1 ? IntStream.rangeClosed(2, (int) Math.sqrt(number)) .noneMatch(n -> (number % n == 0)) : false; } diff --git a/java-numbers-2/src/test/java/com/baeldung/algorithms/primechecker/PrimeCheckerUnitTest.java b/java-numbers-2/src/test/java/com/baeldung/algorithms/primechecker/PrimeCheckerUnitTest.java index 9f8ba8defd..6e425b3051 100644 --- a/java-numbers-2/src/test/java/com/baeldung/algorithms/primechecker/PrimeCheckerUnitTest.java +++ b/java-numbers-2/src/test/java/com/baeldung/algorithms/primechecker/PrimeCheckerUnitTest.java @@ -11,22 +11,24 @@ public class PrimeCheckerUnitTest { @Test public void whenCheckIsPrime_thenTrue() { - assertTrue(primeChecker.isPrime(13l)); + assertTrue(primeChecker.isPrime(2L)); + assertTrue(primeChecker.isPrime(13L)); assertTrue(primeChecker.isPrime(1009L)); assertTrue(primeChecker.isPrime(74207281L)); } @Test public void whenCheckIsPrime_thenFalse() { - assertTrue(!primeChecker.isPrime(50L)); - assertTrue(!primeChecker.isPrime(1001L)); - assertTrue(!primeChecker.isPrime(74207282L)); + assertFalse(primeChecker.isPrime(50L)); + assertFalse(primeChecker.isPrime(1001L)); + assertFalse(primeChecker.isPrime(74207282L)); } private final BruteForcePrimeChecker bfPrimeChecker = new BruteForcePrimeChecker(); @Test public void whenBFCheckIsPrime_thenTrue() { + assertTrue(bfPrimeChecker.isPrime(2)); assertTrue(bfPrimeChecker.isPrime(13)); assertTrue(bfPrimeChecker.isPrime(1009)); } @@ -41,6 +43,7 @@ public class PrimeCheckerUnitTest { @Test public void whenOptCheckIsPrime_thenTrue() { + assertTrue(optimisedPrimeChecker.isPrime(2)); assertTrue(optimisedPrimeChecker.isPrime(13)); assertTrue(optimisedPrimeChecker.isPrime(1009)); } @@ -55,6 +58,7 @@ public class PrimeCheckerUnitTest { @Test public void whenPrimesCheckIsPrime_thenTrue() { + assertTrue(primesPrimeChecker.isPrime(2)); assertTrue(primesPrimeChecker.isPrime(13)); assertTrue(primesPrimeChecker.isPrime(1009)); } diff --git a/java-numbers-3/pom.xml b/java-numbers-3/pom.xml index 3dd8e16bc7..e3c64064c7 100644 --- a/java-numbers-3/pom.xml +++ b/java-numbers-3/pom.xml @@ -12,6 +12,14 @@ 0.0.1-SNAPSHOT ../parent-java + + + + it.unimi.dsi + dsiutils + 2.6.0 + + java-numbers-3 diff --git a/java-numbers-3/src/main/java/com/baeldung/randomnumbers/RandomNumbersGenerator.java b/java-numbers-3/src/main/java/com/baeldung/randomnumbers/RandomNumbersGenerator.java new file mode 100644 index 0000000000..50a072371e --- /dev/null +++ b/java-numbers-3/src/main/java/com/baeldung/randomnumbers/RandomNumbersGenerator.java @@ -0,0 +1,103 @@ +package com.baeldung.randomnumbers; + +import java.security.SecureRandom; +import java.util.Random; +import java.util.SplittableRandom; +import java.util.concurrent.ThreadLocalRandom; +import java.util.stream.IntStream; + +import org.apache.commons.math3.random.RandomDataGenerator; + +import it.unimi.dsi.util.XoRoShiRo128PlusRandom; + +public class RandomNumbersGenerator { + + public Integer generateRandomWithMathRandom(int max, int min) { + return (int) ((Math.random() * (max - min)) + min); + } + + public Integer generateRandomWithNextInt() { + Random random = new Random(); + int randomWithNextInt = random.nextInt(); + return randomWithNextInt; + } + + public Integer generateRandomWithNextIntWithinARange(int min, int max) { + Random random = new Random(); + int randomWintNextIntWithinARange = random.nextInt(max - min) + min; + return randomWintNextIntWithinARange; + } + + public IntStream generateRandomUnlimitedIntStream() { + Random random = new Random(); + IntStream unlimitedIntStream = random.ints(); + return unlimitedIntStream; + } + + public IntStream generateRandomLimitedIntStream(long streamSize) { + Random random = new Random(); + IntStream limitedIntStream = random.ints(streamSize); + return limitedIntStream; + } + + public IntStream generateRandomLimitedIntStreamWithinARange(int min, int max, long streamSize) { + Random random = new Random(); + IntStream limitedIntStreamWithinARange = random.ints(streamSize, min, max); + return limitedIntStreamWithinARange; + } + + public Integer generateRandomWithThreadLocalRandom() { + int randomWithThreadLocalRandom = ThreadLocalRandom.current() + .nextInt(); + return randomWithThreadLocalRandom; + } + + public Integer generateRandomWithThreadLocalRandomInARange(int min, int max) { + int randomWithThreadLocalRandomInARange = ThreadLocalRandom.current() + .nextInt(min, max); + return randomWithThreadLocalRandomInARange; + } + + public Integer generateRandomWithThreadLocalRandomFromZero(int max) { + int randomWithThreadLocalRandomFromZero = ThreadLocalRandom.current() + .nextInt(max); + return randomWithThreadLocalRandomFromZero; + } + + public Integer generateRandomWithSplittableRandom(int min, int max) { + SplittableRandom splittableRandom = new SplittableRandom(); + int randomWithSplittableRandom = splittableRandom.nextInt(min, max); + return randomWithSplittableRandom; + } + + public IntStream generateRandomWithSplittableRandomLimitedIntStreamWithinARange(int min, int max, long streamSize) { + SplittableRandom splittableRandom = new SplittableRandom(); + IntStream limitedIntStreamWithinARangeWithSplittableRandom = splittableRandom.ints(streamSize, min, max); + return limitedIntStreamWithinARangeWithSplittableRandom; + } + + public Integer generateRandomWithSecureRandom() { + SecureRandom secureRandom = new SecureRandom(); + int randomWithSecureRandom = secureRandom.nextInt(); + return randomWithSecureRandom; + } + + public Integer generateRandomWithSecureRandomWithinARange(int min, int max) { + SecureRandom secureRandom = new SecureRandom(); + int randomWithSecureRandomWithinARange = secureRandom.nextInt(max - min) + min; + return randomWithSecureRandomWithinARange; + } + + public Integer generateRandomWithRandomDataGenerator(int min, int max) { + RandomDataGenerator randomDataGenerator = new RandomDataGenerator(); + int randomWithRandomDataGenerator = randomDataGenerator.nextInt(min, max); + return randomWithRandomDataGenerator; + } + + public Integer generateRandomWithXoRoShiRo128PlusRandom(int min, int max) { + XoRoShiRo128PlusRandom xoroRandom = new XoRoShiRo128PlusRandom(); + int randomWithXoRoShiRo128PlusRandom = xoroRandom.nextInt(max - min) + min; + return randomWithXoRoShiRo128PlusRandom; + } + +} diff --git a/java-numbers-3/src/test/java/com/baeldung/randomnumbers/RandomNumbersGeneratorUnitTest.java b/java-numbers-3/src/test/java/com/baeldung/randomnumbers/RandomNumbersGeneratorUnitTest.java new file mode 100644 index 0000000000..bdd955a4ee --- /dev/null +++ b/java-numbers-3/src/test/java/com/baeldung/randomnumbers/RandomNumbersGeneratorUnitTest.java @@ -0,0 +1,154 @@ +package com.baeldung.randomnumbers; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.stream.IntStream; + +import org.junit.Test; + +public class RandomNumbersGeneratorUnitTest { + + private static final int MIN_RANGE = 1; + private static final int MAX_RANGE = 10; + private static final int MIN_RANGE_NEGATIVE = -10; + private static final int ITERATIONS = 50; + private static final long STREAM_SIZE = 50; + + @Test + public void whenGenerateRandomWithMathRandom_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumer = generator.generateRandomWithMathRandom(MIN_RANGE, MAX_RANGE); + assertTrue(isInRange(randomNumer, MIN_RANGE, MAX_RANGE)); + } + } + + @Test + public void whenGenerateRandomWithNextInt_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithNextInt(); + assertTrue(isInRange(randomNumber, Integer.MIN_VALUE, Integer.MAX_VALUE)); + } + } + + @Test + public void whenGenerateRandomWithNextIntWithinARange_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithNextIntWithinARange(MIN_RANGE, MAX_RANGE); + assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE)); + } + } + + @Test + public void whenGenerateRandomUnlimitedIntStream_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + IntStream stream = generator.generateRandomUnlimitedIntStream(); + assertNotNull(stream); + Integer randomNumber = stream.findFirst() + .getAsInt(); + assertNotNull(randomNumber); + assertTrue(isInRange(randomNumber, Integer.MIN_VALUE, Integer.MAX_VALUE)); + } + + @Test + public void whenGenerateRandomLimitedIntStream_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + generator.generateRandomLimitedIntStream(STREAM_SIZE) + .forEach(randomNumber -> assertTrue(isInRange(randomNumber, Integer.MIN_VALUE, Integer.MAX_VALUE))); + } + + @Test + public void whenGenerateRandomLimitedIntStreamWithinARange_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + generator.generateRandomLimitedIntStreamWithinARange(MIN_RANGE, MAX_RANGE, STREAM_SIZE) + .forEach(randomNumber -> assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE))); + } + + @Test + public void whenGenerateRandomWithThreadLocalRandom_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithThreadLocalRandom(); + assertTrue(isInRange(randomNumber, Integer.MIN_VALUE, Integer.MAX_VALUE)); + } + } + + @Test + public void whenGenerateRandomWithThreadLocalRandomInARange_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithThreadLocalRandomInARange(MIN_RANGE, MAX_RANGE); + assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE)); + } + } + + @Test + public void whenGenerateRandomWithThreadLocalRandomFromZero_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithThreadLocalRandomFromZero(MAX_RANGE); + assertTrue(isInRange(randomNumber, 0, MAX_RANGE)); + } + } + + @Test + public void whenGenerateRandomWithSplittableRandom_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithSplittableRandom(MIN_RANGE_NEGATIVE, MAX_RANGE); + assertTrue(isInRange(randomNumber, MIN_RANGE_NEGATIVE, MAX_RANGE)); + } + } + + @Test + public void whenGenerateRandomWithSplittableRandomLimitedIntStreamWithinARange_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + generator.generateRandomWithSplittableRandomLimitedIntStreamWithinARange(MIN_RANGE, MAX_RANGE, STREAM_SIZE) + .forEach(randomNumber -> assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE))); + } + + @Test + public void whenGenerateRandomWithSecureRandom_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithSecureRandom(); + assertTrue(isInRange(randomNumber, Integer.MIN_VALUE, Integer.MAX_VALUE)); + } + } + + @Test + public void whenGenerateRandomWithSecureRandomWithinARange_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithSecureRandomWithinARange(MIN_RANGE, MAX_RANGE); + assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE)); + } + } + + @Test + public void whenGenerateRandomWithRandomDataGenerator_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithRandomDataGenerator(MIN_RANGE, MAX_RANGE); + // RandomDataGenerator top is inclusive + assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE + 1)); + } + } + + @Test + public void whenGenerateRandomWithXoRoShiRo128PlusRandom_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithXoRoShiRo128PlusRandom(MIN_RANGE, MAX_RANGE); + assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE)); + } + } + + private boolean isInRange(int number, int min, int max) { + return min <= number && number < max; + } + +} diff --git a/jee-7/pom.xml b/jee-7/pom.xml index 635d820c2b..a2593e46a5 100644 --- a/jee-7/pom.xml +++ b/jee-7/pom.xml @@ -118,7 +118,7 @@ javax.mvc javax.mvc-api - 20160715 + ${mvc.api.version} org.glassfish.ozark @@ -215,7 +215,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} @@ -506,6 +506,8 @@ + 1.0.0 + 20160715 1.8 3.0.0 7.0 diff --git a/jee-kotlin/pom.xml b/jee-kotlin/pom.xml index 80c5ea4e22..9191885bd4 100644 --- a/jee-kotlin/pom.xml +++ b/jee-kotlin/pom.xml @@ -253,7 +253,7 @@ org.wildfly.arquillian wildfly-arquillian-container-remote - 2.2.0.Final + ${wildfly.arquillian.version} test @@ -261,6 +261,7 @@ + 2.2.0.Final UTF-8 false 8.0 diff --git a/jhipster/jhipster-microservice/car-app/pom.xml b/jhipster/jhipster-microservice/car-app/pom.xml index 86d94d0a44..c53ea8358e 100644 --- a/jhipster/jhipster-microservice/car-app/pom.xml +++ b/jhipster/jhipster-microservice/car-app/pom.xml @@ -17,6 +17,7 @@ + 1.0.0 -Djava.security.egd=file:/dev/./urandom -Xmx256m 3.6.2 2.0.0 @@ -433,7 +434,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} diff --git a/jhipster/jhipster-microservice/dealer-app/pom.xml b/jhipster/jhipster-microservice/dealer-app/pom.xml index 3051399ae6..a0bcc73e31 100644 --- a/jhipster/jhipster-microservice/dealer-app/pom.xml +++ b/jhipster/jhipster-microservice/dealer-app/pom.xml @@ -92,6 +92,7 @@ 1.4.10.Final 1.1.0.Final v0.21.3 + 1.0.0 @@ -427,7 +428,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} diff --git a/jhipster/jhipster-microservice/gateway-app/pom.xml b/jhipster/jhipster-microservice/gateway-app/pom.xml index 4e2c19ed2d..c6dcbb3f3e 100644 --- a/jhipster/jhipster-microservice/gateway-app/pom.xml +++ b/jhipster/jhipster-microservice/gateway-app/pom.xml @@ -96,6 +96,7 @@ 1.4.10.Final 1.1.0.Final v0.21.3 + 1.0.0 @@ -469,7 +470,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} diff --git a/jhipster/jhipster-monolithic/pom.xml b/jhipster/jhipster-monolithic/pom.xml index 12dead99df..04f790faf5 100644 --- a/jhipster/jhipster-monolithic/pom.xml +++ b/jhipster/jhipster-monolithic/pom.xml @@ -302,7 +302,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} @@ -398,8 +398,8 @@ maven-compiler-plugin ${maven-compiler-plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} org.mapstruct @@ -881,6 +881,9 @@ + 1.8 + 1.8 + 1.0.0 -Djava.security.egd=file:/dev/./urandom -Xmx256m 3.6.2 2.0.0 diff --git a/jhipster/jhipster-uaa/gateway/pom.xml b/jhipster/jhipster-uaa/gateway/pom.xml index 0f815bedad..1b85877a9b 100644 --- a/jhipster/jhipster-uaa/gateway/pom.xml +++ b/jhipster/jhipster-uaa/gateway/pom.xml @@ -236,7 +236,7 @@ org.zalando problem-spring-web - 0.24.0-RC.0 + ${spring.web.version} org.springframework.security.oauth @@ -559,7 +559,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} @@ -1012,6 +1012,8 @@ + 1.0.0 + 0.24.0-RC.0 3.0.0 1.8 diff --git a/jhipster/jhipster-uaa/uaa/pom.xml b/jhipster/jhipster-uaa/uaa/pom.xml index 2c4dd9d0f0..27a056820d 100644 --- a/jhipster/jhipster-uaa/uaa/pom.xml +++ b/jhipster/jhipster-uaa/uaa/pom.xml @@ -232,7 +232,7 @@ org.zalando problem-spring-web - 0.24.0-RC.0 + ${spring.web.version} org.springframework.security.oauth @@ -543,7 +543,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} @@ -834,6 +834,8 @@ + 1.0.0 + 0.24.0-RC.0 3.0.0 1.8 diff --git a/kotlin-libraries/pom.xml b/kotlin-libraries/pom.xml index dfd1dc363f..0d6e589377 100644 --- a/kotlin-libraries/pom.xml +++ b/kotlin-libraries/pom.xml @@ -33,19 +33,19 @@ org.jetbrains.spek spek-api - 1.1.5 + ${spek.version} test org.jetbrains.spek spek-subject-extension - 1.1.5 + ${spek.version} test org.jetbrains.spek spek-junit-platform-engine - 1.1.5 + ${spek.version} test @@ -166,6 +166,7 @@ 2.6 2.3.0 0.7.3 + 1.1.5 diff --git a/kotlin-quasar/pom.xml b/kotlin-quasar/pom.xml index a12d27c565..f5fbce6ed7 100644 --- a/kotlin-quasar/pom.xml +++ b/kotlin-quasar/pom.xml @@ -103,7 +103,7 @@ maven-dependency-plugin - 3.1.1 + ${dependency.plugin.version} getClasspathFilenames @@ -116,7 +116,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.1 + ${surefire.plugin.version} -Dco.paralleluniverse.fibers.verifyInstrumentation=true -javaagent:${co.paralleluniverse:quasar-core:jar} @@ -125,7 +125,7 @@ org.codehaus.mojo exec-maven-plugin - 1.3.2 + ${exec.plugin.version} target/classes echo @@ -145,6 +145,9 @@ 1.3.31 1.7.21 1.1.7 + 3.1.1 + 2.22.1 + 1.3.2 diff --git a/libraries-3/pom.xml b/libraries-3/pom.xml index c8980fd309..6942aa736d 100644 --- a/libraries-3/pom.xml +++ b/libraries-3/pom.xml @@ -23,10 +23,16 @@ lombok ${lombok.version} + + org.cactoos + cactoos + ${cactoos.version} + 1.78 1.18.6 + 0.43 - + \ No newline at end of file diff --git a/libraries-3/src/main/java/com/baeldung/cactoos/CactoosCollectionUtils.java b/libraries-3/src/main/java/com/baeldung/cactoos/CactoosCollectionUtils.java new file mode 100644 index 0000000000..717c63ae63 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/cactoos/CactoosCollectionUtils.java @@ -0,0 +1,28 @@ +package com.baeldung.cactoos; + +import java.util.Collection; +import java.util.List; + +import org.cactoos.collection.Filtered; +import org.cactoos.iterable.IterableOf; +import org.cactoos.list.ListOf; +import org.cactoos.scalar.And; +import org.cactoos.text.FormattedText; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CactoosCollectionUtils { + + final Logger LOGGER = LoggerFactory.getLogger(CactoosCollectionUtils.class); + + public void iterateCollection(List strings) throws Exception { + new And((String input) -> LOGGER.info(new FormattedText("%s\n", input).asString()), strings).value(); + } + + public Collection getFilteredList(List strings) { + Collection filteredStrings = new ListOf<>( + new Filtered<>(string -> string.length() == 5, new IterableOf<>(strings))); + return filteredStrings; + } + +} diff --git a/libraries-3/src/main/java/com/baeldung/cactoos/CactoosStringUtils.java b/libraries-3/src/main/java/com/baeldung/cactoos/CactoosStringUtils.java new file mode 100644 index 0000000000..3e2903ebf4 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/cactoos/CactoosStringUtils.java @@ -0,0 +1,37 @@ +package com.baeldung.cactoos; + +import java.io.IOException; + +import org.cactoos.text.FormattedText; +import org.cactoos.text.IsBlank; +import org.cactoos.text.Lowered; +import org.cactoos.text.TextOf; +import org.cactoos.text.Upper; + +public class CactoosStringUtils { + + public String createString() throws IOException { + String testString = new TextOf("Test String").asString(); + return testString; + } + + public String createdFormattedString(String stringToFormat) throws IOException { + String formattedString = new FormattedText("Hello %s", stringToFormat).asString(); + return formattedString; + } + + public String toLowerCase(String testString) throws IOException { + String lowerCaseString = new Lowered(new TextOf(testString)).asString(); + return lowerCaseString; + } + + public String toUpperCase(String testString) throws Exception { + String upperCaseString = new Upper(new TextOf(testString)).asString(); + return upperCaseString; + } + + public boolean isBlank(String testString) throws Exception { + return new IsBlank(new TextOf(testString)) != null; + } + +} diff --git a/libraries-3/src/test/java/com/baeldung/cactoos/CactoosCollectionUtilsUnitTest.java b/libraries-3/src/test/java/com/baeldung/cactoos/CactoosCollectionUtilsUnitTest.java new file mode 100644 index 0000000000..c6bcbd7df7 --- /dev/null +++ b/libraries-3/src/test/java/com/baeldung/cactoos/CactoosCollectionUtilsUnitTest.java @@ -0,0 +1,35 @@ +package com.baeldung.cactoos; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; +import java.util.List; +import java.util.ArrayList; + +import org.junit.Test; + +public class CactoosCollectionUtilsUnitTest { + + @Test + public void whenFilteredClassIsCalledWithSpecificArgs_thenCorrespondingFilteredCollectionShouldBeReturned() throws IOException { + + CactoosCollectionUtils obj = new CactoosCollectionUtils(); + + // when + List strings = new ArrayList() { + { + add("Hello"); + add("John"); + add("Smith"); + add("Eric"); + add("Dizzy"); + } + }; + int size = obj.getFilteredList(strings).size(); + + // then + assertEquals(3, size); + + } + +} diff --git a/libraries-3/src/test/java/com/baeldung/cactoos/CactoosStringUtilsUnitTest.java b/libraries-3/src/test/java/com/baeldung/cactoos/CactoosStringUtilsUnitTest.java new file mode 100644 index 0000000000..67dd6d91e4 --- /dev/null +++ b/libraries-3/src/test/java/com/baeldung/cactoos/CactoosStringUtilsUnitTest.java @@ -0,0 +1,54 @@ +package com.baeldung.cactoos; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; + +import org.junit.Test; + +public class CactoosStringUtilsUnitTest { + + @Test + public void whenFormattedTextIsPassedWithArgs_thenFormattedStringIsReturned() throws IOException { + + CactoosStringUtils obj = new CactoosStringUtils(); + + // when + String formattedString = obj.createdFormattedString("John"); + + // then + assertEquals("Hello John", formattedString); + + } + + @Test + public void whenStringIsPassesdToLoweredOrUpperClass_thenCorrespondingStringIsReturned() throws Exception { + + CactoosStringUtils obj = new CactoosStringUtils(); + + // when + String lowerCaseString = obj.toLowerCase("TeSt StrIng"); + String upperCaseString = obj.toUpperCase("TeSt StrIng"); + + // then + assertEquals("test string", lowerCaseString); + assertEquals("TEST STRING", upperCaseString); + + } + + @Test + public void whenEmptyStringIsPassesd_thenIsBlankReturnsTrue() throws Exception { + + CactoosStringUtils obj = new CactoosStringUtils(); + + // when + boolean isBlankEmptyString = obj.isBlank(""); + boolean isBlankNull = obj.isBlank(null); + + // then + assertEquals(true, isBlankEmptyString); + assertEquals(true, isBlankNull); + + } + +} diff --git a/libraries-data-db/pom.xml b/libraries-data-db/pom.xml index 682a6ed185..f028ffe8c3 100644 --- a/libraries-data-db/pom.xml +++ b/libraries-data-db/pom.xml @@ -183,7 +183,7 @@ io.ebean ebean-maven-plugin - 11.11.2 + ${ebean.plugin.version} @@ -202,6 +202,7 @@ + 11.11.2 16.5.1 3.0.0 1.8 diff --git a/libraries-data/pom.xml b/libraries-data/pom.xml index 2086ecb614..1267982c49 100644 --- a/libraries-data/pom.xml +++ b/libraries-data/pom.xml @@ -74,19 +74,19 @@ commons-cli commons-cli - 1.2 + ${commons.cli.version} provided commons-io commons-io - 2.1 + ${commons.io.version} provided commons-httpclient commons-httpclient - 3.0.1 + ${httpclient.version} provided @@ -133,7 +133,7 @@ org.apache.maven.plugins maven-assembly-plugin - 2.3 + ${assembly.plugin.version} src/main/resources/assembly/hadoop-job.xml @@ -158,6 +158,10 @@ + 2.3 + 1.2 + 2.1 + 3.0.1 1.2.2 1.0.0 2.4.0 diff --git a/libraries-http/pom.xml b/libraries-http/pom.xml index 6261456486..cbc74ce132 100644 --- a/libraries-http/pom.xml +++ b/libraries-http/pom.xml @@ -71,7 +71,7 @@ com.google.code.gson gson - 2.8.5 + ${gson.version} @@ -116,6 +116,7 @@ + 2.8.5 4.5.3 2.9.8 3.6.2 diff --git a/libraries-testing/pom.xml b/libraries-testing/pom.xml index c84f8dda76..3ffbb291a0 100644 --- a/libraries-testing/pom.xml +++ b/libraries-testing/pom.xml @@ -127,7 +127,7 @@ org.asciidoctor asciidoctor-maven-plugin - 1.5.7.1 + ${asciidoctor.version} @@ -154,7 +154,8 @@ - 1.9.9 + 1.5.7.1 + 1.9.9 1.9.0 1.9.0 1.9.27 diff --git a/libraries/pom.xml b/libraries/pom.xml index 13f91711fd..b5340d1ebb 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -523,7 +523,7 @@ org.apache.maven.plugins maven-shade-plugin - 2.2 + ${shade.plugin.version} package @@ -556,6 +556,7 @@ + 2.2 0.7.0 3.2.7 1.2 diff --git a/linux-bash/functions/src/main/bash/functions.sh b/linux-bash/functions/src/main/bash/functions.sh new file mode 100755 index 0000000000..41ff0ca434 --- /dev/null +++ b/linux-bash/functions/src/main/bash/functions.sh @@ -0,0 +1,208 @@ +#!/bin/bash + +# Subsection 2.1 +simple_function() { + for ((i=0;i<5;++i)) do + echo -n " "$i" "; + done +} + +function simple_function_no_parantheses { + for ((i=0;i<5;++i)) do + echo -n " "$i" "; + done +} + +function simple_for_loop() + for ((i=0;i<5;++i)) do + echo -n " "$i" "; + done + +function simple_comparison() + if [[ "$1" -lt 5 ]]; then + echo "$1 is smaller than 5" + else + echo "$1 is greater than 5" + fi + +# Subsection 2.2 +function simple_inputs() { + echo "This is the first argument [$1]" + echo "This is the second argument [$2]" + echo "Calling function with $# aruments" +} + +# Subsection 2.3 +global_sum=0 +function global_sum_outputs() { + global_sum=$(($1+$2)) +} + +function cs_sum_outputs() { + sum=$(($1+$2)) + echo $sum +} + +# Subsection 2.4 +function arg_ref_sum_outputs() { + declare -n sum_ref=$3 + sum_ref=$(($1+$2)) +} + +# Subsection 3.1 +variable="baeldung" +function variable_scope2() { + echo "Variable inside function variable_scope2: [$variable]" + local variable="ipsum" +} + +function variable_scope() { + local variable="lorem" + echo "Variable inside function variable_scope: [$variable]" + variable_scope2 +} + +# Subsection 3.2 +subshell_sum=0 +function simple_subshell_sum() ( + subshell_sum=$(($1+$2)) + echo "Value of sum in function with global variables: [$subshell_sum]" +) + +function simple_subshell_ref_sum() ( + declare -n sum_ref=$3 + sum_ref=$(($1+$2)) + echo "Value of sum in function with ref arguments: [$sum_ref]" +) + +# Subsection 3.3 +function redirection_in() { + while read input; + do + echo "$input" + done +} < infile + +function redirection_in_ps() { + read + while read -a input; + do + echo "User[${input[2]}]->File[${input[8]}]" + done +} < <(ls -ll /) + +function redirection_out_ps() { + declare -a output=("baeldung" "lorem" "ipsum" "caracg") + for element in "${output[@]}" + do + echo "$element" + done +} > >(grep "g") + +function redirection_out() { + declare -a output=("baeldung" "lorem" "ipsum") + for element in "${output[@]}" + do + echo "$element" + done +} > outfile + +# Subsection 3.4 +function fibonnaci_recursion() { + argument=$1 + if [[ "$argument" -eq 0 ]] || [[ "$argument" -eq 1 ]]; then + echo $argument + else + first=$(fibonnaci_recursion $(($argument-1))) + second=$(fibonnaci_recursion $(($argument-2))) + echo $(( $first + $second )) + fi +} + +# main menu entry point +echo "****Functions samples menu*****" +PS3="Your choice (1,2,3 etc.):" +options=("function_definitions" "function_input_args" "function_outputs" \ + "function_variables" "function_subshells" "function_redirections" \ + "function_recursion" "quit") +select option in "${options[@]}" +do + case $option in + "function_definitions") + echo -e "\n" + echo "**Different ways to define a function**" + echo -e "No function keyword:" + simple_function + echo -e "\nNo function parantheses:" + simple_function_no_parantheses + echo -e "\nOmitting curly braces:" + simple_for_loop + echo -e "\n" + ;; + "function_input_args") + echo -e "\n" + echo "**Passing inputs to a function**" + simple_inputs lorem ipsum + echo -e "\n" + ;; + "function_outputs") + echo -e "\n" + echo "**Getting outputs from a function**" + global_sum_outputs 1 2 + echo -e ">1+2 using global variables: [$global_sum]" + cs_sum=$(cs_sum_outputs 1 2) + echo -e ">1+2 using command substitution: [$cs_sum]" + arg_ref_sum_outputs 1 2 arg_ref_sum + echo -e ">1+2 using argument references: [$arg_ref_sum]" + echo -e "\n" + ;; + "function_variables") + echo -e "\n" + echo "**Overriding variable scopes**" + echo "Global value of variable: [$variable]" + variable_scope + echo -e "\n" + ;; + "function_subshells") + echo -e "\n" + echo "**Running function in subshell**" + echo "Global value of sum: [$subshell_sum]" + simple_subshell_sum 1 2 + echo "Value of sum after subshell function with \ +global variables: [$subshell_sum]" + subshell_sum_arg_ref=0 + simple_subshell_ref_sum 1 2 subshell_sum_arg_ref + echo "Value of sum after subshell function with \ +ref arguments: [$subshell_sum_arg_ref]" + echo -e "\n" + ;; + "function_redirections") + echo -e "\n" + echo "**Function redirections**" + echo -e ">Function input redirection from file:" + redirection_in + echo -e ">Function input redirection from command:" + redirection_in_ps + echo -e ">Function output redirection to file:" + redirection_out + cat outfile + echo -e ">Function output redirection to command:" + red_ps=$(redirection_out_ps) + echo "$red_ps" + echo -e "\n" + ;; + "function_recursion") + echo -e "\n" + echo "**Function recursion**" + fibo_res1=$(fibonnaci_recursion 7) + echo "The 7th Fibonnaci number: [$fibo_res1]" + fibo_res2=$(fibonnaci_recursion 15) + echo "The 15th Fibonnaci number: [$fibo_res2]" + echo -e "\n" + ;; + "quit") + break + ;; + *) echo "Invalid option";; + esac +done \ No newline at end of file diff --git a/linux-bash/functions/src/main/bash/infile b/linux-bash/functions/src/main/bash/infile new file mode 100644 index 0000000000..b1fa680af4 --- /dev/null +++ b/linux-bash/functions/src/main/bash/infile @@ -0,0 +1,3 @@ +Honda Insight 2010 +Honda Element 2006 +Chevrolet Avalanche 2002 diff --git a/logging-modules/flogger/pom.xml b/logging-modules/flogger/pom.xml index c27e2c8d7a..f553a4a961 100644 --- a/logging-modules/flogger/pom.xml +++ b/logging-modules/flogger/pom.xml @@ -15,26 +15,26 @@ com.google.flogger flogger - 0.4 + ${flogger.version} com.google.flogger flogger-system-backend - 0.4 + ${flogger.version} runtime com.google.flogger flogger-slf4j-backend - 0.4 + ${flogger.version} com.google.flogger flogger-log4j-backend - 0.4 + ${flogger.version} com.sun.jmx @@ -54,13 +54,18 @@ log4j log4j - 1.2.17 + ${log4j.version} log4j apache-log4j-extras - 1.2.17 + ${log4j.version} + + 0.4 + 1.2.17 + + \ No newline at end of file diff --git a/machine-learning/pom.xml b/machine-learning/pom.xml index 7bc0332012..24162b7b9c 100644 --- a/machine-learning/pom.xml +++ b/machine-learning/pom.xml @@ -19,6 +19,15 @@ 1.7 1.3.50 0.9.1 + 3.1.0 + 3.0.2 + 3.0.2 + 3.8.0 + 2.22.1 + 2.5.2 + 2.8.2 + 3.7.1 + 3.0.0 @@ -63,41 +72,41 @@ maven-clean-plugin - 3.1.0 + ${clean.plugin.version} maven-resources-plugin - 3.0.2 + ${resources.plugin.version} maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} maven-surefire-plugin - 2.22.1 + ${surefire.plugin.version} maven-jar-plugin - 3.0.2 + ${jar.plugin.version} maven-install-plugin - 2.5.2 + ${install.plugin.version} maven-deploy-plugin - 2.8.2 + ${deploy.plugin.version} maven-site-plugin - 3.7.1 + ${site.plugin.version} maven-project-info-reports-plugin - 3.0.0 + ${report.plugin.version} diff --git a/maven-all/compiler-plugin-java-9/pom.xml b/maven-all/compiler-plugin-java-9/pom.xml index 1975e1f7cd..6baadb451c 100644 --- a/maven-all/compiler-plugin-java-9/pom.xml +++ b/maven-all/compiler-plugin-java-9/pom.xml @@ -12,13 +12,19 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 9 - 9 + ${source.version} + ${target.version} + + 3.8.0 + 9 + 9 + + \ No newline at end of file diff --git a/maven-all/maven-custom-plugin/usage-example/pom.xml b/maven-all/maven-custom-plugin/usage-example/pom.xml index 542a02b3eb..bd2b16475e 100644 --- a/maven-all/maven-custom-plugin/usage-example/pom.xml +++ b/maven-all/maven-custom-plugin/usage-example/pom.xml @@ -8,16 +8,21 @@ 0.0.1-SNAPSHOT pom + + 3.9 + 4.12 + + org.apache.commons commons-lang3 - 3.9 + ${commons.lang3.version} junit junit - 4.12 + ${junit.version} test diff --git a/maven-all/maven-war-plugin/pom.xml b/maven-all/maven-war-plugin/pom.xml index 233a9f3571..915be306ca 100644 --- a/maven-all/maven-war-plugin/pom.xml +++ b/maven-all/maven-war-plugin/pom.xml @@ -14,7 +14,7 @@ maven-war-plugin - 3.1.0 + ${war.plugin.version} false @@ -26,6 +26,7 @@ false + 3.1.0 \ No newline at end of file diff --git a/maven-all/versions-maven-plugin/pom.xml b/maven-all/versions-maven-plugin/pom.xml index 3ce25d16f9..9793f55b28 100644 --- a/maven-all/versions-maven-plugin/pom.xml +++ b/maven-all/versions-maven-plugin/pom.xml @@ -12,19 +12,19 @@ commons-io commons-io - 2.3 + ${commons.io.version} org.apache.commons commons-collections4 - 4.0 + ${commons.collections4.version} org.apache.commons commons-lang3 - 3.0 + ${commons.lang3.version} @@ -36,7 +36,7 @@ commons-beanutils commons-beanutils - 1.9.1 + ${commons.beanutils.version} @@ -45,7 +45,7 @@ org.codehaus.mojo versions-maven-plugin - 2.7 + ${versions.plugin.version} org.apache.commons:commons-collections4 @@ -71,6 +71,11 @@ 1.15 + 2.3 + 2.7 + 1.9.1 + 3.0 + 4.0 \ No newline at end of file diff --git a/maven-archetype/src/main/resources/archetype-resources/pom.xml b/maven-archetype/src/main/resources/archetype-resources/pom.xml index a5c813652d..2a73687e2c 100644 --- a/maven-archetype/src/main/resources/archetype-resources/pom.xml +++ b/maven-archetype/src/main/resources/archetype-resources/pom.xml @@ -14,6 +14,8 @@ ${liberty-plugin-version} 9080 9443 + 2.0 + 2.1 @@ -65,14 +67,14 @@ javax.enterprise cdi-api - 2.0 + ${cdi.api.version} provided javax.ws.rs javax.ws.rs-api - 2.1 + ${rsapi.api.version} provided diff --git a/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml b/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml index 42b06bbebd..a4a6575906 100644 --- a/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml +++ b/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml @@ -12,23 +12,26 @@ com.baeldung.multimodule-maven-project multimodule-maven-project 1.0 + 1.0 + 1.0 + 1.0 com.baeldung.entitymodule entitymodule - 1.0 + ${entitymodule.version} com.baeldung.daomodule daomodule - 1.0 + ${daomodule.version} com.baeldung.userdaomodule userdaomodule - 1.0 + ${userdaomodule.version} diff --git a/maven-java-11/multimodule-maven-project/pom.xml b/maven-java-11/multimodule-maven-project/pom.xml index a79dff93d3..65f5b7a814 100644 --- a/maven-java-11/multimodule-maven-project/pom.xml +++ b/maven-java-11/multimodule-maven-project/pom.xml @@ -26,13 +26,13 @@ junit junit - 4.12 + ${junit.version} test org.assertj assertj-core - 3.12.2 + ${assertj.version} test @@ -44,10 +44,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 11 - 11 + ${source.version} + ${target.version} @@ -56,6 +56,11 @@ UTF-8 + 4.12 + 3.12.2 + 3.8.0 + 11 + 11 diff --git a/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml b/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml index 3eb5897f8b..cfa59bdc39 100644 --- a/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml +++ b/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml @@ -14,16 +14,21 @@ 1.0 + + 1.0 + 1.0 + + com.baeldung.entitymodule entitymodule - 1.0 + ${entitymodule.version}1.0 com.baeldung.daomodule daomodule - 1.0 + ${daomodule.version} junit diff --git a/maven-polyglot/maven-polyglot-json-extension/pom.xml b/maven-polyglot/maven-polyglot-json-extension/pom.xml index 0043bae151..15166046c1 100644 --- a/maven-polyglot/maven-polyglot-json-extension/pom.xml +++ b/maven-polyglot/maven-polyglot-json-extension/pom.xml @@ -34,7 +34,7 @@ org.codehaus.plexus plexus-component-metadata - 1.7.1 + ${plexus.component.version} @@ -48,6 +48,7 @@ 3.5.4 + 1.7.1 \ No newline at end of file diff --git a/micronaut/pom.xml b/micronaut/pom.xml index 13639c11ff..2cb05cc1b9 100644 --- a/micronaut/pom.xml +++ b/micronaut/pom.xml @@ -49,7 +49,7 @@ javax.annotation javax.annotation-api - 1.3.2 + ${annotation.api.version} compile @@ -60,19 +60,19 @@ ch.qos.logback logback-classic - 1.2.3 + ${lombok.version} runtime junit junit - 4.12 + ${junit.version} test io.projectreactor reactor-core - 3.1.6.RELEASE + ${reactor.version} @@ -81,7 +81,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.1.0 + ${shade.plugin.version} package @@ -102,7 +102,7 @@ org.codehaus.mojo exec-maven-plugin - 1.6.0 + ${exec.plugin.version} java @@ -118,7 +118,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + ${compiler.plugin.version} ${jdk.version} ${jdk.version} @@ -142,6 +142,13 @@ com.baeldung.micronaut.helloworld.server.ServerApplication 1.0.0.RC2 1.8 + 1.3.2 + 1.2.3 + 4.12 + 3.1.6.RELEASE + 3.7.0 + 1.6.0 + 3.1.0 diff --git a/ninja/pom.xml b/ninja/pom.xml index 8ec2422d9f..b66225f693 100644 --- a/ninja/pom.xml +++ b/ninja/pom.xml @@ -13,6 +13,9 @@ 6.5.0 9.4.18.v20190429 + 3.3.4 + 2.1.3 + 1.4.186 @@ -156,17 +159,17 @@ org.webjars bootstrap - 3.3.4 + ${bootstrap.version} org.webjars jquery - 2.1.3 + ${jquery.version} com.h2database h2 - 1.4.186 + ${h2.version} org.ninjaframework diff --git a/persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernatelogging/HibernateLoggingIntegrationTest.java b/persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernate/logging/HibernateLoggingIntegrationTest.java similarity index 97% rename from persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernatelogging/HibernateLoggingIntegrationTest.java rename to persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernate/logging/HibernateLoggingIntegrationTest.java index 8ec722671d..f609c75834 100644 --- a/persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernatelogging/HibernateLoggingIntegrationTest.java +++ b/persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernate/logging/HibernateLoggingIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.hibernatelogging; +package com.baeldung.hibernate.logging; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java index e202e45b32..7d3a881827 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java @@ -15,6 +15,7 @@ import org.springframework.dao.annotation.PersistenceExceptionTranslationPostPro import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.JpaVendorAdapter; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; @@ -39,12 +40,12 @@ public class PersistenceJPAConfig { // beans @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); - final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/PersistenceTransactionalTestConfig.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/PersistenceTransactionalTestConfig.java index fde1857ca2..72031a2232 100644 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/PersistenceTransactionalTestConfig.java +++ b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/PersistenceTransactionalTestConfig.java @@ -14,6 +14,7 @@ import org.springframework.dao.annotation.PersistenceExceptionTranslationPostPro import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.JpaVendorAdapter; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; @@ -91,12 +92,12 @@ public class PersistenceTransactionalTestConfig { // beans @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); - final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); diff --git a/pom.xml b/pom.xml index c28fcdb273..71e5d21b02 100644 --- a/pom.xml +++ b/pom.xml @@ -341,6 +341,7 @@ algorithms-miscellaneous-4 algorithms-miscellaneous-5 algorithms-sorting + algorithms-sorting-2 algorithms-searching animal-sniffer-mvn-plugin annotations @@ -985,6 +986,7 @@ algorithms-miscellaneous-4 algorithms-miscellaneous-5 algorithms-sorting + algorithms-sorting-2 algorithms-searching animal-sniffer-mvn-plugin annotations diff --git a/spring-boot-properties/src/test/resources/configprops-test.properties b/spring-boot-properties/src/test/resources/configprops-test.properties index 5eed93a22b..3fc1195b98 100644 --- a/spring-boot-properties/src/test/resources/configprops-test.properties +++ b/spring-boot-properties/src/test/resources/configprops-test.properties @@ -24,3 +24,5 @@ item.size=21 #Additional properties additional.unit=km additional.max=100 + +key.something=val \ No newline at end of file diff --git a/spring-boot-properties/src/test/resources/foo.properties b/spring-boot-properties/src/test/resources/foo.properties index c9f0304f65..b5ae2aedd4 100644 --- a/spring-boot-properties/src/test/resources/foo.properties +++ b/spring-boot-properties/src/test/resources/foo.properties @@ -1 +1,2 @@ -foo=bar \ No newline at end of file +foo=bar +key.something=val \ No newline at end of file diff --git a/spring-roo/pom.xml b/spring-roo/pom.xml index 456642b1f0..448574ed19 100644 --- a/spring-roo/pom.xml +++ b/spring-roo/pom.xml @@ -413,7 +413,7 @@ spring-roo-repository Spring Roo Repository - http://repo.spring.io/spring-roo + https://repo.spring.io/spring-roo